[pacman-dev] [PATCH] Add a -C, --cleanbuild option to clear the source directory before building a package.

Allan McRae allan at archlinux.org
Wed Oct 9 20:41:56 EDT 2013


On 04/10/13 23:57, Lukáš Jirkovský wrote:
> Implements FS#17175.

Grr...    Completely rejected.

Issues:
1) it does not remove $srcdir...
2) when you fix the "rm -rf" line to do it properly, it deletes
everything just moved to srcdir (local sources, non-vcs sources...)

Allan


> ---
>  doc/makepkg.8.txt     |  3 +++
>  scripts/makepkg.sh.in | 13 +++++++++++--
>  2 files changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/doc/makepkg.8.txt b/doc/makepkg.8.txt
> index fcafb08..fd3573c 100644
> --- a/doc/makepkg.8.txt
> +++ b/doc/makepkg.8.txt
> @@ -147,6 +147,9 @@ Options
>  *-V, \--version*::
>  	Display version information.
>  
> +*-C, \--cleanbuild*::
> +	Remove the $srcdir before building the package.
> +
>  *\--allsource*::
>  	Do not actually build the package, but build a source-only tarball that
>  	includes all sources, including those that are normally download via
> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
> index 67ec240..04c309f 100644
> --- a/scripts/makepkg.sh.in
> +++ b/scripts/makepkg.sh.in
> @@ -63,6 +63,7 @@ ASROOT=0
>  CLEANUP=0
>  DEP_BIN=0
>  FORCE=0
> +CLEANBUILD=0
>  INFAKEROOT=0
>  GENINTEG=0
>  HOLDVER=0
> @@ -2504,6 +2505,7 @@ usage() {
>  	printf -- "$(gettext "  -s, --syncdeps   Install missing dependencies with %s")\n" "pacman"
>  	printf -- "$(gettext "  -S, --source     Generate a source-only tarball without downloaded sources")\n"
>  	printf -- "$(gettext "  -V, --version    Show version information and exit")\n"
> +	printf -- "$(gettext "  -C, --cleanbuild Remove %s dir before building the package")\n" "src/"
>  	printf -- "$(gettext "  --allsource      Generate a source-only tarball including downloaded sources")\n"
>  	printf -- "$(gettext "  --verifysource   Download source files (if needed) and perform integrity checks")\n"
>  	printf -- "$(gettext "  --asroot         Allow %s to run as root user")\n" "makepkg"
> @@ -2552,8 +2554,8 @@ fi
>  ARGLIST=("$@")
>  
>  # Parse Command Line Options.
> -OPT_SHORT="AcdefFghiLmop:rRsSV"
> -OPT_LONG=('allsource' 'asroot' 'check' 'clean' 'config:' 'force' 'geninteg'
> +OPT_SHORT="AcCdefFghiLmop:rRsSV"
> +OPT_LONG=('allsource' 'asroot' 'check' 'clean' 'cleanbuild' 'config:' 'force' 'geninteg'
>            'help' 'holdver' 'ignorearch' 'install' 'key:' 'log' 'nobuild' 'nocolor'
>            'nocheck' 'nodeps' 'noextract' 'noprepare' 'nosign' 'pkg:' 'repackage' 'rmdeps'
>            'sign' 'skipchecksums' 'skipinteg' 'skippgpcheck' 'source' 'syncdeps'
> @@ -2581,6 +2583,7 @@ while true; do
>  		--asroot)         ASROOT=1 ;;
>  		-A|--ignorearch)  IGNOREARCH=1 ;;
>  		-c|--clean)       CLEANUP=1 ;;
> +		-C|--cleanbuild)  CLEANBUILD=1 ;;
>  		--check)          RUN_CHECK='y' ;;
>  		--config)         shift; MAKEPKG_CONF=$1 ;;
>  		-d|--nodeps)      NODEPS=1 ;;
> @@ -2990,6 +2993,12 @@ elif (( !REPKG )); then
>  	download_sources
>  	check_source_integrity
>  	(( VERIFYSOURCE )) && exit 0 # $E_OK
> +
> +	if (( CLEANBUILD )); then
> +		msg "$(gettext "Removing content of existing %s directory...")" "src/"
> +		rm -rf "$srcdir/*"
> +	fi
> +
>  	extract_sources
>  	if (( PREPAREFUNC )); then
>  		run_prepare
> 



More information about the pacman-dev mailing list