[pacman-dev] [PATCH] [RFC] makepkg: calculate exact total file size

Florian Pritz bluewind at xinu.at
Sun Dec 25 17:50:57 EST 2011


On 25.12.2011 23:09, Allan McRae wrote:
> On 26/12/11 03:27, Dave Reisner wrote:
>> On Sun, Dec 25, 2011 at 06:20:27PM +0100, Florian Pritz wrote:
>>> On 25.12.2011 16:06, Dave Reisner wrote:
>>>> 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.
>> 
>> Yup. I do this in paccache:
>> 
>> @SIZECMD@ "${candidates[@]}" | awk '{ sum += $1 } END { print sum }'
> 
> I'm happy using @SIZECMD@:
> 
> allan at mugen ~/tmp/libreoffice
>> find . -print0 | xargs -0 stat -L -c %s | awk '{sum += $1 } END {
> print sum }'
> 196464312
> 
> allan at mugen ~/tmp/libreoffice
>> find . -print0 | xargs -0 cat 2>/dev/null | wc -c
> 195276472
> 
> allan at mugen ~/tmp/libreoffice
>> du -sb
> 196444140	.
> 
> Of course the numbers between the stat and wc approach are different
> because stat adds a "block size" amount for each directory of which
> there is 290 in the libreoffice package:
> 
> (196464312 - 195276472) / 4096 = 290
> 
> So the SIZECMD approach is filesystem dependent, but in a way that is
> creates minimal difference, unlike the current approach which can wildly
> vary.  It is also about the same speed as the current du based approach.

find . \! -type -d -print0

-- 
Florian Pritz

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://mailman.archlinux.org/pipermail/pacman-dev/attachments/20111225/fadf8d56/attachment.asc>


More information about the pacman-dev mailing list