summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xdb-move120
-rwxr-xr-xtesting2core13
-rwxr-xr-xtesting2extra13
3 files changed, 146 insertions, 0 deletions
diff --git a/db-move b/db-move
new file mode 100755
index 0000000..cb559d2
--- /dev/null
+++ b/db-move
@@ -0,0 +1,120 @@
+#!/bin/bash
+# Originally from Pierre's testing2extra script
+
+if [ $# -ne 4 ]; then
+ echo "usage: $(basename $0) <pkgname> <repo-from> <repo-to> <arch>"
+ exit 1
+fi
+
+if [ -f "/etc/makepkg.conf" ]; then
+ #Get some config info
+ . /etc/makepkg.conf
+else
+ echo "/etc/makepkg.conf does not exist!"
+ exit 1
+fi
+
+packagename="$1"
+repofrom="$2"
+repoto="$3"
+arch="$4"
+
+export CARCH="$arch"
+
+##### Arch specific stuff. TODO make this configurable #####
+ftppath_from="/home/ftp/$repofrom/os/$arch/"
+ftppath_to="/home/ftp/$repoto/os/$arch/"
+svnpath="file:///home/svn-packages"
+svnrepo_from="$repofrom-$arch"
+svnrepo_to="$repoto-$arch"
+############################################################
+
+[ "$UID" = "" ] && UID=$(uid)
+
+WORKDIR="/tmp/db-move.$svnrepo_from.$svnrepo_to.$UID"
+LOCKFILE="/tmp/.repolck.$arch.$reponame"
+
+cleanup() {
+ # unlock
+ rm -f "$LOCKFILE"
+ #rm -rf "$WORKDIR"
+ [ "$1" ] && exit $1
+}
+
+ctrl_c() {
+ echo "Interrupted" >&2
+ cleanup 0
+}
+
+die() {
+ echo "$*" >&2
+ cleanup 1
+}
+
+# check for locks
+if [ -f "$LOCKFILE" ]; then
+ owner="$(/usr/bin/stat -c %U $LOCKFILE)"
+ die "error: db generation is already in progress (started by $owner)"
+fi
+
+trap ctrl_c 2
+trap cleanup 0
+
+/bin/touch "$LOCKFILE"
+/bin/mkdir -p "$WORKDIR"
+
+cd "$WORKDIR"
+/usr/bin/svn checkout -N $svnpath checkout
+cd checkout
+
+/usr/bin/svn up -q $packagename
+if [ -d "$packagename/repos/$svnrepo_from" ]; then
+ . "$packagename/repos/$svnrepo_from/$BUILDSCRIPT"
+ _pkgfile="$pkgname-$pkgver-$pkgrel-$CARCH$PKGEXT"
+
+ if [ ! -f "$ftppath_from/$_pkgfile" ]; then
+ die "error: package file '$_pkgfile' not found in repo '$repofrom'"
+ fi
+
+ if [ -d "$packagename/repos/$svnrepo_to" ]; then
+ echo " Removing existing package from subversion"
+ /usr/bin/svn rm --force -q "$packagename/repos/$svnrepo_to"
+ /usr/bin/svn commit -q -m "$(basename $0): $packagename removed by $(id -un) for move to $repoto"
+ fi
+
+ echo " Moving svn entries"
+ /usr/bin/svn mv -r HEAD "$packagename/repos/$svnrepo_from" "$packagename/repos/$svnrepo_to"
+ /usr/bin/svn commit -m "$(basename $0): moved $packagename from [$repofrom] to [$repoto] ($arch)"
+
+ echo " Moving package file and updating DBs"
+ cd "$WORKDIR"
+ [ -d build/ ] || mkdir build
+ cd build/
+
+ # copy the db file into our working area
+ if [ -f "$ftppath_from/$repofrom.db.tar.$DB_COMPRESSION" ]; then
+ cp "$ftppath_from/$repofrom.db.tar.$DB_COMPRESSION" .
+ else
+ touch "$repofrom.db.tar.$DB_COMPRESSION"
+ fi
+
+ /usr/bin/repo-remove "$repofrom.db.tar.$DB_COMPRESSION" $packagename || die "Error in repo-remove"
+ #use '*' to move the old DB too
+ mv $repofrom.db.tar.$DB_COMPRESSION* $ftppath_from
+ echo " Package files will be cleaned up automatically"
+
+ if [ -f "$ftppath_to/$repoto.db.tar.$DB_COMPRESSION" ]; then
+ cp "$ftppath_to/$repoto.db.tar.$DB_COMPRESSION" .
+ else
+ touch "$repoto.db.tar.$DB_COMPRESSION"
+ fi
+
+ cp "$ftppath_from/$_pkgfile" .
+ /usr/bin/repo-add "$repoto.db.tar.$DB_COMPRESSION" $_pkgfile || die "Error in repo-add"
+ #use '*' to move the old DB too
+ mv $repoto.db.tar.$DB_COMPRESSION* $_pkgfile $ftppath_to
+else
+ die "Error: $packagename is not in repo $repofrom"
+fi
+
+cleanup
diff --git a/testing2core b/testing2core
new file mode 100755
index 0000000..417ab0e
--- /dev/null
+++ b/testing2core
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+if [ $# -le 1 ]; then
+ echo "usage: $(basename 0) <arch> <packagename> [<packagename> [<packagename ...]]"
+ exit 0
+fi
+
+arch=$1; shift
+
+for pkg in $@; do
+ echo "==> Moving package '$pkg'"
+ $(dirname $0)/db-move "$pkg" "testing" "core" "$arch"
+done
diff --git a/testing2extra b/testing2extra
new file mode 100755
index 0000000..7c6c87d
--- /dev/null
+++ b/testing2extra
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+if [ $# -le 1 ]; then
+ echo "usage: $(basename 0) <arch> <packagename> [<packagename> [<packagename ...]]"
+ exit 0
+fi
+
+arch=$1; shift
+
+for pkg in $@; do
+ echo "==> Moving package '$pkg'"
+ $(dirname $0)/db-move "$pkg" "testing" "extra" "$arch"
+done