From 91a013a8791b73daf4d17b2d52c8dfaf12887cc6 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Thu, 4 Sep 2008 20:44:19 -0500 Subject: makepkg: allow compression type to be autodetected Inspired by commit 7e8f1469c4168875b54956d63884b8583ce99e38, use our given PKGEXT or SRCEXT to determine what method of compression to use on the package we create. If the extension is invalid, this should fall back to creating a non-compressed tar file. Signed-off-by: Dan McGee --- scripts/makepkg.sh.in | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index c15d91f4..ff05e481 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -871,13 +871,21 @@ create_package() { # tar it up msg2 "$(gettext "Compressing package...")" + local TAR_OPT + case "$PKGEXT" in + *tar.gz) TAR_OPT="z" ;; + *tar.bz2) TAR_OPT="j" ;; + *) warning "$(gettext "'%s' is not a valid archive extension.")" \ + "$PKGEXT" ;; + esac + local pkg_file="$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}" # when fileglobbing, we want * in an empty directory to expand to # the null string rather than itself shopt -s nullglob - if ! bsdtar -czf "$pkg_file" $comp_files *; then + if ! bsdtar -c${TAR_OPT}f "$pkg_file" $comp_files *; then error "$(gettext "Failed to create package file.")" exit 1 # TODO: error code fi @@ -992,12 +1000,20 @@ create_srcpackage() { fi done + local TAR_OPT + case "$SRCEXT" in + *tar.gz) TAR_OPT="z" ;; + *tar.bz2) TAR_OPT="j" ;; + *) warning "$(gettext "'%s' is not a valid archive extension.")" \ + "$SRCEXT" ;; + esac + local pkg_file="$PKGDEST/${pkgname}-${pkgver}-${pkgrel}${SRCEXT}" # tar it up msg2 "$(gettext "Compressing source package...")" cd "${srclinks}" - if ! bsdtar -czLf "$pkg_file" ${pkgname}; then + if ! bsdtar -c${TAR_OPT}Lf "$pkg_file" ${pkgname}; then error "$(gettext "Failed to create source package file.")" exit 1 # TODO: error code fi -- cgit v1.2.3