On 25.12.2011 16:06, Dave Reisner wrote: > 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 <[email protected]> >> --- >> 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
You forgot the cat. find . -print0 | xargs -0 cat 2>/dev/null | wc -c > > Why can't we use @SIZECMD@ here? Same issues as du? > SIZECMD returns one file size per line so we'd also have to add them up. Small test (1003 bytes PKGBUILD on btrfs with default mount options): SIZECMD (stat -L -c %s) 1003 du -skh 512 du -sb 1003 wc -c 1003 If du -sb is portable that might be the easiest way. -- Florian Pritz
signature.asc
Description: OpenPGP digital signature
