summaryrefslogtreecommitdiffstats
path: root/scripts/makepkg.sh.in
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 12:19:04 +0100
commit9917930ae1f02fdf85c1ca2a35ee039f1a17368f (patch)
tree3612bf435fa5c40d13ee84b6365235a07e591d15 /scripts/makepkg.sh.in
parentbd2e95b00be2ce36767811d2da6d291c85f9a3f1 (diff)
downloadpacman-9917930ae1f02fdf85c1ca2a35ee039f1a17368f.tar.gz
pacman-9917930ae1f02fdf85c1ca2a35ee039f1a17368f.tar.xz
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>
Diffstat (limited to 'scripts/makepkg.sh.in')
-rw-r--r--scripts/makepkg.sh.in21
1 files changed, 20 insertions, 1 deletions
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