[pacman-dev] [PATCH] Add a -C, --cleanbuild option to clear the source directory before building a package.
Implements FS#17175. --- 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 -- 1.8.4
On 04/10/13 23:57, Lukáš Jirkovský wrote:
Implements FS#17175. --- doc/makepkg.8.txt | 3 +++ scripts/makepkg.sh.in | 13 +++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-)
OK - I made minor changes noted below.
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.
Remove the $srcdir directory 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/"
This should have been in alphabetical order
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/"
I made this "Removing existing %s directory..." as we already use that string.
+ rm -rf "$srcdir/*" + fi + extract_sources if (( PREPAREFUNC )); then run_prepare
On 09/10/13 13:12, Allan McRae wrote:
On 04/10/13 23:57, Lukáš Jirkovský wrote:
Implements FS#17175. --- doc/makepkg.8.txt | 3 +++ scripts/makepkg.sh.in | 13 +++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-)
OK - I made minor changes noted below.
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.
Remove the $srcdir directory 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/"
This should have been in alphabetical order
I also replaced "src/" with "\$srcdir/"
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/"
I made this "Removing existing %s directory..." as we already use that string.
+ rm -rf "$srcdir/*" + fi + extract_sources if (( PREPAREFUNC )); then run_prepare
On Wed, Oct 9, 2013 at 5:12 AM, Allan McRae <allan@archlinux.org> wrote:
OK - I made minor changes noted below.
Thank you. Do I need to resubmit the patch? Lukas
On 09/10/13 21:33, Lukas Jirkovsky wrote:
On Wed, Oct 9, 2013 at 5:12 AM, Allan McRae <allan@archlinux.org> wrote:
OK - I made minor changes noted below.
Thank you. Do I need to resubmit the patch?
No - I made the change and pulled to my working branch. Allan
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
On 10/10/13 10:41, Allan McRae wrote:
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...)
I fixed 1) on my working branch. 2) is restricted to local files which are symlinked into $srcdir during download_file. I will add an extract file as the correct fix. Allan
On Thu, Oct 10, 2013 at 2:41 AM, Allan McRae <allan@archlinux.org> wrote:
On 04/10/13 23:57, Lukáš Jirkovský wrote:
Implements FS#17175.
Grr... Completely rejected.
No problem, I won't use it anyway ;-)
Issues: 1) it does not remove $srcdir...
Well, it removes contents of the $srcdir just like the message said. That's because the later code expects $srcdir to exist. Doing "rm -rf $srcdir && make -p $srcdir" seems a bit superfluous.
2) when you fix the "rm -rf" line to do it properly, it deletes everything just moved to srcdir (local sources, non-vcs sources...)
I don't see a problem here. I thought that this is what people wanted it to do. Lukas
On 10/10/13 19:29, Lukas Jirkovsky wrote:
On Thu, Oct 10, 2013 at 2:41 AM, Allan McRae <allan@archlinux.org> wrote:
On 04/10/13 23:57, Lukáš Jirkovský wrote:
Implements FS#17175.
Grr... Completely rejected.
No problem, I won't use it anyway ;-)
Issues: 1) it does not remove $srcdir...
Well, it removes contents of the $srcdir just like the message said. That's because the later code expects $srcdir to exist. Doing "rm -rf $srcdir && make -p $srcdir" seems a bit superfluous.
Did you test it - it does not remove ANYTHING. rm -rf "$srcdir/*" vs rm -rf "$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...)
I don't see a problem here. I thought that this is what people wanted it to do.
With that patch, using -C means anything with a non-vcs will not build due to having no files in $srcdir. My patch "Link non-vcs sources into $srcdir during extraction" fixes that. Allan
On Thu, Oct 10, 2013 at 12:47 PM, Allan McRae <allan@archlinux.org> wrote:
Did you test it - it does not remove ANYTHING.
rm -rf "$srcdir/*"
vs
rm -rf "$srcdir"/*
Ah, damn it. I'm sorry. I did test it, but I manually apllied the patch to the /usr/bin/makepkg where I wrote it correctly, so it worked fine.
With that patch, using -C means anything with a non-vcs will not build due to having no files in $srcdir. My patch "Link non-vcs sources into $srcdir during extraction" fixes that.
That would be the problem, I had only a few PKGBUILDs using VCS sources around, so it worked for me. I'm sorry again. Lukas
participants (3)
-
Allan McRae
-
Lukas Jirkovsky
-
Lukáš Jirkovský