Git comes with commands that are specifically designed to return the working directory to a "pristine" state. We make use of these commands to avoid the expensive operation of creating a temporary build directory. Having a single directory to pull in upstream code and build from greatly simplifies the code, and as a bonus, saves disk space/time! Thanks to Jesse Young for suggesting this idea. [1] [1]: http://mailman.archlinux.org/pipermail/arch-projects/2011-November/002052.ht... Signed-off-by: Linus Arver <linusarver@gmail.com> --- prototypes/PKGBUILD-git.proto | 13 ++++++------- 1 files changed, 6 insertions(+), 7 deletions(-) diff --git a/prototypes/PKGBUILD-git.proto b/prototypes/PKGBUILD-git.proto index 7d9bb90..a2f2f40 100644 --- a/prototypes/PKGBUILD-git.proto +++ b/prototypes/PKGBUILD-git.proto @@ -35,20 +35,19 @@ build() { msg "Connecting to $_gitroot ..." if [[ -d "$_gitname" ]]; then - cd "$_gitname" && git pull origin + cd "$_gitname" + git clean -dxf + git reset --hard + git pull origin msg "The local files are updated." - cd .. else git clone --depth 1 "$_gitroot" "$_gitname" + cd "$_gitname" fi msg "GIT checkout done or connection timeout" msg "Starting build..." - rm -rf "$srcdir/$_gitname-build" - git clone "$srcdir/$_gitname" "$srcdir/$_gitname-build" - cd "$srcdir/$_gitname-build" - # # BUILD HERE # @@ -58,7 +57,7 @@ build() { } package() { - cd "$srcdir/$_gitname-build" + cd "$srcdir/$_gitname" make DESTDIR="$pkgdir/" install } -- 1.7.7.3