diff --git a/etc/makepkg.conf.in b/etc/makepkg.conf.in index c3b7cc0..58b5d08 100644 --- a/etc/makepkg.conf.in +++ b/etc/makepkg.conf.in @@ -69,6 +69,7 @@ BUILDENV=(fakeroot !distcc color !ccache check !sign) #-- emptydirs: Leave empty directories in packages #-- zipman: Compress manual (man and info) pages in MAN_DIRS with gzip #-- purge: Remove files specified by PURGE_TARGETS +#-- upx: Compress executables using UPX # OPTIONS=(strip docs libtool emptydirs zipman purge) @@ -86,7 +87,8 @@ MAN_DIRS=({usr{,/local}{,/share},opt/*}/{man,info}) DOC_DIRS=(usr/{,local/}{,share/}{doc,gtk-doc} opt/*/{doc,gtk-doc}) #-- Files to be removed from all packages (if purge is specified) PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod) - +#-- Flags to pass to upx during file compression +UPX="--lzma" ######################################################################### # PACKAGE OUTPUT ######################################################################### diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 93cf566..7b961c7 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -44,7 +44,7 @@ startdir="$PWD" srcdir="$startdir/src" pkgdir="$startdir/pkg" -packaging_options=('strip' 'docs' 'libtool' 'emptydirs' 'zipman' 'purge') +packaging_options=('strip' 'docs' 'libtool' 'emptydirs' 'zipman' 'purge' 'upx') other_options=('ccache' 'distcc' 'buildflags' 'makeflags') splitpkg_overrides=('pkgver' 'pkgrel' 'pkgdesc' 'arch' 'license' 'groups' \ 'depends' 'optdepends' 'provides' 'conflicts' 'replaces' \ @@ -931,6 +931,20 @@ tidy_install() { msg2 "$(gettext "Removing empty directories...")" find . -depth -type d -empty -delete fi + + if [ "$(check_option upx)" = "y" -a -x /usr/bin/upx ]; then + msg2 "$(gettext "UPXing :)")" + export UPX + local binary + find . -type f 2>/dev/null | while read binary ; do + case "$(file -biz "$binary")" in + *compressed-encoding*) # Skip compressed binaries + ;; + *application/x-executable*) # Binaries + /usr/bin/upx "$binary" >/dev/null 2>&1 || echo "Could not compress $binary";; + esac + done + fi } write_pkginfo() {