[pacman-dev] [PATCH] [RFC] makepkg: calculate exact total file size
Dave Reisner
d at falconindy.com
Sun Dec 25 10:06:25 EST 2011
On Sun, Dec 25, 2011 at 08:37:24PM +1000, Allan McRae wrote:
> The current calculation of the total file size for a package using "du"
> suffers from issues in portability and correctness. Especially on btrfs,
> this can result in clearly wrong package information such as:
>
> Download Size : 14684.29 KiB
> Installed Size : 7628.00 KiB
>
> Use a slower but more accurate method involving "cat" and "wc" to
> calculate total file size.
>
> Signed-off-by: Allan McRae <allan at archlinux.org>
> ---
> configure.ac | 1 -
> scripts/Makefile.am | 1 -
> scripts/makepkg.sh.in | 3 +--
> 3 files changed, 1 insertions(+), 4 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index fb1e0b3..6941054 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -245,7 +245,6 @@ esac
>
> AM_CONDITIONAL([CYGWIN], test "x$host_os_cygwin" = "xyes")
> AM_CONDITIONAL([DARWIN], test "x$host_os_darwin" = "xyes")
> -AC_PATH_PROGS([DUPATH], [du], [du], [/usr/bin$PATH_SEPARATOR/bin] )
> AC_SUBST(SIZECMD)
> AC_SUBST(SEDINPLACE)
> AC_SUBST(STRIP_BINARIES)
> diff --git a/scripts/Makefile.am b/scripts/Makefile.am
> index 328fbff..727de25 100644
> --- a/scripts/Makefile.am
> +++ b/scripts/Makefile.am
> @@ -53,7 +53,6 @@ edit = sed \
> -e 's|@BUILDSCRIPT[@]|$(BUILDSCRIPT)|g' \
> -e 's|@SIZECMD[@]|$(SIZECMD)|g' \
> -e 's|@SEDINPLACE[@]|$(SEDINPLACE)|g' \
> - -e 's|@DUPATH[@]|$(DUPATH)|g' \
> -e 's|@SCRIPTNAME[@]|$@|g' \
> -e 's|@configure_input[@]|Generated from $@.sh.in; do not edit by hand.|g'
>
> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
> index 8c6984d..c78db86 100644
> --- a/scripts/makepkg.sh.in
> +++ b/scripts/makepkg.sh.in
> @@ -1132,8 +1132,7 @@ write_pkginfo() {
> else
> local packager="Unknown Packager"
> fi
> - local size="$(@DUPATH@ -sk)"
> - size="$(( ${size%%[^0-9]*} * 1024 ))"
> + local size="$(find . | xargs cat 2>/dev/null | wc -c)"
Unsafe xargs usage.
find . -print0 | xargs -0 2>/dev/null | wc -c
Why can't we use @SIZECMD@ here? Same issues as du?
>
> msg2 "$(gettext "Generating %s file...")" ".PKGINFO"
> echo "# Generated by makepkg $myver"
> --
> 1.7.8.1
>
>
More information about the pacman-dev
mailing list