[arch-dev-public] [PATCH 3/7] Update db-move to support multiple pkgs
Ghost1227
ghost1227 at archlinux.us
Thu Mar 11 23:02:35 CET 2010
---
db-move | 142 +++++++++++++++++++++++++++++++++------------------------------
1 files changed, 74 insertions(+), 68 deletions(-)
diff --git a/db-move b/db-move
index d385f12..04ce7ca 100755
--- a/db-move
+++ b/db-move
@@ -8,10 +8,12 @@ fi
. "$(dirname $0)/db-functions"
. "$(dirname $0)/config"
-packagebase="$1"
-repofrom="$2"
-repoto="$3"
-_arch="$4"
+#Parse off args from the BACK of the list
+# this adds support for multiple package names
+args=($@)
+_arch="${args[${#args[@]}-1]}" && unset args[${#args[@]}-1]
+repoto="${args[${#args[@]}-1]}" && unset args[${#args[@]}-1]
+repofrom="${args[${#args[@]}-1]}" && unset args[${#args[@]}-1]
ftppath_from="$FTP_BASE/$repofrom/os/"
ftppath_to="$FTP_BASE/$repoto/os/"
@@ -41,85 +43,89 @@ die() {
cleanup 1
}
-trap ctrl_c 2
-trap cleanup 0
+for pkgbase in ${args[@]}; do
+ echo "==> Moving package '$pkgbase'"
-repo_lock $repoto $_arch
-repo_lock $repofrom $_arch
+ trap ctrl_c 2
+ trap cleanup 0
-/bin/mkdir -p "$WORKDIR"
+ repo_lock $repoto $_arch
+ repo_lock $repofrom $_arch
-cd "$WORKDIR"
-/usr/bin/svn checkout -N $SVNREPO checkout
-cd checkout
+ /bin/mkdir -p "$WORKDIR"
-/usr/bin/svn up -q $packagebase
-if [ -d "$packagebase/repos/$svnrepo_from" ]; then
- . "$packagebase/repos/$svnrepo_from/$BUILDSCRIPT"
+ cd "$WORKDIR"
+ /usr/bin/svn checkout -N $SVNREPO checkout
+ cd checkout
- for i in ${pkgname[@]}; do
- _pkgfile="$i-$pkgver-$pkgrel-$_arch$PKGEXT"
- getpkgfile "$ftppath_from/${_arch}/"$_pkgfile >/dev/null
- done
+ /usr/bin/svn up -q $packagebase
+ if [ -d "$packagebase/repos/$svnrepo_from" ]; then
+ . "$packagebase/repos/$svnrepo_from/$BUILDSCRIPT"
- if [ -d "$packagebase/repos/$svnrepo_to" ]; then
- echo ' Removing existing package from subversion'
- /usr/bin/svn rm --force -q "$packagebase/repos/$svnrepo_to"
- /usr/bin/svn commit -q -m "$(basename $0): $packagebase removed by $(id -un) for move to $repoto"
- fi
+ for i in ${pkgname[@]}; do
+ _pkgfile="$i-$pkgver-$pkgrel-$_arch$PKGEXT"
+ getpkgfile "$ftppath_from/${_arch}/"$_pkgfile >/dev/null
+ done
- echo ' Moving svn entries'
- /usr/bin/svn mv -r HEAD "$packagebase/repos/$svnrepo_from" "$packagebase/repos/$svnrepo_to"
- /usr/bin/svn commit -m "$(basename $0): moved $packagebase from [$repofrom] to [$repoto] ($_arch)"
+ if [ -d "$packagebase/repos/$svnrepo_to" ]; then
+ echo ' Removing existing package from subversion'
+ /usr/bin/svn rm --force -q "$packagebase/repos/$svnrepo_to"
+ /usr/bin/svn commit -q -m "$(basename $0): $packagebase removed by $(id -un) for move to $repoto"
+ fi
- echo ' Moving package file and updating DBs'
- cd "$WORKDIR"
- [ -d build/ ] || mkdir build
- cd build/
+ echo ' Moving svn entries'
+ /usr/bin/svn mv -r HEAD "$packagebase/repos/$svnrepo_from" "$packagebase/repos/$svnrepo_to"
+ /usr/bin/svn commit -m "$(basename $0): moved $packagebase from [$repofrom] to [$repoto] ($_arch)"
- if [ "${_arch}" == 'any' ]; then
- arches='i686 x86_64'
- else
- arches="${_arch}"
- fi
+ echo ' Moving package file and updating DBs'
+ cd "$WORKDIR"
+ [ -d build/ ] || mkdir build
+ cd build/
- for architecture in $arches; do
- # copy the db file into our working area
- if [ -f "$ftppath_from/$architecture/$repofrom$DBEXT" ]; then
- /bin/cp "$ftppath_from/$architecture/$repofrom$DBEXT" .
- /usr/bin/repo-remove -q "$repofrom$DBEXT" ${pkgname[@]} || die "Error in repo-remove"
- #use '*' to move the old DB too
- mv $repofrom$DBEXT* "$ftppath_from/$architecture"
- echo ' Package files will be cleaned up automatically'
+ if [ "${_arch}" == 'any' ]; then
+ arches='i686 x86_64'
+ else
+ arches="${_arch}"
fi
- if [ -f "$ftppath_to/$architecture/$repoto$DBEXT" ]; then
- /bin/cp "$ftppath_to/$architecture/$repoto$DBEXT" .
- fi
+ for architecture in $arches; do
+ # copy the db file into our working area
+ if [ -f "$ftppath_from/$architecture/$repofrom$DBEXT" ]; then
+ /bin/cp "$ftppath_from/$architecture/$repofrom$DBEXT" .
+ /usr/bin/repo-remove -q "$repofrom$DBEXT" ${pkgname[@]} || die "Error in repo-remove"
+ #use '*' to move the old DB too
+ mv $repofrom$DBEXT* "$ftppath_from/$architecture"
+ echo ' Package files will be cleaned up automatically'
+ fi
- for i in ${pkgname[@]}; do
- _pkgfile="$i-$pkgver-$pkgrel-$_arch$PKGEXT"
- _cpkgfile=$(getpkgfile "$ftppath_from/$architecture/"$_pkgfile)
- [ $? -gt 0 ] && die
- /bin/cp $_cpkgfile .
- /usr/bin/repo-add -q "$repoto$DBEXT" $_pkgfile || die "Error in repo-add $_pkgfile"
- done
- #use '*' to move the old DB too
- mv $repoto$DBEXT* $ftppath_to/$architecture
- for i in ${pkgname[@]}; do
- _pkgfile=$(getpkgfile "$i-$pkgver-$pkgrel-$_arch"$PKGEXT)
- [ $? -gt 0 ] && die
- if [ "${_arch}" == "any" ]; then
- mv ${_pkgfile} $ftppath_to/any
- ln -s ../any/${_pkgfile} $ftppath_to/$architecture/
- else
- mv ${_pkgfile} $ftppath_to/$architecture
+ if [ -f "$ftppath_to/$architecture/$repoto$DBEXT" ]; then
+ /bin/cp "$ftppath_to/$architecture/$repoto$DBEXT" .
fi
+
+ for i in ${pkgname[@]}; do
+ _pkgfile="$i-$pkgver-$pkgrel-$_arch$PKGEXT"
+ _cpkgfile=$(getpkgfile "$ftppath_from/$architecture/"$_pkgfile)
+ [ $? -gt 0 ] && die
+ /bin/cp $_cpkgfile .
+ /usr/bin/repo-add -q "$repoto$DBEXT" $_pkgfile || die "Error in repo-add $_pkgfile"
+ done
+ #use '*' to move the old DB too
+ mv $repoto$DBEXT* $ftppath_to/$architecture
+ for i in ${pkgname[@]}; do
+ _pkgfile=$(getpkgfile "$i-$pkgver-$pkgrel-$_arch"$PKGEXT)
+ [ $? -gt 0 ] && die
+ if [ "${_arch}" == "any" ]; then
+ mv ${_pkgfile} $ftppath_to/any
+ ln -s ../any/${_pkgfile} $ftppath_to/$architecture/
+ else
+ mv ${_pkgfile} $ftppath_to/$architecture
+ fi
+ done
done
- done
-else
- die "Error: $packagebase is not in repo $repofrom"
-fi
+ else
+ die "Error: $packagebase is not in repo $repofrom"
+ fi
+done
cleanup
--
1.7.0.2
More information about the arch-dev-public
mailing list