Use pipe to create compressed package instead of an intermediate tar file
A pipe between tar and compression command is used. This improves performance by running tar and the compression command simultaneously. Using a pipe also reduces IO by not writing an intermediate tar file to disk. Signed-off-by: Juergen Hoetzel <juergen@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
693ebbd16b
commit
38a60f49bd
|
@ -1032,26 +1032,25 @@ create_package() {
|
||||||
*) warning "$(gettext "'%s' is not a valid archive extension.")" \
|
*) warning "$(gettext "'%s' is not a valid archive extension.")" \
|
||||||
"$PKGEXT" ; EXT=$PKGEXT ;;
|
"$PKGEXT" ; EXT=$PKGEXT ;;
|
||||||
esac
|
esac
|
||||||
local tar_file="$PKGDEST/${nameofpkg}-${pkgver}-${pkgrel}-${PKGARCH}${EXT}"
|
|
||||||
local pkg_file="$PKGDEST/${nameofpkg}-${pkgver}-${pkgrel}-${PKGARCH}${PKGEXT}"
|
|
||||||
|
|
||||||
|
local pkg_file="$PKGDEST/${nameofpkg}-${pkgver}-${pkgrel}-${PKGARCH}${PKGEXT}"
|
||||||
local ret=0
|
local ret=0
|
||||||
|
|
||||||
# when fileglobbing, we want * in an empty directory to expand to
|
# when fileglobbing, we want * in an empty directory to expand to
|
||||||
# the null string rather than itself
|
# the null string rather than itself
|
||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
bsdtar -cf - $comp_files * > "$tar_file" || ret=$?
|
# TODO: Maybe this can be set globally for robustness
|
||||||
shopt -u nullglob
|
shopt -s -o pipefail
|
||||||
|
bsdtar -cf - $comp_files * |
|
||||||
|
case "$PKGEXT" in
|
||||||
|
*tar.gz) gzip -c -f -n ;;
|
||||||
|
*tar.bz2) bzip2 -c -f ;;
|
||||||
|
*tar.xz) xz -c -z - ;;
|
||||||
|
*tar) cat ;;
|
||||||
|
esac > ${pkg_file} || ret=$?
|
||||||
|
|
||||||
if (( ! ret )); then
|
shopt -u nullglob
|
||||||
case "$PKGEXT" in
|
shopt -u -o pipefail
|
||||||
*tar.gz) gzip -f -n "$tar_file" ;;
|
|
||||||
*tar.bz2) bzip2 -f "$tar_file" ;;
|
|
||||||
*tar.xz) xz -z -f "$tar_file" ;;
|
|
||||||
*tar) true ;;
|
|
||||||
esac
|
|
||||||
ret=$?
|
|
||||||
fi
|
|
||||||
|
|
||||||
if (( ret )); then
|
if (( ret )); then
|
||||||
error "$(gettext "Failed to create package file.")"
|
error "$(gettext "Failed to create package file.")"
|
||||||
|
|
Loading…
Reference in New Issue