[pacman-dev] [PATCH] 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 <dan@archlinux.org> --- scripts/makepkg.sh.in | 20 ++++++++++++++++++-- 1 files changed, 18 insertions(+), 2 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index c15d91f..ff05e48 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 -- 1.6.0.1
On Fri, Sep 5, 2008 at 3:46 AM, Dan McGee <dan@archlinux.org> wrote:
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 <dan@archlinux.org>
Looks nice, and repo-add and pacman could already handle tar.gz and tar.bz2 transparently.
Wouldn't this break package extensions that are not *.tar.{gz,bz2}? I personally do not like this, as my Arch fork uses .ipkg (I find pkg.tar.$COMPRESSION very ugly, IMHO). Perhaps tar could simply tar the archive and a setting in makepkg.conf would allow for any method of compression? Example: makepkg.conf: COMPRESS='gzip -9' Makepkg: bsdtar -cf "$pkg_file" $comp_files * $COMPRESS "$pkg_file" Of course, you would need to deal with renaming it from ${EXTENSION}.gz back to $EXTENSION. Some error checking would be nice too. Regarding repo-add, it could simply `tar -xf` and it would be extracted if `tar` understands that type of compression. It could also check with `file`, perhaps. Cheers, Teran (sega01) PS: Why is bsdtar used instead of GNU tar? On Fri, Sep 5, 2008 at 06:03, Xavier <shiningxc@gmail.com> wrote:
On Fri, Sep 5, 2008 at 3:46 AM, Dan McGee <dan@archlinux.org> wrote:
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 <dan@archlinux.org>
Looks nice, and repo-add and pacman could already handle tar.gz and tar.bz2 transparently. _______________________________________________ pacman-dev mailing list pacman-dev@archlinux.org http://archlinux.org/mailman/listinfo/pacman-dev
Wouldn't this break package extensions that are not *.tar.{gz,bz2}? I Yes- partially. It will no longer compress them and will simply tar
On Fri, Sep 5, 2008 at 6:25 AM, Teran McKinney <sega01@gmail.com> wrote: them. Probably not what you intended.
personally do not like this, as my Arch fork uses .ipkg (I find pkg.tar.$COMPRESSION very ugly, IMHO). Perhaps tar could simply tar the archive and a setting in makepkg.conf would allow for any method of compression? Example: We just eliminated a whole bunch of this crud because it was unused and not worth it- it made so much more sense to autodetect.
The one valid case I can see here is defaulting to gzip if no compression method was specified, rather than falling back to an uncompressed tar file.
makepkg.conf: COMPRESS='gzip -9'
Makepkg: bsdtar -cf "$pkg_file" $comp_files * $COMPRESS "$pkg_file"
Of course, you would need to deal with renaming it from ${EXTENSION}.gz back to $EXTENSION. Some error checking would be nice too.
So now we've turned a one step process into two and added the need to error check. Seems like it just got way more complex than necessary.
Regarding repo-add, it could simply `tar -xf` and it would be extracted if `tar` understands that type of compression. It could also check with `file`, perhaps.
Um, this has been the case for ages- we just recently got smart and actually re-compressed it in the "right" format, however. bsdtar does transparent decompression. What you are proposing (I think) is rather than key off the DB extension for the *re-compression* that needs to occur, key off the original archive format? The issue here is that creating a new DB would then be a special case, so what format would we use for that?
PS: Why is bsdtar used instead of GNU tar? bsdtar is shipped with libarchive, which libalpm depends on so we know will be installed on systems. In addition, it is faster, regularly updated, and a pretty good product.
Sorry for sounding overly combative here, but your points just have a ton of issues that may not have been immediately obvious, and I wanted to make sure it was obvious why I settled on the solution I did. -Dan
On Fri, Sep 5, 2008 at 1:25 PM, Teran McKinney <sega01@gmail.com> wrote:
Wouldn't this break package extensions that are not *.tar.{gz,bz2}? I personally do not like this, as my Arch fork uses .ipkg (I find pkg.tar.$COMPRESSION very ugly, IMHO). Perhaps tar could simply tar the archive and a setting in makepkg.conf would allow for any method of compression? Example:
makepkg.conf: COMPRESS='gzip -9'
Makepkg: bsdtar -cf "$pkg_file" $comp_files * $COMPRESS "$pkg_file"
Of course, you would need to deal with renaming it from ${EXTENSION}.gz back to $EXTENSION. Some error checking would be nice too.
And how will you know if a suffix was added, and which one? This looks ugly.
Regarding repo-add, it could simply `tar -xf` and it would be extracted if `tar` understands that type of compression. It could also check with `file`, perhaps.
The problem is compressing, not decompressing. file can not work for repo-add because when you create a repo the first time, it does not exist yet.
PS: Why is bsdtar used instead of GNU tar?
On Fri, Sep 5, 2008 at 1:03 AM, Xavier <shiningxc@gmail.com> wrote:
On Fri, Sep 5, 2008 at 3:46 AM, Dan McGee <dan@archlinux.org> wrote:
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 <dan@archlinux.org>
Looks nice, and repo-add and pacman could already handle tar.gz and tar.bz2 transparently.
I forgot a note saying this was completely untested. We will want to obviously run it through its paces if possible. -Dan
participants (4)
-
Dan McGee
-
Dan McGee
-
Teran McKinney
-
Xavier