summaryrefslogtreecommitdiffstats
path: root/db-move
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2010-08-07 23:49:01 +0200
committerPierre Schmitz <pierre@archlinux.de>2010-08-07 23:49:01 +0200
commitc81c0e57ff41bbc51e13600b8581145b34aef55f (patch)
treef2112d69759848ba0a92df82d67b9fade65345c6 /db-move
parent76ef37d1b1e03b0c517f8513b943474ea379738e (diff)
downloaddbscripts-c81c0e57ff41bbc51e13600b8581145b34aef55f.tar.gz
dbscripts-c81c0e57ff41bbc51e13600b8581145b34aef55f.tar.xz
Rewrite db-move
* Cleanup code * create symlinks instead of copies * Moving split packages is now (more) atomic * Move old packages to pool if needed
Diffstat (limited to 'db-move')
-rwxr-xr-xdb-move97
1 files changed, 37 insertions, 60 deletions
diff --git a/db-move b/db-move
index ed3df69..407027a 100755
--- a/db-move
+++ b/db-move
@@ -1,7 +1,7 @@
#!/bin/bash
if [ $# -ne 4 ]; then
- echo "usage: $(basename $0) <pkgname|packagebase> <repo-from> <repo-to> <arch>"
+ echo "usage: $(basename $0) <pkgname|pkgbase> <repo-from> <repo-to> <arch>"
exit 1
fi
@@ -12,6 +12,11 @@ packagebase="$1"
repofrom="$2"
repoto="$3"
_arch="$4"
+if [ "${_arch}" == 'any' ]; then
+ _tarches=('i686' 'x86_64')
+else
+ _tarches=("${_arch}")
+fi
ftppath_from="$FTP_BASE/$repofrom/os/"
ftppath_to="$FTP_BASE/$repoto/os/"
@@ -23,10 +28,10 @@ svnrepo_to="$repoto-$_arch"
WORKDIR="$TMPDIR/db-move.$svnrepo_from.$svnrepo_to.$UID"
cleanup() {
- trap '' 0 2
+ trap '' 0 2
# unlock
- repo_unlock $repoto $_arch
- repo_unlock $repofrom $_arch
+ repo_unlock $repoto $_arch
+ repo_unlock $repofrom $_arch
rm -rf "$WORKDIR"
[ "$1" ] && exit $1
}
@@ -55,68 +60,40 @@ cd checkout
/usr/bin/svn up -q $packagebase
if [ -d "$packagebase/repos/$svnrepo_from" ]; then
- . "$packagebase/repos/$svnrepo_from/$BUILDSCRIPT"
-
- for i in ${pkgname[@]}; do
- _pkgfile="$i-$pkgver-$pkgrel-$_arch$PKGEXT"
- getpkgfile "$ftppath_from/${_arch}/"$_pkgfile >/dev/null
- done
-
- 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 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)"
-
- echo " Moving package file and updating DBs"
- cd "$WORKDIR"
- [ -d build/ ] || mkdir build
- cd build/
-
- if [ "${_arch}" == "any" ]; then
- arches="i686 x86_64"
- else
- arches="${_arch}"
+ . "$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 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"
- mv $repofrom$DBEXT "$ftppath_from/$architecture"
- echo " Package files will be cleaned up automatically"
- fi
+ 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)"
+
+ _pkgfiles=''
+ for i in ${pkgname[@]}; do
+ _pkgpath=$(getpkgfile "$ftppath_from/${_arch}/"$i-$pkgver-$pkgrel-$_arch$PKGEXT)
+ _pkgfile=$(basename "${_pkgpath}")
- if [ -f "$ftppath_to/$architecture/$repoto$DBEXT" ]; then
- /bin/cp "$ftppath_to/$architecture/$repoto$DBEXT" .
+ # copy package to pool if needed
+ # TODO: can be removed once every package has benn moved to the package pool
+ if [ ! -f $FTP_BASE/$(get_pkgpool_for_host)/${_arch}/$_pkgfile ]; then
+ cp $_pkgpath $FTP_BASE/$(get_pkgpool_for_host)/${_arch}/
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"
+ for _tarch in ${_tarches[@]}; do
+ ln -s "../../../$(get_pkgpool_for_host)/${_arch}/${_pkgfile}" $ftppath_to/${_tarch}/
done
- 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
+
+ _pkgfiles="${_pkgfiles} $FTP_BASE/$(get_pkgpool_for_host)/${_arch}/${_pkgfile}"
+ done
+
+ for _tarch in ${_tarches[@]}; do
+ /usr/bin/repo-add -q "$ftppath_to/${_tarch}/$repoto$DBEXT" ${_pkgfiles} || die "Error in repo-add $_pkgfiles"
+ /usr/bin/repo-remove -q "$ftppath_from/${_tarch}/$repofrom$DBEXT" ${pkgname[@]} || die "Error in repo-remove ${pkgname[@]}"
done
else
- die "Error: $packagebase is not in repo $repofrom"
+ die "Error: $packagebase is not in repo $repofrom"
fi
-
-cleanup