From 0edb8646096b83e20b704f8df47cc117025517ea Mon Sep 17 00:00:00 2001 From: Xavier Chantry Date: Tue, 19 Aug 2008 00:16:54 +0200 Subject: [PATCH] makepkg : Add the STATCMD option. commit 149839c5391e9a93 introduced a small behavior regression as a drawback for a better portability. This fixes FS#11225 by computing the actual size rather than disk usage like previously, but also allows to specify a different stat command on each system, which makes it possible to work around the portability issues between Linux and BSD. Signed-off-by: Xavier Chantry --- etc/makepkg.conf.in | 6 ++++++ scripts/makepkg.sh.in | 9 ++++++++- scripts/repo-add.sh.in | 8 ++++++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/etc/makepkg.conf.in b/etc/makepkg.conf.in index 0241a8e..22361a0 100644 --- a/etc/makepkg.conf.in +++ b/etc/makepkg.conf.in @@ -19,6 +19,12 @@ DLAGENTS=('ftp::/usr/bin/wget -c --passive-ftp -t 3 --waitretry=3 -O %o %u' # /usr/bin/lftpget -c # /usr/bin/curl +#-- The command for displaying the size of a file +#-- Linux / Cygwin +STATCMD=(stat -c %s) +#-- BSD / OSX +#STATCMD=(stat -f %z) + ######################################################################### # ARCHITECTURE, COMPILE FLAGS ######################################################################### diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index c751271..605c4b4 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -768,7 +768,14 @@ create_package() { else local packager="Unknown Packager" fi - local size=$(du -sk | awk '{print $1 * 1024}') + + if [ -z "${STATCMD[*]}" ]; then + error "$(gettext "No STATCMD command defined in %s.")" "$MAKEPKG_CONF" + plain "$(gettext "Aborting...")" + exit 1 # $E_CONFIG_ERROR + fi + local size=$(find . -exec ${STATCMD[*]} '{}' ';' 2>/dev/null | + awk '{sum+=$1} END {printf("%d\n", sum)}') # write the .PKGINFO file msg2 "$(gettext "Generating .PKGINFO file...")" diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in index 9ab023d..3b7c990 100644 --- a/scripts/repo-add.sh.in +++ b/scripts/repo-add.sh.in @@ -123,7 +123,7 @@ db_write_delta() # get md5sum and size of delta md5sum="$(md5sum "$deltafile" | cut -d ' ' -f 1)" - csize=$(du -kL "$deltafile" | awk '{print $1 * 1024}') + csize=$(${STATCMD[*]} "$deltafile") # ensure variables were found if [ -z "$pkgname" -o -z "$fromver" -o -z "$tover" -o -z "$arch" ]; then @@ -170,7 +170,11 @@ db_write_entry() IFS=$OLDIFS # get compressed size of package - csize=$(du -kL "$pkgfile" | awk '{print $1 * 1024}') + if [ -z "${STATCMD[*]}" ]; then + error "$(gettext "No STATCMD command defined in %s.")" "$confdir/makepkg.conf" + return 1 + fi + csize=$(${STATCMD[*]} "$pkgfile") startdir=$(pwd) pushd "$gstmpdir" 2>&1 >/dev/null -- 1.5.6.5