gen2stage4/exstage4.sh

27 lines
710 B
Bash
Raw Normal View History

2022-12-15 17:41:42 -05:00
#!/usr/bin/env bash
STAGE_FILE=${1}
echo "${STAGE_FILE}"
EXT="${STAGE_FILE##*.}"
TARFILE="${STAGE_FILE%%.$EXT}"
TAREXT="${TARFILE##*.}"
if [[ $TAREXT != "tar" ]]; then
echo "The stage file you are trying to unpack (\`$STAGE_FILE\`) does not appear to be an archived TAR file"
else
echo "Extracting \`${STAGE_FILE}\` inplace."
fi
2023-03-12 01:21:19 -05:00
if [ "$EXT" == "xz" ]; then
2022-12-15 17:41:42 -05:00
tar -I 'xz -T0' -xvf "${STAGE_FILE}" --xattrs-include='*.*' --numeric-owner
2023-03-12 01:21:19 -05:00
elif [ "$EXT" == "bz2" ]; then
2022-12-15 17:41:42 -05:00
tar -I pbzip2 -xvf "${STAGE_FILE}" --xattrs-include='*.*' --numeric-owner
2023-03-12 01:21:19 -05:00
elif [ "$EXT" == "gz" ]; then
2022-12-15 17:41:42 -05:00
tar -I unpigz -xvf "${STAGE_FILE}" --xattrs-include='*.*' --numeric-owner
else
echo "Not sure how to unpack \`${STAGE_FILE}\`"
fi