makepkg: Introduce purge option

The purge option, combined with the PURGE_TARGETS variable,
allows makepkg to automatically remove commonly confliting or
removed files (e.g. /usr/share/info/dir, *.pod).

Original work: Tim Yang
Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Allan McRae 2008-12-07 21:14:32 +10:00 committed by Dan McGee
parent 774c252753
commit 9a7f68317a
3 changed files with 27 additions and 4 deletions

View File

@ -125,6 +125,10 @@ Options
*zipman*;;
Compress manual (man and info) pages with gzip.
*purge*;;
Remove files specified by the `PUGRE_TARGETS` variable from the
package.
**INTEGRITY_CHECK=(**check1 ...**)**::
File integrity checks to use. Multiple checks may be specified; this
affects both generation and checking. The current valid options are:
@ -150,6 +154,11 @@ Options
to this array. *NOTE:* Do not add the leading slash to the directory
name.
**PURGE_TARGETS=(**usr/{,share}/info/dir .podlist *.pod...**)**::
If "purge" is specified in the OPTIONS array, this variable will
instruct makepkg which files to remove from the package. This is
useful for index files that are added by multiple packages.
**PKGDEST=**"/path/to/folder"::
If this value is not set, packages will by default be placed in the
current directory (location of the linkman:PKGBUILD[5]). Many people

View File

@ -58,7 +58,7 @@ BUILDENV=(fakeroot !distcc color !ccache !xdelta)
# These are default values for the options=() settings
#########################################################################
#
# Default: OPTIONS=(strip !docs libtool emptydirs zipman)
# Default: OPTIONS=(strip !docs libtool emptydirs zipman purge)
# A negated option will do the opposite of the comments below.
#
#-- strip: Strip symbols from binaries/libraries
@ -66,8 +66,9 @@ BUILDENV=(fakeroot !distcc color !ccache !xdelta)
#-- libtool: Leave libtool (.la) files in packages
#-- emptydirs: Leave empty directories in packages
#-- zipman: Compress manual (man and info) pages with gzip
#-- purge: Remove files sepecified below from package
#
OPTIONS=(strip !docs libtool emptydirs zipman)
OPTIONS=(strip !docs libtool emptydirs zipman purge)
#-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512
INTEGRITY_CHECK=(md5)
@ -77,6 +78,8 @@ MAN_DIRS=({usr{,/local}{,/share},opt/*}/{man,info})
DOC_DIRS=(usr/{,share/}{doc,gtk-doc} opt/*/{doc,gtk-doc})
#-- Directories to be searched for the strip option (if option set correctly above)
STRIP_DIRS=(bin lib sbin usr/{bin,lib,sbin,local/{bin,lib,sbin}} opt/*/{bin,lib,sbin})
#-- Files to be removed from all packages
PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod)
#########################################################################
# PACKAGE OUTPUT

View File

@ -41,7 +41,7 @@ confdir='@sysconfdir@'
startdir="$PWD"
srcdir="$startdir/src"
pkgdir="$startdir/pkg"
packaging_options=('strip' 'docs' 'libtool' 'emptydirs' 'zipman')
packaging_options=('strip' 'docs' 'libtool' 'emptydirs' 'zipman' 'purge')
other_options=('ccache' 'distcc' 'makeflags' 'force')
readonly -a packaging_options other_options
@ -717,6 +717,18 @@ tidy_install() {
rm -rf ${DOC_DIRS[@]}
fi
if [ "$(check_option purge)" = "y" -a -n "PURGE_TARGETS" ]; then
msg2 "$(gettext "Removing pugre targets...")"
local pt
for pt in "${PURGE_TARGETS[@]}"; do
if [ "${pt}" == "${pt//\/}" ]; then
find . -type f -name "${pt}" -exec rm -f -- '{}' \;
else
rm -f ${pt}
fi
done
fi
if [ "$(check_option zipman)" = "y" ]; then
msg2 "$(gettext "Compressing man and info pages...")"
local manpage ext file link hardlinks hl
@ -756,7 +768,6 @@ tidy_install() {
done
fi
if [ "$(check_option strip)" = "y" ]; then
msg2 "$(gettext "Stripping debugging symbols from binaries and libraries...")"
local binary