[pacman-dev] [PATCH] Add a --clearsource option to clear the source directory before build.
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
To be honest I don't believe this option is useful at all. IMO one should write PKGBUILDs so that it works on subsequent rebuilds too. Also it can be implemented using alias/wrapper to run "rm -rf src/" before makepkg. But Alan mentioned it before and it was really simple to implement. Lukas
On 02/10/13 22:58, Lukas Jirkovsky wrote:
To be honest I don't believe this option is useful at all. IMO one should write PKGBUILDs so that it works on subsequent rebuilds too. Also it can be implemented using alias/wrapper to run "rm -rf src/" before makepkg. But Alan mentioned it before and it was really simple to implement.
Hrm... "rm -r src/" is less keystrokes than "--clearsource" and an alias of the form makepkg='rm -r src/; makepkg' would work. I want other peoples opinions here. Is it worth adding this option? I never strike the issues mentioned because I always build using the Arch devtools scripts and so even if my PKGBUILD is not reentrant, there is no issue. I think we can just close that bug report with the suggestion of using an alias. Allan
On Wed, Oct 2, 2013 at 11:20 PM, Allan McRae <allan@archlinux.org> wrote:
On 02/10/13 22:58, Lukas Jirkovsky wrote:
To be honest I don't believe this option is useful at all. IMO one should write PKGBUILDs so that it works on subsequent rebuilds too. Also it can be implemented using alias/wrapper to run "rm -rf src/" before makepkg. But Alan mentioned it before and it was really simple to implement.
Hrm... "rm -r src/" is less keystrokes than "--clearsource" and an alias of the form makepkg='rm -r src/; makepkg' would work.
I want other peoples opinions here. Is it worth adding this option? I never strike the issues mentioned because I always build using the Arch devtools scripts and so even if my PKGBUILD is not reentrant, there is no issue. I think we can just close that bug report with the suggestion of using an alias.
Personally, I wouldn't use this option. To clean up my build directory, I use "rm -rf src pkg *.pkg.tar.xz *.log" wich is usually in my bash history so a few keystrokes is all I need .
Allan
How about "makepkg -C" instead? It's reasonably short and fast to write, and if an even shorter alias is desired, that is possible too. There is a reason that "make clean" turned out to be a good idea instead of manually removing files. If nothing else, it can be used to reduce the chance of deleting the wrong files. --- Best regards, Alexander Rødseth xyproto / TU
On 04/10/13 04:15, Alexander Rødseth wrote:
How about "makepkg -C" instead? It's reasonably short and fast to write, and if an even shorter alias is desired, that is possible too.
There is a reason that "make clean" turned out to be a good idea instead of manually removing files. If nothing else, it can be used to reduce the chance of deleting the wrong files.
OK... here is the plan. @Lukas: Add the -C flag and call the long option "--cleanbuild", and I will accept that. I'm fairly sure we always delete $pkgdir now that the package() function is enforced, so this is doing a clean build. Allan
On Fri, Oct 4, 2013 at 5:34 AM, Allan McRae <allan@archlinux.org> wrote:
@Lukas: Add the -C flag and call the long option "--cleanbuild", and I will accept that. I'm fairly sure we always delete $pkgdir now that the package() function is enforced, so this is doing a clean build.
Allan
Done. Lukas
participants (5)
-
Alexander Rødseth
-
Allan McRae
-
Eric Bélanger
-
Lukas Jirkovsky
-
Lukáš Jirkovský