From d04de4e04a8a26dd10696132cc8cb182f8b3bb3a Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 23 Jun 2008 21:19:44 +0200 Subject: Enabled support for diverse VCSs (currently hg and git) --- bin/pkg | 34 +++++++++++++++++++++++++++++----- man/1/pkg | 5 +++-- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/bin/pkg b/bin/pkg index 16b67ca..4219aad 100755 --- a/bin/pkg +++ b/bin/pkg @@ -120,6 +120,30 @@ confirm_no () { ## Major internal functions ## +## VCS Wrappers + +vcs_add () { + cd "$PDIR" + case "$1" in + git) git clone "$2" ;; + hg|'') hg clone "$2" ;; + *) die "Package '$2' does not exist\n" ;; + esac +} + +vcs_incoming () { + # [ -d .vcs ] && vcs incoming will not work here, since the [] will return + # something. We need the return value of vcs. + if ([ -d .hg ]) && hg incoming + if ([ -d .git ]) && false +} + +vcs_update () { + [ -d .hg ] && hg --quiet pull --update + [ -d .git ] && git pull +} + + # Return an understandable priority from the numeric one real_priority () { case "$1" in @@ -269,7 +293,7 @@ pkg_add () { } cd $PDIR || return 255 info "Retrieving package $1...\n" - $VCS_CMD $VCS_ADD $PKG_ROOT/$1 || return 255 + vcs_add "$2" "$PKG_ROOT/$1" || return 255 if ([ -r $PDIR/$1/Makefile ]) { info "Building binaries\n" cd $PDIR/$1 @@ -303,11 +327,11 @@ pkg_update () { check_installed "$1" cd $PDIR/$1 info "Looking for updates: $1" - NEW=$($VCS_CMD $VCS_INCOMING) + NEW=$(vcs_incoming) if ([ $? = 0 ]) { clear_line info "Updating: $1 to $(echo $NEW | tail -n 1)" - $VCS_CMD $VCS_UPDATE + vcs_update clear_line info "Updated $1 to $(echo $NEW | tail -n 1) \n" check_deps "$1" @@ -459,13 +483,13 @@ pkg_doc () { ## case "$1" in - add) pkg_add "$2" ;; + add) pkg_add "$2" "$3" ;; changelog) pkg_changelog "$2" ;; changeroot) pkg_changesrc "$2" ;; delete) pkg_remove "$2" ;; doc) pkg_doc "$2" ;; info) pkg_info "$2" ;; - install) pkg_add "$2" ;; + install) pkg_add "$2" "$3" ;; list) pkg_list_installed ;; list-all) pkg_list_available ;; log) pkg_log "$2" ;; diff --git a/man/1/pkg b/man/1/pkg index 8c976f1..8695e12 100644 --- a/man/1/pkg +++ b/man/1/pkg @@ -16,9 +16,10 @@ I may be one of: =over -=item B, B I +=item B, B I [ I ] -fetch given I from the package_root and install it +fetch given I, tracked with I (default: hg) +from the package_root and install it =item B I -- cgit v1.2.3