mirror of
https://github.com/moparisthebest/pacman
synced 2024-11-16 06:15:08 -05:00
libmakepkg: make package tidy functions extendable
To add a new packaging option, drop a file into libmakepkg/tidy that contains a 'packaging_options+=('<option>') and a function that implements that option. The function needs added to the 'tidy_remove' array if it removes files or the 'tidy_modify' array otherwise. Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
bfe9b56e1f
commit
00da25a5ea
@ -26,14 +26,14 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
|
|||||||
|
|
||||||
source "$LIBRARY/util/message.sh"
|
source "$LIBRARY/util/message.sh"
|
||||||
|
|
||||||
|
|
||||||
|
declare -a packaging_options tidy_remove tidy_modify
|
||||||
|
|
||||||
for lib in "$LIBRARY/tidy/"*.sh; do
|
for lib in "$LIBRARY/tidy/"*.sh; do
|
||||||
source "$lib"
|
source "$lib"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
readonly -a packaging_options tidy_remove tidy_modify
|
||||||
packaging_options=('strip' 'docs' 'libtool' 'staticlibs' 'emptydirs' 'zipman'
|
|
||||||
'purge' 'upx' 'optipng' 'debug')
|
|
||||||
readonly -a packaging_options
|
|
||||||
|
|
||||||
|
|
||||||
tidy_install() {
|
tidy_install() {
|
||||||
@ -41,15 +41,12 @@ tidy_install() {
|
|||||||
msg "$(gettext "Tidying install...")"
|
msg "$(gettext "Tidying install...")"
|
||||||
|
|
||||||
# options that remove unwanted files
|
# options that remove unwanted files
|
||||||
tidy_docs
|
for func in ${tidy_remove[@]}; do
|
||||||
tidy_purge
|
$func
|
||||||
tidy_libtool
|
done
|
||||||
tidy_staticlibs
|
|
||||||
tidy_emptydirs
|
|
||||||
|
|
||||||
# options that reduce file sizes
|
# options that modify files
|
||||||
tidy_zipman
|
for func in ${tidy_modify[@]}; do
|
||||||
tidy_strip
|
$func
|
||||||
tidy_upx
|
done
|
||||||
tidy_optipng
|
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
|
|||||||
source "$LIBRARY/util/message.sh"
|
source "$LIBRARY/util/message.sh"
|
||||||
source "$LIBRARY/util/option.sh"
|
source "$LIBRARY/util/option.sh"
|
||||||
|
|
||||||
|
packaging_options+=('docs')
|
||||||
|
tidy_remove+=('tidy_docs')
|
||||||
|
|
||||||
tidy_docs() {
|
tidy_docs() {
|
||||||
if check_option "docs" "n" && [[ -n ${DOC_DIRS[*]} ]]; then
|
if check_option "docs" "n" && [[ -n ${DOC_DIRS[*]} ]]; then
|
||||||
|
@ -27,6 +27,9 @@ source "$LIBRARY/util/message.sh"
|
|||||||
source "$LIBRARY/util/option.sh"
|
source "$LIBRARY/util/option.sh"
|
||||||
|
|
||||||
|
|
||||||
|
packaging_options+=('emptydirs')
|
||||||
|
tidy_remove+=('tidy_emptydirs')
|
||||||
|
|
||||||
tidy_emptydirs() {
|
tidy_emptydirs() {
|
||||||
if check_option "emptydirs" "n"; then
|
if check_option "emptydirs" "n"; then
|
||||||
msg2 "$(gettext "Removing empty directories...")"
|
msg2 "$(gettext "Removing empty directories...")"
|
||||||
|
@ -27,6 +27,9 @@ source "$LIBRARY/util/message.sh"
|
|||||||
source "$LIBRARY/util/option.sh"
|
source "$LIBRARY/util/option.sh"
|
||||||
|
|
||||||
|
|
||||||
|
packaging_options+=('libtool')
|
||||||
|
tidy_remove+=('tidy_libtool')
|
||||||
|
|
||||||
tidy_libtool() {
|
tidy_libtool() {
|
||||||
if check_option "libtool" "n"; then
|
if check_option "libtool" "n"; then
|
||||||
msg2 "$(gettext "Removing "%s" files...")" "libtool"
|
msg2 "$(gettext "Removing "%s" files...")" "libtool"
|
||||||
|
@ -27,6 +27,9 @@ source "$LIBRARY/util/message.sh"
|
|||||||
source "$LIBRARY/util/option.sh"
|
source "$LIBRARY/util/option.sh"
|
||||||
|
|
||||||
|
|
||||||
|
packaging_options+=('optipng')
|
||||||
|
tidy_modify+=('tidy_optipng')
|
||||||
|
|
||||||
tidy_optipng() {
|
tidy_optipng() {
|
||||||
if check_option "optipng" "y"; then
|
if check_option "optipng" "y"; then
|
||||||
msg2 "$(gettext "Optimizing PNG images...")"
|
msg2 "$(gettext "Optimizing PNG images...")"
|
||||||
|
@ -27,6 +27,9 @@ source "$LIBRARY/util/message.sh"
|
|||||||
source "$LIBRARY/util/option.sh"
|
source "$LIBRARY/util/option.sh"
|
||||||
|
|
||||||
|
|
||||||
|
packaging_options+=('purge')
|
||||||
|
tidy_remove+=('tidy_purge')
|
||||||
|
|
||||||
tidy_purge() {
|
tidy_purge() {
|
||||||
if check_option "purge" "y" && [[ -n ${PURGE_TARGETS[*]} ]]; then
|
if check_option "purge" "y" && [[ -n ${PURGE_TARGETS[*]} ]]; then
|
||||||
msg2 "$(gettext "Purging unwanted files...")"
|
msg2 "$(gettext "Purging unwanted files...")"
|
||||||
|
@ -27,6 +27,9 @@ source "$LIBRARY/util/message.sh"
|
|||||||
source "$LIBRARY/util/option.sh"
|
source "$LIBRARY/util/option.sh"
|
||||||
|
|
||||||
|
|
||||||
|
packaging_options+=('staticlibs')
|
||||||
|
tidy_remove+=('tidy_staticlibs')
|
||||||
|
|
||||||
tidy_staticlibs() {
|
tidy_staticlibs() {
|
||||||
if check_option "staticlibs" "n"; then
|
if check_option "staticlibs" "n"; then
|
||||||
msg2 "$(gettext "Removing static library files...")"
|
msg2 "$(gettext "Removing static library files...")"
|
||||||
|
@ -27,6 +27,9 @@ source "$LIBRARY/util/message.sh"
|
|||||||
source "$LIBRARY/util/option.sh"
|
source "$LIBRARY/util/option.sh"
|
||||||
|
|
||||||
|
|
||||||
|
packaging_options+=('strip' 'debug')
|
||||||
|
tidy_modify+=('tidy_strip')
|
||||||
|
|
||||||
tidy_strip() {
|
tidy_strip() {
|
||||||
if check_option "strip" "y"; then
|
if check_option "strip" "y"; then
|
||||||
msg2 "$(gettext "Stripping unneeded symbols from binaries and libraries...")"
|
msg2 "$(gettext "Stripping unneeded symbols from binaries and libraries...")"
|
||||||
|
@ -27,6 +27,9 @@ source "$LIBRARY/util/message.sh"
|
|||||||
source "$LIBRARY/util/option.sh"
|
source "$LIBRARY/util/option.sh"
|
||||||
|
|
||||||
|
|
||||||
|
packaging_options+=('upx')
|
||||||
|
tidy_modify+=('tidy_upx')
|
||||||
|
|
||||||
tidy_upx() {
|
tidy_upx() {
|
||||||
if check_option "upx" "y"; then
|
if check_option "upx" "y"; then
|
||||||
msg2 "$(gettext "Compressing binaries with %s...")" "UPX"
|
msg2 "$(gettext "Compressing binaries with %s...")" "UPX"
|
||||||
|
@ -27,6 +27,9 @@ source "$LIBRARY/util/message.sh"
|
|||||||
source "$LIBRARY/util/option.sh"
|
source "$LIBRARY/util/option.sh"
|
||||||
|
|
||||||
|
|
||||||
|
packaging_options+=('zipman')
|
||||||
|
tidy_modify+=('tidy_zipman')
|
||||||
|
|
||||||
tidy_zipman() {
|
tidy_zipman() {
|
||||||
if check_option "zipman" "y" && [[ -n ${MAN_DIRS[*]} ]]; then
|
if check_option "zipman" "y" && [[ -n ${MAN_DIRS[*]} ]]; then
|
||||||
msg2 "$(gettext "Compressing man and info pages...")"
|
msg2 "$(gettext "Compressing man and info pages...")"
|
||||||
|
Loading…
Reference in New Issue
Block a user