[pacman-dev] [PATCH v3] makepkg: Progress bar at package compression stage
Yanus Poluektovich
ypoluektovich at gmail.com
Mon Jun 9 14:25:31 EDT 2014
If pv is installed, use it to provide progress indication
for package compression stage.
Known issues:
1) The 'uncompressed' progress bar freezes a lot when used with
multithreaded xz. This may result in overwriting the last line of
terminal output (the 'compressing package...' message).
2) When compression is disabled (PKGEXT=.pkg.tar), the 'compressed'
progress bar is redundant. I'm not sure if it's acceptable to hard-code
a check for this, however.
Signed-off-by: Yanus Poluektovich <ypoluektovich at gmail.com>
---
scripts/makepkg.sh.in | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 96e5349..2f0b480 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -2006,10 +2006,21 @@ create_package() {
msg2 "$(gettext "Compressing package...")"
# TODO: Maybe this can be set globally for robustness
shopt -s -o pipefail
+
+ local uncompressed_pipe=(cat)
+ local compressed_pipe=(cat)
+ if type -P pv >/dev/null; then
+ local uncompressed_size=$( grep -E '^size =' .PKGINFO )
+ uncompressed_size=${uncompressed_size##*[^0-9]}
+ uncompressed_pipe=(pv -c -N uncompressed -perab -s "$uncompressed_size")
+ compressed_pipe=(pv -c -N compressed -trab)
+ fi
+
# 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[@]}" * |
+ "${uncompressed_pipe[@]}" |
case "$PKGEXT" in
*tar.gz) ${COMPRESSGZ[@]:-gzip -c -f -n} ;;
*tar.bz2) ${COMPRESSBZ2[@]:-bzip2 -c -f} ;;
@@ -2020,7 +2031,7 @@ create_package() {
*tar) cat ;;
*) warning "$(gettext "'%s' is not a valid archive extension.")" \
"$PKGEXT"; cat ;;
- esac > "${pkg_file}" || ret=$?
+ esac | "${compressed_pipe[@]}" > "${pkg_file}" || ret=$?
shopt -u nullglob
shopt -u -o pipefail
--
2.0.0
More information about the pacman-dev
mailing list