smlinux/bldpkg.d/validatecompressors

35 lines
1.1 KiB
Text
Executable file

validatecompressors() {
# Validate package extension set in buildvars.conf
SM_VALIDPKGEXTENSIONS=( "tgz" "tbz" "tlz" "txz" )
if ! inarray "${PKGEXT}" "${SM_VALIDPKGEXTENSIONS[@]}" ; then
echo "[ERROR] $PKGEXT is not a valid package extension for an SMLinux"
echo "[ERROR] installer file! Aborting!"
exit 1
fi
# Figure out the compression tool to be used based on the $PKGEXT variable set in buildvars.conf. At the same time,
# export the compressor options set for makepkg to import from the build environment.
case "$PKGEXT" in
tgz) COMPRESSOR=gzip
COMPRESSOPTS="$SM_GZIPOPTS"
export COMPRESSOPTS ;;
tbz) COMPRESSOR=bzip2
COMPRESSOPTS="$SM_BZIPOPTS"
export COMPRESSOPTS ;;
tlz) COMPRESSOR=lzip
COMPRESSOPTS="$SM_LZIPOPTS"
export COMPRESSOPTS ;;
txz) COMPRESSOR=xz
COMPRESSOPTS="$SM_XZOPTS"
export COMPRESSOPTS ;;
esac
echo -n "Validating $COMPRESSOR...."
# Borrowed from slackware's installpkg utility
if ! $COMPRESSOR --help 1> /dev/null 2> /dev/null ; then
echo "[FAILED]"
exit 1
else
echo "[OK]"
fi
}