[pacman-dev] [PATCH] makepkg: Introduce restrict option

Allan McRae allan at archlinux.org
Sun Dec 7 06:23:12 EST 2008


Allan McRae wrote:
> The restrict option, combined with the RESTRICTED_FILES variable,
> allows makepkg to automatically remove common confliting files
> (e.g. /usr/share/info/dir).
>
> Signed-off-by: Allan McRae <allan at archlinux.org>
> ---
>   

Bonus points if someone comes up with a better name for the options.....

Note that this patch made off my working branch which has a couple of 
patches which have not made mainline yet and overlap with some parts of 
code adjusted here.

>  doc/makepkg.conf.5.txt |    8 ++++++++
>  etc/makepkg.conf.in    |    7 +++++--
>  scripts/makepkg.sh.in  |    8 ++++++--
>  3 files changed, 19 insertions(+), 4 deletions(-)
>
> diff --git a/doc/makepkg.conf.5.txt b/doc/makepkg.conf.5.txt
> index 18dbf35..84e8192 100644
> --- a/doc/makepkg.conf.5.txt
> +++ b/doc/makepkg.conf.5.txt
> @@ -125,6 +125,9 @@ Options
>  	*zipman*;;
>  		Compress manual (man and info) pages with gzip.
>  
> +	*restrict*;;
> +		Remove restricted files 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 +153,11 @@ Options
>  	to this array. *NOTE:* Do not add the leading slash to the directory
>  	name.
>  
> +**RESTRICTED_FILES=(**usr/{,share}/info/dir ...**)**::
> +	If "restrict" 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 to 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
> diff --git a/etc/makepkg.conf.in b/etc/makepkg.conf.in
> index 82722be..545a215 100644
> --- a/etc/makepkg.conf.in
> +++ b/etc/makepkg.conf.in
> @@ -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 restrict)
>  #  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
> +#-- restrict:  Remove files sepecified below from package
>  #
> -OPTIONS=(strip !docs libtool emptydirs zipman)
> +OPTIONS=(strip !docs libtool emptydirs zipman restrict)
>  
>  #-- 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
> +RESTRICTED_FILES=(usr/{,share}/info/dir)
>  
>  #########################################################################
>  # PACKAGE OUTPUT
> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
> index bf6524d..ea27883 100644
> --- a/scripts/makepkg.sh.in
> +++ b/scripts/makepkg.sh.in
> @@ -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' 'restrict')
>  other_options=('ccache' 'distcc' 'makeflags' 'force')
>  readonly -a packaging_options other_options
>  
> @@ -792,7 +792,6 @@ tidy_install() {
>  		done
>  	fi
>  
> -
>  	if [ "$(check_option strip)" = "y" ]; then
>  		msg2 "$(gettext "Stripping debugging symbols from binaries and libraries...")"
>  		local binary
> @@ -818,6 +817,11 @@ tidy_install() {
>  		find . ! -type d -name "*.la" -exec rm -f -- '{}' \;
>  	fi
>  
> +	if [ "$(check_option restrict)" = "y" -a -n "RESTRICTED_FILES" ]; then
> +		msg2 "$(gettext "Removing restricted files...")"
> +		rm -f ${RESTRICTED_FILES[@]}
> +	fi
> +
>  	if [ "$(check_option emptydirs)" = "n" ]; then
>  		msg2 "$(gettext "Removing empty directories...")"
>  		find . -depth -type d -empty -delete
>   





More information about the pacman-dev mailing list