1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-08-13 17:03:46 -04:00

makepkg: allow compression type to be autodetected

Inspired by commit 7e8f1469c4, 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 <dan@archlinux.org>
This commit is contained in:
Dan McGee 2008-09-04 20:44:19 -05:00
parent f1f8f0e1c2
commit 91a013a879

View File

@ -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