Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Hesse <mail@eworm.de>2015-01-26 11:25:23 +0100
committerAllan McRae <allan@archlinux.org>2015-02-01 21:19:04 +1000
commit9917930ae1f02fdf85c1ca2a35ee039f1a17368f (patch)
tree3612bf435fa5c40d13ee84b6365235a07e591d15
parentbd2e95b00be2ce36767811d2da6d291c85f9a3f1 (diff)
add option to optimize PNG images with optipng
This can decrease package size by optimizing PNG image size. Images are just stored with better compression and/or filter options. The actual image content is not altered. Additionally this can automatically fix broken PNG images which caused some trouble lately. Signed-off-by: Christian Hesse <mail@eworm.de> Signed-off-by: Allan McRae <allan@archlinux.org>
-rw-r--r--contrib/PKGBUILD.vim2
-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.in21
5 files changed, 32 insertions, 5 deletions
diff --git a/contrib/PKGBUILD.vim b/contrib/PKGBUILD.vim
index cf264f93..35ca6bd9 100644
--- a/contrib/PKGBUILD.vim
+++ b/contrib/PKGBUILD.vim
@@ -211,7 +211,7 @@ hi def link pbValidSha512sums Number
" options
syn keyword pb_k_options options contained
-syn match pbOptions /\(no\)\?\(strip\|docs\|libtool\|emptydirs\|zipman\|purge\|upx\|distcc\|color\|ccache\|check\|sign\|makeflags\|buildflags\)/ contained
+syn match pbOptions /\(no\)\?\(strip\|docs\|libtool\|emptydirs\|zipman\|purge\|upx\|optipng\|distcc\|color\|ccache\|check\|sign\|makeflags\|buildflags\)/ contained
syn match pbOptionsNeg /\!/ contained
syn match pbOptionsDeprec /no/ contained
syn region pbOptionsGroup start=/^options=(/ end=/)/ contains=pb_k_options,pbOptions,pbOptionsNeg,pbOptionsDeprec,pbIllegalOption
diff --git a/doc/PKGBUILD.5.txt b/doc/PKGBUILD.5.txt
index c95c41d8..10980aba 100644
--- a/doc/PKGBUILD.5.txt
+++ b/doc/PKGBUILD.5.txt
@@ -296,6 +296,9 @@ underscore and the architecture name e.g., 'replaces_x86_64=()'.
*upx*;;
Compress binary executable files using UPX.
+ *optipng*;;
+ Optimize PNG images with optipng.
+
*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 5e34b916..ac5791fd 100644
--- a/doc/makepkg.conf.5.txt
+++ b/doc/makepkg.conf.5.txt
@@ -140,7 +140,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 staticlibs emptydirs zipman purge !upx**)**::
+**OPTIONS=(**strip docs libtool staticlibs emptydirs zipman purge !upx !optipng**)**::
This array contains options that affect 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
@@ -181,6 +181,10 @@ Options
Compress binary executable files using UPX. Additional options
can be passed to UPX by specifying the `UPXFLAGS` array variable.
+ *optipng*;;
+ Optimize PNG images with optipng. Additional options can be passed
+ to optipng by specifying the `OPTIPNGFLAGS` array variable.
+
*debug*;;
Add the user-specified debug flags as specified in DEBUG_CFLAGS and
DEBUG_CXXFLAGS to their counterpart buildflags. Creates a separate
diff --git a/etc/makepkg.conf.in b/etc/makepkg.conf.in
index 19f673d1..71ec624b 100644
--- a/etc/makepkg.conf.in
+++ b/etc/makepkg.conf.in
@@ -71,7 +71,7 @@ BUILDENV=(!distcc color !ccache check !sign)
# These are default values for the options=() settings
#########################################################################
#
-# Default: OPTIONS=(strip docs libtool staticlibs emptydirs zipman purge !upx !debug)
+# Default: OPTIONS=(strip docs libtool staticlibs emptydirs zipman purge !upx !optipng !debug)
# A negated option will do the opposite of the comments below.
#
#-- strip: Strip symbols from binaries/libraries
@@ -82,9 +82,10 @@ BUILDENV=(!distcc color !ccache check !sign)
#-- 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
+#-- optipng: Optimize PNG images with optipng
#-- debug: Add debugging flags as specified in DEBUG_* variables
#
-OPTIONS=(strip docs libtool staticlibs emptydirs zipman purge !upx !debug)
+OPTIONS=(strip docs libtool staticlibs emptydirs zipman purge !upx !optipng !debug)
#-- 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 4640f033..40913c5e 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -49,7 +49,7 @@ declare -r startdir="$PWD"
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
packaging_options=('strip' 'docs' 'libtool' 'staticlibs' 'emptydirs' 'zipman'
- 'purge' 'upx' 'debug')
+ 'purge' 'upx' 'optipng' 'debug')
other_options=('ccache' 'distcc' 'buildflags' 'makeflags')
splitpkg_overrides=('pkgdesc' 'arch' 'url' 'license' 'groups' 'depends'
'optdepends' 'provides' 'conflicts' 'replaces' 'backup'
@@ -1918,6 +1918,17 @@ tidy_install() {
fi
done
fi
+
+ if check_option "optipng" "y"; then
+ msg2 "$(gettext "Optimizing PNG images...")"
+ local png
+ find . -type f -iname "*.png" 2>/dev/null | while read -r png ; do
+ if [[ $(file --brief --mime-type "$png") = 'image/png' ]]; then
+ optipng "${OPTIPNGFLAGS[@]}" "$png" &>/dev/null ||
+ warning "$(gettext "Could not optimize PNG image : %s")" "${png/$pkgdir\//}"
+ fi
+ done
+ fi
}
find_libdepends() {
@@ -3008,6 +3019,14 @@ check_software() {
fi
fi
+ # optipng - PNG image optimization
+ if check_option "optipng" "y"; then
+ if ! type -p optipng >/dev/null; then
+ error "$(gettext "Cannot find the %s binary required for optimizing PNG images.")" "optipng"
+ ret=1
+ fi
+ fi
+
# distcc - compilation with distcc
if check_buildenv "distcc" "y" && ! check_option "distcc" "n"; then
if ! type -p distcc >/dev/null; then