[pacman-dev] [PATCH] makepkg: create tar file for bogus PKGEXT
If PKGEXT is not one of the recognized tar*'s, create_package() would create an empty package file and fail, since bsdtar on the left side of the pipe returns 141 on SIGPIPE (broken pipe). This patch changes the behavior for an invalid PKGEXT. A warning is printed on stderr, and a tar file is created. Also retire the obsolete $EXT variable. Also add the obligatory comment why we don't use bsdtar's compression. Signed-off-by: lolilolicon <lolilolicon@gmail.com> --- scripts/makepkg.sh.in | 26 ++++++++++---------------- 1 files changed, 10 insertions(+), 16 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index cc06baa..213ac32 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1256,17 +1256,6 @@ create_package() { # tar it up msg2 "$(gettext "Compressing package...")" - local EXT - case "$PKGEXT" in - *tar.gz) EXT=${PKGEXT%.gz} ;; - *tar.bz2) EXT=${PKGEXT%.bz2} ;; - *tar.xz) EXT=${PKGEXT%.xz} ;; - *tar.Z) EXT=${PKGEXT%.Z} ;; - *tar) EXT=${PKGEXT} ;; - *) warning "$(gettext "'%s' is not a valid archive extension.")" \ - "$PKGEXT" ; EXT=$PKGEXT ;; - esac - local fullver=$(get_full_version) local pkg_file="$PKGDEST/${nameofpkg}-${fullver}-${PKGARCH}${PKGEXT}" local ret=0 @@ -1279,13 +1268,18 @@ create_package() { shopt -s nullglob # TODO: Maybe this can be set globally for robustness shopt -s -o pipefail + # bsdtar's gzip compression always saves the time stamp, making one + # archive created using the same command line distinct from another. + # Disable bsdtar compression and use gzip -n for now. bsdtar -cf - $comp_files * | case "$PKGEXT" in - *tar.gz) gzip -c -f -n ;; - *tar.bz2) bzip2 -c -f ;; - *tar.xz) xz -c -z - ;; - *tar.Z) compress -c -f ;; - *tar) cat ;; + *tar.gz) gzip -c -f -n ;; + *tar.bz2) bzip2 -c -f ;; + *tar.xz) xz -c -z - ;; + *tar.Z) compress -c -f ;; + *tar) cat ;; + *) warning "$(gettext "'%s' is not a valid archive extension." <&-)" \ + "$PKGEXT" <&- >&2; cat ;; esac > "${pkg_file}" || ret=$? shopt -u nullglob -- 1.7.6.4
On 30/09/11 15:23, lolilolicon wrote:
If PKGEXT is not one of the recognized tar*'s, create_package() would create an empty package file and fail, since bsdtar on the left side of the pipe returns 141 on SIGPIPE (broken pipe). This patch changes the behavior for an invalid PKGEXT. A warning is printed on stderr, and a tar file is created. Also retire the obsolete $EXT variable. Also add the obligatory comment why we don't use bsdtar's compression.
Signed-off-by: lolilolicon<lolilolicon@gmail.com> --- scripts/makepkg.sh.in | 26 ++++++++++---------------- 1 files changed, 10 insertions(+), 16 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index cc06baa..213ac32 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1256,17 +1256,6 @@ create_package() { # tar it up msg2 "$(gettext "Compressing package...")"
- local EXT - case "$PKGEXT" in - *tar.gz) EXT=${PKGEXT%.gz} ;; - *tar.bz2) EXT=${PKGEXT%.bz2} ;; - *tar.xz) EXT=${PKGEXT%.xz} ;; - *tar.Z) EXT=${PKGEXT%.Z} ;; - *tar) EXT=${PKGEXT} ;; - *) warning "$(gettext "'%s' is not a valid archive extension.")" \ - "$PKGEXT" ; EXT=$PKGEXT ;; - esac - local fullver=$(get_full_version) local pkg_file="$PKGDEST/${nameofpkg}-${fullver}-${PKGARCH}${PKGEXT}" local ret=0 @@ -1279,13 +1268,18 @@ create_package() { shopt -s nullglob # TODO: Maybe this can be set globally for robustness shopt -s -o pipefail + # bsdtar's gzip compression always saves the time stamp, making one + # archive created using the same command line distinct from another. + # Disable bsdtar compression and use gzip -n for now. bsdtar -cf - $comp_files * | case "$PKGEXT" in - *tar.gz) gzip -c -f -n ;; - *tar.bz2) bzip2 -c -f ;; - *tar.xz) xz -c -z - ;; - *tar.Z) compress -c -f ;; - *tar) cat ;; + *tar.gz) gzip -c -f -n ;; + *tar.bz2) bzip2 -c -f ;; + *tar.xz) xz -c -z - ;; + *tar.Z) compress -c -f ;; + *tar) cat ;; + *) warning "$(gettext "'%s' is not a valid archive extension."<&-)" \ + "$PKGEXT"<&->&2; cat ;;
I have no idea what all the <&- etc does here...
esac> "${pkg_file}" || ret=$?
shopt -u nullglob
On Fri, Sep 30, 2011 at 2:20 PM, Allan McRae <allan@archlinux.org> wrote:
On 30/09/11 15:23, lolilolicon wrote:
bsdtar -cf - $comp_files * | case "$PKGEXT" in - *tar.gz) gzip -c -f -n ;; - *tar.bz2) bzip2 -c -f ;; - *tar.xz) xz -c -z - ;; - *tar.Z) compress -c -f ;; - *tar) cat ;; + *tar.gz) gzip -c -f -n ;; + *tar.bz2) bzip2 -c -f ;; + *tar.xz) xz -c -z - ;; + *tar.Z) compress -c -f ;; + *tar) cat ;; + *) warning "$(gettext "'%s' is not a valid archive extension." <&-)" \ + "$PKGEXT" <&- >&2; cat ;;
I have no idea what all the <&- etc does here...
<&- closes stdin for the command. Not really needed, but explicitly ensures the stream piped from bsdtar is passed through to cat. For example $ echo a | { tr a A; cat; } A $ echo a | { tr a A <&-; cat; } tr: read error: Bad file descriptor a warning and gettext should not read the pipe, but explicitly closing their stdin doesn't hurt. At least, that's my theory...
On Fri, Sep 30, 2011 at 1:34 AM, lolilolicon <lolilolicon@gmail.com> wrote:
On Fri, Sep 30, 2011 at 2:20 PM, Allan McRae <allan@archlinux.org> wrote:
On 30/09/11 15:23, lolilolicon wrote:
bsdtar -cf - $comp_files * | case "$PKGEXT" in - *tar.gz) gzip -c -f -n ;; - *tar.bz2) bzip2 -c -f ;; - *tar.xz) xz -c -z - ;; - *tar.Z) compress -c -f ;; - *tar) cat ;; + *tar.gz) gzip -c -f -n ;; + *tar.bz2) bzip2 -c -f ;; + *tar.xz) xz -c -z - ;; + *tar.Z) compress -c -f ;; + *tar) cat ;; + *) warning "$(gettext "'%s' is not a valid archive extension." <&-)" \ + "$PKGEXT" <&- >&2; cat ;;
I have no idea what all the <&- etc does here...
<&- closes stdin for the command. Not really needed, but explicitly ensures the stream piped from bsdtar is passed through to cat. Let's not fix (and make more complex!) what's not broken. -1.
Also, why did you reindent everything here? Totally unnecessary and just makes the noise > signal here.
For example
$ echo a | { tr a A; cat; } A $ echo a | { tr a A <&-; cat; } tr: read error: Bad file descriptor a
warning and gettext should not read the pipe, but explicitly closing their stdin doesn't hurt. At least, that's my theory...
On Fri, Sep 30, 2011 at 10:55 PM, Dan McGee <dpmcgee@gmail.com> wrote:
On Fri, Sep 30, 2011 at 1:34 AM, lolilolicon <lolilolicon@gmail.com> wrote:
On Fri, Sep 30, 2011 at 2:20 PM, Allan McRae <allan@archlinux.org> wrote:
On 30/09/11 15:23, lolilolicon wrote:
bsdtar -cf - $comp_files * | case "$PKGEXT" in - *tar.gz) gzip -c -f -n ;; - *tar.bz2) bzip2 -c -f ;; - *tar.xz) xz -c -z - ;; - *tar.Z) compress -c -f ;; - *tar) cat ;; + *tar.gz) gzip -c -f -n ;; + *tar.bz2) bzip2 -c -f ;; + *tar.xz) xz -c -z - ;; + *tar.Z) compress -c -f ;; + *tar) cat ;; + *) warning "$(gettext "'%s' is not a valid archive extension." <&-)" \ + "$PKGEXT" <&- >&2; cat ;;
I have no idea what all the <&- etc does here...
<&- closes stdin for the command. Not really needed, but explicitly ensures the stream piped from bsdtar is passed through to cat. Let's not fix (and make more complex!) what's not broken. -1.
Honestly I thought this warning was the reason the $EXT was not removed in the first place... Oh well, let's implement this when something breaks for not doing it :P
Also, why did you reindent everything here? Totally unnecessary and just makes the noise > signal here.
It was leading TAB mixed spaces. We should fix it.
For example
$ echo a | { tr a A; cat; } A $ echo a | { tr a A <&-; cat; } tr: read error: Bad file descriptor a
warning and gettext should not read the pipe, but explicitly closing their stdin doesn't hurt. At least, that's my theory...
If PKGEXT is not one of the recognized tar*'s, create_package() would create an empty package file and fail, since bsdtar on the left side of the pipe returns 141 on SIGPIPE (broken pipe). This patch changes the behavior for an invalid PKGEXT. A warning is printed on stderr, and a tar file is created. Also retire the obsolete $EXT variable. Also add the obligatory comment why we don't use bsdtar's compression. Finally, fix mixed-tab-space indentation. Signed-off-by: lolilolicon <lolilolicon@gmail.com> --- scripts/makepkg.sh.in | 26 ++++++++++---------------- 1 files changed, 10 insertions(+), 16 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index cc06baa..f60e668 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1256,17 +1256,6 @@ create_package() { # tar it up msg2 "$(gettext "Compressing package...")" - local EXT - case "$PKGEXT" in - *tar.gz) EXT=${PKGEXT%.gz} ;; - *tar.bz2) EXT=${PKGEXT%.bz2} ;; - *tar.xz) EXT=${PKGEXT%.xz} ;; - *tar.Z) EXT=${PKGEXT%.Z} ;; - *tar) EXT=${PKGEXT} ;; - *) warning "$(gettext "'%s' is not a valid archive extension.")" \ - "$PKGEXT" ; EXT=$PKGEXT ;; - esac - local fullver=$(get_full_version) local pkg_file="$PKGDEST/${nameofpkg}-${fullver}-${PKGARCH}${PKGEXT}" local ret=0 @@ -1279,13 +1268,18 @@ create_package() { shopt -s nullglob # TODO: Maybe this can be set globally for robustness shopt -s -o pipefail + # bsdtar's gzip compression always saves the time stamp, making one + # archive created using the same command line distinct from another. + # Disable bsdtar compression and use gzip -n for now. bsdtar -cf - $comp_files * | case "$PKGEXT" in - *tar.gz) gzip -c -f -n ;; - *tar.bz2) bzip2 -c -f ;; - *tar.xz) xz -c -z - ;; - *tar.Z) compress -c -f ;; - *tar) cat ;; + *tar.gz) gzip -c -f -n ;; + *tar.bz2) bzip2 -c -f ;; + *tar.xz) xz -c -z - ;; + *tar.Z) compress -c -f ;; + *tar) cat ;; + *) warning "$(gettext "'%s' is not a valid archive extension.")" \ + "$PKGEXT"; cat ;; esac > "${pkg_file}" || ret=$? shopt -u nullglob -- 1.7.6.4
On 01/10/11 17:31, lolilolicon wrote:
If PKGEXT is not one of the recognized tar*'s, create_package() would create an empty package file and fail, since bsdtar on the left side of the pipe returns 141 on SIGPIPE (broken pipe). This patch changes the behavior for an invalid PKGEXT. A warning is printed on stderr, and a tar file is created. Also retire the obsolete $EXT variable. Also add the obligatory comment why we don't use bsdtar's compression. Finally, fix mixed-tab-space indentation.
Signed-off-by: lolilolicon<lolilolicon@gmail.com>
Looks good now. Signed-off-by: Allan
participants (3)
-
Allan McRae
-
Dan McGee
-
lolilolicon