makepkg: use --apparent-size when du supports it

Amazingly, using "sleep 1" to convince btrfs to report correct file
sizes is only a 90% fix.  Sometimes more sleep is needed.

Instead we use the --apparent-size argument to du to get actual file
sizes. This is used only on Linux as the various BSDs do not support
this argument.

Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Allan McRae 2012-12-16 22:32:54 +10:00
parent d5a6ce8ca1
commit 241d6b884a
3 changed files with 6 additions and 6 deletions

View File

@ -300,6 +300,7 @@ GCC_GNU89_INLINE_CC
INODECMD="stat -c '%i %n'" INODECMD="stat -c '%i %n'"
SIZECMD="stat -c %s" SIZECMD="stat -c %s"
SEDINPLACE="sed -i" SEDINPLACE="sed -i"
DUFLAGS="-sk --apparent-size"
STRIP_BINARIES="--strip-all" STRIP_BINARIES="--strip-all"
STRIP_SHARED="--strip-unneeded" STRIP_SHARED="--strip-unneeded"
STRIP_STATIC="--strip-debug" STRIP_STATIC="--strip-debug"
@ -308,12 +309,14 @@ case "${host_os}" in
INODECMD="stat -f '%i %n'" INODECMD="stat -f '%i %n'"
SIZECMD="stat -f %z" SIZECMD="stat -f %z"
SEDINPLACE="sed -i \"\"" SEDINPLACE="sed -i \"\""
DUFLAGS="-sk"
;; ;;
darwin*) darwin*)
host_os_darwin=yes host_os_darwin=yes
INODECMD="/usr/bin/stat -f '%i %n'" INODECMD="/usr/bin/stat -f '%i %n'"
SIZECMD="/usr/bin/stat -f %z" SIZECMD="/usr/bin/stat -f %z"
SEDINPLACE="/usr/bin/sed -i ''" SEDINPLACE="/usr/bin/sed -i ''"
DUFLAGS="-sk"
STRIP_BINARIES="" STRIP_BINARIES=""
STRIP_SHARED="-S" STRIP_SHARED="-S"
STRIP_STATIC="-S" STRIP_STATIC="-S"
@ -325,6 +328,7 @@ AC_PATH_PROGS([DUPATH], [du], [du], [/usr/bin$PATH_SEPARATOR/bin] )
AC_SUBST(INODECMD) AC_SUBST(INODECMD)
AC_SUBST(SIZECMD) AC_SUBST(SIZECMD)
AC_SUBST(SEDINPLACE) AC_SUBST(SEDINPLACE)
AC_SUBST(DUFLAGS)
AC_SUBST(STRIP_BINARIES) AC_SUBST(STRIP_BINARIES)
AC_SUBST(STRIP_SHARED) AC_SUBST(STRIP_SHARED)
AC_SUBST(STRIP_STATIC) AC_SUBST(STRIP_STATIC)

View File

@ -57,6 +57,7 @@ edit = sed \
-e "s|@INODECMD[@]|$(INODECMD)|g" \ -e "s|@INODECMD[@]|$(INODECMD)|g" \
-e 's|@SIZECMD[@]|$(SIZECMD)|g' \ -e 's|@SIZECMD[@]|$(SIZECMD)|g' \
-e 's|@SEDINPLACE[@]|$(SEDINPLACE)|g' \ -e 's|@SEDINPLACE[@]|$(SEDINPLACE)|g' \
-e 's|@DUFLAGS[@]|$(DUFLAGS)|g' \
-e 's|@DUPATH[@]|$(DUPATH)|g' \ -e 's|@DUPATH[@]|$(DUPATH)|g' \
-e 's|@SCRIPTNAME[@]|$@|g' \ -e 's|@SCRIPTNAME[@]|$@|g' \
-e 's|@configure_input[@]|Generated from $@.sh.in; do not edit by hand.|g' -e 's|@configure_input[@]|Generated from $@.sh.in; do not edit by hand.|g'

View File

@ -1704,12 +1704,7 @@ write_pkginfo() {
local packager="Unknown Packager" local packager="Unknown Packager"
fi fi
# btrfs's delayed allocation causes the stat buffers from the kernel to "lie" local size="$(@DUPATH@ @DUFLAGS@)"
# to us momentarily and report 0 blocks allocated (which is how du calculates
# size). Sleeping for a second here is about the dirtiest thing possible,
# but avoids reporting entirely bogus install sizes.
sleep 1
local size="$(@DUPATH@ -sk)"
size="$(( ${size%%[^0-9]*} * 1024 ))" size="$(( ${size%%[^0-9]*} * 1024 ))"
msg2 "$(gettext "Generating %s file...")" ".PKGINFO" msg2 "$(gettext "Generating %s file...")" ".PKGINFO"