If pv is installed, use it to provide progress indication for package 
compression stage.
---
 scripts/makepkg.sh.in | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 96e5349..0bb619f 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
+
+       comp_files+=( $(ls) )
+       local pv_uncompressed="cat"
+       local pv_compressed="cat"
+       if [[ -f "/usr/bin/pv" ]]; then
+               local uncompressed_size=$( du -sb "${comp_files[@]}" | awk 
'BEGIN {s=0} {s += $1} END {print s}' )
+               pv_uncompressed="/usr/bin/pv -c -N uncompressed -perab -s 
$uncompressed_size"
+               pv_compressed="/usr/bin/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[@]}" * |
+       bsdtar -cf - "${comp_files[@]}" |
+       $pv_uncompressed |
        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 | $pv_compressed > "${pkg_file}" || ret=$?
 
        shopt -u nullglob
        shopt -u -o pipefail
-- 
2.0.0


Reply via email to