From b803a33a8fc2ef86ba2d986c36f31524532d454b Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Tue, 14 Jun 2011 22:01:05 +1000 Subject: makepkg: Add UPX compression support This patch enables the automatic compression of executable binaries using UPX when the 'upx' options is specified in makepkg.conf or the PKGBUILD. Additional arguments can be passed to UPX by specifying the UPXFLAGS variable. Original-patch-by: Bryce Gibson Signed-off-by: Allan McRae Signed-off-by: Dan McGee --- scripts/makepkg.sh.in | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 78cd4cfc..b0247bdf 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' \ @@ -940,6 +940,17 @@ tidy_install() { msg2 "$(gettext "Removing empty directories...")" find . -depth -type d -empty -delete fi + + if [[ $(check_option upx) = "y" ]]; then + msg2 "$(gettext "Compressing binaries with %s...")" "UPX" + local binary + find . -type f -perm -u+w 2>/dev/null | while read binary ; do + if [[ $(file -bi "$binary") = *'application/x-executable'* ]]; then + upx $UPXFLAGS "$binary" &>/dev/null || + warning "$(gettext "Could not compress binary : %s")" "${binary/$pkgdir\//}" + fi + done + fi } find_libdepends() { -- cgit v1.2.3-70-g09d2