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

Dave Reisner d at falconindy.com
Sun Dec 25 17:57:52 EST 2011


On Sun, Dec 25, 2011 at 11:50:57PM +0100, Florian Pritz wrote:
> 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
> 

But directories add to the size of the package. IMO, it's correct to
just sum up everything.

d

P.S. history expansion doesn't happen in a non-interactive shell.
there's no need to escape the !.


More information about the pacman-dev mailing list