From 7a456f2d51ffbb9e77edfa24c65cf193cc439d70 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 31 May 2013 16:10:53 +0200 Subject: [vmplayer] More error checks [stage31] more error checks in stage31 (and then drop to shell) [fileutil] Add option to tarcopy to ignore failed reads --- helper/fileutil.inc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'helper') diff --git a/helper/fileutil.inc b/helper/fileutil.inc index fcb551eb..fb1c8382 100644 --- a/helper/fileutil.inc +++ b/helper/fileutil.inc @@ -25,6 +25,16 @@ install_package() { # copy list of files using tar tarcopy () { + if [ $# -gt 0 -a "x$1" == "x-i" ]; then + shift + local IGNORE_ERROR="--ignore-failed-read" + else + local IGNORE_ERROR= + fi + if [ "x$IGNORE_TAR_ERROR" != "x" ]; then + unset IGNORE_TAR_ERROR + IGNORE_ERROR="--ignore-failed-read" + fi [ $# -ne 2 ] && perror "Sanity check failed: tarcopy needs exactly two params, but $# were given." local FROM=$(trim "$1") local TO=$(trim "$2") @@ -37,9 +47,9 @@ tarcopy () { [ -z "$TO" ] && perror "tarcopy called with empty destination." [ ! -d "$TO" ] && { mkdir -p "$TO" || perror "could not create destination "$TO" for tar-copy."; } # TODO count files copied? would remove the need to do it everywhere :) - tar -cpP $FROM | tar -xp -C "$TO" 2> /dev/null + tar $IGNORE_ERROR -cpP $FROM | tar -xp -C "$TO" 2> /dev/null local PS=(${PIPESTATUS[*]}) - [ "x${PS[0]}" != "x0" ] && perror "packing-part of tar-copy from '$SHORT' to '$TO' failed. (${PS[0]})" + [ "x$IGNORE_ERROR" == "x" -a "x${PS[0]}" != "x0" ] && perror "packing-part of tar-copy from '$SHORT' to '$TO' failed. (${PS[0]})" [ "x${PS[1]}" != "x0" ] && perror "unpacking-part of tar-copy from '$SHORT' to '$TO' failed. (${PS[1]})" } -- cgit v1.2.3-55-g7522