[pacman-dev] [PATCH] Add a --clearsource option to clear the source directory before build.

Lukáš Jirkovský l.jirkovsky at gmail.com
Wed Oct 2 08:50:53 EDT 2013


Implements FS#17175.
---
 doc/makepkg.8.txt     |  3 +++
 scripts/makepkg.sh.in | 11 ++++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/doc/makepkg.8.txt b/doc/makepkg.8.txt
index fcafb08..b2d5dbe 100644
--- a/doc/makepkg.8.txt
+++ b/doc/makepkg.8.txt
@@ -147,6 +147,9 @@ Options
 *-V, \--version*::
 	Display version information.
 
+*\--clearsource*::
+	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..891461f 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -63,6 +63,7 @@ ASROOT=0
 CLEANUP=0
 DEP_BIN=0
 FORCE=0
+CLEARSRC=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 "  --clearsource    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"
@@ -2553,7 +2555,7 @@ ARGLIST=("$@")
 
 # Parse Command Line Options.
 OPT_SHORT="AcdefFghiLmop:rRsSV"
-OPT_LONG=('allsource' 'asroot' 'check' 'clean' 'config:' 'force' 'geninteg'
+OPT_LONG=('allsource' 'asroot' 'check' 'clean' 'clearsource' '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 ;;
+		--clearsource)    CLEARSRC=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 (( CLEARSRC )); then
+		msg "$(gettext "Removing content of existing %s directory...")" "src/"
+		rm -rf "$srcdir/*"
+	fi
+
 	extract_sources
 	if (( PREPAREFUNC )); then
 		run_prepare
-- 
1.8.4



More information about the pacman-dev mailing list