#! /bin/bash #********************************************************************* # # ftar -- extract tar files using FAI classes # # This script is part of FAI (Fully Automatic Installation) # Copyright (C) 2001-2021 Thomas Lange, lange@cs.uni-koeln.de # Universitaet zu Koeln # #********************************************************************* # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # A copy of the GNU General Public License is available as # '/usr/share/common-licences/GPL' in the Debian GNU/Linux distribution # or on the World Wide Web at http://www.gnu.org/copyleft/gpl.html. You # can also obtain it by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA #********************************************************************* # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - die() { local e=$1 # first parameter is the exit code shift echo "ftar: $*" >&2 # print error message exit $e } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - extract() { local file=$1 local catname=$2 if [ $deletefiles -eq 1 ] ; then cd $target/$dir && rm -f -- .* * 2>/dev/null deletefiles=0 fi if [ $removedir -eq 1 ]; then cd $target/$dir || die 4 "ERROR: cd to $target/$dir failed. Aborting." [ $PWD = "/" ] && die 3 "WARNING: Will not do recursive removal of directory /" rm -rf -- .* * 2>/dev/null removedir=0 fi echo "ftar: extracting $file to $target/$dir" | tr -s '/' $catname $file | tar $xattrs --numeric-owner -C $target/$dir $vflag -xf - tardone=1 # if option -1 is set, only one class will be used [ $single -eq 1 ] && exit 0 } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - usage() { cat <