mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-22 07:48:50 -05:00
makepkg: split package tidying into libmakepkg
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
33466000d6
commit
295a3491ad
@ -41,6 +41,7 @@ LIBRARY = \
|
||||
libmakepkgdir = $(datarootdir)/makepkg
|
||||
|
||||
LIBMAKEPKGDIRS = \
|
||||
tidy \
|
||||
util
|
||||
|
||||
LIBMAKEPKG = \
|
||||
@ -48,6 +49,18 @@ LIBMAKEPKG = \
|
||||
libmakepkg/util/option.sh
|
||||
|
||||
LIBMAKEPKG_IN = \
|
||||
libmakepkg/tidy.sh \
|
||||
libmakepkg/tidy/build_references.sh \
|
||||
libmakepkg/tidy/docs.sh \
|
||||
libmakepkg/tidy/emptydirs.sh \
|
||||
libmakepkg/tidy/libtool.sh \
|
||||
libmakepkg/tidy/missing_backup.sh \
|
||||
libmakepkg/tidy/optipng.sh \
|
||||
libmakepkg/tidy/purge.sh \
|
||||
libmakepkg/tidy/staticlibs.sh \
|
||||
libmakepkg/tidy/strip.sh \
|
||||
libmakepkg/tidy/upx.sh \
|
||||
libmakepkg/tidy/zipman.sh \
|
||||
libmakepkg/util.sh
|
||||
|
||||
LIBMAKEPKG_DIST = \
|
||||
|
12
scripts/libmakepkg/.gitignore
vendored
12
scripts/libmakepkg/.gitignore
vendored
@ -1 +1,13 @@
|
||||
tidy.sh
|
||||
tidy/build_references.sh
|
||||
tidy/docs.sh
|
||||
tidy/emptydirs.sh
|
||||
tidy/libtool.sh
|
||||
tidy/missing_backup.sh
|
||||
tidy/optipng.sh
|
||||
tidy/purge.sh
|
||||
tidy/staticlibs.sh
|
||||
tidy/strip.sh
|
||||
tidy/upx.sh
|
||||
tidy/zipman.sh
|
||||
util.sh
|
||||
|
60
scripts/libmakepkg/tidy.sh.in
Normal file
60
scripts/libmakepkg/tidy.sh.in
Normal file
@ -0,0 +1,60 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# tidy.sh - functions for modifying/removing installed files before
|
||||
# package creation
|
||||
#
|
||||
# Copyright (c) 2015 Pacman Development Team <pacman-dev@archlinux.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
[ -n "$LIBMAKEPKG_TIDY_SH" ] && return
|
||||
LIBMAKEPKG_TIDY_SH=1
|
||||
|
||||
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
|
||||
|
||||
source "$LIBRARY/util/message.sh"
|
||||
|
||||
for lib in "$LIBRARY/tidy/"*.sh; do
|
||||
source "$lib"
|
||||
done
|
||||
|
||||
|
||||
packaging_options=('strip' 'docs' 'libtool' 'staticlibs' 'emptydirs' 'zipman'
|
||||
'purge' 'upx' 'optipng' 'debug')
|
||||
readonly -a packaging_options
|
||||
|
||||
|
||||
tidy_install() {
|
||||
cd_safe "$pkgdir"
|
||||
msg "$(gettext "Tidying install...")"
|
||||
|
||||
# options that remove unwanted files
|
||||
tidy_docs
|
||||
tidy_purge
|
||||
tidy_libtool
|
||||
tidy_staticlibs
|
||||
tidy_emptydirs
|
||||
|
||||
# warn about packaging issues
|
||||
# TODO: move these to another module
|
||||
warn_missing_backup
|
||||
warn_build_references
|
||||
|
||||
# options that reduce file sizes
|
||||
tidy_zipman
|
||||
tidy_strip
|
||||
tidy_upx
|
||||
tidy_optipng
|
||||
}
|
36
scripts/libmakepkg/tidy/build_references.sh.in
Normal file
36
scripts/libmakepkg/tidy/build_references.sh.in
Normal file
@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# build_references.sh - Warn about files containing references to build directories
|
||||
#
|
||||
# Copyright (c) 2013-2015 Pacman Development Team <pacman-dev@archlinux.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
[ -n "$LIBMAKEPKG_TIDY_BUILD_REFERENCES_SH" ] && return
|
||||
LIBMAKEPKG_TIDY_BUILD_REFERENCES_SH=1
|
||||
|
||||
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
|
||||
|
||||
source "$LIBRARY/util/message.sh"
|
||||
|
||||
|
||||
warn_build_references() {
|
||||
if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I "${srcdir}" ; then
|
||||
warning "$(gettext "Package contains reference to %s")" "\$srcdir"
|
||||
fi
|
||||
if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I "${pkgdirbase}" ; then
|
||||
warning "$(gettext "Package contains reference to %s")" "\$pkgdir"
|
||||
fi
|
||||
}
|
35
scripts/libmakepkg/tidy/docs.sh.in
Normal file
35
scripts/libmakepkg/tidy/docs.sh.in
Normal file
@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# docs.sh - Remove documentation files from the package
|
||||
#
|
||||
# Copyright (c) 2008-2015 Pacman Development Team <pacman-dev@archlinux.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
[ -n "$LIBMAKEPKG_TIDY_DOCS_SH" ] && return
|
||||
LIBMAKEPKG_TIDY_DOCS_SH=1
|
||||
|
||||
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
|
||||
|
||||
source "$LIBRARY/util/message.sh"
|
||||
source "$LIBRARY/util/option.sh"
|
||||
|
||||
|
||||
tidy_docs() {
|
||||
if check_option "docs" "n" && [[ -n ${DOC_DIRS[*]} ]]; then
|
||||
msg2 "$(gettext "Removing doc files...")"
|
||||
rm -rf -- ${DOC_DIRS[@]}
|
||||
fi
|
||||
}
|
35
scripts/libmakepkg/tidy/emptydirs.sh.in
Normal file
35
scripts/libmakepkg/tidy/emptydirs.sh.in
Normal file
@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# emptydirs.sh - Remove empty directories from the package
|
||||
#
|
||||
# Copyright (c) 2013-2015 Pacman Development Team <pacman-dev@archlinux.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
[ -n "$LIBMAKEPKG_TIDY_EMPTYDIRS_SH" ] && return
|
||||
LIBMAKEPKG_TIDY_EMPTYDIRS_SH=1
|
||||
|
||||
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
|
||||
|
||||
source "$LIBRARY/util/message.sh"
|
||||
source "$LIBRARY/util/option.sh"
|
||||
|
||||
|
||||
tidy_emptydirs() {
|
||||
if check_option "emptydirs" "n"; then
|
||||
msg2 "$(gettext "Removing empty directories...")"
|
||||
find . -depth -type d -exec rmdir '{}' + 2>/dev/null
|
||||
fi
|
||||
}
|
35
scripts/libmakepkg/tidy/libtool.sh.in
Normal file
35
scripts/libmakepkg/tidy/libtool.sh.in
Normal file
@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# libtool.sh - Remove libtool files from the package
|
||||
#
|
||||
# Copyright (c) 2013-2015 Pacman Development Team <pacman-dev@archlinux.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
[ -n "$LIBMAKEPKG_TIDY_LIBTOOL_SH" ] && return
|
||||
LIBMAKEPKG_TIDY_LIBTOOL_SH=1
|
||||
|
||||
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
|
||||
|
||||
source "$LIBRARY/util/message.sh"
|
||||
source "$LIBRARY/util/option.sh"
|
||||
|
||||
|
||||
tidy_libtool() {
|
||||
if check_option "libtool" "n"; then
|
||||
msg2 "$(gettext "Removing "%s" files...")" "libtool"
|
||||
find . ! -type d -name "*.la" -exec rm -f -- '{}' +
|
||||
fi
|
||||
}
|
36
scripts/libmakepkg/tidy/missing_backup.sh.in
Normal file
36
scripts/libmakepkg/tidy/missing_backup.sh.in
Normal file
@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# missing_backup.sh - Warn about missing files in the backup array
|
||||
#
|
||||
# Copyright (c) 2013-2015 Pacman Development Team <pacman-dev@archlinux.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
[ -n "$LIBMAKEPKG_TIDY_MISSING_BACKUP_SH" ] && return
|
||||
LIBMAKEPKG_TIDY_MISSING_BACKUP_SH=1
|
||||
|
||||
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
|
||||
|
||||
source "$LIBRARY/util/message.sh"
|
||||
|
||||
|
||||
warn_missing_backup() {
|
||||
local file
|
||||
for file in "${backup[@]}"; do
|
||||
if [[ ! -f $file ]]; then
|
||||
warning "$(gettext "%s entry file not in package : %s")" "backup" "$file"
|
||||
fi
|
||||
done
|
||||
}
|
41
scripts/libmakepkg/tidy/optipng.sh.in
Normal file
41
scripts/libmakepkg/tidy/optipng.sh.in
Normal file
@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# optipng.sh - Compress PNG files using optpng
|
||||
#
|
||||
# Copyright (c) 2015 Pacman Development Team <pacman-dev@archlinux.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
[ -n "$LIBMAKEPKG_TIDY_OPTIPNG_SH" ] && return
|
||||
LIBMAKEPKG_TIDY_OPTIPNG_SH=1
|
||||
|
||||
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
|
||||
|
||||
source "$LIBRARY/util/message.sh"
|
||||
source "$LIBRARY/util/option.sh"
|
||||
|
||||
|
||||
tidy_optipng() {
|
||||
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
|
||||
}
|
42
scripts/libmakepkg/tidy/purge.sh.in
Normal file
42
scripts/libmakepkg/tidy/purge.sh.in
Normal file
@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# purge.sh - Remove unwanted files from the package
|
||||
#
|
||||
# Copyright (c) 2008-2015 Pacman Development Team <pacman-dev@archlinux.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
[ -n "$LIBMAKEPKG_TIDY_PURGE_SH" ] && return
|
||||
LIBMAKEPKG_TIDY_PURGE_SH=1
|
||||
|
||||
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
|
||||
|
||||
source "$LIBRARY/util/message.sh"
|
||||
source "$LIBRARY/util/option.sh"
|
||||
|
||||
|
||||
tidy_purge() {
|
||||
if check_option "purge" "y" && [[ -n ${PURGE_TARGETS[*]} ]]; then
|
||||
msg2 "$(gettext "Purging unwanted files...")"
|
||||
local pt
|
||||
for pt in "${PURGE_TARGETS[@]}"; do
|
||||
if [[ ${pt} = "${pt//\/}" ]]; then
|
||||
find . ! -type d -name "${pt}" -exec rm -f -- '{}' +
|
||||
else
|
||||
rm -f ${pt}
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
40
scripts/libmakepkg/tidy/staticlibs.sh.in
Normal file
40
scripts/libmakepkg/tidy/staticlibs.sh.in
Normal file
@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# staticlibs.sh - Remove static library files from the package
|
||||
#
|
||||
# Copyright (c) 2013-2015 Pacman Development Team <pacman-dev@archlinux.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
[ -n "$LIBMAKEPKG_TIDY_STATICLIBS_SH" ] && return
|
||||
LIBMAKEPKG_TIDY_STATICLIBS_SH=1
|
||||
|
||||
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
|
||||
|
||||
source "$LIBRARY/util/message.sh"
|
||||
source "$LIBRARY/util/option.sh"
|
||||
|
||||
|
||||
tidy_staticlibs() {
|
||||
if check_option "staticlibs" "n"; then
|
||||
msg2 "$(gettext "Removing static library files...")"
|
||||
local l
|
||||
while read -rd '' l; do
|
||||
if [[ -f "${l%.a}.so" || -h "${l%.a}.so" ]]; then
|
||||
rm "$l"
|
||||
fi
|
||||
done < <(find . ! -type d -name "*.a" -print0)
|
||||
fi
|
||||
}
|
64
scripts/libmakepkg/tidy/strip.sh.in
Normal file
64
scripts/libmakepkg/tidy/strip.sh.in
Normal file
@ -0,0 +1,64 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# strip.sh - Strip debugging symbols from binary files
|
||||
#
|
||||
# Copyright (c) 2007-2015 Pacman Development Team <pacman-dev@archlinux.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
[ -n "$LIBMAKEPKG_TIDY_STRIP_SH" ] && return
|
||||
LIBMAKEPKG_TIDY_STRIP_SH=1
|
||||
|
||||
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
|
||||
|
||||
source "$LIBRARY/util/message.sh"
|
||||
source "$LIBRARY/util/option.sh"
|
||||
|
||||
|
||||
tidy_strip() {
|
||||
if check_option "strip" "y"; then
|
||||
msg2 "$(gettext "Stripping unneeded symbols from binaries and libraries...")"
|
||||
# make sure library stripping variables are defined to prevent excess stripping
|
||||
[[ -z ${STRIP_SHARED+x} ]] && STRIP_SHARED="-S"
|
||||
[[ -z ${STRIP_STATIC+x} ]] && STRIP_STATIC="-S"
|
||||
|
||||
if check_option "debug" "y"; then
|
||||
dbgdir="$pkgdir-@DEBUGSUFFIX@/usr/lib/debug"
|
||||
mkdir -p "$dbgdir"
|
||||
fi
|
||||
|
||||
local binary strip_flags
|
||||
find . -type f -perm -u+w -print0 2>/dev/null | while read -rd '' binary ; do
|
||||
case "$(file -bi "$binary")" in
|
||||
*application/x-sharedlib*) # Libraries (.so)
|
||||
strip_flags="$STRIP_SHARED";;
|
||||
*application/x-archive*) # Libraries (.a)
|
||||
strip_flags="$STRIP_STATIC";;
|
||||
*application/x-object*)
|
||||
case "$binary" in
|
||||
*.ko) # Kernel module
|
||||
strip_flags="$STRIP_SHARED";;
|
||||
*)
|
||||
continue;;
|
||||
esac;;
|
||||
*application/x-executable*) # Binaries
|
||||
strip_flags="$STRIP_BINARIES";;
|
||||
*)
|
||||
continue ;;
|
||||
esac
|
||||
strip_file "$binary" ${strip_flags}
|
||||
done
|
||||
fi
|
||||
}
|
41
scripts/libmakepkg/tidy/upx.sh.in
Normal file
41
scripts/libmakepkg/tidy/upx.sh.in
Normal file
@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# upx.sh - Compress package binaries with UPX
|
||||
#
|
||||
# Copyright (c) 2011-2015 Pacman Development Team <pacman-dev@archlinux.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
[ -n "$LIBMAKEPKG_TIDY_UPX_SH" ] && return
|
||||
LIBMAKEPKG_TIDY_UPX_SH=1
|
||||
|
||||
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
|
||||
|
||||
source "$LIBRARY/util/message.sh"
|
||||
source "$LIBRARY/util/option.sh"
|
||||
|
||||
|
||||
tidy_upx() {
|
||||
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 -r binary ; do
|
||||
if [[ $(file --brief --mime-type "$binary") = 'application/x-executable' ]]; then
|
||||
upx "${UPXFLAGS[@]}" "$binary" &>/dev/null ||
|
||||
warning "$(gettext "Could not compress binary : %s")" "${binary/$pkgdir\//}"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
58
scripts/libmakepkg/tidy/zipman.sh.in
Normal file
58
scripts/libmakepkg/tidy/zipman.sh.in
Normal file
@ -0,0 +1,58 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# zipman.sh - Compress man and info pages
|
||||
#
|
||||
# Copyright (c) 2011-2015 Pacman Development Team <pacman-dev@archlinux.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
[ -n "$LIBMAKEPKG_TIDY_ZIPMAN_SH" ] && return
|
||||
LIBMAKEPKG_TIDY_ZIPMAN_SH=1
|
||||
|
||||
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
|
||||
|
||||
source "$LIBRARY/util/message.sh"
|
||||
source "$LIBRARY/util/option.sh"
|
||||
|
||||
|
||||
tidy_zipman() {
|
||||
if check_option "zipman" "y" && [[ -n ${MAN_DIRS[*]} ]]; then
|
||||
msg2 "$(gettext "Compressing man and info pages...")"
|
||||
local file files inode link
|
||||
while read -rd ' ' inode; do
|
||||
read file
|
||||
find ${MAN_DIRS[@]} -type l 2>/dev/null |
|
||||
while read -r link ; do
|
||||
if [[ "${file}" -ef "${link}" ]] ; then
|
||||
rm -f "$link" "${link}.gz"
|
||||
if [[ ${file%/*} = ${link%/*} ]]; then
|
||||
ln -s -- "${file##*/}.gz" "${link}.gz"
|
||||
else
|
||||
ln -s -- "/${file}.gz" "${link}.gz"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if [[ -z ${files[$inode]} ]]; then
|
||||
files[$inode]=$file
|
||||
gzip -9 -n -f "$file"
|
||||
else
|
||||
rm -f "$file"
|
||||
ln "${files[$inode]}.gz" "${file}.gz"
|
||||
chmod 644 "${file}.gz"
|
||||
fi
|
||||
done < <(find ${MAN_DIRS[@]} -type f \! -name "*.gz" \! -name "*.bz2" \
|
||||
-exec @INODECMD@ '{}' + 2>/dev/null)
|
||||
fi
|
||||
}
|
@ -48,13 +48,11 @@ declare -r startdir="$PWD"
|
||||
|
||||
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
|
||||
|
||||
packaging_options=('strip' 'docs' 'libtool' 'staticlibs' 'emptydirs' 'zipman'
|
||||
'purge' 'upx' 'optipng' 'debug')
|
||||
build_options=('ccache' 'distcc' 'buildflags' 'makeflags')
|
||||
splitpkg_overrides=('pkgdesc' 'arch' 'url' 'license' 'groups' 'depends'
|
||||
'optdepends' 'provides' 'conflicts' 'replaces' 'backup'
|
||||
'options' 'install' 'changelog')
|
||||
readonly -a packaging_options build_options splitpkg_overrides
|
||||
readonly -a build_options splitpkg_overrides
|
||||
|
||||
known_hash_algos=('md5' 'sha1' 'sha224' 'sha256' 'sha384' 'sha512')
|
||||
|
||||
@ -1682,148 +1680,6 @@ strip_file() {
|
||||
strip $@ "$binary"
|
||||
}
|
||||
|
||||
tidy_install() {
|
||||
cd_safe "$pkgdir"
|
||||
msg "$(gettext "Tidying install...")"
|
||||
|
||||
if check_option "docs" "n" && [[ -n ${DOC_DIRS[*]} ]]; then
|
||||
msg2 "$(gettext "Removing doc files...")"
|
||||
rm -rf -- ${DOC_DIRS[@]}
|
||||
fi
|
||||
|
||||
if check_option "purge" "y" && [[ -n ${PURGE_TARGETS[*]} ]]; then
|
||||
msg2 "$(gettext "Purging unwanted files...")"
|
||||
local pt
|
||||
for pt in "${PURGE_TARGETS[@]}"; do
|
||||
if [[ ${pt} = "${pt//\/}" ]]; then
|
||||
find . ! -type d -name "${pt}" -exec rm -f -- '{}' +
|
||||
else
|
||||
rm -f ${pt}
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if check_option "libtool" "n"; then
|
||||
msg2 "$(gettext "Removing "%s" files...")" "libtool"
|
||||
find . ! -type d -name "*.la" -exec rm -f -- '{}' +
|
||||
fi
|
||||
|
||||
if check_option "staticlibs" "n"; then
|
||||
msg2 "$(gettext "Removing static library files...")"
|
||||
local l
|
||||
while read -rd '' l; do
|
||||
if [[ -f "${l%.a}.so" || -h "${l%.a}.so" ]]; then
|
||||
rm "$l"
|
||||
fi
|
||||
done < <(find . ! -type d -name "*.a" -print0)
|
||||
fi
|
||||
|
||||
if check_option "emptydirs" "n"; then
|
||||
msg2 "$(gettext "Removing empty directories...")"
|
||||
find . -depth -type d -exec rmdir '{}' + 2>/dev/null
|
||||
fi
|
||||
|
||||
# check existence of backup files
|
||||
local file
|
||||
for file in "${backup[@]}"; do
|
||||
if [[ ! -f $file ]]; then
|
||||
warning "$(gettext "%s entry file not in package : %s")" "backup" "$file"
|
||||
fi
|
||||
done
|
||||
|
||||
# check for references to the build and package directory
|
||||
if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I "${srcdir}" ; then
|
||||
warning "$(gettext "Package contains reference to %s")" "\$srcdir"
|
||||
fi
|
||||
if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I "${pkgdirbase}" ; then
|
||||
warning "$(gettext "Package contains reference to %s")" "\$pkgdir"
|
||||
fi
|
||||
|
||||
if check_option "zipman" "y" && [[ -n ${MAN_DIRS[*]} ]]; then
|
||||
msg2 "$(gettext "Compressing man and info pages...")"
|
||||
local file files inode link
|
||||
while read -rd ' ' inode; do
|
||||
read file
|
||||
find ${MAN_DIRS[@]} -type l 2>/dev/null |
|
||||
while read -r link ; do
|
||||
if [[ "${file}" -ef "${link}" ]] ; then
|
||||
rm -f "$link" "${link}.gz"
|
||||
if [[ ${file%/*} = ${link%/*} ]]; then
|
||||
ln -s -- "${file##*/}.gz" "${link}.gz"
|
||||
else
|
||||
ln -s -- "/${file}.gz" "${link}.gz"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if [[ -z ${files[$inode]} ]]; then
|
||||
files[$inode]=$file
|
||||
gzip -9 -n -f "$file"
|
||||
else
|
||||
rm -f "$file"
|
||||
ln "${files[$inode]}.gz" "${file}.gz"
|
||||
chmod 644 "${file}.gz"
|
||||
fi
|
||||
done < <(find ${MAN_DIRS[@]} -type f \! -name "*.gz" \! -name "*.bz2" \
|
||||
-exec @INODECMD@ '{}' + 2>/dev/null)
|
||||
fi
|
||||
|
||||
if check_option "strip" "y"; then
|
||||
msg2 "$(gettext "Stripping unneeded symbols from binaries and libraries...")"
|
||||
# make sure library stripping variables are defined to prevent excess stripping
|
||||
[[ -z ${STRIP_SHARED+x} ]] && STRIP_SHARED="-S"
|
||||
[[ -z ${STRIP_STATIC+x} ]] && STRIP_STATIC="-S"
|
||||
|
||||
if check_option "debug" "y"; then
|
||||
dbgdir="$pkgdir-@DEBUGSUFFIX@/usr/lib/debug"
|
||||
mkdir -p "$dbgdir"
|
||||
fi
|
||||
|
||||
local binary strip_flags
|
||||
find . -type f -perm -u+w -print0 2>/dev/null | while read -rd '' binary ; do
|
||||
case "$(file -bi "$binary")" in
|
||||
*application/x-sharedlib*) # Libraries (.so)
|
||||
strip_flags="$STRIP_SHARED";;
|
||||
*application/x-archive*) # Libraries (.a)
|
||||
strip_flags="$STRIP_STATIC";;
|
||||
*application/x-object*)
|
||||
case "$binary" in
|
||||
*.ko) # Kernel module
|
||||
strip_flags="$STRIP_SHARED";;
|
||||
*)
|
||||
continue;;
|
||||
esac;;
|
||||
*application/x-executable*) # Binaries
|
||||
strip_flags="$STRIP_BINARIES";;
|
||||
*)
|
||||
continue ;;
|
||||
esac
|
||||
strip_file "$binary" ${strip_flags}
|
||||
done
|
||||
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 -r binary ; do
|
||||
if [[ $(file --brief --mime-type "$binary") = 'application/x-executable' ]]; then
|
||||
upx "${UPXFLAGS[@]}" "$binary" &>/dev/null ||
|
||||
warning "$(gettext "Could not compress binary : %s")" "${binary/$pkgdir\//}"
|
||||
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() {
|
||||
local d sodepends;
|
||||
|
||||
|
@ -8,6 +8,17 @@ scripts/pacman-key.sh.in
|
||||
scripts/pacman-optimize.sh.in
|
||||
scripts/pkgdelta.sh.in
|
||||
scripts/repo-add.sh.in
|
||||
scripts/libmakepkg/tidy/build_references.sh.in
|
||||
scripts/libmakepkg/tidy/docs.sh.in
|
||||
scripts/libmakepkg/tidy/emptydirs.sh.in
|
||||
scripts/libmakepkg/tidy/libtool.sh.in
|
||||
scripts/libmakepkg/tidy/missing_backup.sh.in
|
||||
scripts/libmakepkg/tidy/optipng.sh.in
|
||||
scripts/libmakepkg/tidy/purge.sh.in
|
||||
scripts/libmakepkg/tidy/staticlibs.sh.in
|
||||
scripts/libmakepkg/tidy/strip.sh.in
|
||||
scripts/libmakepkg/tidy/upx.sh.in
|
||||
scripts/libmakepkg/tidy/zipman.sh.in
|
||||
scripts/libmakepkg/util/message.sh
|
||||
scripts/library/output_format.sh
|
||||
scripts/library/parseopts.sh
|
||||
|
Loading…
Reference in New Issue
Block a user