From 8e2d2c6df75a992cf65ab24e7f97de9a9f04174c Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Wed, 21 May 2008 00:33:12 -0400 Subject: Add db-move related scripts Used to easilly move a package from one repo to another Signed-off-by: Aaron Griffin --- db-move | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100755 db-move (limited to 'db-move') 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) " + 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 -- cgit v1.2.3-54-g00ecf From 39eb3c90a2c021dc750467360e07a6dadf7bcbb2 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Wed, 21 May 2008 00:36:21 -0400 Subject: Make sure to cleanup WORKDIR on exit Signed-off-by: Aaron Griffin --- db-move | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db-move') diff --git a/db-move b/db-move index cb559d2..f8adfc1 100755 --- a/db-move +++ b/db-move @@ -37,7 +37,7 @@ LOCKFILE="/tmp/.repolck.$arch.$reponame" cleanup() { # unlock rm -f "$LOCKFILE" - #rm -rf "$WORKDIR" + rm -rf "$WORKDIR" [ "$1" ] && exit $1 } -- cgit v1.2.3-54-g00ecf From afc6b5b5977fe77e699af8f02f7c8c4c3df603de Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Sat, 30 Aug 2008 21:21:43 -0500 Subject: Create a "common functions" file for DB scripts Common functions, such as sourcing makepkg, and locking a repo Additionally, repo-locking has been unified to prevent multiple users from corrupting a repo (i.e. db-move run while db-remove in progress) Signed-off-by: Aaron Griffin --- db-move | 26 +++++++++----------------- db-remove | 25 +++++++------------------ db-update | 24 ++++++------------------ testing2x | 11 ++++------- 4 files changed, 26 insertions(+), 60 deletions(-) (limited to 'db-move') diff --git a/db-move b/db-move index f8adfc1..13f2c4e 100755 --- a/db-move +++ b/db-move @@ -6,13 +6,9 @@ if [ $# -ne 4 ]; then 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 +. "$(dirname $0)/db-functions" + +source_makepkg packagename="$1" repofrom="$2" @@ -32,11 +28,11 @@ 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" + repo_unlock $repoto $arch + repo_unlock $repofrom $arch rm -rf "$WORKDIR" [ "$1" ] && exit $1 } @@ -51,16 +47,12 @@ die() { 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 +trap cleanup 0 1 + +repo_lock $repoto $arch +repo_lock $repofrom $arch -/bin/touch "$LOCKFILE" /bin/mkdir -p "$WORKDIR" cd "$WORKDIR" diff --git a/db-remove b/db-remove index f9495e9..f4d9419 100755 --- a/db-remove +++ b/db-remove @@ -5,13 +5,9 @@ if [ $# -ne 3 ]; then 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 +. "$(dirname $0)/db-functions" + +source_makepkg packagename="$1" reponame="$2" @@ -28,11 +24,10 @@ svnrepo="$reponame-$arch" [ "$UID" = "" ] && UID=$(uid) WORKDIR="/tmp/db-remove.$svnrepo.$UID" -LOCKFILE="/tmp/.repolck.$arch.$reponame" cleanup() { # unlock - rm -f "$LOCKFILE" + repo_unlock $reponame $arch rm -rf "$WORKDIR" [ "$1" ] && exit $1 } @@ -47,17 +42,11 @@ die() { cleanup 1 } -# check for locks -if [ -f "$LOCKFILE" ]; then - owner="$(/usr/bin/stat -c %U $LOCKFILE)" - echo "error: db generation is already in progress (started by $owner)" - exit 1 -fi - trap ctrl_c 2 -trap cleanup 0 +trap cleanup 0 1 + +repo_lock $reponame $arch -/bin/touch "$LOCKFILE" /bin/mkdir -p "$WORKDIR" diff --git a/db-update b/db-update index 4b2571d..5060449 100755 --- a/db-update +++ b/db-update @@ -5,13 +5,9 @@ if [ $# -ne 2 ]; then 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 +. "$(dirname $0)/db-functions" + +source_makepkg reponame="$1" arch="$2" @@ -28,7 +24,6 @@ stagedir="$HOME/staging/$reponame" [ "$UID" = "" ] && UID=$(uid) WORKDIR="/tmp/db-update.$svnrepo.$UID" -LOCKFILE="/tmp/.repolck.$arch.$reponame" ADDPKGS="" REMPKGS="" @@ -56,7 +51,7 @@ getpkgname() { cleanup() { # unlock - rm -f "$LOCKFILE" + repo_unlock $reponame $arch rm -rf "$WORKDIR" [ "$1" ] && exit $1 } @@ -71,17 +66,10 @@ die() { cleanup 1 } -# check for locks -if [ -f "$LOCKFILE" ]; then - owner="$(/usr/bin/stat -c %U $LOCKFILE)" - echo "error: db generation is already in progress (started by $owner)" - exit 1 -fi - trap ctrl_c 2 -trap cleanup 0 +trap cleanup 0 1 -/bin/touch "$LOCKFILE" +repo_lock $reponame $arch /bin/mkdir -p "$WORKDIR/build" cd "$WORKDIR" diff --git a/testing2x b/testing2x index 7096f1d..c385fd8 100755 --- a/testing2x +++ b/testing2x @@ -1,11 +1,8 @@ #!/bin/bash -if [ -f "/etc/makepkg.conf" ]; then - . /etc/makepkg.conf -else - echo "/etc/makepkg.conf does not exist!" - exit 1 -fi +. "$(dirname $0)/db-functions" + +source_makepkg case "$0" in *64) @@ -29,7 +26,7 @@ ctrl_c() { } trap ctrl_c 2 -trap cleanup 0 +trap cleanup 0 1 cd "${WORKDIR}" /usr/bin/svn checkout -N ${svnpath} checkout -- cgit v1.2.3-54-g00ecf From 42bbb3dd2ef276c5204651fafb152a888c449c15 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Sat, 13 Sep 2008 20:30:27 -0500 Subject: Move temporary directories to /home/tmp This is to allow moves to /home/ftp/ to remain on the same filesystem, thus making the final moves atomic Signed-off-by: Aaron Griffin --- db-move | 2 +- db-remove | 2 +- db-update | 2 +- testing2x | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'db-move') diff --git a/db-move b/db-move index 13f2c4e..c8d30c4 100755 --- a/db-move +++ b/db-move @@ -27,7 +27,7 @@ svnrepo_to="$repoto-$arch" [ "$UID" = "" ] && UID=$(uid) -WORKDIR="/tmp/db-move.$svnrepo_from.$svnrepo_to.$UID" +WORKDIR="/home/tmp/db-move.$svnrepo_from.$svnrepo_to.$UID" cleanup() { # unlock diff --git a/db-remove b/db-remove index f4d9419..fdc7c5d 100755 --- a/db-remove +++ b/db-remove @@ -23,7 +23,7 @@ svnrepo="$reponame-$arch" [ "$UID" = "" ] && UID=$(uid) -WORKDIR="/tmp/db-remove.$svnrepo.$UID" +WORKDIR="/home/tmp/db-remove.$svnrepo.$UID" cleanup() { # unlock diff --git a/db-update b/db-update index d3fff2c..dbfbe51 100755 --- a/db-update +++ b/db-update @@ -23,7 +23,7 @@ stagedir="$HOME/staging/$reponame" [ "$UID" = "" ] && UID=$(uid) -WORKDIR="/tmp/db-update.$svnrepo.$UID" +WORKDIR="/home/tmp/db-update.$svnrepo.$UID" ADDPKGS="" REMPKGS="" diff --git a/testing2x b/testing2x index c385fd8..687994e 100755 --- a/testing2x +++ b/testing2x @@ -13,7 +13,7 @@ case "$0" in ;; esac svnpath="file:///home/svn-packages" -WORKDIR="$(mktemp -d /tmp/testing2x.XXXXXX)" +WORKDIR="/home/tmp/testing2x.$UID" cleanup() { rm -rf "${WORKDIR}" -- cgit v1.2.3-54-g00ecf From 23f48e65a5f4133be8a5d2883de6ffb2f4f04962 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Tue, 21 Oct 2008 13:06:06 -0700 Subject: Add copy_helper function to ensure correct permissions This will force all files copied back and forth to have 0664 permissions so that we can attempt to do away with this permission adjusting cron job Signed-off-by: Aaron Griffin --- db-functions | 7 +++++++ db-move | 6 +++--- db-remove | 4 ++-- db-update | 12 +++++++----- 4 files changed, 19 insertions(+), 10 deletions(-) (limited to 'db-move') diff --git a/db-functions b/db-functions index 9df678c..a20496b 100644 --- a/db-functions +++ b/db-functions @@ -61,4 +61,11 @@ check_pkg_arch () { #check_pkg_arch pkgfile arch fi } +# Simple helper function to ensure we always +# have proper DB permissions +copy_helper () { #copy_helper file dest + /bin/cp $1 $2 || return 1 + /bin/chmod 664 "$(dirname $2)/$(basename $1)" || return 1 +} + # vim: set ts=4 sw=4 noet ft=sh: diff --git a/db-move b/db-move index c8d30c4..aee18f2 100755 --- a/db-move +++ b/db-move @@ -85,7 +85,7 @@ if [ -d "$packagename/repos/$svnrepo_from" ]; then # 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" . + copy_helper "$ftppath_from/$repofrom.db.tar.$DB_COMPRESSION" . else touch "$repofrom.db.tar.$DB_COMPRESSION" fi @@ -96,12 +96,12 @@ if [ -d "$packagename/repos/$svnrepo_from" ]; then 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" . + copy_helper "$ftppath_to/$repoto.db.tar.$DB_COMPRESSION" . else touch "$repoto.db.tar.$DB_COMPRESSION" fi - cp "$ftppath_from/$_pkgfile" . + copy_helper "$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 diff --git a/db-remove b/db-remove index fdc7c5d..bb91afd 100755 --- a/db-remove +++ b/db-remove @@ -68,7 +68,7 @@ cd "$WORKDIR" # copy the db file into our working area if [ -f "$ftppath/$reponame.db.tar.$DB_COMPRESSION" ]; then - cp "$ftppath/$reponame.db.tar.$DB_COMPRESSION" build/ + copy_helper "$ftppath/$reponame.db.tar.$DB_COMPRESSION" build/ else echo "No database found at '$ftpdir', nothing more to do" exit 0 @@ -78,7 +78,7 @@ echo " Removing from $reponame DB file" cd build/ /usr/bin/repo-remove "$reponame.db.tar.$DB_COMPRESSION" $packagename -cp "$reponame.db.tar.$DB_COMPRESSION" "$ftppath/" +copy_helper "$reponame.db.tar.$DB_COMPRESSION" "$ftppath/" echo "Package files will be cleaned up automatically" diff --git a/db-update b/db-update index 81b3905..d25ab2c 100755 --- a/db-update +++ b/db-update @@ -76,7 +76,7 @@ cd "$WORKDIR" # copy the db file into our working area if [ -f "$ftppath/$reponame.db.tar.$DB_COMPRESSION" ]; then - cp "$ftppath/$reponame.db.tar.$DB_COMPRESSION" build/ + copy_helper "$ftppath/$reponame.db.tar.$DB_COMPRESSION" build/ else touch "build/$reponame.db.tar.$DB_COMPRESSION" fi @@ -130,7 +130,7 @@ if [ -n "$ADDPKGS" ]; then if [ -n "$to_add" ]; then cd "$WORKDIR/build/" - /bin/cp $to_add . + for f in $to_add; do copy_helper "$f" .; done pkgs="" for pkg in $to_add; do pkgs="$pkgs $(basename $pkg)"; done @@ -192,9 +192,11 @@ fi # if non empty, move all build dirs if [ $(/bin/ls "$WORKDIR/build/" 2>/dev/null | wc -l) != 0 ]; then echo "Copying new files to '$ftppath'" - if ! /bin/cp -r "$WORKDIR/build/"* "$ftppath"; then - die "error: failure while copying files to $ftppath" - fi + for f in "$WORKDIR/build/"*; do + if ! copy_helper "$f" "$ftppath"; then + die "error: failure while copying files to $ftppath" + fi + done else echo "Nothing to copy, no work done" -- cgit v1.2.3-54-g00ecf From 2063416ef4a160f56bb47f203257fe7903ba77e2 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Sun, 9 Nov 2008 00:27:43 -0600 Subject: Remove an erroneous '1' signal trap for cleanup() func Signed-off-by: Aaron Griffin --- db-move | 2 +- db-remove | 2 +- db-update | 2 +- testing2x | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'db-move') diff --git a/db-move b/db-move index aee18f2..88a8cb6 100755 --- a/db-move +++ b/db-move @@ -48,7 +48,7 @@ die() { } trap ctrl_c 2 -trap cleanup 0 1 +trap cleanup 0 repo_lock $repoto $arch repo_lock $repofrom $arch diff --git a/db-remove b/db-remove index bb91afd..01f18d6 100755 --- a/db-remove +++ b/db-remove @@ -43,7 +43,7 @@ die() { } trap ctrl_c 2 -trap cleanup 0 1 +trap cleanup 0 repo_lock $reponame $arch diff --git a/db-update b/db-update index d25ab2c..e2a6534 100755 --- a/db-update +++ b/db-update @@ -67,7 +67,7 @@ die() { } trap ctrl_c 2 -trap cleanup 0 1 +trap cleanup 0 repo_lock $reponame $arch diff --git a/testing2x b/testing2x index 687994e..0494b98 100755 --- a/testing2x +++ b/testing2x @@ -26,7 +26,7 @@ ctrl_c() { } trap ctrl_c 2 -trap cleanup 0 1 +trap cleanup 0 cd "${WORKDIR}" /usr/bin/svn checkout -N ${svnpath} checkout -- cgit v1.2.3-54-g00ecf From 35e5070403ddae96238bcce6356f4b9713c96675 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Tue, 11 Nov 2008 22:09:24 -0800 Subject: Move as much as we can out to a config file This should allow us to move FTP and SVN placement around Signed-off-by: Aaron Griffin --- config | 4 ++++ db-functions | 5 +++++ db-move | 9 +++------ db-remove | 7 ++----- db-update | 11 ++++------- testing2x | 3 +-- 6 files changed, 19 insertions(+), 20 deletions(-) create mode 100644 config (limited to 'db-move') diff --git a/config b/config new file mode 100644 index 0000000..dbed5bd --- /dev/null +++ b/config @@ -0,0 +1,4 @@ + +FTP_BASE="/home/ftp/" +SVN_PATH="file:///home/svn-packages" +STAGING="$HOME/staging/" diff --git a/db-functions b/db-functions index a20496b..9724e1c 100644 --- a/db-functions +++ b/db-functions @@ -3,6 +3,11 @@ # Random integrity things [ "$UID" = "" ] && UID=$(uid) +BASEDIR="$(dirname $0)" +if [ -f "$BASEDIR/config" ]; then + . "$BASEDIR/config" +fi + # Useful functions source_makepkg () { if [ -f "/etc/makepkg.conf" ]; then diff --git a/db-move b/db-move index 88a8cb6..5be1813 100755 --- a/db-move +++ b/db-move @@ -17,13 +17,10 @@ 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" +ftppath_from="$FTP_BASE/$repofrom/os/$arch/" +ftppath_to="$FTP_BASE/$repoto/os/$arch/" svnrepo_from="$repofrom-$arch" svnrepo_to="$repoto-$arch" -############################################################ [ "$UID" = "" ] && UID=$(uid) @@ -56,7 +53,7 @@ repo_lock $repofrom $arch /bin/mkdir -p "$WORKDIR" cd "$WORKDIR" -/usr/bin/svn checkout -N $svnpath checkout +/usr/bin/svn checkout -N $SVN_PATH checkout cd checkout /usr/bin/svn up -q $packagename diff --git a/db-remove b/db-remove index 01f18d6..bdbd254 100755 --- a/db-remove +++ b/db-remove @@ -15,11 +15,8 @@ arch="$3" export CARCH="$arch" -##### Arch specific stuff. TODO make this configurable ##### -ftppath="/home/ftp/$reponame/os/$arch/" -svnpath="file:///home/svn-packages" +ftppath="$FTP_BASE/$reponame/os/$arch/" svnrepo="$reponame-$arch" -############################################################ [ "$UID" = "" ] && UID=$(uid) @@ -53,7 +50,7 @@ repo_lock $reponame $arch echo "==> Removing package '$packagename' from '$reponame'..." >&2 cd "$WORKDIR" -/usr/bin/svn checkout -N $svnpath checkout +/usr/bin/svn checkout -N $SVN_PATH checkout cd checkout /usr/bin/svn up -q $packagename diff --git a/db-update b/db-update index e2a6534..84764eb 100755 --- a/db-update +++ b/db-update @@ -14,12 +14,9 @@ arch="$2" export CARCH="$arch" -##### Arch specific stuff. TODO make this configurable ##### -ftppath="/home/ftp/$reponame/os/$arch/" -svnpath="file:///home/svn-packages" +ftppath="$FTP_BASE/$reponame/os/$arch/" svnrepo="$reponame-$arch" -stagedir="$HOME/staging/$reponame" -############################################################ +stagedir="$STAGING/$reponame" [ "$UID" = "" ] && UID=$(uid) @@ -102,7 +99,7 @@ if [ -n "$ADDPKGS" ]; then echo "==> Processing new/updated packages for repository '$reponame'..." >&2 cd "$WORKDIR" - /usr/bin/svn checkout -N $svnpath checkout + /usr/bin/svn checkout -N $SVN_PATH checkout cd checkout for pkg in $ADDPKGS; do @@ -154,7 +151,7 @@ if [ -n "$REMPKGS" ]; then if [ ! -d "$WORKDIR/checkout" ]; then cd "$WORKDIR" - /usr/bin/svn checkout -N $svnpath checkout + /usr/bin/svn checkout -N $SVN_PATH checkout fi cd "$WORKDIR/checkout" diff --git a/testing2x b/testing2x index 0494b98..d87de11 100755 --- a/testing2x +++ b/testing2x @@ -12,7 +12,6 @@ case "$0" in arch="i686" ;; esac -svnpath="file:///home/svn-packages" WORKDIR="/home/tmp/testing2x.$UID" cleanup() { @@ -29,7 +28,7 @@ trap ctrl_c 2 trap cleanup 0 cd "${WORKDIR}" -/usr/bin/svn checkout -N ${svnpath} checkout +/usr/bin/svn checkout -N $SVN_PATH checkout cd checkout for pkg in $*; do -- cgit v1.2.3-54-g00ecf From 1809269f1df368aab3f7f1bb615c2cdc52860a1f Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Thu, 20 Nov 2008 21:48:00 -0800 Subject: Move everything to /srv to support new server conf Additionally, make TMPDIR configurable so we can move that Signed-off-by: Aaron Griffin --- config | 5 +++-- db-functions | 4 ++-- db-move | 2 +- db-remove | 2 +- db-update | 2 +- testing2x | 2 +- 6 files changed, 9 insertions(+), 8 deletions(-) (limited to 'db-move') diff --git a/config b/config index dbed5bd..5fe1969 100644 --- a/config +++ b/config @@ -1,4 +1,5 @@ -FTP_BASE="/home/ftp/" -SVN_PATH="file:///home/svn-packages" +FTP_BASE="/srv/ftp/" +SVN_PATH="file:///srv/svn/packages" STAGING="$HOME/staging/" +TMPDIR="/srv/tmp" diff --git a/db-functions b/db-functions index 9724e1c..4252c59 100644 --- a/db-functions +++ b/db-functions @@ -20,7 +20,7 @@ source_makepkg () { } repo_lock () { #repo_lock repo-name arch - LOCKFILE="/tmp/.repolck.$1.$2" + LOCKFILE="$TMPDIR/.repolock.$1.$2" if [ -f "$LOCKFILE" ]; then owner="$(/usr/bin/stat -c %U $LOCKFILE)" echo "error: db generation is already in progress (started by $owner)" @@ -31,7 +31,7 @@ repo_lock () { #repo_lock repo-name arch } repo_unlock () { #repo_unlock repo-name arch - LOCKFILE="/tmp/.repolck.$1.$2" + LOCKFILE="$TMPDIR/.repolock.$1.$2" if [ ! -f "$LOCKFILE" ]; then echo "error: repo lock doesn't exist... something went terribly wrong!" else diff --git a/db-move b/db-move index 5be1813..789e536 100755 --- a/db-move +++ b/db-move @@ -24,7 +24,7 @@ svnrepo_to="$repoto-$arch" [ "$UID" = "" ] && UID=$(uid) -WORKDIR="/home/tmp/db-move.$svnrepo_from.$svnrepo_to.$UID" +WORKDIR="$TMPDIR/db-move.$svnrepo_from.$svnrepo_to.$UID" cleanup() { # unlock diff --git a/db-remove b/db-remove index bdbd254..47268ed 100755 --- a/db-remove +++ b/db-remove @@ -20,7 +20,7 @@ svnrepo="$reponame-$arch" [ "$UID" = "" ] && UID=$(uid) -WORKDIR="/home/tmp/db-remove.$svnrepo.$UID" +WORKDIR="$TMPDIR/db-remove.$svnrepo.$UID" cleanup() { # unlock diff --git a/db-update b/db-update index 84764eb..315c107 100755 --- a/db-update +++ b/db-update @@ -20,7 +20,7 @@ stagedir="$STAGING/$reponame" [ "$UID" = "" ] && UID=$(uid) -WORKDIR="/home/tmp/db-update.$svnrepo.$UID" +WORKDIR="$TMPDIR/db-update.$svnrepo.$UID" ADDPKGS="" REMPKGS="" diff --git a/testing2x b/testing2x index d87de11..812edd3 100755 --- a/testing2x +++ b/testing2x @@ -12,7 +12,7 @@ case "$0" in arch="i686" ;; esac -WORKDIR="/home/tmp/testing2x.$UID" +WORKDIR="$TMPDIR/testing2x.$UID" cleanup() { rm -rf "${WORKDIR}" -- cgit v1.2.3-54-g00ecf From 07ec0708d31794221bec7ee3e7f07755707fd36a Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Fri, 21 Nov 2008 01:05:09 -0500 Subject: Clear traps on cleanup This prevents us from trying to remove the lockfile twice, and calling cleanup multiple times Signed-off-by: Aaron Griffin --- db-move | 1 + db-remove | 1 + db-update | 1 + testing2x | 45 +++++++++++++++++++++++---------------------- 4 files changed, 26 insertions(+), 22 deletions(-) (limited to 'db-move') diff --git a/db-move b/db-move index 789e536..8d006f4 100755 --- a/db-move +++ b/db-move @@ -27,6 +27,7 @@ svnrepo_to="$repoto-$arch" WORKDIR="$TMPDIR/db-move.$svnrepo_from.$svnrepo_to.$UID" cleanup() { + trap '' 0 2 # unlock repo_unlock $repoto $arch repo_unlock $repofrom $arch diff --git a/db-remove b/db-remove index 47268ed..2e0307d 100755 --- a/db-remove +++ b/db-remove @@ -23,6 +23,7 @@ svnrepo="$reponame-$arch" WORKDIR="$TMPDIR/db-remove.$svnrepo.$UID" cleanup() { + trap '' 0 2 # unlock repo_unlock $reponame $arch rm -rf "$WORKDIR" diff --git a/db-update b/db-update index 315c107..9aba199 100755 --- a/db-update +++ b/db-update @@ -47,6 +47,7 @@ getpkgname() { } cleanup() { + trap '' 0 2 # unlock repo_unlock $reponame $arch rm -rf "$WORKDIR" diff --git a/testing2x b/testing2x index 812edd3..b576640 100755 --- a/testing2x +++ b/testing2x @@ -5,23 +5,24 @@ source_makepkg case "$0" in - *64) + *64) arch="x86_64" ;; - *) + *) arch="i686" ;; esac WORKDIR="$TMPDIR/testing2x.$UID" cleanup() { - rm -rf "${WORKDIR}" - [ -n "$1" ] && exit $1 + trap '' 0 2 + rm -rf "${WORKDIR}" + [ -n "$1" ] && exit $1 } ctrl_c() { - echo "Interrupted" >&2 - cleanup 0 + echo "Interrupted" >&2 + cleanup 0 } trap ctrl_c 2 @@ -32,23 +33,23 @@ cd "${WORKDIR}" cd checkout for pkg in $*; do - moved=0 - /usr/bin/svn up -q ${pkg} - if [ -f "${pkg}/repos/testing-${arch}/${BUILDSCRIPT}" ]; then - for repo in core extra; do - if [ -f "${pkg}/repos/${repo}-${arch}/${BUILDSCRIPT}" ]; then - echo "===> Moving package '${pkg}': testing-${arch} -> ${repo}-${arch}" - $(dirname $0)/db-move "${pkg}" "testing" "${repo}" "${arch}" - moved=1 - break - fi - done - if [ ${moved} -eq 0 ]; then - echo "===> Warning: ${pkg} is only in testing-${arch}, cannot determine where to move it" + moved=0 + /usr/bin/svn up -q ${pkg} + if [ -f "${pkg}/repos/testing-${arch}/${BUILDSCRIPT}" ]; then + for repo in core extra; do + if [ -f "${pkg}/repos/${repo}-${arch}/${BUILDSCRIPT}" ]; then + echo "===> Moving package '${pkg}': testing-${arch} -> ${repo}-${arch}" + $(dirname $0)/db-move "${pkg}" "testing" "${repo}" "${arch}" + moved=1 + break + fi + done + if [ ${moved} -eq 0 ]; then + echo "===> Warning: ${pkg} is only in testing-${arch}, cannot determine where to move it" + fi + else + echo "===> Warning: ${pkg} is not in testing-${arch}" fi - else - echo "===> Warning: ${pkg} is not in testing-${arch}" - fi done cleanup -- cgit v1.2.3-54-g00ecf From 3606df775189459eef24fdec2bad5cab6ccc7ec6 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Fri, 21 Nov 2008 17:14:10 -0800 Subject: Fix a variable overwrite when sourcing PKGBUILDs The local variable 'arch' was being overwritten when we source PKGBUILDs. Change it to _arch wherever we deal with PKGBUILD files Signed-off-by: Aaron Griffin --- db-move | 24 ++++++++++++------------ db-update | 22 +++++++++++----------- testing2x | 16 ++++++++-------- 3 files changed, 31 insertions(+), 31 deletions(-) (limited to 'db-move') diff --git a/db-move b/db-move index 8d006f4..74e0b0b 100755 --- a/db-move +++ b/db-move @@ -13,14 +13,14 @@ source_makepkg packagename="$1" repofrom="$2" repoto="$3" -arch="$4" +_arch="$4" -export CARCH="$arch" +export CARCH="$_arch" -ftppath_from="$FTP_BASE/$repofrom/os/$arch/" -ftppath_to="$FTP_BASE/$repoto/os/$arch/" -svnrepo_from="$repofrom-$arch" -svnrepo_to="$repoto-$arch" +ftppath_from="$FTP_BASE/$repofrom/os/$_arch/" +ftppath_to="$FTP_BASE/$repoto/os/$_arch/" +svnrepo_from="$repofrom-$_arch" +svnrepo_to="$repoto-$_arch" [ "$UID" = "" ] && UID=$(uid) @@ -29,8 +29,8 @@ WORKDIR="$TMPDIR/db-move.$svnrepo_from.$svnrepo_to.$UID" cleanup() { 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 } @@ -48,8 +48,8 @@ die() { trap ctrl_c 2 trap cleanup 0 -repo_lock $repoto $arch -repo_lock $repofrom $arch +repo_lock $repoto $_arch +repo_lock $repofrom $_arch /bin/mkdir -p "$WORKDIR" @@ -60,7 +60,7 @@ 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" + _pkgfile="$pkgname-$pkgver-$pkgrel-$_arch$PKGEXT" if [ ! -f "$ftppath_from/$_pkgfile" ]; then die "error: package file '$_pkgfile' not found in repo '$repofrom'" @@ -74,7 +74,7 @@ if [ -d "$packagename/repos/$svnrepo_from" ]; then 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)" + /usr/bin/svn commit -m "$(basename $0): moved $packagename from [$repofrom] to [$repoto] ($_arch)" echo " Moving package file and updating DBs" cd "$WORKDIR" diff --git a/db-update b/db-update index 397a046..d98b60d 100755 --- a/db-update +++ b/db-update @@ -10,12 +10,12 @@ fi source_makepkg reponame="$1" -arch="$2" +_arch="$2" -export CARCH="$arch" +export CARCH="$_arch" -ftppath="$FTP_BASE/$reponame/os/$arch/" -svnrepo="$reponame-$arch" +ftppath="$FTP_BASE/$reponame/os/$_arch/" +svnrepo="$reponame-$_arch" stagedir="$STAGING/$reponame" [ "$UID" = "" ] && UID=$(uid) @@ -48,7 +48,7 @@ getpkgname() { cleanup() { trap '' 0 2 # unlock - repo_unlock $reponame $arch + repo_unlock $reponame $_arch rm -rf "$WORKDIR" [ "$1" ] && exit $1 } @@ -66,7 +66,7 @@ die() { trap ctrl_c 2 trap cleanup 0 -repo_lock $reponame $arch +repo_lock $reponame $_arch /bin/mkdir -p "$WORKDIR/build" cd "$WORKDIR" @@ -78,7 +78,7 @@ else touch "build/$reponame.db.tar.$DB_COMPRESSION" fi -echo "Updating DB for $reponame $arch" +echo "Updating DB for $reponame $_arch" if [ -d "${stagedir}64" ]; then echo "--------------------------------------------------" @@ -102,7 +102,7 @@ fi to_add="" if [ -d "$stagedir" ]; then - ADDPKGS="$(/bin/ls $stagedir/*-${arch}$PKGEXT 2>/dev/null)" + ADDPKGS="$(/bin/ls $stagedir/*-${_arch}$PKGEXT 2>/dev/null)" fi if [ -n "$ADDPKGS" ]; then @@ -116,15 +116,15 @@ if [ -n "$ADDPKGS" ]; then _pkgfile=$(basename $pkg) _pkgname="$(getpkgname $pkg)" - echo " Validating package arch ($arch) $_pkgname" - if ! check_pkg_arch "$pkg" "$arch"; then + echo " Validating package arch ($_arch) $_pkgname" + if ! check_pkg_arch "$pkg" "$_arch"; then echo " ERROR: $_pkgfile was built for the wrong architecture" else echo " Checking SVN for $_pkgname" /usr/bin/svn up -q $_pkgname if [ -d "$_pkgname/repos/$svnrepo" ]; then . "$_pkgname/repos/$svnrepo/$BUILDSCRIPT" - if [ "$_pkgfile" = "$pkgname-$pkgver-$pkgrel-$CARCH$PKGEXT" ]; then + if [ "$_pkgfile" = "$pkgname-$pkgver-$pkgrel-$_arch$PKGEXT" ]; then to_add="$to_add $pkg" else echo " WARNING: $_pkgfile does not match $BUILDSCRIPT in $svnrepo" diff --git a/testing2x b/testing2x index a5e3098..6a3a70e 100755 --- a/testing2x +++ b/testing2x @@ -6,10 +6,10 @@ source_makepkg case "$0" in *64) - arch="x86_64" + _arch="x86_64" ;; *) - arch="i686" + _arch="i686" ;; esac WORKDIR="$TMPDIR/testing2x.$UID" @@ -36,20 +36,20 @@ cd checkout for pkg in $*; do moved=0 /usr/bin/svn up -q ${pkg} - if [ -f "${pkg}/repos/testing-${arch}/${BUILDSCRIPT}" ]; then + if [ -f "${pkg}/repos/testing-${_arch}/${BUILDSCRIPT}" ]; then for repo in core extra; do - if [ -f "${pkg}/repos/${repo}-${arch}/${BUILDSCRIPT}" ]; then - echo "===> Moving package '${pkg}': testing-${arch} -> ${repo}-${arch}" - $(dirname $0)/db-move "${pkg}" "testing" "${repo}" "${arch}" + if [ -f "${pkg}/repos/${repo}-${_arch}/${BUILDSCRIPT}" ]; then + echo "===> Moving package '${pkg}': testing-${_arch} -> ${repo}-${_arch}" + $(dirname $0)/db-move "${pkg}" "testing" "${repo}" "${_arch}" moved=1 break fi done if [ ${moved} -eq 0 ]; then - echo "===> Warning: ${pkg} is only in testing-${arch}, cannot determine where to move it" + echo "===> Warning: ${pkg} is only in testing-${_arch}, cannot determine where to move it" fi else - echo "===> Warning: ${pkg} is not in testing-${arch}" + echo "===> Warning: ${pkg} is not in testing-${_arch}" fi done -- cgit v1.2.3-54-g00ecf From 5ed9e55f4d6a26452baaffadba407459ff96f295 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Sat, 22 Nov 2008 17:48:58 -0600 Subject: Remove 'copy_helper' as chmodding is fail The chmod doesn't work unless the user is the owner of the file Resorting to umask changes here Signed-off-by: Aaron Griffin --- db-functions | 9 --------- db-move | 6 +++--- db-remove | 4 ++-- db-update | 6 +++--- 4 files changed, 8 insertions(+), 17 deletions(-) (limited to 'db-move') diff --git a/db-functions b/db-functions index 8c8c667..740922f 100644 --- a/db-functions +++ b/db-functions @@ -76,13 +76,4 @@ check_pkg_arch () { #check_pkg_arch pkgfile arch fi } -# Simple helper function to ensure we always -# have proper DB permissions -copy_helper () { #copy_helper file dest - /bin/cp $1 $2 || return 1 - dir=$2 - [ -f $dir ] && dir=$(dirname $dir) - /bin/chmod 664 "$dir/$(basename $1)" || return 1 -} - # vim: set ts=4 sw=4 noet ft=sh: diff --git a/db-move b/db-move index 74e0b0b..0e0587c 100755 --- a/db-move +++ b/db-move @@ -83,7 +83,7 @@ if [ -d "$packagename/repos/$svnrepo_from" ]; then # copy the db file into our working area if [ -f "$ftppath_from/$repofrom.db.tar.$DB_COMPRESSION" ]; then - copy_helper "$ftppath_from/$repofrom.db.tar.$DB_COMPRESSION" . + /bin/cp "$ftppath_from/$repofrom.db.tar.$DB_COMPRESSION" . else touch "$repofrom.db.tar.$DB_COMPRESSION" fi @@ -94,12 +94,12 @@ if [ -d "$packagename/repos/$svnrepo_from" ]; then echo " Package files will be cleaned up automatically" if [ -f "$ftppath_to/$repoto.db.tar.$DB_COMPRESSION" ]; then - copy_helper "$ftppath_to/$repoto.db.tar.$DB_COMPRESSION" . + /bin/cp "$ftppath_to/$repoto.db.tar.$DB_COMPRESSION" . else touch "$repoto.db.tar.$DB_COMPRESSION" fi - copy_helper "$ftppath_from/$_pkgfile" . + /bin/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 diff --git a/db-remove b/db-remove index 2e0307d..c5b6819 100755 --- a/db-remove +++ b/db-remove @@ -66,7 +66,7 @@ cd "$WORKDIR" # copy the db file into our working area if [ -f "$ftppath/$reponame.db.tar.$DB_COMPRESSION" ]; then - copy_helper "$ftppath/$reponame.db.tar.$DB_COMPRESSION" build/ + /bin/cp "$ftppath/$reponame.db.tar.$DB_COMPRESSION" build/ else echo "No database found at '$ftpdir', nothing more to do" exit 0 @@ -76,7 +76,7 @@ echo " Removing from $reponame DB file" cd build/ /usr/bin/repo-remove "$reponame.db.tar.$DB_COMPRESSION" $packagename -copy_helper "$reponame.db.tar.$DB_COMPRESSION" "$ftppath/" +/bin/cp "$reponame.db.tar.$DB_COMPRESSION" "$ftppath/" echo "Package files will be cleaned up automatically" diff --git a/db-update b/db-update index d98b60d..c76337a 100755 --- a/db-update +++ b/db-update @@ -73,7 +73,7 @@ cd "$WORKDIR" # copy the db file into our working area if [ -f "$ftppath/$reponame.db.tar.$DB_COMPRESSION" ]; then - copy_helper "$ftppath/$reponame.db.tar.$DB_COMPRESSION" build/ + /bin/cp "$ftppath/$reponame.db.tar.$DB_COMPRESSION" build/ else touch "build/$reponame.db.tar.$DB_COMPRESSION" fi @@ -137,7 +137,7 @@ if [ -n "$ADDPKGS" ]; then if [ -n "$to_add" ]; then cd "$WORKDIR/build/" - for f in $to_add; do copy_helper "$f" .; done + for f in $to_add; do /bin/cp "$f" .; done pkgs="" for pkg in $to_add; do pkgs="$pkgs $(basename $pkg)"; done @@ -155,7 +155,7 @@ fi if [ $(/bin/ls "$WORKDIR/build/" 2>/dev/null | wc -l) != 0 ]; then echo "Copying new files to '$ftppath'" for f in "$WORKDIR/build/"*; do - if ! copy_helper "$f" "$ftppath"; then + if ! /bin/cp "$f" "$ftppath"; then die "error: failure while copying files to $ftppath" fi done -- cgit v1.2.3-54-g00ecf From 87d3436dbd6fe5f3aeb7880d1596aa7a5c6e7905 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Mon, 1 Dec 2008 19:03:03 -0600 Subject: Cleanup missing db file logic Do not touch missing db files. Additionally, no need to call db-remove if the db file doesn't exist Signed-off-by: Aaron Griffin --- db-move | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'db-move') diff --git a/db-move b/db-move index 0e0587c..7fab215 100755 --- a/db-move +++ b/db-move @@ -84,19 +84,14 @@ if [ -d "$packagename/repos/$svnrepo_from" ]; then # copy the db file into our working area if [ -f "$ftppath_from/$repofrom.db.tar.$DB_COMPRESSION" ]; then /bin/cp "$ftppath_from/$repofrom.db.tar.$DB_COMPRESSION" . - else - touch "$repofrom.db.tar.$DB_COMPRESSION" + /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" 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 /bin/cp "$ftppath_to/$repoto.db.tar.$DB_COMPRESSION" . - else - touch "$repoto.db.tar.$DB_COMPRESSION" fi /bin/cp "$ftppath_from/$_pkgfile" . -- cgit v1.2.3-54-g00ecf From 123e7560e49e04f9fdd552f9dc47bcedea2ea128 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Fri, 12 Dec 2008 00:14:39 -0600 Subject: Quiet down repo-add just a bit This assumes the -q flag patch is accepted for pacman 8) Signed-off-by: Aaron Griffin --- db-move | 4 ++-- db-remove | 2 +- db-update | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'db-move') diff --git a/db-move b/db-move index 7fab215..ff9677b 100755 --- a/db-move +++ b/db-move @@ -84,7 +84,7 @@ if [ -d "$packagename/repos/$svnrepo_from" ]; then # copy the db file into our working area if [ -f "$ftppath_from/$repofrom.db.tar.$DB_COMPRESSION" ]; then /bin/cp "$ftppath_from/$repofrom.db.tar.$DB_COMPRESSION" . - /usr/bin/repo-remove "$repofrom.db.tar.$DB_COMPRESSION" $packagename || die "Error in repo-remove" + /usr/bin/repo-remove -q "$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" @@ -95,7 +95,7 @@ if [ -d "$packagename/repos/$svnrepo_from" ]; then fi /bin/cp "$ftppath_from/$_pkgfile" . - /usr/bin/repo-add "$repoto.db.tar.$DB_COMPRESSION" $_pkgfile || die "Error in repo-add" + /usr/bin/repo-add -q "$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 diff --git a/db-remove b/db-remove index c5b6819..acc849d 100755 --- a/db-remove +++ b/db-remove @@ -74,7 +74,7 @@ fi echo " Removing from $reponame DB file" cd build/ -/usr/bin/repo-remove "$reponame.db.tar.$DB_COMPRESSION" $packagename +/usr/bin/repo-remove -q "$reponame.db.tar.$DB_COMPRESSION" $packagename /bin/cp "$reponame.db.tar.$DB_COMPRESSION" "$ftppath/" diff --git a/db-update b/db-update index 0c2d1fe..40c5539 100755 --- a/db-update +++ b/db-update @@ -142,7 +142,7 @@ if [ -n "$ADDPKGS" ]; then pkgs="" for pkg in $to_add; do pkgs="$pkgs $(basename $pkg)"; done - /usr/bin/repo-add "$reponame.db.tar.$DB_COMPRESSION" $pkgs + /usr/bin/repo-add -q "$reponame.db.tar.$DB_COMPRESSION" $pkgs else rm -f "build/$reponame.db.tar.$DB_COMPRESSION" echo "Errors found when adding packages" -- cgit v1.2.3-54-g00ecf From 9b7b2a7e774f307b6b5ab398908e883364af7247 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Fri, 20 Feb 2009 10:23:07 -0800 Subject: Add per-repo SVN configs This could be useful if we move community to a separate SVN repo Signed-off-by: Aaron Griffin --- config | 7 ++++++- db-functions | 15 +++++++++++++++ db-move | 7 ++++++- db-remove | 3 ++- db-update | 3 ++- testing2x | 3 ++- 6 files changed, 33 insertions(+), 5 deletions(-) (limited to 'db-move') diff --git a/config b/config index 07cf783..867d28e 100644 --- a/config +++ b/config @@ -1,6 +1,11 @@ FTP_BASE="/srv/ftp" -SVN_PATH="file:///srv/svn-packages" + +SVNREPO_core="file:///srv/svn-packages" +SVNREPO_extra="file:///srv/svn-packages" +SVNREPO_testing="file:///srv/svn-packages" +SVNREPO_community="file:///srv/svn-community" + STAGING="$HOME/staging" TMPDIR="/srv/tmp" ARCHES=(i686 x86_64) diff --git a/db-functions b/db-functions index c105dab..99de756 100644 --- a/db-functions +++ b/db-functions @@ -92,4 +92,19 @@ check_pkg_arch () { #check_pkg_arch pkgfile arch fi } +get_svnpath () { #get_svnpath reponame + local var + local repopath + var="\$SVNREPO_${1}" + + eval repopath=${var} + if [ -z "$repopath" ]; then + echo "ERROR: SVN path not defined for '${1}'" >2 + echo " Please check SVNREPO_${1} config setting" >2 + fi + + echo "$repopath" +} + + # vim: set ts=4 sw=4 noet ft=sh: diff --git a/db-move b/db-move index ff9677b..e4f2fef 100755 --- a/db-move +++ b/db-move @@ -21,6 +21,11 @@ ftppath_from="$FTP_BASE/$repofrom/os/$_arch/" ftppath_to="$FTP_BASE/$repoto/os/$_arch/" svnrepo_from="$repofrom-$_arch" svnrepo_to="$repoto-$_arch" +svnpath="$(get_svnpath $repoto)" +if [ "$svnpath" != "$(get_svnpath $repofrom" ]; then + echo "ERROR: Cannot move packages across SVN repos" + echo " A move must be within the same svn repo" +fi [ "$UID" = "" ] && UID=$(uid) @@ -54,7 +59,7 @@ repo_lock $repofrom $_arch /bin/mkdir -p "$WORKDIR" cd "$WORKDIR" -/usr/bin/svn checkout -N $SVN_PATH checkout +/usr/bin/svn checkout -N $svnpath checkout cd checkout /usr/bin/svn up -q $packagename diff --git a/db-remove b/db-remove index acc849d..501c70a 100755 --- a/db-remove +++ b/db-remove @@ -17,6 +17,7 @@ export CARCH="$arch" ftppath="$FTP_BASE/$reponame/os/$arch/" svnrepo="$reponame-$arch" +svnpath="$(get_svnpath $reponame)" [ "$UID" = "" ] && UID=$(uid) @@ -51,7 +52,7 @@ repo_lock $reponame $arch echo "==> Removing package '$packagename' from '$reponame'..." >&2 cd "$WORKDIR" -/usr/bin/svn checkout -N $SVN_PATH checkout +/usr/bin/svn checkout -N $svnpath checkout cd checkout /usr/bin/svn up -q $packagename diff --git a/db-update b/db-update index ea57eed..3f3b0cc 100755 --- a/db-update +++ b/db-update @@ -87,6 +87,7 @@ for A in ${ARCHES[@]}; do exit 1 fi + svnpath="$(get_svnpath $reponame)" svnrepo="$reponame-$current_arch" repo_lock $reponame $current_arch @@ -118,7 +119,7 @@ for A in ${ARCHES[@]}; do echo "==> Processing new/updated packages for repository '$reponame'..." >&2 cd "$WORKDIR" - /usr/bin/svn checkout -N $SVN_PATH checkout + /usr/bin/svn checkout -N $svnpath checkout cd checkout for pkg in $ADDPKGS; do diff --git a/testing2x b/testing2x index 6a3a70e..0314738 100755 --- a/testing2x +++ b/testing2x @@ -13,6 +13,7 @@ case "$0" in ;; esac WORKDIR="$TMPDIR/testing2x.$UID" +svnpath="$(get_svnpath testing)" cleanup() { trap '' 0 2 @@ -30,7 +31,7 @@ trap cleanup 0 /bin/mkdir "${WORKDIR}" cd "${WORKDIR}" -/usr/bin/svn checkout -N $SVN_PATH checkout +/usr/bin/svn checkout -N $svnpath checkout cd checkout for pkg in $*; do -- cgit v1.2.3-54-g00ecf From 67e112955482397bae1971fa60e1634a92ec361c Mon Sep 17 00:00:00 2001 From: Abhishek Dasgupta Date: Fri, 20 Mar 2009 20:56:15 +0530 Subject: 'any' architecture support for db-move, db-remove Also: changed empty variable '$ftpdir' in db-remove to '$ftppath/$architecture' --- db-move | 54 ++++++++++++++++++++++++++++++++++-------------------- db-remove | 36 ++++++++++++++++++++++-------------- 2 files changed, 56 insertions(+), 34 deletions(-) (limited to 'db-move') diff --git a/db-move b/db-move index e4f2fef..0759ba2 100755 --- a/db-move +++ b/db-move @@ -17,8 +17,8 @@ _arch="$4" export CARCH="$_arch" -ftppath_from="$FTP_BASE/$repofrom/os/$_arch/" -ftppath_to="$FTP_BASE/$repoto/os/$_arch/" +ftppath_from="$FTP_BASE/$repofrom/os/" +ftppath_to="$FTP_BASE/$repoto/os/" svnrepo_from="$repofrom-$_arch" svnrepo_to="$repoto-$_arch" svnpath="$(get_svnpath $repoto)" @@ -67,7 +67,7 @@ if [ -d "$packagename/repos/$svnrepo_from" ]; then . "$packagename/repos/$svnrepo_from/$BUILDSCRIPT" _pkgfile="$pkgname-$pkgver-$pkgrel-$_arch$PKGEXT" - if [ ! -f "$ftppath_from/$_pkgfile" ]; then + if [ ! -f "$ftppath_from/${_arch}/$_pkgfile" ]; then die "error: package file '$_pkgfile' not found in repo '$repofrom'" fi @@ -86,23 +86,37 @@ if [ -d "$packagename/repos/$svnrepo_from" ]; then [ -d build/ ] || mkdir build cd build/ - # copy the db file into our working area - if [ -f "$ftppath_from/$repofrom.db.tar.$DB_COMPRESSION" ]; then - /bin/cp "$ftppath_from/$repofrom.db.tar.$DB_COMPRESSION" . - /usr/bin/repo-remove -q "$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" - fi - - if [ -f "$ftppath_to/$repoto.db.tar.$DB_COMPRESSION" ]; then - /bin/cp "$ftppath_to/$repoto.db.tar.$DB_COMPRESSION" . - fi - - /bin/cp "$ftppath_from/$_pkgfile" . - /usr/bin/repo-add -q "$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 + if [ "${_arch}" == "any" ]; then + arches="i686 x86_64" + else + arches="${_arch}" + fi + + for architecture in $arches; do + # copy the db file into our working area + if [ -f "$ftppath_from/$architecture/$repofrom.db.tar.$DB_COMPRESSION" ]; then + /bin/cp "$ftppath_from/$architecture/$repofrom.db.tar.$DB_COMPRESSION" . + /usr/bin/repo-remove -q "$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/$architecture" + echo " Package files will be cleaned up automatically" + fi + + if [ -f "$ftppath_to/$architecture/$repoto.db.tar.$DB_COMPRESSION" ]; then + /bin/cp "$ftppath_to/$architecture/$repoto.db.tar.$DB_COMPRESSION" . + fi + + /bin/cp "$ftppath_from/$architecture/$_pkgfile" . + /usr/bin/repo-add -q "$repoto.db.tar.$DB_COMPRESSION" $_pkgfile || die "Error in repo-add" + #use '*' to move the old DB too + mv $repoto.db.tar.$DB_COMPRESSION* $ftppath_to/$architecture + if [ "${_arch}" == "any" ]; then + mv ${_pkgfile} $ftppath_to/any + ln -s $ftppath_to/any/${_pkgfile} $ftppath_to/$architecture/ + else + mv ${_pkgfile} $ftppath_to/$architecture + fi + done else die "Error: $packagename is not in repo $repofrom" fi diff --git a/db-remove b/db-remove index 501c70a..4763f3d 100755 --- a/db-remove +++ b/db-remove @@ -15,7 +15,7 @@ arch="$3" export CARCH="$arch" -ftppath="$FTP_BASE/$reponame/os/$arch/" +ftppath="$FTP_BASE/$reponame/os" svnrepo="$reponame-$arch" svnpath="$(get_svnpath $reponame)" @@ -65,21 +65,29 @@ fi cd "$WORKDIR" [ -d build/ ] || mkdir build -# copy the db file into our working area -if [ -f "$ftppath/$reponame.db.tar.$DB_COMPRESSION" ]; then - /bin/cp "$ftppath/$reponame.db.tar.$DB_COMPRESSION" build/ +if [ "$arch" == "any" ]; then + arches="i686 x86_64" else - echo "No database found at '$ftpdir', nothing more to do" - exit 0 + arches="$arch" fi -echo " Removing from $reponame DB file" -cd build/ -/usr/bin/repo-remove -q "$reponame.db.tar.$DB_COMPRESSION" $packagename - -/bin/cp "$reponame.db.tar.$DB_COMPRESSION" "$ftppath/" - -echo "Package files will be cleaned up automatically" - +# copy the db file into our working area +for architecture in $arches; do + if [ -f "$ftppath/$architecture/$reponame.db.tar.$DB_COMPRESSION" ]; then + /bin/cp "$ftppath/$architecture/$reponame.db.tar.$DB_COMPRESSION" build/ + else + echo "No database found at '$ftppath/$architecture', nothing more to do" + exit 0 + fi + + echo " Removing from $reponame DB file ($architecture)" + cd build/ + /usr/bin/repo-remove -q "$reponame.db.tar.$DB_COMPRESSION" $packagename + + /bin/mv "$reponame.db.tar.$DB_COMPRESSION" "$ftppath/$architecture" + + echo "Package files will be cleaned up automatically" + cd .. +done cleanup # vim: set ts=4 sw=4 noet ft=sh: -- cgit v1.2.3-54-g00ecf From 277fc975d2f9f6e6e1142af8dd38b3d3af53e903 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 9 Jul 2009 16:56:39 +0200 Subject: fix syntax error Signed-off-by: Aaron Griffin --- db-move | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db-move') diff --git a/db-move b/db-move index 0759ba2..0cc8aa4 100755 --- a/db-move +++ b/db-move @@ -22,7 +22,7 @@ ftppath_to="$FTP_BASE/$repoto/os/" svnrepo_from="$repofrom-$_arch" svnrepo_to="$repoto-$_arch" svnpath="$(get_svnpath $repoto)" -if [ "$svnpath" != "$(get_svnpath $repofrom" ]; then +if [ "$svnpath" != "$(get_svnpath $repofrom)" ]; then echo "ERROR: Cannot move packages across SVN repos" echo " A move must be within the same svn repo" fi -- cgit v1.2.3-54-g00ecf From 798a2cb73ce68ecb1068be1f5a6e93d54150f0c4 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Mon, 20 Jul 2009 19:16:53 -0400 Subject: any support: use relative symlinks Signed-off-by: Aaron Griffin --- db-move | 2 +- db-update | 2 +- misc-scripts/ftpdir-cleanup | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'db-move') diff --git a/db-move b/db-move index 0cc8aa4..8200810 100755 --- a/db-move +++ b/db-move @@ -112,7 +112,7 @@ if [ -d "$packagename/repos/$svnrepo_from" ]; then mv $repoto.db.tar.$DB_COMPRESSION* $ftppath_to/$architecture if [ "${_arch}" == "any" ]; then mv ${_pkgfile} $ftppath_to/any - ln -s $ftppath_to/any/${_pkgfile} $ftppath_to/$architecture/ + ln -s ../any/${_pkgfile} $ftppath_to/$architecture/ else mv ${_pkgfile} $ftppath_to/$architecture fi diff --git a/db-update b/db-update index 9d9f7eb..1c6739a 100755 --- a/db-update +++ b/db-update @@ -209,7 +209,7 @@ for current_arch in ${ARCHES[@]}; do die "error: failure while copying files to $ftppath_any" fi bf=$(basename $f) - if ! ln -s "$ftppath_any/$bf" "$ftppath/$bf"; then + if ! ln -s "../any/$bf" "$ftppath/$bf"; then die "error: failed to make link for $bf." fi done diff --git a/misc-scripts/ftpdir-cleanup b/misc-scripts/ftpdir-cleanup index ca411cf..e319b99 100755 --- a/misc-scripts/ftpdir-cleanup +++ b/misc-scripts/ftpdir-cleanup @@ -107,7 +107,7 @@ for mf in $missfiles; do af_satisfied=0 if [ -e "${ftppath_base}/any/${mf}" ]; then echo "Restoring missing 'any' symlink: ${mf}" - ln -s "${ftppath_base}/any/${mf}" "${ftppath}" + ln -s "../any/${mf}" "${ftppath}" else MISSINGFILES="${MISSINGFILES} ${mf}" fi -- cgit v1.2.3-54-g00ecf From f387616777b879a0dfbe801fb609763f72fa0414 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Tue, 21 Jul 2009 18:56:13 +0200 Subject: Add support for split packages to db-move All split packages are treated as unit and can only be moved together. For split packages the pkgbase value has to be used to find the corresponding entry in the svn repository. Note: different architecures (e.g. any) is not supported by makepkg. Signed-off-by: Aaron Griffin --- db-move | 60 ++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 24 deletions(-) (limited to 'db-move') diff --git a/db-move b/db-move index 8200810..be46dc8 100755 --- a/db-move +++ b/db-move @@ -1,8 +1,7 @@ #!/bin/bash -# Originally from Pierre's testing2extra script if [ $# -ne 4 ]; then - echo "usage: $(basename $0) " + echo "usage: $(basename $0) " exit 1 fi @@ -10,7 +9,7 @@ fi source_makepkg -packagename="$1" +packagebase="$1" repofrom="$2" repoto="$3" _arch="$4" @@ -62,24 +61,26 @@ 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-$_arch$PKGEXT" - - if [ ! -f "$ftppath_from/${_arch}/$_pkgfile" ]; then - die "error: package file '$_pkgfile' not found in repo '$repofrom'" - fi - - if [ -d "$packagename/repos/$svnrepo_to" ]; then +/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" + if [ ! -f "$ftppath_from/${_arch}/$_pkgfile" ]; then + die "error: package file '$_pkgfile' not found in repo '$repofrom'" + fi + done + + if [ -d "$packagebase/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" + /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 "$packagename/repos/$svnrepo_from" "$packagename/repos/$svnrepo_to" - /usr/bin/svn commit -m "$(basename $0): moved $packagename from [$repofrom] to [$repoto] ($_arch)" + /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" @@ -96,7 +97,9 @@ if [ -d "$packagename/repos/$svnrepo_from" ]; then # copy the db file into our working area if [ -f "$ftppath_from/$architecture/$repofrom.db.tar.$DB_COMPRESSION" ]; then /bin/cp "$ftppath_from/$architecture/$repofrom.db.tar.$DB_COMPRESSION" . - /usr/bin/repo-remove -q "$repofrom.db.tar.$DB_COMPRESSION" $packagename || die "Error in repo-remove" + for i in ${pkgname[@]}; do + /usr/bin/repo-remove -q "$repofrom.db.tar.$DB_COMPRESSION" $i || die "Error in repo-remove $i" + done #use '*' to move the old DB too mv $repofrom.db.tar.$DB_COMPRESSION* "$ftppath_from/$architecture" echo " Package files will be cleaned up automatically" @@ -106,19 +109,28 @@ if [ -d "$packagename/repos/$svnrepo_from" ]; then /bin/cp "$ftppath_to/$architecture/$repoto.db.tar.$DB_COMPRESSION" . fi - /bin/cp "$ftppath_from/$architecture/$_pkgfile" . - /usr/bin/repo-add -q "$repoto.db.tar.$DB_COMPRESSION" $_pkgfile || die "Error in repo-add" + for i in ${pkgname[@]}; do + _pkgfile="$i-$pkgver-$pkgrel-$_arch$PKGEXT" + /bin/cp "$ftppath_from/$architecture/$_pkgfile" . + /usr/bin/repo-add -q "$repoto.db.tar.$DB_COMPRESSION" $_pkgfile || die "Error in repo-add $_pkgfile" + done #use '*' to move the old DB too mv $repoto.db.tar.$DB_COMPRESSION* $ftppath_to/$architecture if [ "${_arch}" == "any" ]; then - mv ${_pkgfile} $ftppath_to/any - ln -s ../any/${_pkgfile} $ftppath_to/$architecture/ + for i in ${pkgname[@]}; do + _pkgfile="$i-$pkgver-$pkgrel-$_arch$PKGEXT" + mv ${_pkgfile} $ftppath_to/any + ln -s ../any/${_pkgfile} $ftppath_to/$architecture/ + done else - mv ${_pkgfile} $ftppath_to/$architecture + for i in ${pkgname[@]}; do + _pkgfile="$i-$pkgver-$pkgrel-$_arch$PKGEXT" + mv ${_pkgfile} $ftppath_to/$architecture + done fi done else - die "Error: $packagename is not in repo $repofrom" + die "Error: $packagebase is not in repo $repofrom" fi cleanup -- cgit v1.2.3-54-g00ecf From 8df23b9ed44bfffbf84522d4e49b81edb4a72b41 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Tue, 21 Jul 2009 12:53:39 -0700 Subject: db-move: reduce usage of loops Signed-off-by: Aaron Griffin --- db-move | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'db-move') diff --git a/db-move b/db-move index be46dc8..4dbec07 100755 --- a/db-move +++ b/db-move @@ -97,9 +97,7 @@ if [ -d "$packagebase/repos/$svnrepo_from" ]; then # copy the db file into our working area if [ -f "$ftppath_from/$architecture/$repofrom.db.tar.$DB_COMPRESSION" ]; then /bin/cp "$ftppath_from/$architecture/$repofrom.db.tar.$DB_COMPRESSION" . - for i in ${pkgname[@]}; do - /usr/bin/repo-remove -q "$repofrom.db.tar.$DB_COMPRESSION" $i || die "Error in repo-remove $i" - done + /usr/bin/repo-remove -q "$repofrom.db.tar.$DB_COMPRESSION" ${pkgname[@]} || die "Error in repo-remove" #use '*' to move the old DB too mv $repofrom.db.tar.$DB_COMPRESSION* "$ftppath_from/$architecture" echo " Package files will be cleaned up automatically" @@ -116,18 +114,15 @@ if [ -d "$packagebase/repos/$svnrepo_from" ]; then done #use '*' to move the old DB too mv $repoto.db.tar.$DB_COMPRESSION* $ftppath_to/$architecture - if [ "${_arch}" == "any" ]; then - for i in ${pkgname[@]}; do - _pkgfile="$i-$pkgver-$pkgrel-$_arch$PKGEXT" - mv ${_pkgfile} $ftppath_to/any - ln -s ../any/${_pkgfile} $ftppath_to/$architecture/ - done - else - for i in ${pkgname[@]}; do - _pkgfile="$i-$pkgver-$pkgrel-$_arch$PKGEXT" - mv ${_pkgfile} $ftppath_to/$architecture - done - fi + for i in ${pkgname[@]}; do + _pkgfile="$i-$pkgver-$pkgrel-$_arch$PKGEXT" + 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 else die "Error: $packagebase is not in repo $repofrom" -- cgit v1.2.3-54-g00ecf From 94c1ba6eed3fbdda8be0b7c67257d30dcabfd5c6 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 22 Jul 2009 20:02:37 +0200 Subject: remove support for different svn repos Signed-off-by: Aaron Griffin --- config | 5 +---- db-functions | 14 -------------- db-move | 7 +------ db-remove | 3 +-- db-update | 6 ++---- testing2x | 3 +-- 6 files changed, 6 insertions(+), 32 deletions(-) (limited to 'db-move') diff --git a/config b/config index 16a71ce..a8748c7 100644 --- a/config +++ b/config @@ -2,10 +2,7 @@ FTP_BASE="/srv/ftp" FTP_OS_SUFFIX="os" -SVNREPO_core="file:///srv/svn-packages" -SVNREPO_extra="file:///srv/svn-packages" -SVNREPO_testing="file:///srv/svn-packages" -SVNREPO_community="file:///srv/svn-community" +SVNREPO="file:///srv/svn-packages" CLEANUP_DESTDIR="/srv/package-cleanup" diff --git a/db-functions b/db-functions index d183373..bbb6abc 100644 --- a/db-functions +++ b/db-functions @@ -119,19 +119,5 @@ check_pkg_arch () { #check_pkg_arch pkgfile arch fi } -get_svnpath () { #get_svnpath reponame - local var - local repopath - var="\$SVNREPO_${1}" - - eval repopath=${var} - if [ -z "$repopath" ]; then - echo "ERROR: SVN path not defined for '${1}'" >&2 - echo " Please check SVNREPO_${1} config setting" >&2 - fi - - echo "$repopath" -} - # vim: set ts=4 sw=4 noet ft=sh: diff --git a/db-move b/db-move index 4dbec07..e3897e3 100755 --- a/db-move +++ b/db-move @@ -20,11 +20,6 @@ ftppath_from="$FTP_BASE/$repofrom/os/" ftppath_to="$FTP_BASE/$repoto/os/" svnrepo_from="$repofrom-$_arch" svnrepo_to="$repoto-$_arch" -svnpath="$(get_svnpath $repoto)" -if [ "$svnpath" != "$(get_svnpath $repofrom)" ]; then - echo "ERROR: Cannot move packages across SVN repos" - echo " A move must be within the same svn repo" -fi [ "$UID" = "" ] && UID=$(uid) @@ -58,7 +53,7 @@ repo_lock $repofrom $_arch /bin/mkdir -p "$WORKDIR" cd "$WORKDIR" -/usr/bin/svn checkout -N $svnpath checkout +/usr/bin/svn checkout -N $SVNREPO checkout cd checkout /usr/bin/svn up -q $packagebase diff --git a/db-remove b/db-remove index 621154d..bbf8044 100755 --- a/db-remove +++ b/db-remove @@ -17,7 +17,6 @@ export CARCH="$arch" ftppath="$FTP_BASE/$reponame/os" svnrepo="$reponame-$arch" -svnpath="$(get_svnpath $reponame)" [ "$UID" = "" ] && UID=$(uid) @@ -52,7 +51,7 @@ repo_lock $reponame $arch echo "==> Removing package '$packagebase' from '$reponame'..." >&2 cd "$WORKDIR" -/usr/bin/svn checkout -N $svnpath checkout +/usr/bin/svn checkout -N $SVNREPO checkout cd checkout /usr/bin/svn up -q $packagebase diff --git a/db-update b/db-update index ade7a39..939fe56 100755 --- a/db-update +++ b/db-update @@ -76,8 +76,7 @@ if [ -n "$ANYPKGS" ]; then pkgtotal=$(echo "$ANYPKGS" | wc -w) echo "==> Processing $pkgtotal new/updated arch-independent packages for '$reponame'..." >&2 - svnpath="$(get_svnpath $reponame)" - /usr/bin/svn checkout -N $svnpath checkout + /usr/bin/svn checkout -N $SVNREPO checkout cd checkout to_add_any="" for pkg in $ANYPKGS; do @@ -117,7 +116,6 @@ for current_arch in ${ARCHES[@]}; do exit 1 fi - svnpath="$(get_svnpath $reponame)" svnrepo="$reponame-$current_arch" repo_lock $reponame $current_arch @@ -148,7 +146,7 @@ for current_arch in ${ARCHES[@]}; do echo "==> Processing $pkgtotal new/updated packages for repository '$reponame'..." >&2 cd "$WORKDIR" - /usr/bin/svn checkout -N $svnpath checkout + /usr/bin/svn checkout -N $SVNREPO checkout cd checkout if [ -n "$ADDPKGS" ]; then diff --git a/testing2x b/testing2x index 0314738..e116297 100755 --- a/testing2x +++ b/testing2x @@ -13,7 +13,6 @@ case "$0" in ;; esac WORKDIR="$TMPDIR/testing2x.$UID" -svnpath="$(get_svnpath testing)" cleanup() { trap '' 0 2 @@ -31,7 +30,7 @@ trap cleanup 0 /bin/mkdir "${WORKDIR}" cd "${WORKDIR}" -/usr/bin/svn checkout -N $svnpath checkout +/usr/bin/svn checkout -N $SVNREPO checkout cd checkout for pkg in $*; do -- cgit v1.2.3-54-g00ecf From 1d94c827c8e9efe6e56bc15f993a1ce3764a675a Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 16 Aug 2009 09:04:21 -0500 Subject: Add DB_COMPRESSION var to all scripts that need it Signed-off-by: Dan McGee --- cron-jobs/createFileLists | 1 + db-move | 1 + db-remove | 1 + db-update | 1 + 4 files changed, 4 insertions(+) (limited to 'db-move') diff --git a/cron-jobs/createFileLists b/cron-jobs/createFileLists index 61cbc21..2e42e56 100755 --- a/cron-jobs/createFileLists +++ b/cron-jobs/createFileLists @@ -3,6 +3,7 @@ reposdir=/srv/ftp/ targetdir=$reposdir repos="core extra testing community" +DB_COMPRESSION="gz" . $(dirname $0)/../config diff --git a/db-move b/db-move index e3897e3..1b07091 100755 --- a/db-move +++ b/db-move @@ -13,6 +13,7 @@ packagebase="$1" repofrom="$2" repoto="$3" _arch="$4" +DB_COMPRESSION='gz' export CARCH="$_arch" diff --git a/db-remove b/db-remove index bbf8044..b246a8f 100755 --- a/db-remove +++ b/db-remove @@ -12,6 +12,7 @@ source_makepkg packagebase="$1" reponame="$2" arch="$3" +DB_COMPRESSION='gz' export CARCH="$arch" diff --git a/db-update b/db-update index 939fe56..8e7a0c7 100755 --- a/db-update +++ b/db-update @@ -11,6 +11,7 @@ source_makepkg reponame="$1" current_arch="" +DB_COMPRESSION='gz' [ "$UID" = "" ] && UID=$(uid) -- cgit v1.2.3-54-g00ecf From b82a2ec63574c5fe0a0dd49b242d8c365155b828 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Mon, 17 Aug 2009 15:12:33 -0700 Subject: Replace DB_COMPRESSION with DBEXT in the config DBEXT contains the full extension for the db files (.db.tar.gz) and is recorded in the config file Signed-off-by: Aaron Griffin --- config | 1 + db-move | 17 ++++++++--------- db-remove | 9 ++++----- db-update | 13 ++++++------- 4 files changed, 19 insertions(+), 21 deletions(-) (limited to 'db-move') diff --git a/config b/config index a8748c7..873c2f3 100644 --- a/config +++ b/config @@ -11,3 +11,4 @@ TMPDIR="/srv/tmp" ARCHES=(i686 x86_64) # To be used if $BUILDSCRIPT is removed from makepkg.conf #BUILDSCRIPT="PKGBUILD" +DBEXT=".db.tar.gz" diff --git a/db-move b/db-move index 1b07091..e1a50bd 100755 --- a/db-move +++ b/db-move @@ -13,7 +13,6 @@ packagebase="$1" repofrom="$2" repoto="$3" _arch="$4" -DB_COMPRESSION='gz' export CARCH="$_arch" @@ -91,25 +90,25 @@ if [ -d "$packagebase/repos/$svnrepo_from" ]; then for architecture in $arches; do # copy the db file into our working area - if [ -f "$ftppath_from/$architecture/$repofrom.db.tar.$DB_COMPRESSION" ]; then - /bin/cp "$ftppath_from/$architecture/$repofrom.db.tar.$DB_COMPRESSION" . - /usr/bin/repo-remove -q "$repofrom.db.tar.$DB_COMPRESSION" ${pkgname[@]} || die "Error in repo-remove" + 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.db.tar.$DB_COMPRESSION* "$ftppath_from/$architecture" + mv $repofrom$DBEXT"$ftppath_from/$architecture" echo " Package files will be cleaned up automatically" fi - if [ -f "$ftppath_to/$architecture/$repoto.db.tar.$DB_COMPRESSION" ]; then - /bin/cp "$ftppath_to/$architecture/$repoto.db.tar.$DB_COMPRESSION" . + 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" /bin/cp "$ftppath_from/$architecture/$_pkgfile" . - /usr/bin/repo-add -q "$repoto.db.tar.$DB_COMPRESSION" $_pkgfile || die "Error in repo-add $_pkgfile" + /usr/bin/repo-add -q "$repoto$DBEXT" $_pkgfile || die "Error in repo-add $_pkgfile" done #use '*' to move the old DB too - mv $repoto.db.tar.$DB_COMPRESSION* $ftppath_to/$architecture + mv $repoto$DBEXT* $ftppath_to/$architecture for i in ${pkgname[@]}; do _pkgfile="$i-$pkgver-$pkgrel-$_arch$PKGEXT" if [ "${_arch}" == "any" ]; then diff --git a/db-remove b/db-remove index b246a8f..b4151c7 100755 --- a/db-remove +++ b/db-remove @@ -12,7 +12,6 @@ source_makepkg packagebase="$1" reponame="$2" arch="$3" -DB_COMPRESSION='gz' export CARCH="$arch" @@ -79,8 +78,8 @@ fi # copy the db file into our working area for architecture in $arches; do - if [ -f "$ftppath/$architecture/$reponame.db.tar.$DB_COMPRESSION" ]; then - /bin/cp "$ftppath/$architecture/$reponame.db.tar.$DB_COMPRESSION" build/ + if [ -f "$ftppath/$architecture/$reponame$DBEXT" ]; then + /bin/cp "$ftppath/$architecture/$reponame$DBEXT" build/ else echo "No database found at '$ftppath/$architecture', nothing more to do" exit 0 @@ -88,9 +87,9 @@ for architecture in $arches; do echo " Removing from $reponame DB file ($architecture)" cd build/ - /usr/bin/repo-remove -q "$reponame.db.tar.$DB_COMPRESSION" ${pkgname[@]} + /usr/bin/repo-remove -q "$reponame$DBEXT" ${pkgname[@]} - /bin/mv "$reponame.db.tar.$DB_COMPRESSION" "$ftppath/$architecture" + /bin/mv "$reponame$DBEXT" "$ftppath/$architecture" echo "Package files will be cleaned up automatically" cd .. diff --git a/db-update b/db-update index 8e7a0c7..05236fe 100755 --- a/db-update +++ b/db-update @@ -11,7 +11,6 @@ source_makepkg reponame="$1" current_arch="" -DB_COMPRESSION='gz' [ "$UID" = "" ] && UID=$(uid) @@ -125,8 +124,8 @@ for current_arch in ${ARCHES[@]}; do cd "$WORKDIR" # copy the db file into our working area - if [ -f "$ftppath/$reponame.db.tar.$DB_COMPRESSION" ]; then - /bin/cp "$ftppath/$reponame.db.tar.$DB_COMPRESSION" build/ + if [ -f "$ftppath/$reponame$DBEXT" ]; then + /bin/cp "$ftppath/$reponame$DBEXT" build/ fi echo "Updating DB for $svnrepo" @@ -139,8 +138,8 @@ for current_arch in ${ARCHES[@]}; do if [ -n "$ADDPKGS" -o -n "$ANYPKGS" ]; then echo "==> Copying DB file from '$reponame'..." >&2 - if [ -f "$ftppath/$reponame.db.tar.$DB_COMPRESSION" ]; then - /bin/cp "$ftppath/$reponame.db.tar.$DB_COMPRESSION" build/ + if [ -f "$ftppath/$reponame$DBEXT" ]; then + /bin/cp "$ftppath/$reponame$DBEXT" build/ fi pkgtotal=$(echo "$ADDPKGS $ANYPKGS" | wc -w) @@ -183,9 +182,9 @@ for current_arch in ${ARCHES[@]}; do pkgs="" for pkg in $to_add $to_add_any; do pkgs="$pkgs $(basename $pkg)"; done - /usr/bin/repo-add -q "$reponame.db.tar.$DB_COMPRESSION" $pkgs + /usr/bin/repo-add -q "$reponame$DBEXT" $pkgs else - rm -f "build/$reponame.db.tar.$DB_COMPRESSION" + rm -f "build/$reponame$DBEXT" echo "Errors found when adding packages" fi else -- cgit v1.2.3-54-g00ecf From 15de56aa8bb8104a01a983393f8a398348714a3a Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Mon, 17 Aug 2009 15:20:27 -0700 Subject: Remove dependence on makepkg.conf Removed the need for makepkg.conf * Killed off CARCH * Added PKGEXT to the config file * Remove source_makepkg function * Source config file where makepkg.conf was needed Signed-off-by: Aaron Griffin --- config | 1 + convert-to-any | 7 +------ db-functions | 9 --------- db-move | 4 ---- db-remove | 4 ---- db-update | 2 -- testing2x | 2 -- 7 files changed, 2 insertions(+), 27 deletions(-) (limited to 'db-move') diff --git a/config b/config index 66ef7e8..c735a91 100644 --- a/config +++ b/config @@ -11,3 +11,4 @@ TMPDIR="/srv/tmp" ARCHES=(i686 x86_64) BUILDSCRIPT="PKGBUILD" DBEXT=".db.tar.gz" +PKGEXT=".pkg.tar.gz" diff --git a/convert-to-any b/convert-to-any index 2ad1521..e21b7cd 100755 --- a/convert-to-any +++ b/convert-to-any @@ -15,12 +15,7 @@ if [ $# -ne 1 ]; then exit 1 fi -if [ -f /etc/makepkg.conf ]; then - . /etc/makepkg.conf -else - echo "E: /etc/makepkg.conf does not exist." - exit 1 -fi +. "$(dirname $0)/db-functions" cleanup() { trap '' 0 2 diff --git a/db-functions b/db-functions index bbb6abc..ccab830 100644 --- a/db-functions +++ b/db-functions @@ -12,15 +12,6 @@ if [ -f "$BASEDIR/config" ]; then fi # Useful functions -source_makepkg () { - if [ -f "/etc/makepkg.conf" ]; then - #Get some config info - . /etc/makepkg.conf - else - echo "error: /etc/makepkg.conf does not exist!" - exit 1 - fi -} UMASK="" set_umask () { diff --git a/db-move b/db-move index e1a50bd..de81e85 100755 --- a/db-move +++ b/db-move @@ -7,15 +7,11 @@ fi . "$(dirname $0)/db-functions" -source_makepkg - packagebase="$1" repofrom="$2" repoto="$3" _arch="$4" -export CARCH="$_arch" - ftppath_from="$FTP_BASE/$repofrom/os/" ftppath_to="$FTP_BASE/$repoto/os/" svnrepo_from="$repofrom-$_arch" diff --git a/db-remove b/db-remove index b4151c7..eae204e 100755 --- a/db-remove +++ b/db-remove @@ -7,14 +7,10 @@ fi . "$(dirname $0)/db-functions" -source_makepkg - packagebase="$1" reponame="$2" arch="$3" -export CARCH="$arch" - ftppath="$FTP_BASE/$reponame/os" svnrepo="$reponame-$arch" diff --git a/db-update b/db-update index 05236fe..7ff48ba 100755 --- a/db-update +++ b/db-update @@ -7,8 +7,6 @@ fi . "$(dirname $0)/db-functions" -source_makepkg - reponame="$1" current_arch="" diff --git a/testing2x b/testing2x index e116297..f3b256b 100755 --- a/testing2x +++ b/testing2x @@ -2,8 +2,6 @@ . "$(dirname $0)/db-functions" -source_makepkg - case "$0" in *64) _arch="x86_64" -- cgit v1.2.3-54-g00ecf From fa9fe91849e46ea50cd32cc55539a4f0833eb642 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Mon, 17 Aug 2009 15:26:02 -0700 Subject: Fix an error in db-move due to DBEXT commit Signed-off-by: Aaron Griffin --- db-move | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db-move') diff --git a/db-move b/db-move index de81e85..b49aeda 100755 --- a/db-move +++ b/db-move @@ -90,7 +90,7 @@ if [ -d "$packagebase/repos/$svnrepo_from" ]; 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" + mv $repofrom$DBEXT* "$ftppath_from/$architecture" echo " Package files will be cleaned up automatically" fi -- cgit v1.2.3-54-g00ecf From 2afa1063284a25ae2691b2727c45238d15025a9a Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 13 Sep 2009 18:16:55 -0500 Subject: Be more careful with config file inclusion We can't really do the basedir magic from db-functions as it is just being sourced and is not the currently executing script. Although a bit repetitive, it is a lot safer to just include the config file everywhere. Noticed this when trying to run the latest available scripts on sigurd. Signed-off-by: Dan McGee --- convert-to-any | 1 + cron-jobs/createFileLists | 1 + cron-jobs/sourceballs | 1 + db-functions | 8 -------- db-move | 1 + db-remove | 1 + db-update | 1 + misc-scripts/ftpdir-cleanup | 1 + misc-scripts/make-sourceball | 1 + testing2x | 1 + 10 files changed, 9 insertions(+), 8 deletions(-) (limited to 'db-move') diff --git a/convert-to-any b/convert-to-any index e21b7cd..53d1a7b 100755 --- a/convert-to-any +++ b/convert-to-any @@ -16,6 +16,7 @@ if [ $# -ne 1 ]; then fi . "$(dirname $0)/db-functions" +. "$(dirname $0)/config" cleanup() { trap '' 0 2 diff --git a/cron-jobs/createFileLists b/cron-jobs/createFileLists index 345f9aa..d936853 100755 --- a/cron-jobs/createFileLists +++ b/cron-jobs/createFileLists @@ -5,6 +5,7 @@ targetdir=$reposdir repos="core extra testing community" . "$(dirname $0)/../db-functions" +. "$(dirname $0)/../config" if [ -f "/tmp/createFileList.lock" ]; then echo "Error: createFileList allready in progress." diff --git a/cron-jobs/sourceballs b/cron-jobs/sourceballs index aa06aff..46c2fa3 100755 --- a/cron-jobs/sourceballs +++ b/cron-jobs/sourceballs @@ -5,6 +5,7 @@ srcbase="/srv/ftp/sources" repos="core extra testing community" . "$(dirname $0)/../db-functions" +. "$(dirname $0)/../config" LOCKFILE="/tmp/.sourceball.lock" diff --git a/db-functions b/db-functions index ccab830..071fb85 100644 --- a/db-functions +++ b/db-functions @@ -3,14 +3,6 @@ # Random integrity things [ "$UID" = "" ] && UID=$(uid) -if [ -z "$BASEDIR" ]; then - BASEDIR="$(dirname $0)" -fi - -if [ -f "$BASEDIR/config" ]; then - . "$BASEDIR/config" -fi - # Useful functions UMASK="" diff --git a/db-move b/db-move index b49aeda..efd54e0 100755 --- a/db-move +++ b/db-move @@ -6,6 +6,7 @@ if [ $# -ne 4 ]; then fi . "$(dirname $0)/db-functions" +. "$(dirname $0)/config" packagebase="$1" repofrom="$2" diff --git a/db-remove b/db-remove index 3ba7dd7..3190231 100755 --- a/db-remove +++ b/db-remove @@ -6,6 +6,7 @@ if [ $# -ne 3 ]; then fi . "$(dirname $0)/db-functions" +. "$(dirname $0)/config" packagebase="$1" reponame="$2" diff --git a/db-update b/db-update index 7ff48ba..577a028 100755 --- a/db-update +++ b/db-update @@ -6,6 +6,7 @@ if [ $# -ne 1 ]; then fi . "$(dirname $0)/db-functions" +. "$(dirname $0)/config" reponame="$1" current_arch="" diff --git a/misc-scripts/ftpdir-cleanup b/misc-scripts/ftpdir-cleanup index 96407c0..9349bca 100755 --- a/misc-scripts/ftpdir-cleanup +++ b/misc-scripts/ftpdir-cleanup @@ -11,6 +11,7 @@ dest=$2 ############################################################ . "$(dirname $0)/../db-functions" +. "$(dirname $0)/../config" getpkgname() { local tmp diff --git a/misc-scripts/make-sourceball b/misc-scripts/make-sourceball index 9f565f7..f2d8415 100755 --- a/misc-scripts/make-sourceball +++ b/misc-scripts/make-sourceball @@ -10,6 +10,7 @@ if [ $# -ne 3 -a $# -ne 4 ]; then fi . "$(dirname $0)/../db-functions" +. "$(dirname $0)/../config" FORCE=0 if [ "$1" = "-f" ]; then diff --git a/testing2x b/testing2x index f3b256b..f9ded9e 100755 --- a/testing2x +++ b/testing2x @@ -1,6 +1,7 @@ #!/bin/bash . "$(dirname $0)/db-functions" +. "$(dirname $0)/config" case "$0" in *64) -- cgit v1.2.3-54-g00ecf From de0c93a652333b242e7ea282110619f25de7be8d Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 21 Feb 2010 16:54:10 +0100 Subject: Accept any *.pkg.tar.* package file name With this patch packages with different compressions are accepted. It is ensured that one cannot have the same package with different compression extensions. The new functions getpkgfile{,s} are used to sanitize globed filenames. Signed-off-by: Pierre Schmitz --- config | 2 +- db-functions | 34 +++++++++++++++++++++++++++++++--- db-move | 11 ++++++----- db-update | 12 ++++++------ 4 files changed, 44 insertions(+), 15 deletions(-) (limited to 'db-move') diff --git a/config b/config index 7864532..8e582d9 100644 --- a/config +++ b/config @@ -13,7 +13,7 @@ TMPDIR="/srv/tmp" ARCHES=(i686 x86_64) BUILDSCRIPT="PKGBUILD" DBEXT=".db.tar.gz" -PKGEXT=".pkg.tar.gz" +PKGEXT=".pkg.tar.*" SRCEXT=".src.tar.gz" # Allowed licenses: get sourceballs only for licenses in this array diff --git a/db-functions b/db-functions index a4cffd7..c27366c 100644 --- a/db-functions +++ b/db-functions @@ -19,12 +19,12 @@ repo_lock () { #repo_lock repo-name arch LOCKFILE="$TMPDIR/.repolock.$1.$2" if [ -f "$LOCKFILE" ]; then owner="$(/usr/bin/stat -c %U $LOCKFILE)" - echo "error: db generation is already in progress (started by $owner)" + echo "error: db generation is already in progress (started by $owner)" >&2 exit 1 else /bin/touch "$LOCKFILE" if [ ! -f "$LOCKFILE" ]; then - echo "error: could not create repo lock... something went wrong!" + echo "error: could not create repo lock... something went wrong!" >&2 fi set_umask fi @@ -33,7 +33,7 @@ repo_lock () { #repo_lock repo-name arch repo_unlock () { #repo_unlock repo-name arch LOCKFILE="$TMPDIR/.repolock.$1.$2" if [ ! -f "$LOCKFILE" ]; then - echo "error: repo lock doesn't exist... something went terribly wrong!" + echo "error: repo lock doesn't exist... something went terribly wrong!" >&2 else rm -f "$LOCKFILE" fi @@ -87,6 +87,34 @@ getpkgver() { echo "$_ver" } +getpkgfile() { + if [[ ${#} -ne 1 ]]; then + echo 'ERROR: No canonical package found!' >&2 + exit 1 + elif [ ! -f "${1}" ]; then + echo "ERROR: Package ${1} not found!" >&2 + exit 1 + fi + + echo ${1} +} + +getpkgfiles() { + if [ ! -z "$(echo ${@%\.*} | sed "s/ /\n/g" | sort | uniq -D)" ]; then + echo 'ERROR: Duplicate packages found!'>&2 + exit 1 + fi + + for f in ${@}; do + if [ ! -f "${f}" ]; then + echo "ERROR: Package ${f} not found!" >&2 + exit 1 + fi + done + + echo ${@} +} + check_pkg_arch () { #check_pkg_arch pkgfile arch local _arch _arch="$(_grep_pkginfo "$1" "^arch")" diff --git a/db-move b/db-move index efd54e0..c5bd32e 100755 --- a/db-move +++ b/db-move @@ -59,9 +59,7 @@ if [ -d "$packagebase/repos/$svnrepo_from" ]; then for i in ${pkgname[@]}; do _pkgfile="$i-$pkgver-$pkgrel-$_arch$PKGEXT" - if [ ! -f "$ftppath_from/${_arch}/$_pkgfile" ]; then - die "error: package file '$_pkgfile' not found in repo '$repofrom'" - fi + getpkgfile "$ftppath_from/${_arch}/"$_pkgfile >/dev/null done if [ -d "$packagebase/repos/$svnrepo_to" ]; then @@ -101,13 +99,16 @@ if [ -d "$packagebase/repos/$svnrepo_from" ]; then for i in ${pkgname[@]}; do _pkgfile="$i-$pkgver-$pkgrel-$_arch$PKGEXT" - /bin/cp "$ftppath_from/$architecture/$_pkgfile" . + _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="$i-$pkgver-$pkgrel-$_arch$PKGEXT" + _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/ diff --git a/db-update b/db-update index 17d3b71..0973bf3 100755 --- a/db-update +++ b/db-update @@ -89,7 +89,7 @@ done # Process architecture-independent packages first. if [ -d "$stagedir" ]; then - ANYPKGS="$(/bin/ls $stagedir/*-any$PKGEXT 2>/dev/null)" + ANYPKGS="$(getpkgfiles $stagedir/*-any$PKGEXT 2>/dev/null)" fi mkdir -p $WORKDIR @@ -115,7 +115,7 @@ if [ -n "$ANYPKGS" ]; then /usr/bin/svn up -q $_pkgbase if [ -d "$_pkgbase/repos/$svnrepo" ]; then . "$_pkgbase/repos/$svnrepo/$BUILDSCRIPT" - if [ "$_pkgfile" = "$_pkgname-$pkgver-$pkgrel-any$PKGEXT" ]; then + if echo "$_pkgfile" | grep -q "$_pkgname-$pkgver-$pkgrel-any"; then to_add_any="$to_add_any $pkg" else echo " WARNING: $_pkgfile does not match $BUILDSCRIPT in $svnrepo" @@ -155,7 +155,7 @@ for current_arch in ${ARCHES[@]}; do to_add="" if [ -d "$stagedir" ]; then - ADDPKGS="$(/bin/ls $stagedir/*-${current_arch}$PKGEXT 2>/dev/null)" + ADDPKGS="$(getpkgfiles $stagedir/*-${current_arch}$PKGEXT 2>/dev/null)" fi if [ -n "$ADDPKGS" -o -n "$ANYPKGS" ]; then @@ -186,7 +186,7 @@ for current_arch in ${ARCHES[@]}; do /usr/bin/svn up -q $_pkgbase if [ -d "$_pkgbase/repos/$svnrepo" ]; then . "$_pkgbase/repos/$svnrepo/$BUILDSCRIPT" - if [ "$_pkgfile" = "$_pkgname-$pkgver-$pkgrel-$current_arch$PKGEXT" ]; then + if echo "$_pkgfile" | grep -q "$_pkgname-$pkgver-$pkgrel-$current_arch"; then to_add="$to_add $pkg" else echo " WARNING: $_pkgfile does not match $BUILDSCRIPT in $svnrepo" @@ -216,7 +216,7 @@ for current_arch in ${ARCHES[@]}; do # if non empty, move all build dirs if [ $(/bin/ls "$WORKDIR/build/" 2>/dev/null | wc -l) != 0 ]; then - if [ $(/bin/ls "$WORKDIR/build/"*-$current_arch$PKGEXT 2>/dev/null | wc -l) != 0 ]; then + if [ $(getpkgfiles "$WORKDIR/build/"*-$current_arch$PKGEXT 2>/dev/null | wc -l) != 0 ]; then echo "Copying new files to '$ftppath'" for f in "$WORKDIR/build/"*-$current_arch$PKGEXT; do if ! /bin/cp "$f" "$ftppath/"; then @@ -224,7 +224,7 @@ for current_arch in ${ARCHES[@]}; do fi done fi - if [ $(/bin/ls "$WORKDIR/build/"*-any$PKGEXT 2>/dev/null | wc -l) != 0 ]; then + if [ $(getpkgfiles "$WORKDIR/build/"*-any$PKGEXT 2>/dev/null | wc -l) != 0 ]; then echo "Copying new files to '$ftppath_any' and symlinking" for f in "$WORKDIR/build/"*-any$PKGEXT; do if ! /bin/cp "$f" "$ftppath_any"; then -- cgit v1.2.3-54-g00ecf From 57987ae42fb58c58e044bfd7d3486010b32bb313 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 31 Mar 2010 23:09:57 +0200 Subject: don't publish *.old files --- cron-jobs/create-filelists | 3 +-- db-move | 6 ++---- db-update | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) (limited to 'db-move') diff --git a/cron-jobs/create-filelists b/cron-jobs/create-filelists index 84867d8..a25fd1a 100755 --- a/cron-jobs/create-filelists +++ b/cron-jobs/create-filelists @@ -88,8 +88,7 @@ for repo in $repos; do pkgdir="${targetdir}/${repodir}" mkdir -p "$pkgdir" cd "${TMPDIR}/${repodir}" - [ -f "${pkgdir}/${FILES_DB_FILE}.old" ] && rm "${pkgdir}/${FILES_DB_FILE}.old" - [ -f "${pkgdir}/${FILES_DB_FILE}" ] && mv "${pkgdir}/${FILES_DB_FILE}" "${pkgdir}/${FILES_DB_FILE}.old" + [ -f "${pkgdir}/${FILES_DB_FILE}" ] && rm "${pkgdir}/${FILES_DB_FILE}" bsdtar --exclude=*${DBEXT//\.db/} -c${TAR_OPT}f "${pkgdir}/${FILES_DB_FILE}" * fi done diff --git a/db-move b/db-move index c5bd32e..ca1b5da 100755 --- a/db-move +++ b/db-move @@ -88,8 +88,7 @@ if [ -d "$packagebase/repos/$svnrepo_from" ]; then 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" + mv $repofrom$DBEXT "$ftppath_from/$architecture" echo " Package files will be cleaned up automatically" fi @@ -104,8 +103,7 @@ if [ -d "$packagebase/repos/$svnrepo_from" ]; then /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 + mv $repoto$DBEXT $ftppath_to/$architecture for i in ${pkgname[@]}; do _pkgfile=$(getpkgfile "$i-$pkgver-$pkgrel-$_arch"$PKGEXT) [ $? -gt 0 ] && die diff --git a/db-update b/db-update index 0973bf3..82d2e25 100755 --- a/db-update +++ b/db-update @@ -236,7 +236,7 @@ for current_arch in ${ARCHES[@]}; do fi done fi - if ! /bin/cp "$WORKDIR/build/$reponame.db"* "$ftppath/"; then + if ! /bin/cp "$WORKDIR/build/$reponame$DBEXT" "$ftppath/"; then die "failed to move repository $reponame-$current_arch". fi else -- cgit v1.2.3-54-g00ecf From ad520b527f3c5d2471e4b471eca5439643a01939 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 11 Apr 2010 13:52:32 +0200 Subject: Fail if lock couldn't be obtained; Unlock the repos if ftpdir-cleanup fails --- db-functions | 17 ++++++++++++----- db-move | 4 ++-- db-remove | 2 +- db-update | 2 +- misc-scripts/ftpdir-cleanup | 13 ++++++++++++- 5 files changed, 28 insertions(+), 10 deletions(-) (limited to 'db-move') diff --git a/db-functions b/db-functions index d688df6..d0665b0 100644 --- a/db-functions +++ b/db-functions @@ -8,11 +8,12 @@ UMASK="" set_umask () { [ "$UMASK" == "" ] && UMASK="$(umask)" + export UMASK umask 002 } restore_umask () { - umask $UMASK + umask $UMASK >/dev/null } repo_lock () { #repo_lock [timeout] @@ -36,24 +37,30 @@ repo_lock () { #repo_lock [timeout] while [ $_count -le $_trial ] || $_lockblock ; do if ! mkdir "$LOCKDIR" >/dev/null 2>&1 ; then _owner="$(/usr/bin/stat -c %U $LOCKDIR)" - echo "error: Repo $1-$2 is already locked by $_owner. Retrying in $LOCK_DELAY seconds..." >&2 + echo "warning: Repo $1-$2 is already locked by $_owner. Retrying in $LOCK_DELAY seconds..." >&2 else set_umask - break + return 0 fi sleep $LOCK_DELAY let _count=$_count+1 done + + echo "error: Repo $1-$2 is already locked by $_owner. Giving up!" >&2 + return 1 } repo_unlock () { #repo_unlock LOCKDIR="$TMPDIR/.repolock.$1.$2" if [ ! -d "$LOCKDIR" ]; then - echo "error: repo lock doesn't exist... something went terribly wrong!" >&2 + echo "warning: Repo lock $1-$2 was not locked!" >&2 + restore_umask + return 1 else rmdir "$LOCKDIR" + restore_umask + return 0 fi - restore_umask } # usage: _grep_pkginfo pkgfile pattern diff --git a/db-move b/db-move index ca1b5da..ed3df69 100755 --- a/db-move +++ b/db-move @@ -44,8 +44,8 @@ die() { trap ctrl_c 2 trap cleanup 0 -repo_lock $repoto $_arch -repo_lock $repofrom $_arch +repo_lock $repoto $_arch || exit 1 +repo_lock $repofrom $_arch || exit 1 /bin/mkdir -p "$WORKDIR" diff --git a/db-remove b/db-remove index 3190231..0b77fc1 100755 --- a/db-remove +++ b/db-remove @@ -40,7 +40,7 @@ die() { trap ctrl_c 2 trap cleanup 0 -repo_lock $reponame $_arch +repo_lock $reponame $_arch || exit 1 /bin/mkdir -p "$WORKDIR" diff --git a/db-update b/db-update index e4f8020..418c680 100755 --- a/db-update +++ b/db-update @@ -141,7 +141,7 @@ for current_arch in ${ARCHES[@]}; do svnrepo="$reponame-$current_arch" - repo_lock $reponame $current_arch + repo_lock $reponame $current_arch || continue /bin/mkdir -p "$WORKDIR/build" cd "$WORKDIR" diff --git a/misc-scripts/ftpdir-cleanup b/misc-scripts/ftpdir-cleanup index 4c559b9..d5f5737 100755 --- a/misc-scripts/ftpdir-cleanup +++ b/misc-scripts/ftpdir-cleanup @@ -13,13 +13,24 @@ dest=$2 . "$(dirname $0)/../db-functions" . "$(dirname $0)/../config" +cleanup() { + trap '' 2 15 + for arch in ${ARCHES[@]}; do + repo_unlock $reponame $arch + done + exit 1 +} + +trap cleanup 2 +trap cleanup 15 + ${CLEANUP_DRYRUN} && echo 'dry run mode is active' ftppath_base="$FTP_BASE/$reponame/$FTP_OS_SUFFIX" for arch in ${ARCHES[@]}; do - repo_lock $reponame $arch $LOCK_TIMEOUT + repo_lock $reponame $arch $LOCK_TIMEOUT || continue TMPDIR=$(mktemp -d /tmp/cleanup-XXXXXX) || exit 1 ftppath="$ftppath_base/$arch" -- cgit v1.2.3-54-g00ecf From c81c0e57ff41bbc51e13600b8581145b34aef55f Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 7 Aug 2010 23:49:01 +0200 Subject: Rewrite db-move * Cleanup code * create symlinks instead of copies * Moving split packages is now (more) atomic * Move old packages to pool if needed --- db-move | 97 +++++++++++++++++++++++++---------------------------------------- 1 file changed, 37 insertions(+), 60 deletions(-) (limited to 'db-move') 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) " + echo "usage: $(basename $0) " 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 -- cgit v1.2.3-54-g00ecf From 23d4669b8e330d131b2f78cd5858b30a07478c8a Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 8 Aug 2010 00:33:46 +0200 Subject: Use package pool instead of $repo/os/any dirs --- db-move | 17 ++++++++--------- db-update | 16 +++++----------- test/lib/common.inc | 2 ++ 3 files changed, 15 insertions(+), 20 deletions(-) (limited to 'db-move') diff --git a/db-move b/db-move index 407027a..8609459 100755 --- a/db-move +++ b/db-move @@ -74,16 +74,15 @@ if [ -d "$packagebase/repos/$svnrepo_from" ]; then _pkgfiles='' for i in ${pkgname[@]}; do - _pkgpath=$(getpkgfile "$ftppath_from/${_arch}/"$i-$pkgver-$pkgrel-$_arch$PKGEXT) - _pkgfile=$(basename "${_pkgpath}") - - # 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 _tarch in ${_tarches[@]}; do + _pkgpath=$(getpkgfile "$ftppath_from/${_tarch}/"$i-$pkgver-$pkgrel-$_arch$PKGEXT) + _pkgfile=$(basename "${_pkgpath}") + + # copy package to pool if needed + # TODO: can be removed once every package has been 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 ln -s "../../../$(get_pkgpool_for_host)/${_arch}/${_pkgfile}" $ftppath_to/${_tarch}/ done diff --git a/db-update b/db-update index f05246b..9e641d2 100755 --- a/db-update +++ b/db-update @@ -223,7 +223,7 @@ for current_arch in ${ARCHES[@]}; do # if non empty, move all build dirs if [ $(/bin/ls "$WORKDIR/build/" 2>/dev/null | wc -l) != 0 ]; then if [ $(getpkgfiles "$WORKDIR/build/"*-$current_arch$PKGEXT 2>/dev/null | wc -l) != 0 ]; then - echo "Copying new files to '$ftppath'" + echo "Copying new files to '$poolpath' and symlinking" for f in "$WORKDIR/build/"*-$current_arch$PKGEXT; do /bin/chmod 664 "$f" &>/dev/null if ! /bin/cp "$f" "$poolpath/"; then @@ -236,20 +236,14 @@ for current_arch in ${ARCHES[@]}; do done fi if [ $(getpkgfiles "$WORKDIR/build/"*-any$PKGEXT 2>/dev/null | wc -l) != 0 ]; then - echo "Copying new files to '$ftppath_any' and symlinking" + echo "Copying new files to '$poolpath_any' and symlinking" for f in "$WORKDIR/build/"*-any$PKGEXT; do /bin/chmod 664 "$f" &>/dev/null fname="$(basename $f)" - if [ ! -f "$poolrel_any/$fname" ]; then - if ! /bin/cp "$f" "$poolpath_any/"; then - die "error: failure while copying files to $poolpath_any" - fi - fi - if [ ! -f "$ftppath_any/$fname" ]; then - if ! ln -s "$poolrel_any/$fname" "$ftppath_any/$fname"; then - die "error: failure symlinking $fname to $ftppath_any" - fi + if ! /bin/cp "$f" "$poolpath_any/"; then + die "error: failure while copying files to $poolpath_any" fi + if ! ln -s "$poolrel_any/$fname" "$ftppath/$fname"; then die "error: failure symlinking $fname to $ftppath" fi diff --git a/test/lib/common.inc b/test/lib/common.inc index 3ba715e..4080c38 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -91,6 +91,8 @@ checkAnyPackage() { [ -f "${STAGING}"/${repo}/${pkg} ] && fail "${repo}/${pkg} found in staging dir" bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}.db.tar.gz" -O | grep -q ${pkg} || fail "${pkg} not in ${repo}/os/${arch}/${repo}.db.tar.gz" + + [ -f "${FTP_BASE}/${repo}/os/any/${pkg}" ] && fail "${repo}/os/any/${pkg} should not exist" } checkPackage() { -- cgit v1.2.3-54-g00ecf From c117d9048ae591401a79037222da7bf7bda85705 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 8 Aug 2010 03:44:17 +0200 Subject: Reduce verbosity Only inform of errors and processes that might take longer. --- db-move | 15 ++++++++------- db-remove | 21 +++++++++------------ db-update | 23 +++++++---------------- test/lib/common.inc | 4 +--- test/runTest | 14 +++++++------- 5 files changed, 32 insertions(+), 45 deletions(-) (limited to 'db-move') diff --git a/db-move b/db-move index 8609459..7dff563 100755 --- a/db-move +++ b/db-move @@ -55,22 +55,21 @@ repo_lock $repofrom $_arch || exit 1 /bin/mkdir -p "$WORKDIR" cd "$WORKDIR" -/usr/bin/svn checkout -N $SVNREPO checkout +/usr/bin/svn checkout -q -N $SVNREPO checkout >/dev/null cd checkout /usr/bin/svn up -q $packagebase if [ -d "$packagebase/repos/$svnrepo_from" ]; then . "$packagebase/repos/$svnrepo_from/$BUILDSCRIPT" + echo -n "Moving $packagebase from $repofrom to $repoto..." 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)" + /usr/bin/svn mv -q -r HEAD "$packagebase/repos/$svnrepo_from" "$packagebase/repos/$svnrepo_to" + /usr/bin/svn commit -q -m "$(basename $0): moved $packagebase from [$repofrom] to [$repoto] ($_arch)" _pkgfiles='' for i in ${pkgname[@]}; do @@ -90,9 +89,11 @@ if [ -d "$packagebase/repos/$svnrepo_from" ]; then 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[@]}" + /usr/bin/repo-add -q "$ftppath_to/${_tarch}/$repoto$DBEXT" ${_pkgfiles} >/dev/null || die "Error in repo-add $_pkgfiles" + /usr/bin/repo-remove -q "$ftppath_from/${_tarch}/$repofrom$DBEXT" ${pkgname[@]} >/dev/null || die "Error in repo-remove ${pkgname[@]}" done + + echo 'done' else die "Error: $packagebase is not in repo $repofrom" fi diff --git a/db-remove b/db-remove index 0b77fc1..357e6c4 100755 --- a/db-remove +++ b/db-remove @@ -42,26 +42,21 @@ trap cleanup 0 repo_lock $reponame $_arch || exit 1 +echo -n "Removing $packagebase from $reponame..." /bin/mkdir -p "$WORKDIR" - - -echo "==> Removing package '$packagebase' from '$reponame'..." >&2 - cd "$WORKDIR" -/usr/bin/svn checkout -N $SVNREPO checkout +/usr/bin/svn checkout -q -N $SVNREPO checkout >/dev/null cd checkout /usr/bin/svn up -q $packagebase if [ -d "$packagebase/repos/$svnrepo" ]; then - echo " Removing from subversion" . "$packagebase/repos/$svnrepo/$BUILDSCRIPT" /usr/bin/svn rm --force -q "$packagebase/repos/$svnrepo" /usr/bin/svn commit -q -m "$(basename $0): $packagebase removed by $(id -un)" else echo " Warning: $packagebase not found in $svnrepo" - echo " Removing split packages is not supported" - echo " You need to specify each sub package instead" - pkgname=$packagebase + echo " Removing split packages is not yet supported" + exit 1 fi cd "$WORKDIR" @@ -82,14 +77,16 @@ for architecture in $arches; do exit 0 fi - echo " Removing from $reponame DB file ($architecture)" cd build/ - /usr/bin/repo-remove -q "$reponame$DBEXT" ${pkgname[@]} + /usr/bin/repo-remove -q "$reponame$DBEXT" ${pkgname[@]} >/dev/null /bin/mv "$reponame$DBEXT" "$ftppath/$architecture" - echo "Package files will be cleaned up automatically" cd .. done + +echo 'done' + cleanup + # vim: set ts=4 sw=4 noet ft=sh: diff --git a/db-update b/db-update index 9e641d2..057de39 100755 --- a/db-update +++ b/db-update @@ -74,6 +74,8 @@ die() { trap ctrl_c 2 trap cleanup 0 +echo -n "Updating $reponame..." + # Remove any package from $stagedir that is already in the FTP repository for current_arch in ${ARCHES[@]} any; do ftppath="$FTP_BASE/$reponame/os/$current_arch" @@ -97,9 +99,8 @@ cd "$WORKDIR" if [ -n "$ANYPKGS" ]; then pkgtotal=$(echo "$ANYPKGS" | wc -w) - echo "==> Processing $pkgtotal new/updated arch-independent packages for '$reponame'..." >&2 - /usr/bin/svn checkout -N $SVNREPO checkout + /usr/bin/svn checkout -q -N $SVNREPO checkout >/dev/null cd checkout to_add_any="" for pkg in $ANYPKGS; do @@ -107,11 +108,9 @@ if [ -n "$ANYPKGS" ]; then _pkgname="$(getpkgname $pkg)" _pkgbase="$(getpkgbase $pkg)" svnrepo="$reponame-any" - echo " Validating package arch (any) $_pkgname" if ! check_pkg_arch "$pkg" "any"; then echo " ERROR: $_pkgfile is not architecture independent!" else - echo " Checking SVN for $_pkgbase" /usr/bin/svn up -q $_pkgbase if [ -d "$_pkgbase/repos/$svnrepo" ]; then . "$_pkgbase/repos/$svnrepo/$BUILDSCRIPT" @@ -156,8 +155,6 @@ for current_arch in ${ARCHES[@]}; do /bin/cp "$ftppath/$reponame$DBEXT" build/$reponame-$current_arch$DBEXT fi - echo "Updating DB for $svnrepo" - to_add="" if [ -d "$stagedir" ]; then ADDPKGS="$(getpkgfiles $stagedir/*-${current_arch}$PKGEXT 2>/dev/null)" @@ -165,17 +162,14 @@ for current_arch in ${ARCHES[@]}; do if [ -n "$ADDPKGS" -o -n "$ANYPKGS" ]; then - echo "==> Copying DB file from '$reponame'..." >&2 - if [ -f "$ftppath/$reponame$DBEXT" ]; then /bin/cp "$ftppath/$reponame$DBEXT" build/$reponame-$current_arch$DBEXT fi pkgtotal=$(echo "$ADDPKGS $ANYPKGS" | wc -w) - echo "==> Processing $pkgtotal new/updated packages for repository '$reponame'..." >&2 cd "$WORKDIR" - /usr/bin/svn checkout -N $SVNREPO checkout + /usr/bin/svn checkout -N $SVNREPO checkout >/dev/null cd checkout if [ -n "$ADDPKGS" ]; then @@ -184,11 +178,9 @@ for current_arch in ${ARCHES[@]}; do _pkgname="$(getpkgname $pkg)" _pkgbase="$(getpkgbase $pkg)" - echo " Validating package arch ($current_arch) $_pkgname" if ! check_pkg_arch "$pkg" "$current_arch"; then echo " ERROR: $_pkgfile was built for the wrong architecture" else - echo " Checking SVN for $_pkgbase" /usr/bin/svn up -q $_pkgbase if [ -d "$_pkgbase/repos/$svnrepo" ]; then . "$_pkgbase/repos/$svnrepo/$BUILDSCRIPT" @@ -211,7 +203,7 @@ for current_arch in ${ARCHES[@]}; do pkgs="" for pkg in $to_add $to_add_any; do pkgs="$pkgs $(basename $pkg)"; done - /usr/bin/repo-add -q "$reponame-$current_arch$DBEXT" $pkgs + /usr/bin/repo-add -q "$reponame-$current_arch$DBEXT" $pkgs >/dev/null else rm -f "build/$reponame-$current_arch$DBEXT" echo "Errors found when adding packages" @@ -223,7 +215,6 @@ for current_arch in ${ARCHES[@]}; do # if non empty, move all build dirs if [ $(/bin/ls "$WORKDIR/build/" 2>/dev/null | wc -l) != 0 ]; then if [ $(getpkgfiles "$WORKDIR/build/"*-$current_arch$PKGEXT 2>/dev/null | wc -l) != 0 ]; then - echo "Copying new files to '$poolpath' and symlinking" for f in "$WORKDIR/build/"*-$current_arch$PKGEXT; do /bin/chmod 664 "$f" &>/dev/null if ! /bin/cp "$f" "$poolpath/"; then @@ -236,7 +227,6 @@ for current_arch in ${ARCHES[@]}; do done fi if [ $(getpkgfiles "$WORKDIR/build/"*-any$PKGEXT 2>/dev/null | wc -l) != 0 ]; then - echo "Copying new files to '$poolpath_any' and symlinking" for f in "$WORKDIR/build/"*-any$PKGEXT; do /bin/chmod 664 "$f" &>/dev/null fname="$(basename $f)" @@ -257,7 +247,6 @@ for current_arch in ${ARCHES[@]}; do fi if [ -n "$to_add" ]; then - echo "Cleaning staging dir" /bin/rm $to_add fi @@ -268,6 +257,8 @@ if [ -n "$to_add_any" ]; then /bin/rm $to_add_any fi +echo 'done' + trap '' 0 2 rm -rf $WORKDIR # vim: set ts=4 sw=4 noet ft=sh: diff --git a/test/lib/common.inc b/test/lib/common.inc index dd3022e..2d2b612 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -60,10 +60,8 @@ eot } tearDown() { - echo -n 'Cleaning up...' rm -rf "${TMP}" rm -f "${curdir}/../config.local" - echo 'done' echo } @@ -73,7 +71,7 @@ releasePackage() { local arch=$3 pushd "${TMP}/svn-packages-copy"/${pkgbase}/trunk/ >/dev/null - archrelease ${repo}-${arch} >/dev/null + archrelease ${repo}-${arch} >/dev/null 2&>1 popd >/dev/null cp "${pkgdir}/${pkgbase}"/*.pkg.tar.* "${STAGING}"/${repo}/ } diff --git a/test/runTest b/test/runTest index d453493..b24b7ea 100755 --- a/test/runTest +++ b/test/runTest @@ -235,7 +235,7 @@ testCleanupSimplePackages() { ../db-remove pkg-simple-a extra ${arch} done - ../cron-jobs/ftpdir-cleanup + ../cron-jobs/ftpdir-cleanup >/dev/null for arch in ${arches[@]}; do local pkg1="pkg-simple-a-1-1-${arch}.pkg.tar.xz" @@ -258,7 +258,7 @@ testCleanupAnyPackages() { ../db-update extra ../db-remove pkg-any-a extra any - ../cron-jobs/ftpdir-cleanup + ../cron-jobs/ftpdir-cleanup >/dev/null local pkg1='pkg-any-a-1-1-any.pkg.tar.xz' [ -f "${FTP_BASE}/packages/arch/${arch}/${pkg1}" ] && fail "packages/arch/${arch}/${pkg1} found" @@ -289,7 +289,7 @@ testCleanupSplitPackages() { done done - ../cron-jobs/ftpdir-cleanup + ../cron-jobs/ftpdir-cleanup >/dev/null for arch in ${arches[@]}; do for pkg in "${pkgdir}/${pkgs[0]}"/*-${arch}.pkg.tar.*; do @@ -333,7 +333,7 @@ testMovePackagesWithoutPool() { done done - ../cron-jobs/ftpdir-cleanup + ../cron-jobs/ftpdir-cleanup >/dev/null for pkgbase in ${pkgs[@]}; do for arch in ${arches[@]}; do @@ -341,7 +341,7 @@ testMovePackagesWithoutPool() { done done - ../cron-jobs/ftpdir-cleanup + ../cron-jobs/ftpdir-cleanup >/dev/null for pkgbase in ${pkgs[@]}; do for arch in ${arches[@]}; do @@ -374,13 +374,13 @@ testMoveAnyPackagesWithoutPool() { done done - ../cron-jobs/ftpdir-cleanup + ../cron-jobs/ftpdir-cleanup >/dev/null for pkgbase in ${pkgs[@]}; do ../db-move ${pkgbase} testing extra any done - ../cron-jobs/ftpdir-cleanup + ../cron-jobs/ftpdir-cleanup >/dev/null for pkgbase in ${pkgs[@]}; do for pkg in "${pkgdir}/${pkgbase}"/*-any.pkg.tar.*; do -- cgit v1.2.3-54-g00ecf From d0b5dcb3ce6a1ec5222fc7a0420b3e1dc4c3a27e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 8 Aug 2010 11:53:07 +0200 Subject: Remove BUILDSCRIPT variable There is no need to have a variable for things like PKGBUILD that are very unlikely to ever change. --- config | 1 - db-move | 2 +- db-remove | 2 +- db-update | 8 ++++---- misc-scripts/make-sourceball | 2 +- misc-scripts/sourceballs-cleanup | 4 ++-- testing2x | 4 ++-- 7 files changed, 11 insertions(+), 12 deletions(-) (limited to 'db-move') diff --git a/config b/config index 88e50bc..f6600a6 100644 --- a/config +++ b/config @@ -14,7 +14,6 @@ LOCK_TIMEOUT=300 STAGING="$HOME/staging" TMPDIR="/srv/tmp" ARCHES=(i686 x86_64) -BUILDSCRIPT="PKGBUILD" DBEXT=".db.tar.gz" PKGEXT=".pkg.tar.*" SRCEXT=".src.tar.gz" diff --git a/db-move b/db-move index 7dff563..8347a18 100755 --- a/db-move +++ b/db-move @@ -60,7 +60,7 @@ cd checkout /usr/bin/svn up -q $packagebase if [ -d "$packagebase/repos/$svnrepo_from" ]; then - . "$packagebase/repos/$svnrepo_from/$BUILDSCRIPT" + . "$packagebase/repos/$svnrepo_from/PKGBUILD" echo -n "Moving $packagebase from $repofrom to $repoto..." if [ -d "$packagebase/repos/$svnrepo_to" ]; then diff --git a/db-remove b/db-remove index bf325c4..1314bb7 100755 --- a/db-remove +++ b/db-remove @@ -50,7 +50,7 @@ cd checkout /usr/bin/svn up -q $packagebase if [ -d "$packagebase/repos/$svnrepo" ]; then - . "$packagebase/repos/$svnrepo/$BUILDSCRIPT" + . "$packagebase/repos/$svnrepo/PKGBUILD" /usr/bin/svn rm --force -q "$packagebase/repos/$svnrepo" /usr/bin/svn commit -q -m "$(basename $0): $packagebase removed by $(id -un)" else diff --git a/db-update b/db-update index 9dd5c9d..a08bee2 100755 --- a/db-update +++ b/db-update @@ -93,11 +93,11 @@ if [ -n "$ANYPKGS" ]; then else /usr/bin/svn up -q $_pkgbase if [ -d "$_pkgbase/repos/$svnrepo" ]; then - . "$_pkgbase/repos/$svnrepo/$BUILDSCRIPT" + . "$_pkgbase/repos/$svnrepo/PKGBUILD" if echo "$_pkgfile" | grep -q "$_pkgname-$pkgver-$pkgrel-any"; then to_add_any="$to_add_any $pkg" else - echo " WARNING: $_pkgfile does not match $BUILDSCRIPT in $svnrepo" + echo " WARNING: $_pkgfile does not match PKGBUILD in $svnrepo" fi else echo " WARNING: Package $_pkgbase not found in $svnrepo" @@ -163,11 +163,11 @@ for current_arch in ${ARCHES[@]}; do else /usr/bin/svn up -q $_pkgbase if [ -d "$_pkgbase/repos/$svnrepo" ]; then - . "$_pkgbase/repos/$svnrepo/$BUILDSCRIPT" + . "$_pkgbase/repos/$svnrepo/PKGBUILD" if echo "$_pkgfile" | grep -q "$_pkgname-$pkgver-$pkgrel-$current_arch"; then to_add="$to_add $pkg" else - echo " WARNING: $_pkgfile does not match $BUILDSCRIPT in $svnrepo" + echo " WARNING: $_pkgfile does not match PKGBUILD in $svnrepo" fi else echo " WARNING: Package $_pkgbase not found in $svnrepo" diff --git a/misc-scripts/make-sourceball b/misc-scripts/make-sourceball index 37141c7..41767d0 100755 --- a/misc-scripts/make-sourceball +++ b/misc-scripts/make-sourceball @@ -43,7 +43,7 @@ die() { create_srcpackage() { if [ -d "$1" ]; then pushd "$1" >/dev/null - . "$BUILDSCRIPT" + . "PKGBUILD" if ! [ $FORCE == 1 ] && ! chk_license ${license[@]} ; then #Removed so as not to clutter failed.txt #echo -e "\t$packagename license (${license[@]}) does not require source tarballs" >&2 diff --git a/misc-scripts/sourceballs-cleanup b/misc-scripts/sourceballs-cleanup index c7f284d..d259d3a 100755 --- a/misc-scripts/sourceballs-cleanup +++ b/misc-scripts/sourceballs-cleanup @@ -27,7 +27,7 @@ remove_old() { PKGVERS="" for repo in *; do cd "$repo" - . "$BUILDSCRIPT" + . "PKGBUILD" PKGVERS="$PKGVERS $pkgver-$pkgrel" cd .. done @@ -85,7 +85,7 @@ for sourceball in "$srcpath"/*$SRCEXT; do elif [ -z "$(ls -A "$packagename/repos")" ]; then echo "$packagename : no longer in repos but trunk is still in svn. Removing sourceball." >> "$logfile" mv $sourceball $SOURCE_CLEANUP_DESTDIR - elif ! source "$packagename/trunk/$BUILDSCRIPT" && chk_license ${license[@]}; then + elif ! source "$packagename/trunk/PKGBUILD" && chk_license ${license[@]}; then echo "$packagename : source hosting no longer required by license. Removing sourceball." >> "$logfile" mv $sourceball $SOURCE_CLEANUP_DESTDIR else diff --git a/testing2x b/testing2x index f9ded9e..4826853 100755 --- a/testing2x +++ b/testing2x @@ -35,9 +35,9 @@ cd checkout for pkg in $*; do moved=0 /usr/bin/svn up -q ${pkg} - if [ -f "${pkg}/repos/testing-${_arch}/${BUILDSCRIPT}" ]; then + if [ -f "${pkg}/repos/testing-${_arch}/PKGBUILD" ]; then for repo in core extra; do - if [ -f "${pkg}/repos/${repo}-${_arch}/${BUILDSCRIPT}" ]; then + if [ -f "${pkg}/repos/${repo}-${_arch}/PKGBUILD" ]; then echo "===> Moving package '${pkg}': testing-${_arch} -> ${repo}-${_arch}" $(dirname $0)/db-move "${pkg}" "testing" "${repo}" "${_arch}" moved=1 -- cgit v1.2.3-54-g00ecf From 388d629327d97e8d15a7a67cc87ae36edfe2f385 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 8 Aug 2010 13:08:47 +0200 Subject: use common workdir --- db-functions | 4 ++-- db-move | 6 ------ db-remove | 5 ----- db-update | 2 -- misc-scripts/make-sourceball | 3 --- misc-scripts/sourceballs-cleanup | 2 -- testing2x | 2 -- 7 files changed, 2 insertions(+), 22 deletions(-) (limited to 'db-move') diff --git a/db-functions b/db-functions index 2fe7a49..caaf9a0 100644 --- a/db-functions +++ b/db-functions @@ -1,7 +1,7 @@ #!/bin/bash -# Random integrity things -[ "$UID" = "" ] && UID=$(uid) +# set up general environment +WORKDIR=$(mktemp -d /tmp/$(basename $0).XXXXXXXXXX) # Useful functions diff --git a/db-move b/db-move index 8347a18..8b15831 100755 --- a/db-move +++ b/db-move @@ -23,10 +23,6 @@ ftppath_to="$FTP_BASE/$repoto/os/" svnrepo_from="$repofrom-$_arch" svnrepo_to="$repoto-$_arch" -[ "$UID" = "" ] && UID=$(uid) - -WORKDIR="$TMPDIR/db-move.$svnrepo_from.$svnrepo_to.$UID" - cleanup() { trap '' 0 2 # unlock @@ -52,8 +48,6 @@ trap cleanup 0 repo_lock $repoto $_arch || exit 1 repo_lock $repofrom $_arch || exit 1 -/bin/mkdir -p "$WORKDIR" - cd "$WORKDIR" /usr/bin/svn checkout -q -N $SVNREPO checkout >/dev/null cd checkout diff --git a/db-remove b/db-remove index 1314bb7..0da9e75 100755 --- a/db-remove +++ b/db-remove @@ -15,10 +15,6 @@ _arch="$3" ftppath="$FTP_BASE/$reponame/os" svnrepo="$reponame-$_arch" -[ "$UID" = "" ] && UID=$(uid) - -WORKDIR="$TMPDIR/db-remove.$svnrepo.$UID" - cleanup() { trap '' 0 2 # unlock @@ -43,7 +39,6 @@ trap cleanup 0 repo_lock $reponame $_arch || exit 1 echo -n "Removing $packagebase from $reponame..." -/bin/mkdir -p "$WORKDIR" cd "$WORKDIR" /usr/bin/svn checkout -q -N $SVNREPO checkout >/dev/null cd checkout diff --git a/db-update b/db-update index d08c96d..e53aee8 100755 --- a/db-update +++ b/db-update @@ -24,7 +24,6 @@ if [ $found -ne 1 ]; then exit 1 fi -WORKDIR="$TMPDIR/db-update.$reponame.$UID" ADDPKGS="" ANYPKGS="" @@ -74,7 +73,6 @@ if [ -d "$stagedir" ]; then ANYPKGS="$(getpkgfiles $stagedir/*-any$PKGEXT 2>/dev/null)" fi -mkdir -p $WORKDIR cd "$WORKDIR" if [ -n "$ANYPKGS" ]; then diff --git a/misc-scripts/make-sourceball b/misc-scripts/make-sourceball index 41767d0..e216356 100755 --- a/misc-scripts/make-sourceball +++ b/misc-scripts/make-sourceball @@ -22,8 +22,6 @@ _arch="$3" srcpath="$FTP_BASE/sources/" logpath="/var/log/sourceballs/" -WORKDIR="/tmp/make-sourceball.$packagename.$UID" - cleanup() { restore_umask rm -rf "$WORKDIR" @@ -77,7 +75,6 @@ trap ctrl_c 2 trap cleanup 0 1 set_umask -/bin/mkdir -p "$WORKDIR" /bin/mkdir -p "$logpath" cd "$WORKDIR" diff --git a/misc-scripts/sourceballs-cleanup b/misc-scripts/sourceballs-cleanup index d259d3a..c87a888 100755 --- a/misc-scripts/sourceballs-cleanup +++ b/misc-scripts/sourceballs-cleanup @@ -7,7 +7,6 @@ srcpath="$FTP_BASE/sources/" logfile="$srcpath/cleanup.txt" LOCKFILE="/tmp/.sourceball-cleanup.lock" -WORKDIR="/tmp/sourceball-cleanup.$packagename.$UID" cleanup () { restore_umask @@ -68,7 +67,6 @@ trap ctrl_c 2 /usr/bin/renice +10 -p $$ > /dev/null set_umask -/bin/mkdir -p "$WORKDIR" cd "$WORKDIR" [ -e "$logfile" ] && /bin/mv "$logfile" "$logfile.old" diff --git a/testing2x b/testing2x index 4826853..e9fbeaa 100755 --- a/testing2x +++ b/testing2x @@ -11,7 +11,6 @@ case "$0" in _arch="i686" ;; esac -WORKDIR="$TMPDIR/testing2x.$UID" cleanup() { trap '' 0 2 @@ -27,7 +26,6 @@ ctrl_c() { trap ctrl_c 2 trap cleanup 0 -/bin/mkdir "${WORKDIR}" cd "${WORKDIR}" /usr/bin/svn checkout -N $SVNREPO checkout cd checkout -- cgit v1.2.3-54-g00ecf From 9eb1cd7b9403533c4b60ecfbbbf00a08c211059a Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 8 Aug 2010 15:03:27 +0200 Subject: Move common function to db-functions db-functions now sets an individual $WORKDIR and implements trap functinos that remove locks on exit or error. There are new functions to lock and unlock the running script. misc-scripts/ftpdir-cleanup was renamed to ftpdir-cleanup-repo as the cron-job had the same name. Script names have to be unique when using db-functions. --- cron-jobs/ftpdir-cleanup | 26 +---- db-functions | 74 +++++++++++-- db-move | 25 +---- db-remove | 23 +---- db-update | 22 ---- misc-scripts/ftpdir-cleanup | 218 --------------------------------------- misc-scripts/ftpdir-cleanup-repo | 207 +++++++++++++++++++++++++++++++++++++ misc-scripts/make-sourceball | 21 +--- misc-scripts/sourceballs-cleanup | 27 +---- test/lib/common.inc | 6 +- testing2x | 16 --- 11 files changed, 291 insertions(+), 374 deletions(-) delete mode 100755 misc-scripts/ftpdir-cleanup create mode 100755 misc-scripts/ftpdir-cleanup-repo (limited to 'db-move') diff --git a/cron-jobs/ftpdir-cleanup b/cron-jobs/ftpdir-cleanup index 546afd9..f5e401a 100755 --- a/cron-jobs/ftpdir-cleanup +++ b/cron-jobs/ftpdir-cleanup @@ -5,34 +5,14 @@ repos="$(get_repos_for_host)" -LOCKFILE="/tmp/.ftpdircleanup.lock" - -cleanup () { - rm -f "$LOCKFILE" - exit 0 -} - -ctrl_c() { - cleanup -} - -if [ -f "$LOCKFILE" ]; then - owner="$(/usr/bin/stat -c %U $LOCKFILE)" - echo "error: ftp cleanup is already in progress (started by $owner)" - exit 1 -fi - -trap cleanup 0 -trap ctrl_c 2 - -/bin/touch "$LOCKFILE" +script_lock #adjust the nice level to run at a lower priority /usr/bin/renice +10 -p $$ > /dev/null repopaths='' for repo in $repos; do - $(dirname $0)/../misc-scripts/ftpdir-cleanup $repo + $(dirname $0)/../misc-scripts/ftpdir-cleanup-repo $repo repopaths="${repopaths} ${FTP_BASE}/${repo}/os/" done @@ -60,4 +40,4 @@ if [ -n "$to_cleanup" ]; then mv $to_cleanup "$CLEANUP_DESTDIR" fi -cleanup +script_unlock diff --git a/db-functions b/db-functions index caaf9a0..36ffb07 100644 --- a/db-functions +++ b/db-functions @@ -1,10 +1,6 @@ #!/bin/bash -# set up general environment -WORKDIR=$(mktemp -d /tmp/$(basename $0).XXXXXXXXXX) - # Useful functions - UMASK="" set_umask () { [ "$UMASK" == "" ] && UMASK="$(umask)" @@ -16,8 +12,73 @@ restore_umask () { umask $UMASK >/dev/null } +# set up general environment +WORKDIR=$(mktemp -d /tmp/$(basename $0).XXXXXXXXXX) +LOCKS=() + +script_lock() { + local LOCKDIR="$TMPDIR/.scriptlock.$(basename $0)" + if ! mkdir "$LOCKDIR" >/dev/null 2>&1 ; then + local _owner="$(/usr/bin/stat -c %U $LOCKDIR)" + echo "Error: Script $(basename $0) is already locked by $_owner." >&2 + exit 1 + else + set_umask + return 0 + fi +} + +script_unlock() { + local LOCKDIR="$TMPDIR/.scriptlock.$(basename $0)" + if [ ! -d "$LOCKDIR" ]; then + echo "Warning: Script $(basename $0) was not locked!" >&2 + restore_umask + return 1 + else + rmdir "$LOCKDIR" + restore_umask + return 0 + fi +} + +cleanup() { + local l + local repo + local arch + + trap - EXIT INT QUIT TERM + for l in ${LOCKS[@]}; do + repo=${l%.*} + arch=${l#*.} + if [ -d "$TMPDIR/.repolock.$repo.$arch" ]; then + echo "Removing left over lock from $repo/$arch" >&2 + repo_unlock $repo $_arch + fi + done + if [ -d "$TMPDIR/.scriptlock.$(basename $0)" ]; then + echo "Removing left over lock from $(basename $0)" >&2 + script_unlock + fi + rm -rf "$WORKDIR" + [ "$1" ] && exit $1 +} + +abort() { + echo 'Aborting...' >&2 + cleanup 0 +} + +die() { + echo "$*" >&2 + cleanup 1 +} + +trap abort INT QUIT TERM +trap cleanup EXIT + + repo_lock () { #repo_lock [timeout] - LOCKDIR="$TMPDIR/.repolock.$1.$2" + local LOCKDIR="$TMPDIR/.repolock.$1.$2" local _count local _trial local _timeout @@ -39,6 +100,7 @@ repo_lock () { #repo_lock [timeout] _owner="$(/usr/bin/stat -c %U $LOCKDIR)" echo "warning: Repo $1-$2 is already locked by $_owner. Retrying in $LOCK_DELAY seconds..." >&2 else + LOCKS[${#LOCKS[*]}]="$1.$2" set_umask return 0 fi @@ -51,7 +113,7 @@ repo_lock () { #repo_lock [timeout] } repo_unlock () { #repo_unlock - LOCKDIR="$TMPDIR/.repolock.$1.$2" + local LOCKDIR="$TMPDIR/.repolock.$1.$2" if [ ! -d "$LOCKDIR" ]; then echo "warning: Repo lock $1-$2 was not locked!" >&2 restore_umask diff --git a/db-move b/db-move index 8b15831..b846e79 100755 --- a/db-move +++ b/db-move @@ -23,28 +23,6 @@ ftppath_to="$FTP_BASE/$repoto/os/" svnrepo_from="$repofrom-$_arch" svnrepo_to="$repoto-$_arch" -cleanup() { - trap '' 0 2 - # unlock - repo_unlock $repoto $_arch - repo_unlock $repofrom $_arch - rm -rf "$WORKDIR" - [ "$1" ] && exit $1 -} - -ctrl_c() { - echo "Interrupted" >&2 - cleanup 0 -} - -die() { - echo "$*" >&2 - cleanup 1 -} - -trap ctrl_c 2 -trap cleanup 0 - repo_lock $repoto $_arch || exit 1 repo_lock $repofrom $_arch || exit 1 @@ -91,3 +69,6 @@ if [ -d "$packagebase/repos/$svnrepo_from" ]; then else die "Error: $packagebase is not in repo $repofrom" fi + +repo_unlock $repoto $_arch || exit 1 +repo_unlock $repofrom $_arch || exit 1 diff --git a/db-remove b/db-remove index 0da9e75..5d61c97 100755 --- a/db-remove +++ b/db-remove @@ -15,27 +15,6 @@ _arch="$3" ftppath="$FTP_BASE/$reponame/os" svnrepo="$reponame-$_arch" -cleanup() { - trap '' 0 2 - # unlock - repo_unlock $reponame $_arch - rm -rf "$WORKDIR" - [ "$1" ] && exit $1 -} - -ctrl_c() { - echo "Interrupted" >&2 - cleanup 0 -} - -die() { - echo "$*" >&2 - cleanup 1 -} - -trap ctrl_c 2 -trap cleanup 0 - repo_lock $reponame $_arch || exit 1 echo -n "Removing $packagebase from $reponame..." @@ -71,4 +50,6 @@ done echo 'done' +repo_unlock $reponame $_arch || exit 1 + # vim: set ts=4 sw=4 noet ft=sh: diff --git a/db-update b/db-update index e53aee8..f971a6f 100755 --- a/db-update +++ b/db-update @@ -33,26 +33,6 @@ if [ ! -d $stagedir ]; then exit 1 fi -cleanup() { - trap '' 0 2 - repo_unlock $reponame $current_arch - rm -rf "$WORKDIR" - [ "$1" ] && exit $1 -} - -ctrl_c() { - echo "Interrupted" >&2 - cleanup 1 -} - -die() { - echo "$*" >&2 - cleanup 1 -} - -trap ctrl_c 2 -trap cleanup 0 - echo -n "Updating $reponame..." # Remove any package from $stagedir that is already in the FTP repository @@ -238,6 +218,4 @@ fi echo 'done' -trap '' 0 2 -rm -rf $WORKDIR # vim: set ts=4 sw=4 noet ft=sh: diff --git a/misc-scripts/ftpdir-cleanup b/misc-scripts/ftpdir-cleanup deleted file mode 100755 index ac17a8d..0000000 --- a/misc-scripts/ftpdir-cleanup +++ /dev/null @@ -1,218 +0,0 @@ -#!/bin/bash - -if [ $# -ne 1 ]; then - echo "usage: $(basename $0) " - exit 1 -fi - -reponame=$1 - -############################################################ - -. "$(dirname $0)/../db-functions" -. "$(dirname $0)/../config" - -cleanup() { - trap '' 2 15 - for arch in ${ARCHES[@]}; do - repo_unlock $reponame $arch - done - exit 1 -} - -clean_pkgs () { - for pkg in "$@"; do - if [ -h "$pkg" ]; then - rm -f "$pkg" - else - mv "$pkg" "$CLEANUP_DESTDIR" - fi - done -} - -trap cleanup 2 -trap cleanup 15 - -${CLEANUP_DRYRUN} && echo 'dry run mode is active' - -ftppath_base="$FTP_BASE/$reponame/os" - -for arch in ${ARCHES[@]}; do - - repo_lock $reponame $arch $LOCK_TIMEOUT || continue - - CLEANUP_TMPDIR=$(mktemp -d ${TMPDIR}/cleanup-XXXXXX) || exit 1 - ftppath="$ftppath_base/$arch" - MISSINGFILES="" - DELETEFILES="" - DELETESYMLINKS="" - EXTRAFILES="" - - if [ ! -d "$ftppath" ]; then - echo "FTP path '$ftppath' does not exist" - exit 1 - fi - - if ! cd "${CLEANUP_TMPDIR}" ; then - echo "Failed to cd to ${CLEANUP_TMPDIR}" - exit 1 - fi - - if [ ! -f "$ftppath/$reponame$DBEXT" ]; then - echo "" - echo "WARNING: The file \"$ftppath/$reponame$DBEXT\" could not be found, skipping." - echo "" - repo_unlock $reponame $arch - continue - fi - - if ! bsdtar xf "$ftppath/$reponame$DBEXT"; then - echo "" - echo "ERROR: Command failed: bsdtar xf \"$ftppath/$reponame$DBEXT\"" - exit 1 - fi - - cd "$ftppath" - - for pkg in $CLEANUP_TMPDIR/*; do - [ -f "${pkg}" ] || continue - filename=$(grep -A1 '^%FILENAME%$' "${pkg}/desc" | tail -n1) - - if [ ! -e "${filename}" ]; then - MISSINGFILES="${MISSINGFILES} ${filename}" - else - pkgname="$(getpkgname ${filename})" - for otherfile in ${pkgname}-*; do - if [ "${otherfile}" != "${filename}" -a "${pkgname}" = "$(getpkgname ${otherfile})" ]; then - if [ -h "${otherfile}" ]; then - DELETESYMLINKS="${DELETESYMLINKS} ${otherfile}" - else - DELETEFILES="${DELETEFILES} ${otherfile}" - fi - fi - done - fi - done - - for pkg in *$PKGEXT; do - if [ ! -e "$pkg" ]; then - continue - fi - pkgname="$(getpkgname $pkg)" - for p in ${CLEANUP_TMPDIR}/${pkgname}-*; do - [ ! -d "${p}" ] || continue 2 - dbpkgname=$(grep -A1 '^%FILENAME%$' "${p}/desc" 2>/dev/null| tail -n1) - if [ "${dbpkgname}" = "${pkgname}" ]; then - continue 2 - fi - done - EXTRAFILES="$EXTRAFILES $pkg" - done - - rm -rf ${CLEANUP_TMPDIR} - - # Do a quick check to see if a missing ARCHINDEPFILE is in the any dir - # If it is, and the file is MISSING, restore it - missfiles="$MISSINGFILES" - MISSINGFILES="" - for mf in $missfiles; do - if [ -e "${ftppath_base}/any/${mf}" ]; then - echo "Restoring missing 'any' symlink: ${mf}" - ${CLEANUP_DRYRUN} || ln -s "../any/${mf}" "${ftppath}" - else - MISSINGFILES="${MISSINGFILES} ${mf}" - fi - done - - repo_unlock $reponame $arch - - #Make sure we've done *something* before outputting anything - if [ -z "$DELETEFILES$DELETESYMLINKS$MISSINGFILES$EXTRAFILES" ]; then - continue - fi - - echo "Scan complete for $reponame ($arch) at ${ftppath}" - - if [ -n "$DELETEFILES" ]; then - echo " The following files are out of date" - for f in $DELETEFILES; do - echo " $f" - done - echo "" - fi - - if [ -n "$DELETESYMLINKS" ]; then - echo " The following symlinks are out of date" - echo " They will be deleted" - for f in $DELETESYMLINKS; do - echo " $f" - done - echo "" - fi - - if [ -n "$MISSINGFILES" ]; then - echo " The following files are missing in the repo" - for f in $MISSINGFILES; do - echo " $f" - done - echo "" - fi - - if [ -n "$EXTRAFILES" ]; then - echo " The following files are in the repo but not the db" - for f in $EXTRAFILES; do - echo " $f" - done - fi - - if [ -n "${DELETEFILES}" ]; then - ${CLEANUP_DRYRUN} || clean_pkgs ${DELETEFILES} - echo "" - fi - - if [ -n "${DELETESYMLINKS}" ]; then - ${CLEANUP_DRYRUN} || clean_pkgs ${DELETESYMLINKS} - echo "" - fi - - if [ -n "${EXTRAFILES}" ]; then - ${CLEANUP_DRYRUN} || clean_pkgs ${EXTRAFILES} - echo "" - fi - -done - -ARCHINDEPFILES="" - -if [ -d "$ftppath_base/any" ]; then - cd "$ftppath_base/any" - for pkg in *$PKGEXT; do - [ -f "$pkg" ] || continue # in case we get a file named "*.pkg.tar.gz" - found=0 - #check for any existing symlinks - for arch in ${ARCHES[@]}; do - if [ -h "$ftppath_base/$arch/$pkg" ]; then - found=1 - break - fi - done - if [ $found -eq 0 ]; then - # We found no symlinks to this, delete it - ARCHINDEPFILES="$ARCHINDEPFILES $pkg" - fi - done -fi - -if [ -n "$ARCHINDEPFILES" ]; then - echo " The following architecture independent packages" - echo " are not symlinked in the architecture repositories." - for f in $ARCHINDEPFILES; do - echo " $f" - done -fi - -if [ -d "$ftppath_base/any" -a -n "${ARCHINDEPFILES}" ]; then - cd "$ftppath_base/any" - ${CLEANUP_DRYRUN} || clean_pkgs ${ARCHINDEPFILES} - echo "" -fi diff --git a/misc-scripts/ftpdir-cleanup-repo b/misc-scripts/ftpdir-cleanup-repo new file mode 100755 index 0000000..12f726c --- /dev/null +++ b/misc-scripts/ftpdir-cleanup-repo @@ -0,0 +1,207 @@ +#!/bin/bash + +if [ $# -ne 1 ]; then + echo "usage: $(basename $0) " + exit 1 +fi + +reponame=$1 + +############################################################ + +. "$(dirname $0)/../db-functions" +. "$(dirname $0)/../config" + +clean_pkgs () { + for pkg in "$@"; do + if [ -h "$pkg" ]; then + rm -f "$pkg" + else + mv "$pkg" "$CLEANUP_DESTDIR" + fi + done +} + +${CLEANUP_DRYRUN} && echo 'dry run mode is active' + +ftppath_base="$FTP_BASE/$reponame/os" + +for arch in ${ARCHES[@]}; do + + repo_lock $reponame $arch $LOCK_TIMEOUT || continue + + CLEANUP_TMPDIR=$(mktemp -d ${WORKDIR}/cleanup-XXXXXX) || exit 1 + ftppath="$ftppath_base/$arch" + MISSINGFILES="" + DELETEFILES="" + DELETESYMLINKS="" + EXTRAFILES="" + + if [ ! -d "$ftppath" ]; then + echo "FTP path '$ftppath' does not exist" + exit 1 + fi + + if ! cd "${CLEANUP_TMPDIR}" ; then + echo "Failed to cd to ${CLEANUP_TMPDIR}" + exit 1 + fi + + if [ ! -f "$ftppath/$reponame$DBEXT" ]; then + echo "" + echo "WARNING: The file \"$ftppath/$reponame$DBEXT\" could not be found, skipping." + echo "" + repo_unlock $reponame $arch + continue + fi + + if ! bsdtar xf "$ftppath/$reponame$DBEXT"; then + echo "" + echo "ERROR: Command failed: bsdtar xf \"$ftppath/$reponame$DBEXT\"" + exit 1 + fi + + cd "$ftppath" + + for pkg in $CLEANUP_TMPDIR/*; do + [ -f "${pkg}" ] || continue + filename=$(grep -A1 '^%FILENAME%$' "${pkg}/desc" | tail -n1) + + if [ ! -e "${filename}" ]; then + MISSINGFILES="${MISSINGFILES} ${filename}" + else + pkgname="$(getpkgname ${filename})" + for otherfile in ${pkgname}-*; do + if [ "${otherfile}" != "${filename}" -a "${pkgname}" = "$(getpkgname ${otherfile})" ]; then + if [ -h "${otherfile}" ]; then + DELETESYMLINKS="${DELETESYMLINKS} ${otherfile}" + else + DELETEFILES="${DELETEFILES} ${otherfile}" + fi + fi + done + fi + done + + for pkg in *$PKGEXT; do + if [ ! -e "$pkg" ]; then + continue + fi + pkgname="$(getpkgname $pkg)" + for p in ${CLEANUP_TMPDIR}/${pkgname}-*; do + [ ! -d "${p}" ] || continue 2 + dbpkgname=$(grep -A1 '^%FILENAME%$' "${p}/desc" 2>/dev/null| tail -n1) + if [ "${dbpkgname}" = "${pkgname}" ]; then + continue 2 + fi + done + EXTRAFILES="$EXTRAFILES $pkg" + done + + rm -rf ${CLEANUP_TMPDIR} + + # Do a quick check to see if a missing ARCHINDEPFILE is in the any dir + # If it is, and the file is MISSING, restore it + missfiles="$MISSINGFILES" + MISSINGFILES="" + for mf in $missfiles; do + if [ -e "${ftppath_base}/any/${mf}" ]; then + echo "Restoring missing 'any' symlink: ${mf}" + ${CLEANUP_DRYRUN} || ln -s "../any/${mf}" "${ftppath}" + else + MISSINGFILES="${MISSINGFILES} ${mf}" + fi + done + + repo_unlock $reponame $arch + + #Make sure we've done *something* before outputting anything + if [ -z "$DELETEFILES$DELETESYMLINKS$MISSINGFILES$EXTRAFILES" ]; then + continue + fi + + echo "Scan complete for $reponame ($arch) at ${ftppath}" + + if [ -n "$DELETEFILES" ]; then + echo " The following files are out of date" + for f in $DELETEFILES; do + echo " $f" + done + echo "" + fi + + if [ -n "$DELETESYMLINKS" ]; then + echo " The following symlinks are out of date" + echo " They will be deleted" + for f in $DELETESYMLINKS; do + echo " $f" + done + echo "" + fi + + if [ -n "$MISSINGFILES" ]; then + echo " The following files are missing in the repo" + for f in $MISSINGFILES; do + echo " $f" + done + echo "" + fi + + if [ -n "$EXTRAFILES" ]; then + echo " The following files are in the repo but not the db" + for f in $EXTRAFILES; do + echo " $f" + done + fi + + if [ -n "${DELETEFILES}" ]; then + ${CLEANUP_DRYRUN} || clean_pkgs ${DELETEFILES} + echo "" + fi + + if [ -n "${DELETESYMLINKS}" ]; then + ${CLEANUP_DRYRUN} || clean_pkgs ${DELETESYMLINKS} + echo "" + fi + + if [ -n "${EXTRAFILES}" ]; then + ${CLEANUP_DRYRUN} || clean_pkgs ${EXTRAFILES} + echo "" + fi + +done + +ARCHINDEPFILES="" + +if [ -d "$ftppath_base/any" ]; then + cd "$ftppath_base/any" + for pkg in *$PKGEXT; do + [ -f "$pkg" ] || continue # in case we get a file named "*.pkg.tar.gz" + found=0 + #check for any existing symlinks + for arch in ${ARCHES[@]}; do + if [ -h "$ftppath_base/$arch/$pkg" ]; then + found=1 + break + fi + done + if [ $found -eq 0 ]; then + # We found no symlinks to this, delete it + ARCHINDEPFILES="$ARCHINDEPFILES $pkg" + fi + done +fi + +if [ -n "$ARCHINDEPFILES" ]; then + echo " The following architecture independent packages" + echo " are not symlinked in the architecture repositories." + for f in $ARCHINDEPFILES; do + echo " $f" + done +fi + +if [ -d "$ftppath_base/any" -a -n "${ARCHINDEPFILES}" ]; then + cd "$ftppath_base/any" + ${CLEANUP_DRYRUN} || clean_pkgs ${ARCHINDEPFILES} + echo "" +fi diff --git a/misc-scripts/make-sourceball b/misc-scripts/make-sourceball index e216356..6e57385 100755 --- a/misc-scripts/make-sourceball +++ b/misc-scripts/make-sourceball @@ -22,21 +22,7 @@ _arch="$3" srcpath="$FTP_BASE/sources/" logpath="/var/log/sourceballs/" -cleanup() { - restore_umask - rm -rf "$WORKDIR" - [ "$1" ] && exit $1 -} - -ctrl_c() { - echo "Interrupted" >&2 - cleanup 0 -} - -die() { - echo -e "$*" >&2 - cleanup 1 -} +script_lock create_srcpackage() { if [ -d "$1" ]; then @@ -71,9 +57,6 @@ create_srcpackage() { fi } -trap ctrl_c 2 -trap cleanup 0 1 - set_umask /bin/mkdir -p "$logpath" cd "$WORKDIR" @@ -91,3 +74,5 @@ else die "\tPackage '$packagename' does not exist in repo '$reponame-$_arch'" fi fi + +script_unlock diff --git a/misc-scripts/sourceballs-cleanup b/misc-scripts/sourceballs-cleanup index c87a888..e058c38 100755 --- a/misc-scripts/sourceballs-cleanup +++ b/misc-scripts/sourceballs-cleanup @@ -6,19 +6,7 @@ srcpath="$FTP_BASE/sources/" logfile="$srcpath/cleanup.txt" -LOCKFILE="/tmp/.sourceball-cleanup.lock" - -cleanup () { - restore_umask - rm -rf "$WORKDIR" - rm -f "$LOCKFILE" - exit 0 -} - -ctrl_c() { - echo "Interrupted" >&2 - cleanup 0 -} +script_lock remove_old() { if [ -d "$1" ]; then @@ -52,17 +40,6 @@ remove_old() { fi } -if [ -f "$LOCKFILE" ]; then - owner="$(/usr/bin/stat -c %U $LOCKFILE)" - echo "error: source tarball generation is already in progress (started by $owner)" - exit 1 -fi - -trap cleanup 0 -trap ctrl_c 2 - -/bin/touch "$LOCKFILE" - #adjust the nice level to run at a lower priority /usr/bin/renice +10 -p $$ > /dev/null @@ -91,4 +68,4 @@ for sourceball in "$srcpath"/*$SRCEXT; do fi done -cleanup 0 +script_unlock diff --git a/test/lib/common.inc b/test/lib/common.inc index d28017d..ba5be9f 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -7,8 +7,8 @@ oneTimeSetUp() { echo -n 'Building packages...' for p in "${pkgdir}"/*; do pushd $p >/dev/null - linux32 makepkg -cf --config ${curdir}/lib/makepkg-i686.conf >/dev/null 2>&1 || exit 1 - [ -f *-any.pkg.tar.* ] || linux64 makepkg -cf --config ${curdir}/lib/makepkg-x86_64.conf >/dev/null 2>&1 || exit 1 + linux32 makepkg -cf --config ${curdir}/lib/makepkg-i686.conf >/dev/null 2>&1 || die 'makepkg failed' + [ -f *-any.pkg.tar.* ] || linux64 makepkg -cf --config ${curdir}/lib/makepkg-x86_64.conf >/dev/null 2>&1 || die 'makepkg failed' popd >/dev/null done echo 'done' @@ -23,7 +23,7 @@ setUp() { local p local pkg - [ -f "${curdir}/../config.local" ] && exit 1 + [ -f "${curdir}/../config.local" ] && die "${curdir}/../config.local exists" TMP="$(mktemp -d /dev/shm/$(basename $0).XXXXXXXXXX)" #echo "Using ${TMP}" diff --git a/testing2x b/testing2x index e9fbeaa..bf48be6 100755 --- a/testing2x +++ b/testing2x @@ -12,20 +12,6 @@ case "$0" in ;; esac -cleanup() { - trap '' 0 2 - rm -rf "${WORKDIR}" - [ -n "$1" ] && exit $1 -} - -ctrl_c() { - echo "Interrupted" >&2 - cleanup 0 -} - -trap ctrl_c 2 -trap cleanup 0 - cd "${WORKDIR}" /usr/bin/svn checkout -N $SVNREPO checkout cd checkout @@ -49,5 +35,3 @@ for pkg in $*; do echo "===> Warning: ${pkg} is not in testing-${_arch}" fi done - -cleanup -- cgit v1.2.3-54-g00ecf From 830c4d84d13712974ffd392cdcc58b038c0dcfd9 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 8 Aug 2010 16:03:11 +0200 Subject: Source PKGBUILD in subshells This patch sources a PKGBUILD in a subshells instead of directly. This way we don't polute our scope or overwrite our vars which might lead to unexpected behavior. --- db-move | 48 +++++++++++++++++++++------------------- db-remove | 22 +++++++++--------- db-update | 42 ++++++++++++++++++----------------- misc-scripts/make-sourceball | 15 +++++++------ misc-scripts/sourceballs-cleanup | 3 ++- 5 files changed, 68 insertions(+), 62 deletions(-) (limited to 'db-move') diff --git a/db-move b/db-move index b846e79..bbe7ff7 100755 --- a/db-move +++ b/db-move @@ -11,20 +11,20 @@ fi packagebase="$1" repofrom="$2" repoto="$3" -_arch="$4" -if [ "${_arch}" == 'any' ]; then - _tarches=('i686' 'x86_64') +arch="$4" +if [ "${arch}" == 'any' ]; then + tarches=('i686' 'x86_64') else - _tarches=("${_arch}") + tarches=("${arch}") fi ftppath_from="$FTP_BASE/$repofrom/os/" ftppath_to="$FTP_BASE/$repoto/os/" -svnrepo_from="$repofrom-$_arch" -svnrepo_to="$repoto-$_arch" +svnrepo_from="$repofrom-$arch" +svnrepo_to="$repoto-$arch" -repo_lock $repoto $_arch || exit 1 -repo_lock $repofrom $_arch || exit 1 +repo_lock $repoto $arch || exit 1 +repo_lock $repofrom $arch || exit 1 cd "$WORKDIR" /usr/bin/svn checkout -q -N $SVNREPO checkout >/dev/null @@ -32,7 +32,9 @@ cd checkout /usr/bin/svn up -q $packagebase if [ -d "$packagebase/repos/$svnrepo_from" ]; then - . "$packagebase/repos/$svnrepo_from/PKGBUILD" + pkgname=($(. "$packagebase/repos/$svnrepo_from/PKGBUILD"; echo ${pkgname[@]})) + pkgver=$(. "$packagebase/repos/$svnrepo_from/PKGBUILD"; echo ${pkgver}) + pkgrel=$(. "$packagebase/repos/$svnrepo_from/PKGBUILD"; echo ${pkgrel}) echo -n "Moving $packagebase from $repofrom to $repoto..." if [ -d "$packagebase/repos/$svnrepo_to" ]; then @@ -41,28 +43,28 @@ if [ -d "$packagebase/repos/$svnrepo_from" ]; then fi /usr/bin/svn mv -q -r HEAD "$packagebase/repos/$svnrepo_from" "$packagebase/repos/$svnrepo_to" - /usr/bin/svn commit -q -m "$(basename $0): moved $packagebase from [$repofrom] to [$repoto] ($_arch)" + /usr/bin/svn commit -q -m "$(basename $0): moved $packagebase from [$repofrom] to [$repoto] ($arch)" - _pkgfiles='' + pkgfiles='' for i in ${pkgname[@]}; do - for _tarch in ${_tarches[@]}; do - _pkgpath=$(getpkgfile "$ftppath_from/${_tarch}/"$i-$pkgver-$pkgrel-$_arch$PKGEXT) - _pkgfile=$(basename "${_pkgpath}") + for tarch in ${tarches[@]}; do + pkgpath=$(getpkgfile "$ftppath_from/${tarch}/"$i-$pkgver-$pkgrel-$arch$PKGEXT) + pkgfile=$(basename "${pkgpath}") # copy package to pool if needed # TODO: can be removed once every package has been 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}/ + if [ ! -f $FTP_BASE/$(get_pkgpool_for_host)/${arch}/$pkgfile ]; then + cp $pkgpath $FTP_BASE/$(get_pkgpool_for_host)/${arch}/ fi - ln -s "../../../$(get_pkgpool_for_host)/${_arch}/${_pkgfile}" $ftppath_to/${_tarch}/ + ln -s "../../../$(get_pkgpool_for_host)/${arch}/${pkgfile}" $ftppath_to/${tarch}/ done - _pkgfiles="${_pkgfiles} $FTP_BASE/$(get_pkgpool_for_host)/${_arch}/${_pkgfile}" + 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} >/dev/null || die "Error in repo-add $_pkgfiles" - /usr/bin/repo-remove -q "$ftppath_from/${_tarch}/$repofrom$DBEXT" ${pkgname[@]} >/dev/null || die "Error in repo-remove ${pkgname[@]}" + for tarch in ${tarches[@]}; do + /usr/bin/repo-add -q "$ftppath_to/${tarch}/$repoto$DBEXT" ${pkgfiles} >/dev/null || die "Error in repo-add $pkgfiles" + /usr/bin/repo-remove -q "$ftppath_from/${tarch}/$repofrom$DBEXT" ${pkgname[@]} >/dev/null || die "Error in repo-remove ${pkgname[@]}" done echo 'done' @@ -70,5 +72,5 @@ else die "Error: $packagebase is not in repo $repofrom" fi -repo_unlock $repoto $_arch || exit 1 -repo_unlock $repofrom $_arch || exit 1 +repo_unlock $repoto $arch || exit 1 +repo_unlock $repofrom $arch || exit 1 diff --git a/db-remove b/db-remove index 5d61c97..5a55849 100755 --- a/db-remove +++ b/db-remove @@ -10,12 +10,12 @@ fi packagebase="$1" reponame="$2" -_arch="$3" +arch="$3" ftppath="$FTP_BASE/$reponame/os" -svnrepo="$reponame-$_arch" +svnrepo="$reponame-$arch" -repo_lock $reponame $_arch || exit 1 +repo_lock $reponame $arch || exit 1 echo -n "Removing $packagebase from $reponame..." cd "$WORKDIR" @@ -24,7 +24,7 @@ cd checkout /usr/bin/svn up -q $packagebase if [ -d "$packagebase/repos/$svnrepo" ]; then - . "$packagebase/repos/$svnrepo/PKGBUILD" + pkgname=($(. "$packagebase/repos/$svnrepo/PKGBUILD"; echo ${pkgname[@]})) /usr/bin/svn rm --force -q "$packagebase/repos/$svnrepo" /usr/bin/svn commit -q -m "$(basename $0): $packagebase removed by $(id -un)" else @@ -33,23 +33,23 @@ fi cd "$WORKDIR" -if [ "$_arch" == "any" ]; then +if [ "$arch" == "any" ]; then arches="i686 x86_64" else - arches="$_arch" + arches="$arch" fi # copy the db file into our working area -for arch in $arches; do - if [ ! -f "$ftppath/$arch/$reponame$DBEXT" ]; then - die "No database found at '$ftppath/$arch', nothing more to do" +for tarch in $arches; do + if [ ! -f "$ftppath/$tarch/$reponame$DBEXT" ]; then + die "No database found at '$ftppath/$tarch', nothing more to do" fi - /usr/bin/repo-remove -q "$ftppath/$arch/$reponame$DBEXT" ${pkgname[@]} >/dev/null + /usr/bin/repo-remove -q "$ftppath/$tarch/$reponame$DBEXT" ${pkgname[@]} >/dev/null done echo 'done' -repo_unlock $reponame $_arch || exit 1 +repo_unlock $reponame $arch || exit 1 # vim: set ts=4 sw=4 noet ft=sh: diff --git a/db-update b/db-update index f971a6f..375ed02 100755 --- a/db-update +++ b/db-update @@ -62,23 +62,24 @@ if [ -n "$ANYPKGS" ]; then cd checkout to_add_any="" for pkg in $ANYPKGS; do - _pkgfile=$(basename $pkg) - _pkgname="$(getpkgname $pkg)" - _pkgbase="$(getpkgbase $pkg)" + pkgfile=$(basename $pkg) + pkgname="$(getpkgname $pkg)" + pkgbase="$(getpkgbase $pkg)" svnrepo="$reponame-any" if ! check_pkg_arch "$pkg" "any"; then - echo " ERROR: $_pkgfile is not architecture independent!" + echo " ERROR: $pkgfile is not architecture independent!" else - /usr/bin/svn up -q $_pkgbase - if [ -d "$_pkgbase/repos/$svnrepo" ]; then - . "$_pkgbase/repos/$svnrepo/PKGBUILD" - if echo "$_pkgfile" | grep -q "$_pkgname-$pkgver-$pkgrel-any"; then + /usr/bin/svn up -q $pkgbase + if [ -d "$pkgbase/repos/$svnrepo" ]; then + pkgver=$(. "$pkgbase/repos/$svnrepo/PKGBUILD"; echo ${pkgver}) + pkgrel=$(. "$pkgbase/repos/$svnrepo/PKGBUILD"; echo ${pkgrel}) + if echo "$pkgfile" | grep -q "$pkgname-$pkgver-$pkgrel-any"; then to_add_any="$to_add_any $pkg" else - echo " WARNING: $_pkgfile does not match PKGBUILD in $svnrepo" + echo " WARNING: $pkgfile does not match PKGBUILD in $svnrepo" fi else - echo " WARNING: Package $_pkgbase not found in $svnrepo" + echo " WARNING: Package $pkgbase not found in $svnrepo" fi fi done @@ -132,23 +133,24 @@ for current_arch in ${ARCHES[@]}; do if [ -n "$ADDPKGS" ]; then for pkg in $ADDPKGS; do - _pkgfile=$(basename $pkg) - _pkgname="$(getpkgname $pkg)" - _pkgbase="$(getpkgbase $pkg)" + pkgfile=$(basename $pkg) + pkgname="$(getpkgname $pkg)" + pkgbase="$(getpkgbase $pkg)" if ! check_pkg_arch "$pkg" "$current_arch"; then - echo " ERROR: $_pkgfile was built for the wrong architecture" + echo " ERROR: $pkgfile was built for the wrong architecture" else - /usr/bin/svn up -q $_pkgbase - if [ -d "$_pkgbase/repos/$svnrepo" ]; then - . "$_pkgbase/repos/$svnrepo/PKGBUILD" - if echo "$_pkgfile" | grep -q "$_pkgname-$pkgver-$pkgrel-$current_arch"; then + /usr/bin/svn up -q $pkgbase + if [ -d "$pkgbase/repos/$svnrepo" ]; then + pkgver=$(. "$pkgbase/repos/$svnrepo/PKGBUILD"; echo ${pkgver}) + pkgrel=$(. "$pkgbase/repos/$svnrepo/PKGBUILD"; echo ${pkgrel}) + if echo "$pkgfile" | grep -q "$pkgname-$pkgver-$pkgrel-$current_arch"; then to_add="$to_add $pkg" else - echo " WARNING: $_pkgfile does not match PKGBUILD in $svnrepo" + echo " WARNING: $pkgfile does not match PKGBUILD in $svnrepo" fi else - echo " WARNING: Package $_pkgbase not found in $svnrepo" + echo " WARNING: Package $pkgbase not found in $svnrepo" fi fi done diff --git a/misc-scripts/make-sourceball b/misc-scripts/make-sourceball index 6e57385..8e26eec 100755 --- a/misc-scripts/make-sourceball +++ b/misc-scripts/make-sourceball @@ -17,7 +17,7 @@ fi packagename="$1" reponame="$2" -_arch="$3" +arch="$3" srcpath="$FTP_BASE/sources/" logpath="/var/log/sourceballs/" @@ -27,7 +27,8 @@ script_lock create_srcpackage() { if [ -d "$1" ]; then pushd "$1" >/dev/null - . "PKGBUILD" + pkgver=$(. PKGBUILD; echo ${pkgver}) + pkgrel=$(. PKGBUILD; echo ${pkgrel}) if ! [ $FORCE == 1 ] && ! chk_license ${license[@]} ; then #Removed so as not to clutter failed.txt #echo -e "\t$packagename license (${license[@]}) does not require source tarballs" >&2 @@ -40,7 +41,7 @@ create_srcpackage() { if ! /usr/bin/makepkg --allsource --ignorearch >"$logfile" 2>&1; then popd >/dev/null /bin/gzip -f -9 "$logfile" - die "\tFailed to download source for $packagename-$pkgver-$pkgrel ($reponame-$_arch)" + die "\tFailed to download source for $packagename-$pkgver-$pkgrel ($reponame-$arch)" fi /bin/rm -f "$logfile"{,.gz} @@ -63,15 +64,15 @@ cd "$WORKDIR" if [[ "$reponame" = "community" || "$reponame" = "community-testing" ]]; then if /usr/bin/svn export -q "$SVNREPOCOMMUNITY/$packagename" $packagename; then - create_srcpackage "$packagename/repos/$reponame-$_arch" + create_srcpackage "$packagename/repos/$reponame-$arch" else - die "\tPackage '$packagename' does not exist in repo '$reponame-$_arch'" + die "\tPackage '$packagename' does not exist in repo '$reponame-$arch'" fi else if /usr/bin/svn export -q "$SVNREPO/$packagename" $packagename; then - create_srcpackage "$packagename/repos/$reponame-$_arch" + create_srcpackage "$packagename/repos/$reponame-$arch" else - die "\tPackage '$packagename' does not exist in repo '$reponame-$_arch'" + die "\tPackage '$packagename' does not exist in repo '$reponame-$arch'" fi fi diff --git a/misc-scripts/sourceballs-cleanup b/misc-scripts/sourceballs-cleanup index e058c38..e407989 100755 --- a/misc-scripts/sourceballs-cleanup +++ b/misc-scripts/sourceballs-cleanup @@ -14,7 +14,8 @@ remove_old() { PKGVERS="" for repo in *; do cd "$repo" - . "PKGBUILD" + pkgver=$(. PKGBUILD; echo ${pkgver}) + pkgrel=$(. PKGBUILD; echo ${pkgrel}) PKGVERS="$PKGVERS $pkgver-$pkgrel" cd .. done -- cgit v1.2.3-54-g00ecf From af4f86808e8cd45cc171f55a1ec15bf30d858a0d Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Tue, 10 Aug 2010 21:40:24 +0200 Subject: Use more consitent naming for package pool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are no longer architecture-specific subdirs and the structure was switch to this: ftp └── pool ├── community └── packages packages contains all packages from core, extra and testing; this naming is in sync with the svn repo naming: svn-packages and svn-community --- cron-jobs/adjust-permissions | 8 ++++---- cron-jobs/ftpdir-cleanup | 20 +++++++++----------- db-functions | 4 ++-- db-move | 8 ++++---- db-update | 12 +++++------- test/lib/common.inc | 13 +++++++------ test/runTest | 10 +++++----- 7 files changed, 36 insertions(+), 39 deletions(-) (limited to 'db-move') diff --git a/cron-jobs/adjust-permissions b/cron-jobs/adjust-permissions index c21af0c..c28ca7c 100755 --- a/cron-jobs/adjust-permissions +++ b/cron-jobs/adjust-permissions @@ -17,9 +17,9 @@ get_dir_owner() { echo "root:tusers" ;; community-testing) echo "root:tusers" ;; - packages/arch) + pool/packages) echo "ftp:ftp-extra" ;; - packages/community) + pool/community) echo "root:tusers" ;; esac } @@ -35,8 +35,8 @@ for d in $(get_repos_for_host); do done for p in $(get_pkgpool_for_host); do owner="$(get_dir_owner $p)" - /bin/chown -R $owner $p/{any,i686,x86_64} - /bin/chmod -R g+w $p/{any,i686,x86_64} + /bin/chown $owner $p + /bin/chmod g+w $p done /bin/chmod 555 $FTP_BASE popd >/dev/null diff --git a/cron-jobs/ftpdir-cleanup b/cron-jobs/ftpdir-cleanup index f5e401a..7668ab5 100755 --- a/cron-jobs/ftpdir-cleanup +++ b/cron-jobs/ftpdir-cleanup @@ -17,18 +17,16 @@ for repo in $repos; do done to_cleanup="" -for _arch in any ${ARCHES[@]}; do - poolpath="$FTP_BASE/$(get_pkgpool_for_host)/$_arch/" - pushd $poolpath >/dev/null - for pkg in *$PKGEXT; do - [ -f "$pkg" ] || continue # in case we get a file named "*.pkg.tar.gz" - LINKS="$(/usr/bin/find $repopaths -type l -name "$pkg" 2>/dev/null)" - if [ -z "$LINKS" ]; then - to_cleanup="$to_cleanup $poolpath/$pkg" - fi - done - popd >/dev/null +poolpath="$FTP_BASE/$(get_pkgpool_for_host)/" +pushd $poolpath >/dev/null +for pkg in *$PKGEXT; do +[ -f "$pkg" ] || continue # in case we get a file named "*.pkg.tar.gz" +LINKS="$(/usr/bin/find $repopaths -type l -name "$pkg" 2>/dev/null)" +if [ -z "$LINKS" ]; then + to_cleanup="$to_cleanup $poolpath/$pkg" +fi done +popd >/dev/null if [ -n "$to_cleanup" ]; then echo " The following packages are no longer in any repo" diff --git a/db-functions b/db-functions index 9abb694..c4fc8f3 100644 --- a/db-functions +++ b/db-functions @@ -228,9 +228,9 @@ get_repos_for_host() { get_pkgpool_for_host() { if [ "$(hostname)" = "sigurd" ]; then - echo "packages/community" + echo "pool/community" else - echo "packages/arch" + echo "pool/packages" fi } diff --git a/db-move b/db-move index bbe7ff7..d18a4fa 100755 --- a/db-move +++ b/db-move @@ -53,13 +53,13 @@ if [ -d "$packagebase/repos/$svnrepo_from" ]; then # copy package to pool if needed # TODO: can be removed once every package has been 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}/ + if [ ! -f $FTP_BASE/$(get_pkgpool_for_host)/$pkgfile ]; then + cp $pkgpath $FTP_BASE/$(get_pkgpool_for_host) fi - ln -s "../../../$(get_pkgpool_for_host)/${arch}/${pkgfile}" $ftppath_to/${tarch}/ + ln -s "../../../$(get_pkgpool_for_host)/${pkgfile}" $ftppath_to/${tarch}/ done - pkgfiles="${pkgfiles} $FTP_BASE/$(get_pkgpool_for_host)/${arch}/${pkgfile}" + pkgfiles="${pkgfiles} $FTP_BASE/$(get_pkgpool_for_host)/${pkgfile}" done for tarch in ${tarches[@]}; do diff --git a/db-update b/db-update index 375ed02..46becac 100755 --- a/db-update +++ b/db-update @@ -89,11 +89,9 @@ for current_arch in ${ARCHES[@]}; do ftppath="$FTP_BASE/$reponame/os/$current_arch" ftppath_any="$FTP_BASE/$reponame/os/any" - poolpath="$FTP_BASE/$(get_pkgpool_for_host)/$current_arch" - poolpath_any="$FTP_BASE/$(get_pkgpool_for_host)/any" + poolpath="$FTP_BASE/$(get_pkgpool_for_host)" # The following is used to create relative symlinks - poolrel="../../../$(get_pkgpool_for_host)/$current_arch" - poolrel_any="../../../$(get_pkgpool_for_host)/any" + poolrel="../../../$(get_pkgpool_for_host)" if [ ! -d "$ftppath" ]; then echo "FTP path for this repo ($reponame) is missing" @@ -190,11 +188,11 @@ for current_arch in ${ARCHES[@]}; do for f in "$WORKDIR/build/"*-any$PKGEXT; do /bin/chmod 664 "$f" &>/dev/null fname="$(basename $f)" - if ! /bin/cp "$f" "$poolpath_any/"; then - die "error: failure while copying files to $poolpath_any" + if ! /bin/cp "$f" "$poolpath/"; then + die "error: failure while copying files to $poolpath" fi - if ! ln -s "$poolrel_any/$fname" "$ftppath/$fname"; then + if ! ln -s "$poolrel/$fname" "$ftppath/$fname"; then die "error: failure symlinking $fname to $ftppath" fi done diff --git a/test/lib/common.inc b/test/lib/common.inc index ba5be9f..89155c7 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -28,7 +28,8 @@ setUp() { #echo "Using ${TMP}" mkdir -p "${TMP}/"{ftp,tmp,staging,{package,source}-cleanup,svn-{packages,community}-{copy,repo}} - mkdir -p "${TMP}/ftp/"{{core,extra,community,testing,community-testing}/os,packages/{arch,community}}/{i686,any,x86_64} + mkdir -p "${TMP}/ftp/"{core,extra,community,testing,community-testing}/os/{i686,any,x86_64} + mkdir -p "${TMP}/ftp/pool/"{packages,community} mkdir -p "${TMP}/staging/"{core,extra,community,testing,community-testing} echo -n 'Creating svn repository...' @@ -81,11 +82,11 @@ checkAnyPackage() { local pkg=$2 local arch - [ -f "${FTP_BASE}/packages/arch/any/${pkg}" ] || fail "packages/arch/any/${pkg} not found" + [ -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] || fail "$(get_pkgpool_for_host)/${pkg} not found" for arch in i686 x86_64; do [ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} not a symlink" - [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/packages/arch/any/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} does not link to packages/arch/any/${pkg}" + [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} does not link to $(get_pkgpool_for_host)/${pkg}" done [ -f "${STAGING}"/${repo}/${pkg} ] && fail "${repo}/${pkg} found in staging dir" @@ -99,15 +100,15 @@ checkPackage() { local pkg=$2 local arch=$3 - [ -f "${FTP_BASE}/packages/arch/${arch}/${pkg}" ] || fail "packages/arch/${arch}/${pkg} not found" + [ -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] || fail "$(get_pkgpool_for_host)/${pkg} not found" [ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} not a symlink" [ -f "${STAGING}"/${repo}/${pkg} ] && fail "${repo}/${pkg} found in staging dir" - [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/packages/arch/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} does not link to packages/arch/${arch}/${pkg}" + [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} does not link to $(get_pkgpool_for_host)/${pkg}" bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkg} || fail "${pkg} not in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" - local pkgbase=$(getpkgbase "${FTP_BASE}/packages/arch/${arch}/${pkg}") + local pkgbase=$(getpkgbase "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}") svn up -q "${TMP}/svn-packages-copy/${pkgbase}" [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-${arch}" ] || fail "svn-packages-copy/${pkgbase}/repos/${repo}-${arch} does not exist" } diff --git a/test/runTest b/test/runTest index 5bbea05..75c7a05 100755 --- a/test/runTest +++ b/test/runTest @@ -240,7 +240,7 @@ testCleanupSimplePackages() { for arch in ${arches[@]}; do local pkg1="pkg-simple-a-1-1-${arch}.pkg.tar.xz" checkRemovedPackage extra 'pkg-simple-a' ${arch} - [ -f "${FTP_BASE}/packages/arch/${arch}/${pkg1}" ] && fail "packages/arch/${arch}/${pkg1} found" + [ -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg1}" ] && fail "$(get_pkgpool_for_host)/${pkg1} found" [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg1}" ] && fail "${repo}/os/${arch}/${pkg1} found" local pkg2="pkg-simple-b-1-1-${arch}.pkg.tar.xz" @@ -263,7 +263,7 @@ testCleanupAnyPackages() { local pkg1='pkg-any-a-1-1-any.pkg.tar.xz' checkRemovedAnyPackage extra 'pkg-any-a' - [ -f "${FTP_BASE}/packages/arch/${arch}/${pkg1}" ] && fail "packages/arch/${arch}/${pkg1} found" + [ -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg1}" ] && fail "$(get_pkgpool_for_host)/${pkg1} found" [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg1}" ] && fail "${repo}/os/${arch}/${pkg1} found" local pkg2="pkg-any-b-1-1-${arch}.pkg.tar.xz" @@ -294,7 +294,7 @@ testCleanupSplitPackages() { for arch in ${arches[@]}; do for pkg in "${pkgdir}/${pkgs[0]}"/*-${arch}.pkg.tar.*; do checkRemovedPackage extra ${pkgs[0]} ${arch} - [ -f "${FTP_BASE}/packages/arch/${arch}/${pkg}" ] && fail "packages/arch/${arch}/${pkg} found" + [ -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] && fail "$(get_pkgpool_for_host)/${pkg} found" [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] && fail "${repo}/os/${arch}/${pkg} found" done @@ -329,7 +329,7 @@ testMovePackagesWithoutPool() { for old in 0 2; do for pkg in "${pkgdir}/${pkgs[${old}]}"/*-${arch}.pkg.tar.*; do pkg=$(basename $pkg) - mv -f "${FTP_BASE}/packages/arch/${arch}/${pkg}" "${FTP_BASE}/testing/os/${arch}/${pkg}" + mv -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" "${FTP_BASE}/testing/os/${arch}/${pkg}" done done done @@ -369,7 +369,7 @@ testMoveAnyPackagesWithoutPool() { # transform a package to old style layout for pkg in "${pkgdir}/${pkgs[0]}"/*-any.pkg.tar.*; do pkg=$(basename $pkg) - mv -f "${FTP_BASE}/packages/arch/any/${pkg}" "${FTP_BASE}/testing/os/any/${pkg}" + mv -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" "${FTP_BASE}/testing/os/any/${pkg}" for arch in i686 x86_64; do ln -sf "../any/${pkg}" "${FTP_BASE}/testing/os/${arch}/${pkg}" done -- cgit v1.2.3-54-g00ecf From e2c005b490df6762e23da3223944151c17d1de80 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 13 Aug 2010 08:20:27 +0200 Subject: Check permission before any action Added a function to check if user has permission to alter the repos and db files. --- db-functions | 29 ++++++++++++++++++++++++++++- db-move | 5 +++++ db-remove | 5 +++++ db-update | 10 +--------- test/lib/common.inc | 49 +++++++++++++++++++++++++++++++++---------------- 5 files changed, 72 insertions(+), 26 deletions(-) (limited to 'db-move') diff --git a/db-functions b/db-functions index c4fc8f3..f22567b 100644 --- a/db-functions +++ b/db-functions @@ -73,7 +73,7 @@ die() { cleanup 1 } -trap abort INT QUIT TERM +trap abort INT QUIT TERM HUP trap cleanup EXIT @@ -274,3 +274,30 @@ pkgver_from_src() { tmp=${tmp%-any} echo $tmp | sed 's|.*-\(.*-.*\)$|\1|g' } + +check_repo_permission() { + local repo=$1 + + local repos="$(get_repos_for_host)" + local found=false + local r + for r in $repos; do + if [ "$r" = "$repo" ]; then + found=true + fi + done + [ $found ] || return 1 + + [ -w "$FTP_BASE/$(get_pkgpool_for_host)" ] || return 1 + + local arch + for arch in ${ARCHES} any; do + local w + local ws=("${FTP_BASE}/${repo}/os/${arch}/"{,${repo}${DBEXT}}) + for w in ws; do + [ -w ] || return 1 + done + done + + return 0 +} diff --git a/db-move b/db-move index d18a4fa..41b360d 100755 --- a/db-move +++ b/db-move @@ -23,6 +23,11 @@ ftppath_to="$FTP_BASE/$repoto/os/" svnrepo_from="$repofrom-$arch" svnrepo_to="$repoto-$arch" +if ! check_repo_permission $repoto || ! check_repo_permission $repofrom; then + echo "Error: You don't have permission to move packages from ${repofrom} to ${repoto}" + exit 1 +fi + repo_lock $repoto $arch || exit 1 repo_lock $repofrom $arch || exit 1 diff --git a/db-remove b/db-remove index 5a55849..1492d18 100755 --- a/db-remove +++ b/db-remove @@ -15,6 +15,11 @@ arch="$3" ftppath="$FTP_BASE/$reponame/os" svnrepo="$reponame-$arch" +if ! check_repo_permission $reponame; then + echo "Error: You don't have permission to remove packages from ${reponam}" + exit 1 +fi + repo_lock $reponame $arch || exit 1 echo -n "Removing $packagebase from $reponame..." diff --git a/db-update b/db-update index 46becac..c049714 100755 --- a/db-update +++ b/db-update @@ -11,15 +11,7 @@ fi reponame="$1" current_arch="" -# ensure we should be playing with this DB on this server -repos="$(get_repos_for_host)" -found=0 -for r in $repos; do - if [ "$r" = "$reponame" ]; then - found=1 - fi -done -if [ $found -ne 1 ]; then +if ! check_repo_permission "$reponame"; then echo "error: you shouldn't be updating $reponame on this server!" exit 1 fi diff --git a/test/lib/common.inc b/test/lib/common.inc index 89155c7..795d01a 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -1,3 +1,5 @@ +set -E + . "${curdir}/../db-functions" oneTimeSetUp() { @@ -8,7 +10,9 @@ oneTimeSetUp() { for p in "${pkgdir}"/*; do pushd $p >/dev/null linux32 makepkg -cf --config ${curdir}/lib/makepkg-i686.conf >/dev/null 2>&1 || die 'makepkg failed' - [ -f *-any.pkg.tar.* ] || linux64 makepkg -cf --config ${curdir}/lib/makepkg-x86_64.conf >/dev/null 2>&1 || die 'makepkg failed' + [ -f *-any.pkg.tar.* ] \ + || linux64 makepkg -cf --config ${curdir}/lib/makepkg-x86_64.conf >/dev/null 2>&1 \ + || die 'makepkg failed' popd >/dev/null done echo 'done' @@ -23,7 +27,7 @@ setUp() { local p local pkg - [ -f "${curdir}/../config.local" ] && die "${curdir}/../config.local exists" + #[ -f "${curdir}/../config.local" ] && die "${curdir}/../config.local exists" TMP="$(mktemp -d /dev/shm/$(basename $0).XXXXXXXXXX)" #echo "Using ${TMP}" @@ -82,17 +86,20 @@ checkAnyPackage() { local pkg=$2 local arch - [ -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] || fail "$(get_pkgpool_for_host)/${pkg} not found" + [ -r "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] || fail "$(get_pkgpool_for_host)/${pkg} not found" for arch in i686 x86_64; do [ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} not a symlink" - [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} does not link to $(get_pkgpool_for_host)/${pkg}" + [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] \ + || fail "${repo}/os/${arch}/${pkg} does not link to $(get_pkgpool_for_host)/${pkg}" done - [ -f "${STAGING}"/${repo}/${pkg} ] && fail "${repo}/${pkg} found in staging dir" + [ -r "${STAGING}"/${repo}/${pkg} ] && fail "${repo}/${pkg} found in staging dir" - bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkg} || fail "${pkg} not in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" + ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" ] \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkg}) \ + || fail "${pkg} not in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" - [ -f "${FTP_BASE}/${repo}/os/any/${pkg}" ] && fail "${repo}/os/any/${pkg} should not exist" + [ -r "${FTP_BASE}/${repo}/os/any/${pkg}" ] && fail "${repo}/os/any/${pkg} should not exist" } checkPackage() { @@ -100,17 +107,21 @@ checkPackage() { local pkg=$2 local arch=$3 - [ -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] || fail "$(get_pkgpool_for_host)/${pkg} not found" + [ -r "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] || fail "$(get_pkgpool_for_host)/${pkg} not found" [ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} not a symlink" - [ -f "${STAGING}"/${repo}/${pkg} ] && fail "${repo}/${pkg} found in staging dir" + [ -r "${STAGING}"/${repo}/${pkg} ] && fail "${repo}/${pkg} found in staging dir" - [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} does not link to $(get_pkgpool_for_host)/${pkg}" + [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] \ + || fail "${repo}/os/${arch}/${pkg} does not link to $(get_pkgpool_for_host)/${pkg}" - bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkg} || fail "${pkg} not in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" + ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" ] \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkg}) \ + || fail "${pkg} not in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" local pkgbase=$(getpkgbase "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}") svn up -q "${TMP}/svn-packages-copy/${pkgbase}" - [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-${arch}" ] || fail "svn-packages-copy/${pkgbase}/repos/${repo}-${arch} does not exist" + [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-${arch}" ] \ + || fail "svn-packages-copy/${pkgbase}/repos/${repo}-${arch} does not exist" } checkRemovedPackage() { @@ -118,10 +129,13 @@ checkRemovedPackage() { local pkgbase=$2 local arch=$3 - bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkgbase} && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" + ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" ] \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkgbase}) \ + && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" svn up -q "${TMP}/svn-packages-copy/${pkgbase}" - [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-${arch}" ] && fail "svn-packages-copy/${pkgbase}/repos/${repo}-${arch} should not exist" + [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-${arch}" ] \ + && fail "svn-packages-copy/${pkgbase}/repos/${repo}-${arch} should not exist" } checkRemovedAnyPackage() { @@ -130,9 +144,12 @@ checkRemovedAnyPackage() { local arch for arch in i686 x86_64; do - bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkgbase} && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" + ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" ] \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkgbase}) \ + && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" done svn up -q "${TMP}/svn-packages-copy/${pkgbase}" - [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-any" ] && fail "svn-packages-copy/${pkgbase}/repos/${repo}-any should not exist" + [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-any" ] \ + && fail "svn-packages-copy/${pkgbase}/repos/${repo}-any should not exist" } \ No newline at end of file -- cgit v1.2.3-54-g00ecf From a422060414670bb49d2422a38467b73ae01e7ecb Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 13 Aug 2010 09:47:31 +0200 Subject: Use common functions to print messages, warnings and errors These functions are copied from makepkg --- cron-jobs/create-filelists | 4 +-- cron-jobs/ftpdir-cleanup | 8 ++--- cron-jobs/sourceballs | 2 +- db-functions | 70 +++++++++++++++++++++++++++--------- db-move | 10 +++--- db-remove | 10 +++--- db-update | 48 ++++++++++++------------- misc-scripts/ftpdir-cleanup-repo | 78 +++++++++++++++------------------------- misc-scripts/make-sourceball | 14 ++++---- test/lib/common.inc | 10 +++--- testing2x | 6 ++-- 11 files changed, 134 insertions(+), 126 deletions(-) (limited to 'db-move') diff --git a/cron-jobs/create-filelists b/cron-jobs/create-filelists index 8c354fc..9249408 100755 --- a/cron-jobs/create-filelists +++ b/cron-jobs/create-filelists @@ -23,7 +23,7 @@ case "${DBEXT}" in *.gz) TAR_OPT="z" ;; *.bz2) TAR_OPT="j" ;; *.xz) TAR_OPT="J" ;; - *) echo "Unknown compression type for DBEXT=${DBEXT}" && exit 1 ;; + *) die "Unknown compression type for DBEXT=${DBEXT}" ;; esac FILESEXT="${DBEXT//db/files}" @@ -42,7 +42,7 @@ for repo in ${repos[@]}; do mkdir -p "${DBDIR}/${repodir}" bsdtar -xf "${targetdir}/${repodir}/${REPO_DB_FILE}" -C "${DBDIR}/${repodir}" else - echo "Fail! Does the repo $repo with arch $arch even exist?" + error "Fail! Does the repo $repo with arch $arch even exist?" continue fi diff --git a/cron-jobs/ftpdir-cleanup b/cron-jobs/ftpdir-cleanup index 7668ab5..3456e9c 100755 --- a/cron-jobs/ftpdir-cleanup +++ b/cron-jobs/ftpdir-cleanup @@ -29,13 +29,11 @@ done popd >/dev/null if [ -n "$to_cleanup" ]; then - echo " The following packages are no longer in any repo" - echo " They will be moved to $CLEANUP_DESTDIR" + msg "The following packages are no longer in any repo" for f in $to_cleanup; do - echo " $(basename "$f")" + msg2 "$(basename "$f")" done - echo "" - mv $to_cleanup "$CLEANUP_DESTDIR" + ${CLEANUP_DRYRUN} || mv $to_cleanup "$CLEANUP_DESTDIR" fi script_unlock diff --git a/cron-jobs/sourceballs b/cron-jobs/sourceballs index 78c3959..b82e375 100755 --- a/cron-jobs/sourceballs +++ b/cron-jobs/sourceballs @@ -22,7 +22,7 @@ for repo in ${repos[@]}; do for arch in ${ARCHES[@]} any; do ftppath="$ftpbase/$repo/os/$arch" if [ ! -d "$ftppath" ]; then - echo "FTP path does not exist: $ftppath" >2 + error "FTP path does not exist: $ftppath" continue fi cd $ftppath diff --git a/db-functions b/db-functions index f22567b..0c96913 100644 --- a/db-functions +++ b/db-functions @@ -16,11 +16,48 @@ restore_umask () { WORKDIR=$(mktemp -d /tmp/$(basename $0).XXXXXXXXXX) LOCKS=() +# check if messages are to be printed using color +unset ALL_OFF BOLD BLUE GREEN RED YELLOW +if [[ -t 2 ]]; then + ALL_OFF="$(tput sgr0)" + BOLD="$(tput bold)" + BLUE="${BOLD}$(tput setaf 4)" + GREEN="${BOLD}$(tput setaf 2)" + RED="${BOLD}$(tput setaf 1)" + YELLOW="${BOLD}$(tput setaf 3)" +fi +readonly ALL_OFF BOLD BLUE GREEN RED YELLOW + +plain() { + local mesg=$1; shift + printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" +} + +msg() { + local mesg=$1; shift + printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" +} + +msg2() { + local mesg=$1; shift + printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" +} + +warning() { + local mesg=$1; shift + printf "${YELLOW}==> WARNING:${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 +} + +error() { + local mesg=$1; shift + printf "${RED}==> ERROR${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 +} + script_lock() { local LOCKDIR="$TMPDIR/.scriptlock.$(basename $0)" if ! mkdir "$LOCKDIR" >/dev/null 2>&1 ; then local _owner="$(/usr/bin/stat -c %U $LOCKDIR)" - echo "Error: Script $(basename $0) is already locked by $_owner." >&2 + error "Script $(basename $0) is already locked by $_owner." exit 1 else set_umask @@ -31,7 +68,7 @@ script_lock() { script_unlock() { local LOCKDIR="$TMPDIR/.scriptlock.$(basename $0)" if [ ! -d "$LOCKDIR" ]; then - echo "Warning: Script $(basename $0) was not locked!" >&2 + warning "Script $(basename $0) was not locked!" restore_umask return 1 else @@ -51,12 +88,12 @@ cleanup() { repo=${l%.*} arch=${l#*.} if [ -d "$TMPDIR/.repolock.$repo.$arch" ]; then - echo "Removing left over lock from $repo/$arch" >&2 + msg "Removing left over lock from $repo/$arch" repo_unlock $repo $arch fi done if [ -d "$TMPDIR/.scriptlock.$(basename $0)" ]; then - echo "Removing left over lock from $(basename $0)" >&2 + msg "Removing left over lock from $(basename $0)" script_unlock fi rm -rf "$WORKDIR" @@ -64,12 +101,12 @@ cleanup() { } abort() { - echo 'Aborting...' >&2 + msg 'Aborting...' cleanup 0 } die() { - echo "$*" >&2 + error "$*" cleanup 1 } @@ -99,7 +136,8 @@ repo_lock () { while [ $_count -le $_trial ] || $_lockblock ; do if ! mkdir "$LOCKDIR" >/dev/null 2>&1 ; then _owner="$(/usr/bin/stat -c %U $LOCKDIR)" - echo "Warning: Repo $1-$2 is already locked by $_owner. Retrying in $LOCK_DELAY seconds..." >&2 + warning "Repo $1-$2 is already locked by $_owner. " \ + "Retrying in $LOCK_DELAY seconds..." else LOCKS[${#LOCKS[*]}]="$1.$2" set_umask @@ -109,14 +147,14 @@ repo_lock () { let _count=$_count+1 done - echo "Error: Repo $1-$2 is already locked by $_owner. Giving up!" >&2 + error "Repo $1-$2 is already locked by $_owner. Giving up!" return 1 } repo_unlock () { #repo_unlock local LOCKDIR="$TMPDIR/.repolock.$1.$2" if [ ! -d "$LOCKDIR" ]; then - echo "Warning: Repo lock $1-$2 was not locked!" >&2 + warning "Repo lock $1-$2 was not locked!" restore_umask return 1 else @@ -153,7 +191,7 @@ getpkgname() { _name="$(_grep_pkginfo "$1" "^pkgname")" if [ -z "$_name" ]; then - echo "Error: Package '$1' has no pkgname in the PKGINFO. Fail!" >&2 + error "Package '$1' has no pkgname in the PKGINFO. Fail!" exit 1 fi @@ -166,7 +204,7 @@ getpkgver() { _ver="$(_grep_pkginfo "$1" "^pkgver")" if [ -z "$_ver" ]; then - echo "Error: Package '$1' has no pkgver in the PKGINFO. Fail!" >&2 + error "Package '$1' has no pkgver in the PKGINFO. Fail!" exit 1 fi @@ -175,10 +213,10 @@ getpkgver() { getpkgfile() { if [[ ${#} -ne 1 ]]; then - echo 'Error: No canonical package found!' >&2 + error 'No canonical package found!' exit 1 elif [ ! -f "${1}" ]; then - echo "Error: Package ${1} not found!" >&2 + error "Package ${1} not found!" exit 1 fi @@ -188,13 +226,13 @@ getpkgfile() { getpkgfiles() { local f if [ ! -z "$(echo ${@%\.*} | sed "s/ /\n/g" | sort | uniq -D)" ]; then - echo 'Error: Duplicate packages found!'>&2 + error 'Duplicate packages found!' exit 1 fi for f in ${@}; do if [ ! -f "${f}" ]; then - echo "Error: Package ${f} not found!" >&2 + error "Package ${f} not found!" exit 1 fi done @@ -208,7 +246,7 @@ check_pkg_arch () { _arch="$(_grep_pkginfo "$1" "^arch")" if [ -z "$_arch" ]; then - echo "Error: Package '$1' has no arch in the PKGINFO. Fail!" >&2 + error "Package '$1' has no arch in the PKGINFO. Fail!" return 1 fi if [ "$_arch" = "$2" ]; then diff --git a/db-move b/db-move index 41b360d..207baec 100755 --- a/db-move +++ b/db-move @@ -1,7 +1,7 @@ #!/bin/bash if [ $# -ne 4 ]; then - echo "usage: $(basename $0) " + msg "usage: $(basename $0) " exit 1 fi @@ -24,7 +24,7 @@ svnrepo_from="$repofrom-$arch" svnrepo_to="$repoto-$arch" if ! check_repo_permission $repoto || ! check_repo_permission $repofrom; then - echo "Error: You don't have permission to move packages from ${repofrom} to ${repoto}" + error "You don't have permission to move packages from ${repofrom} to ${repoto}" exit 1 fi @@ -41,7 +41,7 @@ if [ -d "$packagebase/repos/$svnrepo_from" ]; then pkgver=$(. "$packagebase/repos/$svnrepo_from/PKGBUILD"; echo ${pkgver}) pkgrel=$(. "$packagebase/repos/$svnrepo_from/PKGBUILD"; echo ${pkgrel}) - echo -n "Moving $packagebase from $repofrom to $repoto..." + msg "Moving $packagebase from $repofrom to $repoto..." if [ -d "$packagebase/repos/$svnrepo_to" ]; then /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" @@ -71,10 +71,8 @@ if [ -d "$packagebase/repos/$svnrepo_from" ]; then /usr/bin/repo-add -q "$ftppath_to/${tarch}/$repoto$DBEXT" ${pkgfiles} >/dev/null || die "Error in repo-add $pkgfiles" /usr/bin/repo-remove -q "$ftppath_from/${tarch}/$repofrom$DBEXT" ${pkgname[@]} >/dev/null || die "Error in repo-remove ${pkgname[@]}" done - - echo 'done' else - die "Error: $packagebase is not in repo $repofrom" + die "$packagebase is not in repo $repofrom" fi repo_unlock $repoto $arch || exit 1 diff --git a/db-remove b/db-remove index 1492d18..2f05c16 100755 --- a/db-remove +++ b/db-remove @@ -1,7 +1,7 @@ #!/bin/bash if [ $# -ne 3 ]; then - echo "usage: $(basename $0) " + msg "usage: $(basename $0) " exit 1 fi @@ -16,13 +16,13 @@ ftppath="$FTP_BASE/$reponame/os" svnrepo="$reponame-$arch" if ! check_repo_permission $reponame; then - echo "Error: You don't have permission to remove packages from ${reponam}" + error "You don't have permission to remove packages from ${reponam}" exit 1 fi repo_lock $reponame $arch || exit 1 -echo -n "Removing $packagebase from $reponame..." +msg "Removing $packagebase from $reponame..." cd "$WORKDIR" /usr/bin/svn checkout -q -N $SVNREPO checkout >/dev/null cd checkout @@ -33,7 +33,7 @@ if [ -d "$packagebase/repos/$svnrepo" ]; then /usr/bin/svn rm --force -q "$packagebase/repos/$svnrepo" /usr/bin/svn commit -q -m "$(basename $0): $packagebase removed by $(id -un)" else - die "Error: $packagebase not found in $svnrepo" + die "$packagebase not found in $svnrepo" fi cd "$WORKDIR" @@ -53,8 +53,6 @@ for tarch in $arches; do /usr/bin/repo-remove -q "$ftppath/$tarch/$reponame$DBEXT" ${pkgname[@]} >/dev/null done -echo 'done' - repo_unlock $reponame $arch || exit 1 # vim: set ts=4 sw=4 noet ft=sh: diff --git a/db-update b/db-update index c049714..b56a70f 100755 --- a/db-update +++ b/db-update @@ -1,7 +1,7 @@ #!/bin/bash if [ $# -ne 1 ]; then - echo "usage: $(basename $0) " + msg "usage: $(basename $0) " exit 1 fi @@ -12,7 +12,7 @@ reponame="$1" current_arch="" if ! check_repo_permission "$reponame"; then - echo "error: you shouldn't be updating $reponame on this server!" + error "you shouldn't be updating $reponame on this server!" exit 1 fi @@ -21,11 +21,11 @@ ANYPKGS="" stagedir="$STAGING/$reponame" if [ ! -d $stagedir ]; then - echo "error: staging directory missing: $stagedir" >&2 + error "staging directory missing: $stagedir" exit 1 fi -echo -n "Updating $reponame..." +msg "Updating $reponame..." # Remove any package from $stagedir that is already in the FTP repository for current_arch in ${ARCHES[@]} any; do @@ -33,8 +33,8 @@ for current_arch in ${ARCHES[@]} any; do for f in $stagedir/*-$current_arch$PKGEXT; do bf=$(basename $f) if [[ -f $ftppath/$bf ]]; then - echo " WARNING: Package file $bf already exists in FTP repo" - echo " Removing from $stagedir" + warning " Package file $bf already exists in FTP repo" \ + " Removing from $stagedir" /bin/rm $f fi done @@ -59,7 +59,7 @@ if [ -n "$ANYPKGS" ]; then pkgbase="$(getpkgbase $pkg)" svnrepo="$reponame-any" if ! check_pkg_arch "$pkg" "any"; then - echo " ERROR: $pkgfile is not architecture independent!" + error "$pkgfile is not architecture independent!" else /usr/bin/svn up -q $pkgbase if [ -d "$pkgbase/repos/$svnrepo" ]; then @@ -68,10 +68,10 @@ if [ -n "$ANYPKGS" ]; then if echo "$pkgfile" | grep -q "$pkgname-$pkgver-$pkgrel-any"; then to_add_any="$to_add_any $pkg" else - echo " WARNING: $pkgfile does not match PKGBUILD in $svnrepo" + warning "$pkgfile does not match PKGBUILD in $svnrepo" fi else - echo " WARNING: Package $pkgbase not found in $svnrepo" + warning "Package $pkgbase not found in $svnrepo" fi fi done @@ -86,9 +86,9 @@ for current_arch in ${ARCHES[@]}; do poolrel="../../../$(get_pkgpool_for_host)" if [ ! -d "$ftppath" ]; then - echo "FTP path for this repo ($reponame) is missing" - echo " -> $ftppath" - echo "Please contact a system administrator" + error "FTP path for this repo ($reponame) is missing" \ + " -> $ftppath" \ + "Please contact a system administrator" exit 1 fi @@ -120,7 +120,7 @@ for current_arch in ${ARCHES[@]}; do cd "$WORKDIR" /usr/bin/svn checkout -N $SVNREPO checkout >/dev/null cd checkout - + if [ -n "$ADDPKGS" ]; then for pkg in $ADDPKGS; do pkgfile=$(basename $pkg) @@ -128,7 +128,7 @@ for current_arch in ${ARCHES[@]}; do pkgbase="$(getpkgbase $pkg)" if ! check_pkg_arch "$pkg" "$current_arch"; then - echo " ERROR: $pkgfile was built for the wrong architecture" + error "$pkgfile was built for the wrong architecture" else /usr/bin/svn up -q $pkgbase if [ -d "$pkgbase/repos/$svnrepo" ]; then @@ -137,10 +137,10 @@ for current_arch in ${ARCHES[@]}; do if echo "$pkgfile" | grep -q "$pkgname-$pkgver-$pkgrel-$current_arch"; then to_add="$to_add $pkg" else - echo " WARNING: $pkgfile does not match PKGBUILD in $svnrepo" + warning "$pkgfile does not match PKGBUILD in $svnrepo" fi else - echo " WARNING: Package $pkgbase not found in $svnrepo" + warning "Package $pkgbase not found in $svnrepo" fi fi done @@ -156,10 +156,10 @@ for current_arch in ${ARCHES[@]}; do /usr/bin/repo-add -q "$reponame-$current_arch$DBEXT" $pkgs >/dev/null else rm -f "build/$reponame-$current_arch$DBEXT" - echo "Errors found when adding packages" + error "Errors found when adding packages" fi else - echo "No packages to add" + warning "No packages to add" fi # if non empty, move all build dirs @@ -168,11 +168,11 @@ for current_arch in ${ARCHES[@]}; do for f in "$WORKDIR/build/"*-$current_arch$PKGEXT; do /bin/chmod 664 "$f" &>/dev/null if ! /bin/cp "$f" "$poolpath/"; then - die "error: failure while copying files to $poolpath" + die "failure while copying files to $poolpath" fi fname="$(basename $f)" if ! ln -s "$poolrel/$fname" "$ftppath/$fname"; then - die "error: failure symlinking $fname to $ftppath" + die "failure symlinking $fname to $ftppath" fi done fi @@ -181,11 +181,11 @@ for current_arch in ${ARCHES[@]}; do /bin/chmod 664 "$f" &>/dev/null fname="$(basename $f)" if ! /bin/cp "$f" "$poolpath/"; then - die "error: failure while copying files to $poolpath" + die "failure while copying files to $poolpath" fi if ! ln -s "$poolrel/$fname" "$ftppath/$fname"; then - die "error: failure symlinking $fname to $ftppath" + die "failure symlinking $fname to $ftppath" fi done fi @@ -194,7 +194,7 @@ for current_arch in ${ARCHES[@]}; do fi ln -sf "$reponame$DBEXT" "$ftppath/$reponame${DBEXT%.tar.*}" else - echo "Nothing to copy, no work done" + warning "Nothing to copy, no work done" fi if [ -n "$to_add" ]; then @@ -208,6 +208,4 @@ if [ -n "$to_add_any" ]; then /bin/rm $to_add_any fi -echo 'done' - # vim: set ts=4 sw=4 noet ft=sh: diff --git a/misc-scripts/ftpdir-cleanup-repo b/misc-scripts/ftpdir-cleanup-repo index 12f726c..20f297b 100755 --- a/misc-scripts/ftpdir-cleanup-repo +++ b/misc-scripts/ftpdir-cleanup-repo @@ -1,7 +1,7 @@ #!/bin/bash if [ $# -ne 1 ]; then - echo "usage: $(basename $0) " + msg "usage: $(basename $0) " exit 1 fi @@ -13,6 +13,7 @@ reponame=$1 . "$(dirname $0)/../config" clean_pkgs () { + if ! ${CLEANUP_DRYRUN}; then for pkg in "$@"; do if [ -h "$pkg" ]; then rm -f "$pkg" @@ -20,9 +21,10 @@ clean_pkgs () { mv "$pkg" "$CLEANUP_DESTDIR" fi done + fi } -${CLEANUP_DRYRUN} && echo 'dry run mode is active' +${CLEANUP_DRYRUN} && warning 'dry run mode is active' ftppath_base="$FTP_BASE/$reponame/os" @@ -38,26 +40,23 @@ for arch in ${ARCHES[@]}; do EXTRAFILES="" if [ ! -d "$ftppath" ]; then - echo "FTP path '$ftppath' does not exist" + error "FTP path '$ftppath' does not exist" exit 1 fi if ! cd "${CLEANUP_TMPDIR}" ; then - echo "Failed to cd to ${CLEANUP_TMPDIR}" + error "Failed to cd to ${CLEANUP_TMPDIR}" exit 1 fi if [ ! -f "$ftppath/$reponame$DBEXT" ]; then - echo "" - echo "WARNING: The file \"$ftppath/$reponame$DBEXT\" could not be found, skipping." - echo "" + msg "The file \"$ftppath/$reponame$DBEXT\" could not be found, skipping." repo_unlock $reponame $arch continue fi if ! bsdtar xf "$ftppath/$reponame$DBEXT"; then - echo "" - echo "ERROR: Command failed: bsdtar xf \"$ftppath/$reponame$DBEXT\"" + error "Command failed: bsdtar xf \"$ftppath/$reponame$DBEXT\"" exit 1 fi @@ -106,7 +105,7 @@ for arch in ${ARCHES[@]}; do MISSINGFILES="" for mf in $missfiles; do if [ -e "${ftppath_base}/any/${mf}" ]; then - echo "Restoring missing 'any' symlink: ${mf}" + msg "Restoring missing 'any' symlink: ${mf}" ${CLEANUP_DRYRUN} || ln -s "../any/${mf}" "${ftppath}" else MISSINGFILES="${MISSINGFILES} ${mf}" @@ -120,53 +119,36 @@ for arch in ${ARCHES[@]}; do continue fi - echo "Scan complete for $reponame ($arch) at ${ftppath}" - - if [ -n "$DELETEFILES" ]; then - echo " The following files are out of date" - for f in $DELETEFILES; do - echo " $f" - done - echo "" - fi - - if [ -n "$DELETESYMLINKS" ]; then - echo " The following symlinks are out of date" - echo " They will be deleted" - for f in $DELETESYMLINKS; do - echo " $f" - done - echo "" - fi + msg "Scan complete for $reponame ($arch) at ${ftppath}" if [ -n "$MISSINGFILES" ]; then - echo " The following files are missing in the repo" for f in $MISSINGFILES; do - echo " $f" - done - echo "" - fi - - if [ -n "$EXTRAFILES" ]; then - echo " The following files are in the repo but not the db" - for f in $EXTRAFILES; do - echo " $f" + error "$f is missing" done fi if [ -n "${DELETEFILES}" ]; then - ${CLEANUP_DRYRUN} || clean_pkgs ${DELETEFILES} - echo "" + msg "The following files are out of date" + for f in $DELETEFILES; do + msg2 "$f" + done + clean_pkgs ${DELETEFILES} fi if [ -n "${DELETESYMLINKS}" ]; then - ${CLEANUP_DRYRUN} || clean_pkgs ${DELETESYMLINKS} - echo "" + msg "The following symlinks are out of date" + for f in $DELETESYMLINKS; do + msg2 "$f" + done + clean_pkgs ${DELETESYMLINKS} fi if [ -n "${EXTRAFILES}" ]; then - ${CLEANUP_DRYRUN} || clean_pkgs ${EXTRAFILES} - echo "" + msg "The following files are in the repo but not the db" + for f in $EXTRAFILES; do + msg2 "$f" + done + clean_pkgs ${EXTRAFILES} fi done @@ -193,15 +175,13 @@ if [ -d "$ftppath_base/any" ]; then fi if [ -n "$ARCHINDEPFILES" ]; then - echo " The following architecture independent packages" - echo " are not symlinked in the architecture repositories." + msg "The following architecture independent packages are not symlinked in the architecture repositories." for f in $ARCHINDEPFILES; do - echo " $f" + msg2 "$f" done fi if [ -d "$ftppath_base/any" -a -n "${ARCHINDEPFILES}" ]; then cd "$ftppath_base/any" - ${CLEANUP_DRYRUN} || clean_pkgs ${ARCHINDEPFILES} - echo "" + clean_pkgs ${ARCHINDEPFILES} fi diff --git a/misc-scripts/make-sourceball b/misc-scripts/make-sourceball index 8e26eec..5bd155f 100755 --- a/misc-scripts/make-sourceball +++ b/misc-scripts/make-sourceball @@ -1,8 +1,8 @@ #!/bin/bash if [ $# -ne 3 -a $# -ne 4 ]; then - echo "usage: $(basename $0) [-f] " - echo " -f Force building. Skip license checks" + msg "usage: $(basename $0) [-f] " + msg " -f Force building. Skip license checks" exit 1 fi @@ -31,17 +31,17 @@ create_srcpackage() { pkgrel=$(. PKGBUILD; echo ${pkgrel}) if ! [ $FORCE == 1 ] && ! chk_license ${license[@]} ; then #Removed so as not to clutter failed.txt - #echo -e "\t$packagename license (${license[@]}) does not require source tarballs" >&2 + #warning "$packagename license (${license[@]}) does not require source tarballs" cleanup 0 else - echo "Creating source tarball for $packagename-$pkgver-$pkgrel" + msg "Creating source tarball for $packagename-$pkgver-$pkgrel" fi local logfile="$logpath/$packagename" if ! /usr/bin/makepkg --allsource --ignorearch >"$logfile" 2>&1; then popd >/dev/null /bin/gzip -f -9 "$logfile" - die "\tFailed to download source for $packagename-$pkgver-$pkgrel ($reponame-$arch)" + die "Failed to download source for $packagename-$pkgver-$pkgrel ($reponame-$arch)" fi /bin/rm -f "$logfile"{,.gz} @@ -66,13 +66,13 @@ if [[ "$reponame" = "community" || "$reponame" = "community-testing" ]]; then if /usr/bin/svn export -q "$SVNREPOCOMMUNITY/$packagename" $packagename; then create_srcpackage "$packagename/repos/$reponame-$arch" else - die "\tPackage '$packagename' does not exist in repo '$reponame-$arch'" + die "Package '$packagename' does not exist in repo '$reponame-$arch'" fi else if /usr/bin/svn export -q "$SVNREPO/$packagename" $packagename; then create_srcpackage "$packagename/repos/$reponame-$arch" else - die "\tPackage '$packagename' does not exist in repo '$reponame-$arch'" + die "Package '$packagename' does not exist in repo '$reponame-$arch'" fi fi diff --git a/test/lib/common.inc b/test/lib/common.inc index 795d01a..5c76eb5 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -6,7 +6,7 @@ oneTimeSetUp() { local p pkgdir="$(mktemp -d /dev/shm/$(basename $0).XXXXXXXXXX)" cp -r ${curdir}/packages/* "${pkgdir}" - echo -n 'Building packages...' + msg 'Building packages...' for p in "${pkgdir}"/*; do pushd $p >/dev/null linux32 makepkg -cf --config ${curdir}/lib/makepkg-i686.conf >/dev/null 2>&1 || die 'makepkg failed' @@ -15,7 +15,6 @@ oneTimeSetUp() { || die 'makepkg failed' popd >/dev/null done - echo 'done' echo } @@ -29,14 +28,14 @@ setUp() { #[ -f "${curdir}/../config.local" ] && die "${curdir}/../config.local exists" TMP="$(mktemp -d /dev/shm/$(basename $0).XXXXXXXXXX)" - #echo "Using ${TMP}" + #msg "Using ${TMP}" mkdir -p "${TMP}/"{ftp,tmp,staging,{package,source}-cleanup,svn-{packages,community}-{copy,repo}} mkdir -p "${TMP}/ftp/"{core,extra,community,testing,community-testing}/os/{i686,any,x86_64} mkdir -p "${TMP}/ftp/pool/"{packages,community} mkdir -p "${TMP}/staging/"{core,extra,community,testing,community-testing} - echo -n 'Creating svn repository...' + msg 'Creating svn repository...' svnadmin create "${TMP}/svn-packages-repo" svnadmin create "${TMP}/svn-community-repo" svn checkout -q "file://${TMP}/svn-packages-repo" "${TMP}/svn-packages-copy" @@ -49,7 +48,6 @@ setUp() { svn add -q "${TMP}/svn-packages-copy"/${pkg} svn commit -q -m"initial commit of ${pkg}" "${TMP}/svn-packages-copy" done - echo 'done' cat < "${curdir}/../config.local" FTP_BASE="${TMP}/ftp" @@ -152,4 +150,4 @@ checkRemovedAnyPackage() { svn up -q "${TMP}/svn-packages-copy/${pkgbase}" [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-any" ] \ && fail "svn-packages-copy/${pkgbase}/repos/${repo}-any should not exist" -} \ No newline at end of file +} diff --git a/testing2x b/testing2x index bf48be6..3626432 100755 --- a/testing2x +++ b/testing2x @@ -22,16 +22,16 @@ for pkg in $*; do if [ -f "${pkg}/repos/testing-${_arch}/PKGBUILD" ]; then for repo in core extra; do if [ -f "${pkg}/repos/${repo}-${_arch}/PKGBUILD" ]; then - echo "===> Moving package '${pkg}': testing-${_arch} -> ${repo}-${_arch}" + msg "Moving package '${pkg}': testing-${_arch} -> ${repo}-${_arch}" $(dirname $0)/db-move "${pkg}" "testing" "${repo}" "${_arch}" moved=1 break fi done if [ ${moved} -eq 0 ]; then - echo "===> Warning: ${pkg} is only in testing-${_arch}, cannot determine where to move it" + warning "${pkg} is only in testing-${_arch}, cannot determine where to move it" fi else - echo "===> Warning: ${pkg} is not in testing-${_arch}" + warning "${pkg} is not in testing-${_arch}" fi done -- cgit v1.2.3-54-g00ecf From cfa19b31cdeb6698d69ae9a82904c09d3d65a5d7 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 14 Aug 2010 20:20:11 +0200 Subject: Don't hardcode supported architectures in db-move --- db-move | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db-move') diff --git a/db-move b/db-move index 207baec..68cfc07 100755 --- a/db-move +++ b/db-move @@ -13,7 +13,7 @@ repofrom="$2" repoto="$3" arch="$4" if [ "${arch}" == 'any' ]; then - tarches=('i686' 'x86_64') + tarches=(${ARCHES[@]}) else tarches=("${arch}") fi -- cgit v1.2.3-54-g00ecf From 55aa721771c7486c447b270325c504724622fd00 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 14 Aug 2010 22:41:16 +0200 Subject: Prepare support for multiple packages in db-move --- db-move | 87 +++++++++++++++++++++++++++++++++--------------------------- test/runTest | 10 +++---- 2 files changed, 53 insertions(+), 44 deletions(-) (limited to 'db-move') diff --git a/db-move b/db-move index 68cfc07..4c18167 100755 --- a/db-move +++ b/db-move @@ -1,17 +1,18 @@ #!/bin/bash if [ $# -ne 4 ]; then - msg "usage: $(basename $0) " + msg "usage: $(basename $0) ..." exit 1 fi . "$(dirname $0)/db-functions" . "$(dirname $0)/config" -packagebase="$1" -repofrom="$2" -repoto="$3" -arch="$4" +args=(${@}) +repofrom="${args[0]}" +repoto="${args[1]}" +arch="${args[2]}" +# TODO: make db-move arch-independent? if [ "${arch}" == 'any' ]; then tarches=(${ARCHES[@]}) else @@ -27,53 +28,61 @@ if ! check_repo_permission $repoto || ! check_repo_permission $repofrom; then error "You don't have permission to move packages from ${repofrom} to ${repoto}" exit 1 fi +# TODO: add other tests before touch the repos repo_lock $repoto $arch || exit 1 repo_lock $repofrom $arch || exit 1 -cd "$WORKDIR" +pushd "$WORKDIR" >/dev/null /usr/bin/svn checkout -q -N $SVNREPO checkout >/dev/null -cd checkout +pushd checkout >/dev/null -/usr/bin/svn up -q $packagebase -if [ -d "$packagebase/repos/$svnrepo_from" ]; then - pkgname=($(. "$packagebase/repos/$svnrepo_from/PKGBUILD"; echo ${pkgname[@]})) - pkgver=$(. "$packagebase/repos/$svnrepo_from/PKGBUILD"; echo ${pkgver}) - pkgrel=$(. "$packagebase/repos/$svnrepo_from/PKGBUILD"; echo ${pkgrel}) +add_pkgs=() +remove_pkgs=() +for pkgbase in ${args[@]:3}; do + # TODO: optimize + /usr/bin/svn up -q $pkgbase + if [ -d "$pkgbase/repos/$svnrepo_from" ]; then + pkgname=($(. "$pkgbase/repos/$svnrepo_from/PKGBUILD"; echo ${pkgname[@]})) + pkgver=$(. "$pkgbase/repos/$svnrepo_from/PKGBUILD"; echo ${pkgver}) + pkgrel=$(. "$pkgbase/repos/$svnrepo_from/PKGBUILD"; echo ${pkgrel}) - msg "Moving $packagebase from $repofrom to $repoto..." - if [ -d "$packagebase/repos/$svnrepo_to" ]; then - /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 + msg "Moving $pkgbase from $repofrom to $repoto..." + if [ -d "$pkgbase/repos/$svnrepo_to" ]; then + /usr/bin/svn rm --force -q "$pkgbase/repos/$svnrepo_to" + /usr/bin/svn commit -q -m "$(basename $0): $pkgbase removed by $(id -un) for move to $repoto" + fi - /usr/bin/svn mv -q -r HEAD "$packagebase/repos/$svnrepo_from" "$packagebase/repos/$svnrepo_to" - /usr/bin/svn commit -q -m "$(basename $0): moved $packagebase from [$repofrom] to [$repoto] ($arch)" + /usr/bin/svn mv -q -r HEAD "$pkgbase/repos/$svnrepo_from" "$pkgbase/repos/$svnrepo_to" + /usr/bin/svn commit -q -m "$(basename $0): moved $pkgbase from [$repofrom] to [$repoto] ($arch)" - pkgfiles='' - for i in ${pkgname[@]}; do - for tarch in ${tarches[@]}; do - pkgpath=$(getpkgfile "$ftppath_from/${tarch}/"$i-$pkgver-$pkgrel-$arch$PKGEXT) - pkgfile=$(basename "${pkgpath}") + for i in ${pkgname[@]}; do + for tarch in ${tarches[@]}; do + pkgpath=$(getpkgfile "$ftppath_from/${tarch}/"$i-$pkgver-$pkgrel-$arch$PKGEXT) + pkgfile=$(basename "${pkgpath}") - # copy package to pool if needed - # TODO: can be removed once every package has been moved to the package pool - if [ ! -f $FTP_BASE/$(get_pkgpool_for_host)/$pkgfile ]; then - cp $pkgpath $FTP_BASE/$(get_pkgpool_for_host) - fi - ln -s "../../../$(get_pkgpool_for_host)/${pkgfile}" $ftppath_to/${tarch}/ + # copy package to pool if needed + # TODO: can be removed once every package has been moved to the package pool + if [ ! -f $FTP_BASE/$(get_pkgpool_for_host)/$pkgfile ]; then + cp $pkgpath $FTP_BASE/$(get_pkgpool_for_host) + fi + ln -s "../../../$(get_pkgpool_for_host)/${pkgfile}" $ftppath_to/${tarch}/ + done + add_pkgs[${#add_pkgs[*]}]="$FTP_BASE/$(get_pkgpool_for_host)/${pkgfile}" + remove_pkgs[${#remove_pkgs[*]}]=${i} done + else + die "$pkgbase is not in repo $repofrom" + fi +done - pkgfiles="${pkgfiles} $FTP_BASE/$(get_pkgpool_for_host)/${pkgfile}" - done +for tarch in ${tarches[@]}; do + /usr/bin/repo-add -q "$ftppath_to/${tarch}/$repoto$DBEXT" ${add_pkgs[@]} >/dev/null || die "Error in repo-add" + /usr/bin/repo-remove -q "$ftppath_from/${tarch}/$repofrom$DBEXT" ${remove_pkgs[@]} >/dev/null || die "Error in repo-remove" +done - for tarch in ${tarches[@]}; do - /usr/bin/repo-add -q "$ftppath_to/${tarch}/$repoto$DBEXT" ${pkgfiles} >/dev/null || die "Error in repo-add $pkgfiles" - /usr/bin/repo-remove -q "$ftppath_from/${tarch}/$repofrom$DBEXT" ${pkgname[@]} >/dev/null || die "Error in repo-remove ${pkgname[@]}" - done -else - die "$packagebase is not in repo $repofrom" -fi +popd >/dev/null +popd >/dev/null repo_unlock $repoto $arch || exit 1 repo_unlock $repofrom $arch || exit 1 diff --git a/test/runTest b/test/runTest index 06ca000..8c1aa04 100755 --- a/test/runTest +++ b/test/runTest @@ -152,7 +152,7 @@ testMoveSimplePackages() { ../db-update for arch in ${arches[@]}; do - ../db-move pkg-simple-a testing extra ${arch} + ../db-move testing extra ${arch} pkg-simple-a done for arch in ${arches[@]}; do @@ -172,7 +172,7 @@ testMoveAnyPackages() { done ../db-update - ../db-move pkg-any-a testing extra any + ../db-move testing extra any pkg-any-a checkAnyPackage extra pkg-any-a-1-1-any.pkg.tar.xz checkRemovedAnyPackage testing pkg-any-a @@ -195,7 +195,7 @@ testMoveSplitPackages() { ../db-update for arch in ${arches[@]}; do - ../db-move pkg-split-a testing extra ${arch} + ../db-move testing extra ${arch} pkg-split-a done for arch in ${arches[@]}; do @@ -338,7 +338,7 @@ testMovePackagesWithoutPool() { for pkgbase in ${pkgs[@]}; do for arch in ${arches[@]}; do - ../db-move ${pkgbase} testing extra ${arch} + ../db-move testing extra ${arch} ${pkgbase} done done @@ -378,7 +378,7 @@ testMoveAnyPackagesWithoutPool() { ../cron-jobs/ftpdir-cleanup >/dev/null for pkgbase in ${pkgs[@]}; do - ../db-move ${pkgbase} testing extra any + ../db-move testing extra any ${pkgbase} done ../cron-jobs/ftpdir-cleanup >/dev/null -- cgit v1.2.3-54-g00ecf From 79db58732efbab54911ccbbb8cd876da29ea48c8 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 15 Aug 2010 18:21:33 +0200 Subject: Move packages of all arches within one transaction db-move does no longer need a specific architecture. It will move all architecures of a given package at once. testing2x has been rewritten to respect these changes and testing2x64 is no longer needed. --- db-move | 143 +++++++++++++++++++++++++++++++---------------------------- test/runTest | 21 +++------ testing2x | 67 ++++++++++++++++------------ 3 files changed, 119 insertions(+), 112 deletions(-) (limited to 'db-move') diff --git a/db-move b/db-move index 4c18167..ae98958 100755 --- a/db-move +++ b/db-move @@ -1,88 +1,97 @@ #!/bin/bash -if [ $# -ne 4 ]; then - msg "usage: $(basename $0) ..." - exit 1 -fi - . "$(dirname $0)/db-functions" . "$(dirname $0)/config" -args=(${@}) -repofrom="${args[0]}" -repoto="${args[1]}" -arch="${args[2]}" -# TODO: make db-move arch-independent? -if [ "${arch}" == 'any' ]; then - tarches=(${ARCHES[@]}) -else - tarches=("${arch}") +if [ $# -lt 3 ]; then + msg "usage: $(basename $0) ..." + exit 1 fi -ftppath_from="$FTP_BASE/$repofrom/os/" -ftppath_to="$FTP_BASE/$repoto/os/" -svnrepo_from="$repofrom-$arch" -svnrepo_to="$repoto-$arch" +args=(${@}) +repo_from="${args[0]}" +repo_to="${args[1]}" +ftppath_from="${FTP_BASE}/${repo_from}/os/" +ftppath_to="${FTP_BASE}/${repo_to}/os/" -if ! check_repo_permission $repoto || ! check_repo_permission $repofrom; then - error "You don't have permission to move packages from ${repofrom} to ${repoto}" - exit 1 +if ! check_repo_permission $repo_to || ! check_repo_permission $repo_from; then + die "You don't have permission to move packages from ${repo_from} to ${repo_to}" fi -# TODO: add other tests before touch the repos -repo_lock $repoto $arch || exit 1 -repo_lock $repofrom $arch || exit 1 +/usr/bin/svn checkout -q -N "${SVNREPO}" "${WORKDIR}/svn" >/dev/null +for pkgbase in ${args[@]:2}; do + /usr/bin/svn up -q "${WORKDIR}/svn/${pkgbase}" >/dev/null + for pkgarch in ${ARCHES[@]} 'any'; do + svnrepo_from="${WORKDIR}/svn/${pkgbase}/repos/${repo_from}-${pkgarch}" + if [ -r "${svnrepo_from}/PKGBUILD" ]; then + continue 2 + fi + done + die "${pkgbase} not found in ${repo_from}" +done + +# TODO: this might lock too much (architectures) +for pkgarch in ${ARCHES[@]}; do + repo_lock ${repo_to} ${pkgarch} || exit 1 + repo_lock ${repo_from} ${pkgarch} || exit 1 +done -pushd "$WORKDIR" >/dev/null -/usr/bin/svn checkout -q -N $SVNREPO checkout >/dev/null -pushd checkout >/dev/null +msg "Moving packages from [${repo_from}] to [${repo_to}]..." -add_pkgs=() -remove_pkgs=() -for pkgbase in ${args[@]:3}; do - # TODO: optimize - /usr/bin/svn up -q $pkgbase - if [ -d "$pkgbase/repos/$svnrepo_from" ]; then - pkgname=($(. "$pkgbase/repos/$svnrepo_from/PKGBUILD"; echo ${pkgname[@]})) - pkgver=$(. "$pkgbase/repos/$svnrepo_from/PKGBUILD"; echo ${pkgver}) - pkgrel=$(. "$pkgbase/repos/$svnrepo_from/PKGBUILD"; echo ${pkgrel}) +declare -A add_pkgs +declare -A remove_pkgs +for pkgbase in ${args[@]:2}; do + for pkgarch in ${ARCHES[@]} 'any'; do + svnrepo_from="${WORKDIR}/svn/${pkgbase}/repos/${repo_from}-${pkgarch}" + svnrepo_to="${WORKDIR}/svn/${pkgbase}/repos/${repo_to}-${pkgarch}" - msg "Moving $pkgbase from $repofrom to $repoto..." - if [ -d "$pkgbase/repos/$svnrepo_to" ]; then - /usr/bin/svn rm --force -q "$pkgbase/repos/$svnrepo_to" - /usr/bin/svn commit -q -m "$(basename $0): $pkgbase removed by $(id -un) for move to $repoto" - fi + if [ -f "${svnrepo_from}/PKGBUILD" ]; then + if [ "${pkgarch}" == 'any' ]; then + tarches=(${ARCHES[@]}) + else + tarches=("${pkgarch}") + fi + msg2 "${pkgbase} ($(echo ${tarches[@]}))" + pkgnames=($(. "${svnrepo_from}/PKGBUILD"; echo ${pkgname[@]})) + pkgver=$(. "${svnrepo_from}/PKGBUILD"; echo "${pkgver}-${pkgrel}") - /usr/bin/svn mv -q -r HEAD "$pkgbase/repos/$svnrepo_from" "$pkgbase/repos/$svnrepo_to" - /usr/bin/svn commit -q -m "$(basename $0): moved $pkgbase from [$repofrom] to [$repoto] ($arch)" + if [ -d "${svnrepo_to}" ]; then + /usr/bin/svn rm --force -q "${svnrepo_to}" + /usr/bin/svn commit -q "${WORKDIR}/svn/${pkgbase}" -m "$(basename $0): ${pkgbase} removed by $(id -un) for move to [${repo_to}] (${pkgarch})" + fi - for i in ${pkgname[@]}; do - for tarch in ${tarches[@]}; do - pkgpath=$(getpkgfile "$ftppath_from/${tarch}/"$i-$pkgver-$pkgrel-$arch$PKGEXT) - pkgfile=$(basename "${pkgpath}") + /usr/bin/svn mv -q -r HEAD "${svnrepo_from}" "${svnrepo_to}" + /usr/bin/svn commit -q "${WORKDIR}/svn/${pkgbase}" -m "$(basename $0): moved ${pkgbase} from [${repo_from}] to [${repo_to}] (${pkgarch})" - # copy package to pool if needed - # TODO: can be removed once every package has been moved to the package pool - if [ ! -f $FTP_BASE/$(get_pkgpool_for_host)/$pkgfile ]; then - cp $pkgpath $FTP_BASE/$(get_pkgpool_for_host) - fi - ln -s "../../../$(get_pkgpool_for_host)/${pkgfile}" $ftppath_to/${tarch}/ + for pkgname in ${pkgnames[@]}; do + for tarch in ${tarches[@]}; do + pkgpath=$(getpkgfile "${ftppath_from}/${tarch}/"${pkgname}-${pkgver}-${pkgarch}${PKGEXT}) + pkgfile=$(basename "${pkgpath}") + + # copy package to pool if needed + # TODO: can be removed once every package has been moved to the package pool + if [ ! -f ${FTP_BASE}/$(get_pkgpool_for_host)/${pkgfile} ]; then + cp ${pkgpath} ${FTP_BASE}/$(get_pkgpool_for_host) + fi + ln -s "../../../$(get_pkgpool_for_host)/${pkgfile}" ${ftppath_to}/${tarch}/ + add_pkgs[${tarch}]+="${FTP_BASE}/$(get_pkgpool_for_host)/${pkgfile} " + remove_pkgs[${tarch}]+="${pkgname} " + done done - add_pkgs[${#add_pkgs[*]}]="$FTP_BASE/$(get_pkgpool_for_host)/${pkgfile}" - remove_pkgs[${#remove_pkgs[*]}]=${i} - done - else - die "$pkgbase is not in repo $repofrom" - fi + fi + done done -for tarch in ${tarches[@]}; do - /usr/bin/repo-add -q "$ftppath_to/${tarch}/$repoto$DBEXT" ${add_pkgs[@]} >/dev/null || die "Error in repo-add" - /usr/bin/repo-remove -q "$ftppath_from/${tarch}/$repofrom$DBEXT" ${remove_pkgs[@]} >/dev/null || die "Error in repo-remove" +for tarch in ${ARCHES[@]}; do + if [ -n "${add_pkgs[${tarch}]}" ]; then + /usr/bin/repo-add -q "${ftppath_to}/${tarch}/${repo_to}${DBEXT}" ${add_pkgs[${tarch}]} >/dev/null \ + || die "Error in repo-add ${add_pkgs[${tarch}]}" + /usr/bin/repo-remove -q "${ftppath_from}/${tarch}/${repo_from}${DBEXT}" ${remove_pkgs[${tarch}]} >/dev/null \ + || die "Error in repo-remove ${remove_pkgs[${tarch}]}" + fi done -popd >/dev/null -popd >/dev/null - -repo_unlock $repoto $arch || exit 1 -repo_unlock $repofrom $arch || exit 1 +for pkgarch in ${ARCHES[@]}; do + repo_unlock ${repo_from} ${pkgarch} + repo_unlock ${repo_to} ${pkgarch} +done diff --git a/test/runTest b/test/runTest index 8c1aa04..03f94c2 100755 --- a/test/runTest +++ b/test/runTest @@ -151,9 +151,7 @@ testMoveSimplePackages() { ../db-update - for arch in ${arches[@]}; do - ../db-move testing extra ${arch} pkg-simple-a - done + ../db-move testing extra pkg-simple-a for arch in ${arches[@]}; do checkPackage extra pkg-simple-a-1-1-${arch}.pkg.tar.xz ${arch} @@ -172,7 +170,7 @@ testMoveAnyPackages() { done ../db-update - ../db-move testing extra any pkg-any-a + ../db-move testing extra pkg-any-a checkAnyPackage extra pkg-any-a-1-1-any.pkg.tar.xz checkRemovedAnyPackage testing pkg-any-a @@ -193,10 +191,7 @@ testMoveSplitPackages() { done ../db-update - - for arch in ${arches[@]}; do - ../db-move testing extra ${arch} pkg-split-a - done + ../db-move testing extra pkg-split-a for arch in ${arches[@]}; do for pkg in "${pkgdir}/pkg-split-a"/*-${arch}.pkg.tar.*; do @@ -336,11 +331,7 @@ testMovePackagesWithoutPool() { ../cron-jobs/ftpdir-cleanup >/dev/null - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - ../db-move testing extra ${arch} ${pkgbase} - done - done + ../db-move testing extra ${pkgs[@]} ../cron-jobs/ftpdir-cleanup >/dev/null @@ -377,9 +368,7 @@ testMoveAnyPackagesWithoutPool() { ../cron-jobs/ftpdir-cleanup >/dev/null - for pkgbase in ${pkgs[@]}; do - ../db-move testing extra any ${pkgbase} - done + ../db-move testing extra ${pkgs[@]} ../cron-jobs/ftpdir-cleanup >/dev/null diff --git a/testing2x b/testing2x index 3626432..83b12fa 100755 --- a/testing2x +++ b/testing2x @@ -3,35 +3,44 @@ . "$(dirname $0)/db-functions" . "$(dirname $0)/config" -case "$0" in - *64) - _arch="x86_64" - ;; - *) - _arch="i686" - ;; -esac +if [ $# -lt 1 ]; then + msg "usage: $(basename $0) ..." + exit 1 +fi -cd "${WORKDIR}" -/usr/bin/svn checkout -N $SVNREPO checkout -cd checkout -for pkg in $*; do - moved=0 - /usr/bin/svn up -q ${pkg} - if [ -f "${pkg}/repos/testing-${_arch}/PKGBUILD" ]; then - for repo in core extra; do - if [ -f "${pkg}/repos/${repo}-${_arch}/PKGBUILD" ]; then - msg "Moving package '${pkg}': testing-${_arch} -> ${repo}-${_arch}" - $(dirname $0)/db-move "${pkg}" "testing" "${repo}" "${_arch}" - moved=1 - break - fi - done - if [ ${moved} -eq 0 ]; then - warning "${pkg} is only in testing-${_arch}, cannot determine where to move it" - fi - else - warning "${pkg} is not in testing-${_arch}" - fi +declare -A pkgs + +for pkgbase in $*; do + if [ ! -d "${WORKDIR}/${pkgbase}" ]; then + /usr/bin/svn export -q "${SVNREPO}/${pkgbase}/repos" "${WORKDIR}/${pkgbase}" >/dev/null + + found_source=false + for pkgarch in ${ARCHES[@]} 'any'; do + svnrepo_from="${WORKDIR}/${pkgbase}/testing-${pkgarch}" + if [ -r "${svnrepo_from}/PKGBUILD" ]; then + found_source=true + break + fi + done + ${found_source} || die "${pkgbase} not found in [testing]" + found_target=false + for pkgarch in ${ARCHES[@]} 'any'; do + for repo in 'core' 'extra'; do + svnrepo_to="${WORKDIR}/${pkgbase}/${repo}-${pkgarch}" + if [ -r "${svnrepo_to}/PKGBUILD" ]; then + found_target=true + pkgs[${repo}]+="${pkgbase} " + break 2 + fi + done + done + ${found_target} || die "${pkgbase} neither found in [core] nor [extra]" + fi +done + +for repo in 'core' 'extra'; do + if [ -n "${pkgs[${repo}]}" ]; then + "$(dirname $0)/db-move" 'testing' "${repo}" ${pkgs[${repo}]} + fi done -- cgit v1.2.3-54-g00ecf From b5fb2927cde513dc0fd82e4fd4dfe3836cf35728 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 15 Aug 2010 20:55:26 +0200 Subject: Lock repos before checking --- db-functions | 4 ++-- db-move | 25 +++++++++++++++++++------ db-update | 32 ++++++++++++++------------------ testing2x | 15 +++++++++++++++ 4 files changed, 50 insertions(+), 26 deletions(-) (limited to 'db-move') diff --git a/db-functions b/db-functions index 1f54dd9..015f254 100644 --- a/db-functions +++ b/db-functions @@ -151,8 +151,8 @@ repo_lock () { while [ $_count -le $_trial ] || $_lockblock ; do if ! mkdir "$LOCKDIR" >/dev/null 2>&1 ; then _owner="$(/usr/bin/stat -c %U $LOCKDIR)" - warning "Repo [${1}] (${2}) is already locked by $_owner. " \ - "Retrying in $LOCK_DELAY seconds..." + warning "Repo [${1}] (${2}) is already locked by $_owner. " + msg2 "Retrying in $LOCK_DELAY seconds..." else LOCKS[${#LOCKS[*]}]="$1.$2" set_umask diff --git a/db-move b/db-move index ae98958..a274cd3 100755 --- a/db-move +++ b/db-move @@ -18,24 +18,37 @@ if ! check_repo_permission $repo_to || ! check_repo_permission $repo_from; then die "You don't have permission to move packages from ${repo_from} to ${repo_to}" fi +# TODO: this might lock too much (architectures) +for pkgarch in ${ARCHES[@]}; do + repo_lock ${repo_to} ${pkgarch} || exit 1 + repo_lock ${repo_from} ${pkgarch} || exit 1 +done + +# check if packages to be moved exist in svn and ftp dir /usr/bin/svn checkout -q -N "${SVNREPO}" "${WORKDIR}/svn" >/dev/null for pkgbase in ${args[@]:2}; do /usr/bin/svn up -q "${WORKDIR}/svn/${pkgbase}" >/dev/null for pkgarch in ${ARCHES[@]} 'any'; do svnrepo_from="${WORKDIR}/svn/${pkgbase}/repos/${repo_from}-${pkgarch}" if [ -r "${svnrepo_from}/PKGBUILD" ]; then + pkgnames=($(. "${svnrepo_from}/PKGBUILD"; echo ${pkgname[@]})) + pkgver=$(. "${svnrepo_from}/PKGBUILD"; echo "${pkgver}-${pkgrel}") + if [ "${pkgarch}" == 'any' ]; then + tarches=(${ARCHES[@]}) + else + tarches=("${pkgarch}") + fi + for pkgname in ${pkgnames[@]}; do + for tarch in ${tarches[@]}; do + getpkgfile "${ftppath_from}/${tarch}/"${pkgname}-${pkgver}-${pkgarch}${PKGEXT} >/dev/null + done + done continue 2 fi done die "${pkgbase} not found in ${repo_from}" done -# TODO: this might lock too much (architectures) -for pkgarch in ${ARCHES[@]}; do - repo_lock ${repo_to} ${pkgarch} || exit 1 - repo_lock ${repo_from} ${pkgarch} || exit 1 -done - msg "Moving packages from [${repo_from}] to [${repo_to}]..." declare -A add_pkgs diff --git a/db-update b/db-update index 73897f3..b11face 100755 --- a/db-update +++ b/db-update @@ -11,43 +11,39 @@ fi # Find repos with packages to release repos=($(find "${STAGING}" -mindepth 1 -type d ! -empty -printf '%f ' 2>/dev/null)) if [ $? -ge 1 ]; then - error "Could not read ${STAGING}" - exit 1 + die "Could not read ${STAGING}" fi +# TODO: this might lock too much (architectures) +for repo in ${repos[@]}; do + for pkgarch in ${ARCHES[@]}; do + repo_lock ${repo} ${pkgarch} || exit 1 + done +done + +# check if packages are valid for repo in ${repos[@]}; do if ! check_repo_permission "${repo}"; then - error "You don't have permission to update packages in ${repo}" - exit 1 + die "You don't have permission to update packages in ${repo}" fi pkgs=($(getpkgfiles "${STAGING}/${repo}/"*${PKGEXT})) if [ $? -eq 0 ]; then for pkg in ${pkgs[@]}; do if ! check_pkgfile "${pkg}"; then - error "Package ${repo}/$(basename ${pkg}) is not consistent with its meta data" - exit 1 + die "Package ${repo}/$(basename ${pkg}) is not consistent with its meta data" fi if ! check_pkgsvn "${pkg}" "${repo}"; then - error "Package ${repo}/$(basename ${pkg}) is not consistent with svn repository" - exit 1 + die "Package ${repo}/$(basename ${pkg}) is not consistent with svn repository" fi if [ -f "${FTP_BASE}/$(get_pkgpool_for_host)/$(basename ${pkg})" ]; then - error "Package ${repo}/$(basename pkg) already exists in ${FTP_BASE}/$(get_pkgpool_for_host)" - exit 1 + die "Package ${repo}/$(basename pkg) already exists in ${FTP_BASE}/$(get_pkgpool_for_host)" fi done else - exit 1 + die "Could not read ${STAGING}" fi done -# TODO: this might lock too much (architectures) -for repo in ${repos[@]}; do - for pkgarch in ${ARCHES[@]}; do - repo_lock ${repo} ${pkgarch} || exit 1 - done -done - for repo in ${repos[@]}; do msg "Updating [${repo}]..." any_pkgs=($(getpkgfiles "${STAGING}/${repo}/"*-any${PKGEXT} 2>/dev/null)) diff --git a/testing2x b/testing2x index 83b12fa..54cae11 100755 --- a/testing2x +++ b/testing2x @@ -8,6 +8,13 @@ if [ $# -lt 1 ]; then exit 1 fi +# Lock everything to reduce possibility of interfering task between the different repo-updates +script_lock +for repo in 'core' 'extra' 'testing'; do + for pkgarch in ${ARCHES[@]}; do + repo_lock ${repo} ${pkgarch} || exit 1 + done +done declare -A pkgs @@ -39,8 +46,16 @@ for pkgbase in $*; do fi done +for pkgarch in ${ARCHES[@]}; do + repo_unlock 'testing' ${pkgarch} +done for repo in 'core' 'extra'; do + for pkgarch in ${ARCHES[@]}; do + repo_unlock ${repo} ${pkgarch} + done if [ -n "${pkgs[${repo}]}" ]; then "$(dirname $0)/db-move" 'testing' "${repo}" ${pkgs[${repo}]} fi done + +script_unlock -- cgit v1.2.3-54-g00ecf From 17c9dab4b420ca55fd4fb3f277805af148159a4d Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Tue, 17 Aug 2010 20:32:47 +0200 Subject: Add additional checks when reading PKGBUILDs If reading from a PKGBUILD fails stop immediatly. Also put out more usefull error messages. --- db-functions | 1 + db-move | 13 +++++++++++-- db-update | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) (limited to 'db-move') diff --git a/db-functions b/db-functions index a04dbf5..292e3ff 100644 --- a/db-functions +++ b/db-functions @@ -304,6 +304,7 @@ check_pkgsvn() { fi local pkgver="$(. "${WORKDIR}/pkgbuilds/${pkgbase}"; echo "${pkgver}-${pkgrel}")" + [ -z "${pkgver}" ] && return 1 if echo "$(basename ${pkgfile})" | grep -q "${pkgver}-${pkgarch}"; then return 0 else diff --git a/db-move b/db-move index a274cd3..5ffb8bc 100755 --- a/db-move +++ b/db-move @@ -32,12 +32,21 @@ for pkgbase in ${args[@]:2}; do svnrepo_from="${WORKDIR}/svn/${pkgbase}/repos/${repo_from}-${pkgarch}" if [ -r "${svnrepo_from}/PKGBUILD" ]; then pkgnames=($(. "${svnrepo_from}/PKGBUILD"; echo ${pkgname[@]})) + if [ ${#pkgnames[@]} -lt 1 ]; then + die "Could not read pkgname" + fi + pkgver=$(. "${svnrepo_from}/PKGBUILD"; echo "${pkgver}-${pkgrel}") + if [ -z "${pkgver}" ]; then + die "Could not read pkgver" + fi + if [ "${pkgarch}" == 'any' ]; then tarches=(${ARCHES[@]}) else tarches=("${pkgarch}") fi + for pkgname in ${pkgnames[@]}; do for tarch in ${tarches[@]}; do getpkgfile "${ftppath_from}/${tarch}/"${pkgname}-${pkgver}-${pkgarch}${PKGEXT} >/dev/null @@ -98,9 +107,9 @@ done for tarch in ${ARCHES[@]}; do if [ -n "${add_pkgs[${tarch}]}" ]; then /usr/bin/repo-add -q "${ftppath_to}/${tarch}/${repo_to}${DBEXT}" ${add_pkgs[${tarch}]} >/dev/null \ - || die "Error in repo-add ${add_pkgs[${tarch}]}" + || error "repo-add ${tarch}/${repo_to}${DBEXT} ${add_pkgs[${tarch}]}" /usr/bin/repo-remove -q "${ftppath_from}/${tarch}/${repo_from}${DBEXT}" ${remove_pkgs[${tarch}]} >/dev/null \ - || die "Error in repo-remove ${remove_pkgs[${tarch}]}" + || error "repo-remove ${tarch}/${repo_from}${DBEXT} ${remove_pkgs[${tarch}]}" fi done diff --git a/db-update b/db-update index dd8d1c0..68450b4 100755 --- a/db-update +++ b/db-update @@ -63,7 +63,7 @@ for repo in ${repos[@]}; do if [ ${#add_pkgs[@]} -ge 1 ]; then pushd "$FTP_BASE/$repo/os/${pkgarch}" >/dev/null /usr/bin/repo-add -q "$repo$DBEXT" ${add_pkgs[@]} >/dev/null \ - || die "Could not add packages" + || die "repo-add $repo$DBEXT ${add_pkgs[@]}" popd >/dev/null fi done -- cgit v1.2.3-54-g00ecf From 3b903c5c46287cc6f453b3138842715a467c57fb Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 2 Sep 2010 14:50:04 +0200 Subject: Set correct group after touching the db file * When writing the db file ensure that it has write permission of the group which owns the parent directory. * This should make the adjust-permissions cron job obsolete. --- db-functions | 14 ++++++++++++++ db-move | 3 +++ db-remove | 1 + db-update | 1 + 4 files changed, 19 insertions(+) (limited to 'db-move') diff --git a/db-functions b/db-functions index 28928da..7a751bf 100644 --- a/db-functions +++ b/db-functions @@ -387,3 +387,17 @@ check_repo_permission() { return 0 } + +set_repo_permission() { + local repo=$1 + local arch=$2 + local dbfile="${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT}" + + if [ -w "${dbfile}" ]; then + local group=$(/usr/bin/stat --printf='%G' "$(dirname "${dbfile}")") + chgrp $group "${dbfile}" || error "Could not change group of ${dbfile} to $group" + chmod g+w "${dbfile}" || error "Could not set write permission for group $group to ${dbfile}" + else + error "You don't have permission to change ${dbfile}" + fi +} diff --git a/db-move b/db-move index 5ffb8bc..fe9d2c9 100755 --- a/db-move +++ b/db-move @@ -108,8 +108,11 @@ for tarch in ${ARCHES[@]}; do if [ -n "${add_pkgs[${tarch}]}" ]; then /usr/bin/repo-add -q "${ftppath_to}/${tarch}/${repo_to}${DBEXT}" ${add_pkgs[${tarch}]} >/dev/null \ || error "repo-add ${tarch}/${repo_to}${DBEXT} ${add_pkgs[${tarch}]}" + set_repo_permission "${repo_to}" "${tarch}" + /usr/bin/repo-remove -q "${ftppath_from}/${tarch}/${repo_from}${DBEXT}" ${remove_pkgs[${tarch}]} >/dev/null \ || error "repo-remove ${tarch}/${repo_from}${DBEXT} ${remove_pkgs[${tarch}]}" + set_repo_permission "${repo_from}" "${tarch}" fi done diff --git a/db-remove b/db-remove index 8dabb18..6743eea 100755 --- a/db-remove +++ b/db-remove @@ -48,5 +48,6 @@ for tarch in ${tarches[@]}; do fi /usr/bin/repo-remove -q "$ftppath/$tarch/$repo$DBEXT" ${pkgnames[@]} >/dev/null + set_repo_permission "${repo}" "${tarch}" repo_unlock $repo $tarch done diff --git a/db-update b/db-update index 13c7441..61d1636 100755 --- a/db-update +++ b/db-update @@ -68,6 +68,7 @@ for repo in ${repos[@]}; do /usr/bin/repo-add -q "$repo$DBEXT" ${add_pkgs[@]} >/dev/null \ || die "repo-add $repo$DBEXT ${add_pkgs[@]}" popd >/dev/null + set_repo_permission "${repo}" "${pkgarch}" fi done done -- cgit v1.2.3-54-g00ecf From f121126f8166fb6dc261ea82f2890ba6693d047e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 11 Sep 2010 22:52:23 +0200 Subject: Use local config instead of guessing by hostname Using the hostname to decide which repos to use is not releiable and hard to test. Instead use config.local to configure these. config files for sigurd and gerolde were added which can be copied or symlinked to config.local on the specific host. --- config | 10 ++-------- config.local.gerolde | 2 ++ config.local.sigurd | 2 ++ cron-jobs/ftpdir-cleanup | 14 ++++++-------- db-functions | 29 ++++++++--------------------- db-move | 8 ++++---- db-update | 4 ++-- test/lib/common.inc | 26 ++++++++++++++------------ test/runTest | 16 ++++++++-------- 9 files changed, 48 insertions(+), 63 deletions(-) create mode 100644 config.local.gerolde create mode 100644 config.local.sigurd (limited to 'db-move') diff --git a/config b/config index a595331..89e89fd 100644 --- a/config +++ b/config @@ -1,16 +1,10 @@ - FTP_BASE="/srv/ftp" SVNREPO="file:///srv/svn-packages" SVNREPOCOMMUNITY="file:///srv/svn-community" -declare -A PKGREPO -PKGREPO['default']='core extra testing staging kde-unstable gnome-unstable' -PKGREPO['sigurd']='community community-testing community-staging multilib multilib-testing' - -declare -A PKGPOOL -PKGPOOL['default']='pool/packages' -PKGPOOL['sigurd']='pool/community' +PKGREPOS=() +PKGPOOL='' CLEANUP_DESTDIR="/srv/package-cleanup" CLEANUP_DRYRUN=false diff --git a/config.local.gerolde b/config.local.gerolde new file mode 100644 index 0000000..dd8ba86 --- /dev/null +++ b/config.local.gerolde @@ -0,0 +1,2 @@ +PKGREPOS=('core' 'extra' 'testing' 'staging' 'kde-unstable' 'gnome-unstable') +PKGPOOL='pool/packages' diff --git a/config.local.sigurd b/config.local.sigurd new file mode 100644 index 0000000..c8c3c9f --- /dev/null +++ b/config.local.sigurd @@ -0,0 +1,2 @@ +PKGREPOS=('community' 'community-testing' 'community-staging' 'multilib' 'multilib-testing') +PKGPOOL='pool/community' diff --git a/cron-jobs/ftpdir-cleanup b/cron-jobs/ftpdir-cleanup index 5c8776e..914ef8c 100755 --- a/cron-jobs/ftpdir-cleanup +++ b/cron-jobs/ftpdir-cleanup @@ -18,11 +18,9 @@ clean_pkg() { fi } -repos=($(get_repos_for_host)) - script_lock -for repo in ${repos[@]}; do +for repo in ${PKGREPOS[@]}; do for arch in ${ARCHES[@]}; do repo_lock ${repo} ${arch} || exit 1 done @@ -30,7 +28,7 @@ done ${CLEANUP_DRYRUN} && warning 'dry run mode is active' -for repo in ${repos[@]}; do +for repo in ${PKGREPOS[@]}; do for arch in ${ARCHES[@]}; do if [ ! -f "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT}" ]; then warning "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT} not found, skipping" @@ -61,7 +59,7 @@ for repo in ${repos[@]}; do done # get a list of all available packages in the pacakge pool -find "$FTP_BASE/$(get_pkgpool_for_host)" -name "*${PKGEXT}" -printf '%f\n' | sort > "${WORKDIR}/pool" +find "$FTP_BASE/${PKGPOOL}" -name "*${PKGEXT}" -printf '%f\n' | sort > "${WORKDIR}/pool" # create a list of packages in our db cat "${WORKDIR}/db-"* | sort -u > "${WORKDIR}/db" @@ -70,12 +68,12 @@ if [ ${#old_pkgs[@]} -ge 1 ]; then msg "Removing old packages from package pool..." for old_pkg in ${old_pkgs[@]}; do msg2 "${old_pkg}" - clean_pkg "$FTP_BASE/$(get_pkgpool_for_host)/${old_pkg}" + clean_pkg "$FTP_BASE/${PKGPOOL}/${old_pkg}" done fi # cleanup of legacy $repo/os/any directories -for repo in ${repos[@]}; do +for repo in ${PKGREPOS[@]}; do if [ ! -d "${FTP_BASE}/${repo}/os/any" ]; then continue fi @@ -98,7 +96,7 @@ for repo in ${repos[@]}; do done -for repo in ${repos[@]}; do +for repo in ${PKGREPOS[@]}; do for arch in ${ARCHES[@]}; do repo_unlock ${repo} ${arch} done diff --git a/db-functions b/db-functions index 18029ee..939f2d5 100644 --- a/db-functions +++ b/db-functions @@ -294,7 +294,7 @@ check_pkgsvn() { [ $? -ge 1 ] && return 1 local repo="${2}" - in_array "${repo}" $(get_repos_for_host) || return 1 + in_array "${repo}" ${PKGREPOS[@]} || return 1 if [ ! -f "${WORKDIR}/pkgbuilds/${repo}/${pkgbase}" ]; then mkdir -p "${WORKDIR}/pkgbuilds/${repo}" @@ -320,13 +320,13 @@ check_pkgrepos() { local pkgver="$(getpkgver ${pkgfile})" [ $? -ge 1 ] && return 1 - if [ -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkgname}-${pkgver}-"*${PKGEXT} ]; then + if [ -f "${FTP_BASE}/${PKGPOOL}/${pkgname}-${pkgver}-"*${PKGEXT} ]; then return 1 fi local repo local arch - for repo in $(get_repos_for_host); do + for repo in ${PKGREPOS[@]}; do for arch in ${ARCHES[@]}; do if [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkgname}-${pkgver}"*${PKGEXT} ]; then return 1 @@ -337,22 +337,6 @@ check_pkgrepos() { return 0 } -get_repos_for_host() { - if [ -n "${PKGREPO[$(hostname -s)]}" ]; then - echo "${PKGREPO[$(hostname -s)]}" - else - echo "${PKGREPO['default']}" - fi -} - -get_pkgpool_for_host() { - if [ -n "${PKGPOOL[$(hostname -s)]}" ]; then - echo "${PKGPOOL[$(hostname -s)]}" - else - echo "${PKGPOOL['default']}" - fi -} - #usage: chk_license ${license[@]}" chk_license() { local l @@ -397,9 +381,12 @@ pkgver_from_src() { check_repo_permission() { local repo=$1 - in_array "${repo}" $(get_repos_for_host) || return 1 + [ ${#PKGREPOS[@]} -eq 0 ] && return 1 + [ -z "${PKGPOOL}" ] && return 1 + + in_array "${repo}" ${PKGREPOS[@]} || return 1 - [ -w "$FTP_BASE/$(get_pkgpool_for_host)" ] || return 1 + [ -w "$FTP_BASE/${PKGPOOL}" ] || return 1 local arch for arch in ${ARCHES}; do diff --git a/db-move b/db-move index fe9d2c9..cdc261c 100755 --- a/db-move +++ b/db-move @@ -92,11 +92,11 @@ for pkgbase in ${args[@]:2}; do # copy package to pool if needed # TODO: can be removed once every package has been moved to the package pool - if [ ! -f ${FTP_BASE}/$(get_pkgpool_for_host)/${pkgfile} ]; then - cp ${pkgpath} ${FTP_BASE}/$(get_pkgpool_for_host) + if [ ! -f ${FTP_BASE}/${PKGPOOL}/${pkgfile} ]; then + cp ${pkgpath} ${FTP_BASE}/${PKGPOOL} fi - ln -s "../../../$(get_pkgpool_for_host)/${pkgfile}" ${ftppath_to}/${tarch}/ - add_pkgs[${tarch}]+="${FTP_BASE}/$(get_pkgpool_for_host)/${pkgfile} " + ln -s "../../../${PKGPOOL}/${pkgfile}" ${ftppath_to}/${tarch}/ + add_pkgs[${tarch}]+="${FTP_BASE}/${PKGPOOL}/${pkgfile} " remove_pkgs[${tarch}]+="${pkgname} " done done diff --git a/db-update b/db-update index 70f0525..49ecbde 100755 --- a/db-update +++ b/db-update @@ -58,9 +58,9 @@ for repo in ${repos[@]}; do msg2 "${pkgfile} (${pkgarch})" # any packages might have been moved by the previous run if [ -f "${pkg}" ]; then - mv "${pkg}" "$FTP_BASE/$(get_pkgpool_for_host)" + mv "${pkg}" "$FTP_BASE/${PKGPOOL}" fi - ln -s "../../../$(get_pkgpool_for_host)/${pkgfile}" "$FTP_BASE/$repo/os/${pkgarch}" + ln -s "../../../${PKGPOOL}/${pkgfile}" "$FTP_BASE/$repo/os/${pkgarch}" add_pkgs[${#add_pkgs[*]}]=${pkgfile} done if [ ${#add_pkgs[@]} -ge 1 ]; then diff --git a/test/lib/common.inc b/test/lib/common.inc index 71dfd3d..a0d864a 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -29,13 +29,15 @@ setUp() { local r local a - #[ -f "${curdir}/../config.local" ] && die "${curdir}/../config.local exists" + [ -f "${curdir}/../config.local" ] && die "${curdir}/../config.local exists" TMP="$(mktemp -d /dev/shm/$(basename $0).XXXXXXXXXX)" #msg "Using ${TMP}" - mkdir -p "${TMP}/"{ftp,tmp,staging,{package,source}-cleanup,svn-{packages,community}-{copy,repo}} + PKGREPOS=('core' 'extra' 'testing') + PKGPOOL='pool/packages' + mkdir -p "${TMP}/"{ftp,tmp,staging,{package,source}-cleanup,svn-packages-{copy,repo}} - for r in ${PKGREPO[@]}; do + for r in ${PKGREPOS[@]}; do mkdir -p "${TMP}/staging/${r}" for a in ${ARCHES[@]} any; do mkdir -p "${TMP}/ftp/${r}/os/${a}" @@ -47,9 +49,7 @@ setUp() { msg 'Creating svn repository...' svnadmin create "${TMP}/svn-packages-repo" - svnadmin create "${TMP}/svn-community-repo" svn checkout -q "file://${TMP}/svn-packages-repo" "${TMP}/svn-packages-copy" - svn checkout -q "file://${TMP}/svn-community-repo" "${TMP}/svn-community-copy" for p in "${pkgdir}"/*; do pkg=$(basename $p) @@ -63,6 +63,8 @@ setUp() { FTP_BASE="${TMP}/ftp" SVNREPO="file://${TMP}/svn-packages-repo" SVNREPOCOMMUNITY="file://${TMP}/svn-community-repo" + PKGREPOS=(${PKGREPOS[@]}) + PKGPOOL="${PKGPOOL}" CLEANUP_DESTDIR="${TMP}/package-cleanup" SOURCE_CLEANUP_DESTDIR="${TMP}/source-cleanup" STAGING="${TMP}/staging" @@ -95,12 +97,12 @@ checkAnyPackage() { local pkg=$2 local arch - [ -r "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] || fail "$(get_pkgpool_for_host)/${pkg} not found" + [ -r "${FTP_BASE}/${PKGPOOL}/${pkg}" ] || fail "${PKGPOOL}/${pkg} not found" for arch in i686 x86_64; do [ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} not a symlink" - [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] \ - || fail "${repo}/os/${arch}/${pkg} does not link to $(get_pkgpool_for_host)/${pkg}" + [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/${PKGPOOL}/${pkg}" ] \ + || fail "${repo}/os/${arch}/${pkg} does not link to ${PKGPOOL}/${pkg}" done [ -r "${STAGING}"/${repo}/${pkg} ] && fail "${repo}/${pkg} found in staging dir" @@ -116,18 +118,18 @@ checkPackage() { local pkg=$2 local arch=$3 - [ -r "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] || fail "$(get_pkgpool_for_host)/${pkg} not found" + [ -r "${FTP_BASE}/${PKGPOOL}/${pkg}" ] || fail "${PKGPOOL}/${pkg} not found" [ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} not a symlink" [ -r "${STAGING}"/${repo}/${pkg} ] && fail "${repo}/${pkg} found in staging dir" - [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] \ - || fail "${repo}/os/${arch}/${pkg} does not link to $(get_pkgpool_for_host)/${pkg}" + [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/${PKGPOOL}/${pkg}" ] \ + || fail "${repo}/os/${arch}/${pkg} does not link to ${PKGPOOL}/${pkg}" ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" ] \ && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkg}) \ || fail "${pkg} not in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" - local pkgbase=$(getpkgbase "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}") + local pkgbase=$(getpkgbase "${FTP_BASE}/${PKGPOOL}/${pkg}") svn up -q "${TMP}/svn-packages-copy/${pkgbase}" [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-${arch}" ] \ || fail "svn-packages-copy/${pkgbase}/repos/${repo}-${arch} does not exist" diff --git a/test/runTest b/test/runTest index b07b099..4681944 100755 --- a/test/runTest +++ b/test/runTest @@ -321,7 +321,7 @@ testCleanupSimplePackages() { for arch in ${arches[@]}; do local pkg1="pkg-simple-a-1-1-${arch}.pkg.tar.xz" checkRemovedPackage extra 'pkg-simple-a' ${arch} - [ -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg1}" ] && fail "$(get_pkgpool_for_host)/${pkg1} found" + [ -f "${FTP_BASE}/${PKGPOOL}/${pkg1}" ] && fail "${PKGPOOL}/${pkg1} found" [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg1}" ] && fail "${repo}/os/${arch}/${pkg1} found" local pkg2="pkg-simple-b-1-1-${arch}.pkg.tar.xz" @@ -344,7 +344,7 @@ testCleanupAnyPackages() { local pkg1='pkg-any-a-1-1-any.pkg.tar.xz' checkRemovedAnyPackage extra 'pkg-any-a' - [ -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg1}" ] && fail "$(get_pkgpool_for_host)/${pkg1} found" + [ -f "${FTP_BASE}/${PKGPOOL}/${pkg1}" ] && fail "${PKGPOOL}/${pkg1} found" [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg1}" ] && fail "${repo}/os/${arch}/${pkg1} found" local pkg2="pkg-any-b-1-1-${arch}.pkg.tar.xz" @@ -375,7 +375,7 @@ testCleanupSplitPackages() { for arch in ${arches[@]}; do for pkg in "${pkgdir}/${pkgs[0]}"/*-${arch}.pkg.tar.*; do checkRemovedPackage extra ${pkgs[0]} ${arch} - [ -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" ] && fail "$(get_pkgpool_for_host)/${pkg} found" + [ -f "${FTP_BASE}/${PKGPOOL}/${pkg}" ] && fail "${PKGPOOL}/${pkg} found" [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] && fail "${repo}/os/${arch}/${pkg} found" done @@ -410,7 +410,7 @@ testMovePackagesWithoutPool() { for old in 0 2; do for pkg in "${pkgdir}/${pkgs[${old}]}"/*-${arch}.pkg.tar.*; do pkg=$(basename $pkg) - mv -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" "${FTP_BASE}/testing/os/${arch}/${pkg}" + mv -f "${FTP_BASE}/${PKGPOOL}/${pkg}" "${FTP_BASE}/testing/os/${arch}/${pkg}" done done done @@ -441,7 +441,7 @@ testUpdateAnyPackageWithoutPool() { releasePackage extra pkg-any-a any ../db-update # transform two packages to old style layout - mv -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg1}" "${FTP_BASE}/extra/os/any" + mv -f "${FTP_BASE}/${PKGPOOL}/${pkg1}" "${FTP_BASE}/extra/os/any" for arch in i686 x86_64; do ln -sf "../any/${pkg1}" "${FTP_BASE}/extra/os/${arch}" done @@ -461,7 +461,7 @@ testUpdateAnyPackageWithoutPool() { checkAnyPackage extra "${pkg2}" - [ -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg1}" ] && fail "$(get_pkgpool_for_host)/${pkg1} found" + [ -f "${FTP_BASE}/${PKGPOOL}/${pkg1}" ] && fail "${PKGPOOL}/${pkg1} found" for arch in any i686 x86_64; do [ -f "${FTP_BASE}/extra/os/${arch}/${pkg1}" ] && fail "extra/os/${arch}/${pkg1} found" done @@ -482,7 +482,7 @@ testMoveAnyPackagesWithoutPool() { # transform a package to old style layout for pkg in "${pkgdir}/${pkgs[0]}"/*-any.pkg.tar.*; do pkg=$(basename $pkg) - mv -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" "${FTP_BASE}/testing/os/any/${pkg}" + mv -f "${FTP_BASE}/${PKGPOOL}/${pkg}" "${FTP_BASE}/testing/os/any/${pkg}" for arch in i686 x86_64; do ln -sf "../any/${pkg}" "${FTP_BASE}/testing/os/${arch}/${pkg}" done @@ -519,7 +519,7 @@ testUpdateSameAnyPackageToDifferentRepositoriesWithoutPool() { # transform a package to old style layout for pkg in "${pkgdir}/pkg-any-a"/*-any.pkg.tar.*; do pkg=$(basename $pkg) - mv -f "${FTP_BASE}/$(get_pkgpool_for_host)/${pkg}" "${FTP_BASE}/extra/os/any/${pkg}" + mv -f "${FTP_BASE}/${PKGPOOL}/${pkg}" "${FTP_BASE}/extra/os/any/${pkg}" for arch in i686 x86_64; do ln -sf "../any/${pkg}" "${FTP_BASE}/extra/os/${arch}/${pkg}" done -- cgit v1.2.3-54-g00ecf From 4da9bf112b07c94a7fd65a729ce62610ade8e5aa Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 15 Jan 2011 01:12:09 +0100 Subject: Move repo manipulation code into common functions repo-add and repo-remove is now indirectly called by arch_repo_add/remove. This simplifies future extensions like incremental file list creations. See FS#11302 --- db-functions | 28 ++++++++++++++++++++++++++++ db-move | 9 ++------- db-remove | 7 +------ db-repo-add | 3 +-- db-repo-remove | 7 +------ db-update | 6 +----- 6 files changed, 34 insertions(+), 26 deletions(-) (limited to 'db-move') diff --git a/db-functions b/db-functions index 8ac9e63..7d431fc 100644 --- a/db-functions +++ b/db-functions @@ -450,3 +450,31 @@ set_repo_permission() { error "You don't have permission to change ${dbfile}" fi } + +arch_repo_add() { + local repo=$1 + local arch=$2 + local pkgs=(${@:3}) + + # package files might be relative to repo dir + pushd "${FTP_BASE}/${repo}/os/${arch}" >/dev/null + /usr/bin/repo-add -q "${repo}${DBEXT}" ${pkgs[@]} >/dev/null \ + || error "repo-add ${repo}${DBEXT} ${pkgs[@]}" + popd >/dev/null + set_repo_permission "${repo}" "${arch}" +} + +arch_repo_remove() { + local repo=$1 + local arch=$2 + local pkgs=(${@:3}) + local dbfile="${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT}" + + if [ ! -f "${dbfile}" ]; then + error "No database found at '${dbfile}'" + return 1 + fi + /usr/bin/repo-remove -q "${dbfile}" ${pkgs[@]} >/dev/null \ + || error "repo-remove ${dbfile} ${pkgs[@]}" + set_repo_permission "${repo}" "${arch}" +} diff --git a/db-move b/db-move index cdc261c..ae21781 100755 --- a/db-move +++ b/db-move @@ -106,13 +106,8 @@ done for tarch in ${ARCHES[@]}; do if [ -n "${add_pkgs[${tarch}]}" ]; then - /usr/bin/repo-add -q "${ftppath_to}/${tarch}/${repo_to}${DBEXT}" ${add_pkgs[${tarch}]} >/dev/null \ - || error "repo-add ${tarch}/${repo_to}${DBEXT} ${add_pkgs[${tarch}]}" - set_repo_permission "${repo_to}" "${tarch}" - - /usr/bin/repo-remove -q "${ftppath_from}/${tarch}/${repo_from}${DBEXT}" ${remove_pkgs[${tarch}]} >/dev/null \ - || error "repo-remove ${tarch}/${repo_from}${DBEXT} ${remove_pkgs[${tarch}]}" - set_repo_permission "${repo_from}" "${tarch}" + arch_repo_add "${repo_to}" "${tarch}" ${add_pkgs[${tarch}]} + arch_repo_remove "${repo_from}" "${tarch}" ${remove_pkgs[${tarch}]} fi done diff --git a/db-remove b/db-remove index b246ce3..cc65eb9 100755 --- a/db-remove +++ b/db-remove @@ -41,11 +41,6 @@ else fi for tarch in ${tarches[@]}; do - if [ ! -f "$ftppath/$tarch/$repo$DBEXT" ]; then - die "No database found at '$ftppath/$tarch', nothing more to do" - fi - - /usr/bin/repo-remove -q "$ftppath/$tarch/$repo$DBEXT" ${pkgnames[@]} >/dev/null - set_repo_permission "${repo}" "${tarch}" + arch_repo_remove "${repo}" "${tarch}" ${pkgnames[@]} repo_unlock $repo $tarch done diff --git a/db-repo-add b/db-repo-add index b6dd8b8..53cfc84 100755 --- a/db-repo-add +++ b/db-repo-add @@ -34,7 +34,6 @@ for tarch in ${tarches[@]}; do if [ ! -f "${pkgfile}" ]; then die "Package file ${pkgfile} not found" fi - /usr/bin/repo-add -q "$ftppath/$tarch/$repo$DBEXT" ${pkgfile} >/dev/null - set_repo_permission "${repo}" "${tarch}" + arch_repo_add "${repo}" "${tarch}" ${pkgfile} repo_unlock $repo $tarch done diff --git a/db-repo-remove b/db-repo-remove index 6fa0e05..b01910f 100755 --- a/db-repo-remove +++ b/db-repo-remove @@ -31,11 +31,6 @@ done msg "Removing $pkgname from [$repo]..." for tarch in ${tarches[@]}; do - if [ ! -f "$ftppath/$tarch/$repo$DBEXT" ]; then - die "No database found at '$ftppath/$tarch', nothing more to do" - fi - - /usr/bin/repo-remove -q "$ftppath/$tarch/$repo$DBEXT" ${pkgname} >/dev/null - set_repo_permission "${repo}" "${tarch}" + arch_repo_remove "${repo}" "${tarch}" ${pkgname} repo_unlock $repo $tarch done diff --git a/db-update b/db-update index 3a49f0a..5bdce5e 100755 --- a/db-update +++ b/db-update @@ -67,11 +67,7 @@ for repo in ${repos[@]}; do add_pkgs[${#add_pkgs[*]}]=${pkgfile} done if [ ${#add_pkgs[@]} -ge 1 ]; then - pushd "$FTP_BASE/$repo/os/${pkgarch}" >/dev/null - /usr/bin/repo-add -q "$repo$DBEXT" ${add_pkgs[@]} >/dev/null \ - || die "repo-add $repo$DBEXT ${add_pkgs[@]}" - popd >/dev/null - set_repo_permission "${repo}" "${pkgarch}" + arch_repo_add "${repo}" "${pkgarch}" ${add_pkgs[@]} fi done done -- cgit v1.2.3-54-g00ecf