mirror of
https://github.com/moparisthebest/pacman
synced 2024-10-31 15:45:03 -04:00
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>
This commit is contained in:
parent
bd2e95b00b
commit
9917930ae1
@ -211,7 +211,7 @@ hi def link pbValidSha512sums Number
|
|||||||
|
|
||||||
" options
|
" options
|
||||||
syn keyword pb_k_options options contained
|
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 pbOptionsNeg /\!/ contained
|
||||||
syn match pbOptionsDeprec /no/ contained
|
syn match pbOptionsDeprec /no/ contained
|
||||||
syn region pbOptionsGroup start=/^options=(/ end=/)/ contains=pb_k_options,pbOptions,pbOptionsNeg,pbOptionsDeprec,pbIllegalOption
|
syn region pbOptionsGroup start=/^options=(/ end=/)/ contains=pb_k_options,pbOptions,pbOptionsNeg,pbOptionsDeprec,pbIllegalOption
|
||||||
|
@ -296,6 +296,9 @@ underscore and the architecture name e.g., 'replaces_x86_64=()'.
|
|||||||
*upx*;;
|
*upx*;;
|
||||||
Compress binary executable files using UPX.
|
Compress binary executable files using UPX.
|
||||||
|
|
||||||
|
*optipng*;;
|
||||||
|
Optimize PNG images with optipng.
|
||||||
|
|
||||||
*ccache*;;
|
*ccache*;;
|
||||||
Allow the use of ccache during build. More useful in its negative
|
Allow the use of ccache during build. More useful in its negative
|
||||||
form `!ccache` with select packages that have problems building
|
form `!ccache` with select packages that have problems building
|
||||||
|
@ -140,7 +140,7 @@ Options
|
|||||||
Specify a key to use for GPG signing instead of the default key in the
|
Specify a key to use for GPG signing instead of the default key in the
|
||||||
keyring. Can be overridden with makepkg's '\--key' option.
|
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
|
This array contains options that affect default packaging. They are
|
||||||
equivalent to options that can be placed in the PKGBUILD; the defaults 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
|
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
|
Compress binary executable files using UPX. Additional options
|
||||||
can be passed to UPX by specifying the `UPXFLAGS` array variable.
|
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*;;
|
*debug*;;
|
||||||
Add the user-specified debug flags as specified in DEBUG_CFLAGS and
|
Add the user-specified debug flags as specified in DEBUG_CFLAGS and
|
||||||
DEBUG_CXXFLAGS to their counterpart buildflags. Creates a separate
|
DEBUG_CXXFLAGS to their counterpart buildflags. Creates a separate
|
||||||
|
@ -71,7 +71,7 @@ BUILDENV=(!distcc color !ccache check !sign)
|
|||||||
# These are default values for the options=() settings
|
# 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.
|
# A negated option will do the opposite of the comments below.
|
||||||
#
|
#
|
||||||
#-- strip: Strip symbols from binaries/libraries
|
#-- 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
|
#-- zipman: Compress manual (man and info) pages in MAN_DIRS with gzip
|
||||||
#-- purge: Remove files specified by PURGE_TARGETS
|
#-- purge: Remove files specified by PURGE_TARGETS
|
||||||
#-- upx: Compress binary executable files using UPX
|
#-- upx: Compress binary executable files using UPX
|
||||||
|
#-- optipng: Optimize PNG images with optipng
|
||||||
#-- debug: Add debugging flags as specified in DEBUG_* variables
|
#-- 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
|
#-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512
|
||||||
INTEGRITY_CHECK=(md5)
|
INTEGRITY_CHECK=(md5)
|
||||||
|
@ -49,7 +49,7 @@ declare -r startdir="$PWD"
|
|||||||
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
|
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
|
||||||
|
|
||||||
packaging_options=('strip' 'docs' 'libtool' 'staticlibs' 'emptydirs' 'zipman'
|
packaging_options=('strip' 'docs' 'libtool' 'staticlibs' 'emptydirs' 'zipman'
|
||||||
'purge' 'upx' 'debug')
|
'purge' 'upx' 'optipng' 'debug')
|
||||||
other_options=('ccache' 'distcc' 'buildflags' 'makeflags')
|
other_options=('ccache' 'distcc' 'buildflags' 'makeflags')
|
||||||
splitpkg_overrides=('pkgdesc' 'arch' 'url' 'license' 'groups' 'depends'
|
splitpkg_overrides=('pkgdesc' 'arch' 'url' 'license' 'groups' 'depends'
|
||||||
'optdepends' 'provides' 'conflicts' 'replaces' 'backup'
|
'optdepends' 'provides' 'conflicts' 'replaces' 'backup'
|
||||||
@ -1918,6 +1918,17 @@ tidy_install() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
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() {
|
find_libdepends() {
|
||||||
@ -3008,6 +3019,14 @@ check_software() {
|
|||||||
fi
|
fi
|
||||||
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
|
# distcc - compilation with distcc
|
||||||
if check_buildenv "distcc" "y" && ! check_option "distcc" "n"; then
|
if check_buildenv "distcc" "y" && ! check_option "distcc" "n"; then
|
||||||
if ! type -p distcc >/dev/null; then
|
if ! type -p distcc >/dev/null; then
|
||||||
|
Loading…
Reference in New Issue
Block a user