summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan McRae <allan@archlinux.org>2011-06-14 22:01:05 +1000
committerDan McGee <dan@archlinux.org>2011-06-22 10:45:18 -0500
commitb803a33a8fc2ef86ba2d986c36f31524532d454b (patch)
tree6a5e5a8a88be9ab10535a352d09a19647baf037c
parentb8990993271b34d309ada49197090895b0fbdfb6 (diff)
downloadpacman-b803a33a8fc2ef86ba2d986c36f31524532d454b.tar.xz
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 <bryce@gibson-consulting.com.au> Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--doc/PKGBUILD.5.txt3
-rw-r--r--doc/makepkg.conf.5.txt6
-rw-r--r--etc/makepkg.conf.in5
-rw-r--r--scripts/makepkg.sh.in13
4 files changed, 23 insertions, 4 deletions
diff --git a/doc/PKGBUILD.5.txt b/doc/PKGBUILD.5.txt
index 24e1a125..4d761214 100644
--- a/doc/PKGBUILD.5.txt
+++ b/doc/PKGBUILD.5.txt
@@ -231,6 +231,9 @@ version. Appending the version yourself disables auto detection.
*zipman*;;
Compress man and info pages with gzip.
+ *upx*;;
+ Compress binary executable files using UPX.
+
*ccache*;;
Allow the use of ccache during build. More useful in its negative
form `!ccache` with select packages that have problems building
diff --git a/doc/makepkg.conf.5.txt b/doc/makepkg.conf.5.txt
index 3ce4759f..48f5ef56 100644
--- a/doc/makepkg.conf.5.txt
+++ b/doc/makepkg.conf.5.txt
@@ -114,7 +114,7 @@ Options
Specify a key to use for gpg signing instead of the default key in the
keyring. Can be overridden with makepkg's `--key` option.
-**OPTIONS=(**strip !docs libtool emptydirs zipman**)**::
+**OPTIONS=(**strip docs libtool emptydirs zipman purge !upx**)**::
This array contains options that affect the default packaging. They are
equivalent to options that can be placed in the PKGBUILD; the defaults are
shown here. All options should always be left in the array; to enable or
@@ -146,6 +146,10 @@ Options
Remove files specified by the `PURGE_TARGETS` variable from the
package.
+ *upx*;;
+ Compress binary executable files using UPX. Additional options
+ can be passed to UPX by specifying the `UPXFLAGS` variable.
+
**INTEGRITY_CHECK=(**check1 ...**)**::
File integrity checks to use. Multiple checks may be specified; this
affects both generation and checking. The current valid options are:
diff --git a/etc/makepkg.conf.in b/etc/makepkg.conf.in
index 9a790fcf..42ae9405 100644
--- a/etc/makepkg.conf.in
+++ b/etc/makepkg.conf.in
@@ -60,7 +60,7 @@ BUILDENV=(fakeroot !distcc color !ccache check !sign)
# These are default values for the options=() settings
#########################################################################
#
-# Default: OPTIONS=(strip docs libtool emptydirs zipman purge)
+# Default: OPTIONS=(strip docs libtool emptydirs zipman purge !upx)
# A negated option will do the opposite of the comments below.
#
#-- strip: Strip symbols from binaries/libraries
@@ -69,8 +69,9 @@ 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 binary executable files using UPX
#
-OPTIONS=(strip docs libtool emptydirs zipman purge)
+OPTIONS=(strip docs libtool emptydirs zipman purge !upx)
#-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512
INTEGRITY_CHECK=(md5)
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() {