[pacman-dev] [PATCH v2] makepkg: Progress bar at package compression stage
Yanus Poluektovich
ypoluektovich at gmail.com
Sat Jun 7 22:18:11 EDT 2014
If pv is installed, use it to provide progress indication for package compression stage.
Signed-off-by: Yanus Poluektovich <ypoluektovich at gmail.com>
---
scripts/makepkg.sh.in | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 96e5349..a4eab07 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -1971,7 +1971,11 @@ create_package() {
pkgarch=$(get_pkg_arch)
write_pkginfo > .PKGINFO
- local comp_files=('.PKGINFO')
+ # when fileglobbing, we want * in an empty directory to expand to
+ # the null string rather than itself
+ shopt -s nullglob
+
+ local comp_files=( * '.PKGINFO' )
# check for changelog/install files
for i in 'changelog/.CHANGELOG' 'install/.INSTALL'; do
@@ -1993,23 +1997,30 @@ create_package() {
[[ -f $pkg_file ]] && rm -f "$pkg_file"
[[ -f $pkg_file.sig ]] && rm -f "$pkg_file.sig"
- # when fileglobbing, we want * in an empty directory to expand to
- # the null string rather than itself
- shopt -s nullglob
-
msg2 "$(gettext "Generating .MTREE file...")"
bsdtar -czf .MTREE --format=mtree \
--options='!all,use-set,type,uid,gid,mode,time,size,md5,sha256,link' \
- "${comp_files[@]}" *
+ "${comp_files[@]}"
comp_files+=(".MTREE")
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[@]}" * |
+ 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