From 594568c71b3f322f9a65fecd838cb3fa1265ba1d Mon Sep 17 00:00:00 2001 From: Muhammed Uluyol Date: Sat, 15 May 2010 15:49:31 -0500 Subject: [PATCH] makepkg: no duplication of vcs downloads in pkgbuilds --- scripts/makepkg.sh.in | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 51 insertions(+), 0 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index e8aaa8b..1a79580 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -342,6 +342,57 @@ download_file() { fi } +# Make a generic vcs checkout function, and make vcs-specific ones from it +vcs_checkout() +{ + VCS=$1 + msg "Connecting to $VCS server...." + + if [[ -d "$4" ]] ; then + cd "$4" && $3 + if [[ $? == 0 ]]; then + msg "The local files are updated." + else + error "$VCS update failed" + cd "$OLDPWD" + return 1 + fi + cd "$OLDPWD" + else + $2 + if [[ $? != 0 ]]; then + error "$VCS download failed" + return 1 + fi + msg "$VCS checkout done" + fi +} + +get_hg() +{ + vcs_checkout "Mercurial" "hg clone "$1" "$2"" "hg pull -u" "$2" +} + +get_git() +{ + vcs_checkout "GIT" "git clone "$1" "$2"" "git pull origin" "$2" +} + +get_darcs() +{ + vcs_checkout "DARCS" "darcs get --partial --set-scripts-executable "$1" "$2"" "darcs pull -a $1" "$2" +} + +get_cvs() +{ + vcs_checkout "CVS" "cvs -z3 -d "$1" co -D "$3" -f "$2"" "cvs -z3 update -d" "$2" +} + +get_svn() +{ + vcs_checkout "SVN" "svn co "$1" "$2"" "svn up -r $3" "$2" +} + run_pacman() { local ret=0 if (( ! ASROOT )) && [[ $1 != "-T" && $1 != "-Qq" ]]; then -- 1.7.1