[pacman-dev] Fwd: [PATCH] RFC: support incremental build with VCS sources.

Lukas Jirkovsky l.jirkovsky at gmail.com
Sat Sep 28 13:01:44 EDT 2013


Accidentally sent this to a wrong address... I hope forwarding this
won't break the patch.

---
Hi,
This patch adds incremental build support for the packages with VCS sources.
It is not complete work (only GIT is supported), but a mere request for
comments. If there is a chance that something like this will be accepted,
I will extend the support to other VCS, too.

Rationale:
When someone uses a VCS package, there is a high chance that such user wants
to follow the development more closely. This means that the user will be
rebuilding the package often. However, rebuilding the whole package takes a lot
of time. This can be somewhat mitigated by using ccache. However, the greatest
speedup can be achieved by incremental build. The problem is that current VCS
support makes this pretty much imposible by removing the cloned sources
before building.

This patch adds a new option --incremental. Using this option forces makepkg
to only update the cloned source directory instead of removing it and cloning
anew. This allows make to use the incremental build feature.

See also FS#35050

I've been using this patch for a few days with kdevplatform-git and
kdevelop-git (not the ones from AUR) at it works great. It already saved me a
lot of time, while using nice and clean PKGBUILD (so far I have been using the
old-style VCS packages that clone sources in their build() function to achive
similar functionality).

Any comments are welcome.

Lukas

 scripts/makepkg.sh.in | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 67ec240..2ac813a 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -66,6 +66,7 @@ FORCE=0
 INFAKEROOT=0
 GENINTEG=0
 HOLDVER=0
+VCSINCREMENTAL=0
 SKIPCHECKSUMS=0
 SKIPPGPCHECK=0
 INSTALL=0
@@ -580,12 +581,20 @@ extract_git() {

        msg2 "$(gettext "Creating working copy of %s %s repo...")"
"${repo}" "git"
        pushd "$srcdir" &>/dev/null
-       rm -rf "${dir##*/}"

-       if ! git clone "$dir"; then
-               error "$(gettext "Failure while creating working copy
of %s %s repo")" "${repo}" "git"
-               plain "$(gettext "Aborting...")"
-               exit 1
+       if [[ VCSINCREMENTAL -ne 0 && -d "${dir##*/}" ]]; then
+               pushd `pwd` &>/dev/null
+               cd_safe "${dir##*/}"
+               git pull
+               popd &>/dev/null
+       else
+               rm -rf "${dir##*/}"
+
+               if ! git clone "$dir"; then
+                       error "$(gettext "Failure while creating
working copy of %s %s repo")" "${repo}" "git"
+                       plain "$(gettext "Aborting...")"
+                       exit 1
+               fi
        fi

        cd_safe "${dir##*/}"
@@ -607,7 +616,7 @@ extract_git() {
        fi

        if [[ -n $ref ]]; then
-               if ! git checkout -b makepkg $ref; then
+               if ! git checkout -B makepkg $ref; then
                        error "$(gettext "Failure while creating
working copy of %s %s repo")" "${repo}" "git"
                        plain "$(gettext "Aborting...")"
                        exit 1
@@ -2510,6 +2519,7 @@ usage() {
        printf -- "$(gettext "  --check          Run the %s function
in the %s")\n" "check()" "$BUILDSCRIPT"
        printf -- "$(gettext "  --config <file>  Use an alternate
config file (instead of '%s')")\n" "$confdir/makepkg.conf"
        printf -- "$(gettext "  --holdver        Do not update VCS sources")\n"
+       printf -- "$(gettext "  --incremental    Incremental build
with VCS sources (only updates build dir)")\n"
        printf -- "$(gettext "  --key <key>      Specify a key to use
for %s signing instead of the default")\n" "gpg"
        printf -- "$(gettext "  --nocheck        Do not run the %s
function in the %s")\n" "check()" "$BUILDSCRIPT"
        printf -- "$(gettext "  --noprepare      Do not run the %s
function in the %s")\n" "prepare()" "$BUILDSCRIPT"
@@ -2554,7 +2564,7 @@ ARGLIST=("$@")
 # Parse Command Line Options.
 OPT_SHORT="AcdefFghiLmop:rRsSV"
 OPT_LONG=('allsource' 'asroot' 'check' 'clean' 'config:' 'force' 'geninteg'
-          'help' 'holdver' 'ignorearch' 'install' 'key:' 'log'
'nobuild' 'nocolor'
+          'help' 'holdver' 'incremental' 'ignorearch' 'install'
'key:' 'log' 'nobuild' 'nocolor'
           'nocheck' 'nodeps' 'noextract' 'noprepare' 'nosign' 'pkg:'
'repackage' 'rmdeps'
           'sign' 'skipchecksums' 'skipinteg' 'skippgpcheck' 'source' 'syncdeps'
           'verifysource' 'version')
@@ -2589,6 +2599,7 @@ while true; do
                -F)               INFAKEROOT=1 ;;
                -g|--geninteg)    GENINTEG=1 ;;
                --holdver)        HOLDVER=1 ;;
+               --incremental)    VCSINCREMENTAL=1 ;;
                -i|--install)     INSTALL=1 ;;
                --key)            shift; GPGKEY=$1 ;;
                -L|--log)         LOGGING=1 ;;
--
1.8.4


More information about the pacman-dev mailing list