From 01a1eedbdb93a0c7312af1543658997ae7aa680c Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Wed, 14 May 2008 15:07:37 -0400 Subject: Add new db-remove script This script deletes by package NAME only. Additionally, it also removes from svn. The goal is to simplify the process of removing packages. Signed-off-by: Aaron Griffin --- db-remove | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100755 db-remove (limited to 'db-remove') diff --git a/db-remove b/db-remove new file mode 100755 index 0000000..c69e179 --- /dev/null +++ b/db-remove @@ -0,0 +1,97 @@ +#!/bin/bash + +if [ $# -ne 3 ]; 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" +reponame="$2" +arch="$3" + +export CARCH="$arch" + +##### Arch specific stuff. TODO make this configurable ##### +ftppath="/home/ftp/$reponame/os/$arch/" +svnpath="file:///home/svn-packages" +svnrepo="$reponame-$arch" +############################################################ + +[ "$UID" = "" ] && UID=$(uid) + +WORKDIR="/tmp/db-remove.$svnrepo.$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)" + echo "error: db generation is already in progress (started by $owner)" + exit 1 +fi + +trap ctrl_c 2 +trap cleanup 0 + +/bin/touch "$LOCKFILE" +/bin/mkdir -p "$WORKDIR" + + +echo "==> Removing package '$packagename' from '$reponame'..." >&2 + +cd "$WORKDIR" +/usr/bin/svn checkout -N $svnpath checkout +cd checkout + +/usr/bin/svn up -q $packagename +if [ -d "$packagename/repos/$svnrepo" ]; then + echo " Removing from subversion" + /usr/bin/svn rm --force -q "$packagename/repos/$svnrepo" + /usr/bin/svn commit -q -m "$(basename $0): $packagename removed by $(id -un)" +fi + +cd "$WORKDIR" +[ -d build/ ] || mkdir build + +# 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/ +else + echo "No database found at '$ftpdir', nothing more to do" + exit 0 +fi + +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/" + +echo "Package files will be cleaned up automatically" + +cleanup +# vim: set ts=4 sw=4 noet ft=sh: -- cgit v1.2.3-54-g00ecf From a0c4daf2679a56f6eaa7df0062c7184fc55f95bf Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Thu, 22 May 2008 12:52:53 -0400 Subject: Fix db-remove usage text Signed-off-by: Aaron Griffin --- db-remove | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db-remove') diff --git a/db-remove b/db-remove index c69e179..f9495e9 100755 --- a/db-remove +++ b/db-remove @@ -1,7 +1,7 @@ #!/bin/bash if [ $# -ne 3 ]; then - echo "usage: $(basename $0) " + echo "usage: $(basename $0) " exit 1 fi -- 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-remove') 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-remove') 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-remove') 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-remove') 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-remove') 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-remove') 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-remove') 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 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-remove') 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 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-remove') 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-remove') 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-remove') 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 0691b6632e612818c52dbecfd2635fd954d42e23 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Tue, 21 Jul 2009 19:19:22 +0200 Subject: add support for split packages to db-remove Signed-off-by: Aaron Griffin --- db-remove | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'db-remove') diff --git a/db-remove b/db-remove index 4763f3d..621154d 100755 --- a/db-remove +++ b/db-remove @@ -1,7 +1,7 @@ #!/bin/bash if [ $# -ne 3 ]; then - echo "usage: $(basename $0) " + echo "usage: $(basename $0) " exit 1 fi @@ -9,7 +9,7 @@ fi source_makepkg -packagename="$1" +packagebase="$1" reponame="$2" arch="$3" @@ -49,17 +49,23 @@ repo_lock $reponame $arch /bin/mkdir -p "$WORKDIR" -echo "==> Removing package '$packagename' from '$reponame'..." >&2 +echo "==> Removing package '$packagebase' from '$reponame'..." >&2 cd "$WORKDIR" /usr/bin/svn checkout -N $svnpath checkout cd checkout -/usr/bin/svn up -q $packagename -if [ -d "$packagename/repos/$svnrepo" ]; then +/usr/bin/svn up -q $packagebase +if [ -d "$packagebase/repos/$svnrepo" ]; then echo " Removing from subversion" - /usr/bin/svn rm --force -q "$packagename/repos/$svnrepo" - /usr/bin/svn commit -q -m "$(basename $0): $packagename removed by $(id -un)" + . "$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 fi cd "$WORKDIR" @@ -82,7 +88,7 @@ for architecture in $arches; do echo " Removing from $reponame DB file ($architecture)" cd build/ - /usr/bin/repo-remove -q "$reponame.db.tar.$DB_COMPRESSION" $packagename + /usr/bin/repo-remove -q "$reponame.db.tar.$DB_COMPRESSION" ${pkgname[@]} /bin/mv "$reponame.db.tar.$DB_COMPRESSION" "$ftppath/$architecture" -- 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-remove') 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-remove') 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-remove') 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-remove') 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 a4d0a6cba591e0866c249a0c2014297bdbbfb779 Mon Sep 17 00:00:00 2001 From: Eric BĂ©langer Date: Tue, 18 Aug 2009 16:37:09 -0700 Subject: Fix arch parameter handling in db-remove db-remove use the arch variable to handle the arch parameter passed to the script. As the arch variable is already used in PKGBUILD, this variable conflict cause unwanted behaviour. Signed-off-by: Aaron Griffin --- db-remove | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'db-remove') diff --git a/db-remove b/db-remove index eae204e..3ba7dd7 100755 --- a/db-remove +++ b/db-remove @@ -9,10 +9,10 @@ fi packagebase="$1" reponame="$2" -arch="$3" +_arch="$3" ftppath="$FTP_BASE/$reponame/os" -svnrepo="$reponame-$arch" +svnrepo="$reponame-$_arch" [ "$UID" = "" ] && UID=$(uid) @@ -21,7 +21,7 @@ WORKDIR="$TMPDIR/db-remove.$svnrepo.$UID" cleanup() { trap '' 0 2 # unlock - repo_unlock $reponame $arch + repo_unlock $reponame $_arch rm -rf "$WORKDIR" [ "$1" ] && exit $1 } @@ -39,7 +39,7 @@ die() { trap ctrl_c 2 trap cleanup 0 -repo_lock $reponame $arch +repo_lock $reponame $_arch /bin/mkdir -p "$WORKDIR" @@ -66,10 +66,10 @@ fi cd "$WORKDIR" [ -d build/ ] || mkdir build -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 -- 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-remove') 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 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-remove') 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 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-remove') 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 20f1c1c27a1691cf92ad11ebc81dfaa175ace305 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 8 Aug 2010 11:39:42 +0200 Subject: Cleanup db-remove * There is no need to copy the db into a working dir * cleanup is automatically called on exit --- db-remove | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'db-remove') diff --git a/db-remove b/db-remove index 357e6c4..bf325c4 100755 --- a/db-remove +++ b/db-remove @@ -54,13 +54,10 @@ 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 - echo " Warning: $packagebase not found in $svnrepo" - echo " Removing split packages is not yet supported" - exit 1 + die "Error: $packagebase not found in $svnrepo" fi cd "$WORKDIR" -[ -d build/ ] || mkdir build if [ "$_arch" == "any" ]; then arches="i686 x86_64" @@ -69,24 +66,14 @@ else fi # copy the db file into our working area -for architecture in $arches; do - 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 +for arch in $arches; do + if [ ! -f "$ftppath/$arch/$reponame$DBEXT" ]; then + die "No database found at '$ftppath/$arch', nothing more to do" fi - cd build/ - /usr/bin/repo-remove -q "$reponame$DBEXT" ${pkgname[@]} >/dev/null - - /bin/mv "$reponame$DBEXT" "$ftppath/$architecture" - - cd .. + /usr/bin/repo-remove -q "$ftppath/$arch/$reponame$DBEXT" ${pkgname[@]} >/dev/null done echo 'done' -cleanup - # vim: set ts=4 sw=4 noet ft=sh: -- 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-remove') 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-remove') 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-remove') 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-remove') 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 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-remove') 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-remove') 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 1aec9771b5c2b29ef2427e3aaabd7ef5f58195c5 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 14 Aug 2010 22:40:14 +0200 Subject: Don't use hard coded architectures in db-remove --- db-remove | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'db-remove') diff --git a/db-remove b/db-remove index 2f05c16..3a4a38e 100755 --- a/db-remove +++ b/db-remove @@ -39,13 +39,13 @@ fi cd "$WORKDIR" if [ "$arch" == "any" ]; then - arches="i686 x86_64" + tarches=(${ARCHES[@]}) else - arches="$arch" + tarches=("$arch") fi # copy the db file into our working area -for tarch in $arches; do +for tarch in ${tarches[@]}; do if [ ! -f "$ftppath/$tarch/$reponame$DBEXT" ]; then die "No database found at '$ftppath/$tarch', nothing more to do" fi -- cgit v1.2.3-54-g00ecf From e81b73f7cd4d0fc5944c26ccd1ff22e0883c295e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 15 Aug 2010 18:17:10 +0200 Subject: Use common names for repos --- db-functions | 8 ++++---- db-remove | 2 +- db-update | 4 ++-- testing2community | 11 ----------- testing2community-any | 11 ----------- testing2community64 | 11 ----------- testing2core | 11 ----------- testing2core-any | 11 ----------- testing2core64 | 11 ----------- testing2extra | 11 ----------- testing2extra-any | 11 ----------- testing2extra64 | 11 ----------- testing2x64 | 1 - 13 files changed, 7 insertions(+), 107 deletions(-) delete mode 100755 testing2community delete mode 100755 testing2community-any delete mode 100755 testing2community64 delete mode 100755 testing2core delete mode 100755 testing2core-any delete mode 100755 testing2core64 delete mode 100755 testing2extra delete mode 100755 testing2extra-any delete mode 100755 testing2extra64 delete mode 120000 testing2x64 (limited to 'db-remove') diff --git a/db-functions b/db-functions index 102f2c8..1f54dd9 100644 --- a/db-functions +++ b/db-functions @@ -103,7 +103,7 @@ cleanup() { repo=${l%.*} arch=${l#*.} if [ -d "$TMPDIR/.repolock.$repo.$arch" ]; then - msg "Removing left over lock from $repo/$arch" + msg "Removing left over lock from [${repo}] (${arch})" repo_unlock $repo $arch fi done @@ -151,7 +151,7 @@ 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. " \ + warning "Repo [${1}] (${2}) is already locked by $_owner. " \ "Retrying in $LOCK_DELAY seconds..." else LOCKS[${#LOCKS[*]}]="$1.$2" @@ -162,14 +162,14 @@ repo_lock () { let _count=$_count+1 done - error "Repo $1-$2 is already locked by $_owner. Giving up!" + 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 - warning "Repo lock $1-$2 was not locked!" + warning "Repo lock [${1}] (${2}) was not locked!" restore_umask return 1 else diff --git a/db-remove b/db-remove index 3a4a38e..5afd858 100755 --- a/db-remove +++ b/db-remove @@ -22,7 +22,7 @@ fi repo_lock $reponame $arch || exit 1 -msg "Removing $packagebase from $reponame..." +msg "Removing $packagebase from [$reponame]..." cd "$WORKDIR" /usr/bin/svn checkout -q -N $SVNREPO checkout >/dev/null cd checkout diff --git a/db-update b/db-update index 43c44f7..73897f3 100755 --- a/db-update +++ b/db-update @@ -49,14 +49,14 @@ for repo in ${repos[@]}; do done for repo in ${repos[@]}; do + msg "Updating [${repo}]..." any_pkgs=($(getpkgfiles "${STAGING}/${repo}/"*-any${PKGEXT} 2>/dev/null)) for pkgarch in ${ARCHES[@]}; do - msg "Updating [${repo}] (${pkgarch})..." add_pkgs=() arch_pkgs=($(getpkgfiles "${STAGING}/${repo}/"*-${pkgarch}${PKGEXT} 2>/dev/null)) for pkg in ${arch_pkgs[@]} ${any_pkgs[@]}; do pkgfile="$(basename ${pkg})" - msg2 "${pkgfile}" + 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)" diff --git a/testing2community b/testing2community deleted file mode 100755 index 557b39d..0000000 --- a/testing2community +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -if [ $# -le 0 ]; then - echo "usage: $(basename 0) [ [ Moving package '$pkg'" - $(dirname $0)/db-move "$pkg" "community-testing" "community" "i686" -done diff --git a/testing2community-any b/testing2community-any deleted file mode 100755 index e63a7ec..0000000 --- a/testing2community-any +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -if [ $# -le 0 ]; then - echo "usage: $(basename 0) [ [ Moving package '$pkg'" - $(dirname $0)/db-move "$pkg" "community-testing" "community" "any" -done diff --git a/testing2community64 b/testing2community64 deleted file mode 100755 index 3f88a4d..0000000 --- a/testing2community64 +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -if [ $# -le 0 ]; then - echo "usage: $(basename 0) [ [ Moving package '$pkg'" - $(dirname $0)/db-move "$pkg" "community-testing" "community" "x86_64" -done diff --git a/testing2core b/testing2core deleted file mode 100755 index 3a7acbf..0000000 --- a/testing2core +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -if [ $# -le 0 ]; then - echo "usage: $(basename 0) [ [ Moving package '$pkg'" - $(dirname $0)/db-move "$pkg" "testing" "core" "i686" -done diff --git a/testing2core-any b/testing2core-any deleted file mode 100755 index a0993e8..0000000 --- a/testing2core-any +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -if [ $# -le 0 ]; then - echo "usage: $(basename 0) [ [ Moving package '$pkg'" - $(dirname $0)/db-move "$pkg" "testing" "core" "any" -done diff --git a/testing2core64 b/testing2core64 deleted file mode 100755 index 4d30036..0000000 --- a/testing2core64 +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -if [ $# -le 0 ]; then - echo "usage: $(basename 0) [ [ Moving package '$pkg'" - $(dirname $0)/db-move "$pkg" "testing" "core" "x86_64" -done diff --git a/testing2extra b/testing2extra deleted file mode 100755 index 3be108e..0000000 --- a/testing2extra +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -if [ $# -le 0 ]; then - echo "usage: $(basename 0) [ [ Moving package '$pkg'" - $(dirname $0)/db-move "$pkg" "testing" "extra" "i686" -done diff --git a/testing2extra-any b/testing2extra-any deleted file mode 100755 index 46ab2f0..0000000 --- a/testing2extra-any +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -if [ $# -le 0 ]; then - echo "usage: $(basename 0) [ [ Moving package '$pkg'" - $(dirname $0)/db-move "$pkg" "testing" "extra" "any" -done diff --git a/testing2extra64 b/testing2extra64 deleted file mode 100755 index 418876c..0000000 --- a/testing2extra64 +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -if [ $# -le 0 ]; then - echo "usage: $(basename 0) [ [ Moving package '$pkg'" - $(dirname $0)/db-move "$pkg" "testing" "extra" "x86_64" -done diff --git a/testing2x64 b/testing2x64 deleted file mode 120000 index ff08aa7..0000000 --- a/testing2x64 +++ /dev/null @@ -1 +0,0 @@ -testing2x \ No newline at end of file -- cgit v1.2.3-54-g00ecf From 6f6ed4dc9f1bbce3638824def5d07b78aff44cde Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 15 Aug 2010 20:56:12 +0200 Subject: Fix locking in db-remove --- db-remove | 56 +++++++++++++++++++++++++------------------------------- 1 file changed, 25 insertions(+), 31 deletions(-) (limited to 'db-remove') diff --git a/db-remove b/db-remove index 5afd858..188cc60 100755 --- a/db-remove +++ b/db-remove @@ -1,58 +1,52 @@ #!/bin/bash if [ $# -ne 3 ]; then - msg "usage: $(basename $0) " + msg "usage: $(basename $0) " exit 1 fi . "$(dirname $0)/db-functions" . "$(dirname $0)/config" -packagebase="$1" -reponame="$2" +pkgbase="$1" +repo="$2" arch="$3" -ftppath="$FTP_BASE/$reponame/os" -svnrepo="$reponame-$arch" +ftppath="$FTP_BASE/$repo/os" +svnrepo="$repo-$arch" -if ! check_repo_permission $reponame; then - error "You don't have permission to remove packages from ${reponam}" - exit 1 +if ! check_repo_permission $repo; then + die "You don't have permission to remove packages from ${reponam}" fi -repo_lock $reponame $arch || exit 1 - -msg "Removing $packagebase from [$reponame]..." -cd "$WORKDIR" -/usr/bin/svn checkout -q -N $SVNREPO checkout >/dev/null -cd checkout - -/usr/bin/svn up -q $packagebase -if [ -d "$packagebase/repos/$svnrepo" ]; then - 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)" +if [ "$arch" == "any" ]; then + tarches=(${ARCHES[@]}) else - die "$packagebase not found in $svnrepo" + tarches=("$arch") fi -cd "$WORKDIR" +for tarch in ${tarches[@]}; do + repo_lock $repo $tarch || exit 1 +done -if [ "$arch" == "any" ]; then - tarches=(${ARCHES[@]}) +msg "Removing $pkgbase from [$repo]..." +/usr/bin/svn checkout -q "${SVNREPO}/${pkgbase}" "${WORKDIR}/svn/${pkgbase}" >/dev/null + +if [ -d "${WORKDIR}/svn/$pkgbase/repos/$svnrepo" ]; then + pkgnames=($(. "${WORKDIR}/svn/$pkgbase/repos/$svnrepo/PKGBUILD"; echo ${pkgname[@]})) + /usr/bin/svn rm --force -q "${WORKDIR}/svn/$pkgbase/repos/$svnrepo" + /usr/bin/svn commit -q "${WORKDIR}/svn/$pkgbase" -m "$(basename $0): $pkgbase removed by $(id -un)" else - tarches=("$arch") + die "$pkgbase not found in $svnrepo" fi + # copy the db file into our working area for tarch in ${tarches[@]}; do - if [ ! -f "$ftppath/$tarch/$reponame$DBEXT" ]; then + 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/$reponame$DBEXT" ${pkgname[@]} >/dev/null + /usr/bin/repo-remove -q "$ftppath/$tarch/$repo$DBEXT" ${pkgnames[@]} >/dev/null + repo_unlock $repo $tarch done - -repo_unlock $reponame $arch || exit 1 - -# vim: set ts=4 sw=4 noet ft=sh: -- cgit v1.2.3-54-g00ecf From e9948d8392d5ab986541c0d7120f1e5c510261ad Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Tue, 24 Aug 2010 12:27:52 +0200 Subject: db-remove: source functions before using them --- db-remove | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'db-remove') diff --git a/db-remove b/db-remove index 188cc60..8dabb18 100755 --- a/db-remove +++ b/db-remove @@ -1,13 +1,13 @@ #!/bin/bash +. "$(dirname $0)/db-functions" +. "$(dirname $0)/config" + if [ $# -ne 3 ]; then msg "usage: $(basename $0) " exit 1 fi -. "$(dirname $0)/db-functions" -. "$(dirname $0)/config" - pkgbase="$1" repo="$2" arch="$3" -- 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-remove') 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 53ecffc2f30b2678709105892b60073f7c9c0847 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Mon, 22 Nov 2010 14:36:09 +0100 Subject: Add wrappers for repo-add and repo-remove --- db-remove | 4 +--- db-repo-add | 40 ++++++++++++++++++++++++++++++++++++++++ db-repo-remove | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 3 deletions(-) create mode 100755 db-repo-add create mode 100755 db-repo-remove (limited to 'db-remove') diff --git a/db-remove b/db-remove index 6743eea..b246ce3 100755 --- a/db-remove +++ b/db-remove @@ -16,7 +16,7 @@ ftppath="$FTP_BASE/$repo/os" svnrepo="$repo-$arch" if ! check_repo_permission $repo; then - die "You don't have permission to remove packages from ${reponam}" + die "You don't have permission to remove packages from ${repo}" fi if [ "$arch" == "any" ]; then @@ -40,8 +40,6 @@ else die "$pkgbase not found in $svnrepo" fi - -# copy the db file into our working area for tarch in ${tarches[@]}; do if [ ! -f "$ftppath/$tarch/$repo$DBEXT" ]; then die "No database found at '$ftppath/$tarch', nothing more to do" diff --git a/db-repo-add b/db-repo-add new file mode 100755 index 0000000..b6dd8b8 --- /dev/null +++ b/db-repo-add @@ -0,0 +1,40 @@ +#!/bin/bash + +. "$(dirname $0)/db-functions" +. "$(dirname $0)/config" + +if [ $# -ne 3 ]; then + msg "usage: $(basename $0) " + exit 1 +fi + +pkgfile="$1" +repo="$2" +arch="$3" + +ftppath="$FTP_BASE/$repo/os" + +if ! check_repo_permission $repo; then + die "You don't have permission to add packages to ${repo}" +fi + +if [ "$arch" == "any" ]; then + tarches=(${ARCHES[@]}) +else + tarches=("$arch") +fi + +for tarch in ${tarches[@]}; do + repo_lock $repo $tarch || exit 1 +done + +msg "Adding $pkgfile to [$repo]..." + +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}" + repo_unlock $repo $tarch +done diff --git a/db-repo-remove b/db-repo-remove new file mode 100755 index 0000000..6fa0e05 --- /dev/null +++ b/db-repo-remove @@ -0,0 +1,41 @@ +#!/bin/bash + +. "$(dirname $0)/db-functions" +. "$(dirname $0)/config" + +if [ $# -ne 3 ]; then + msg "usage: $(basename $0) " + exit 1 +fi + +pkgname="$1" +repo="$2" +arch="$3" + +ftppath="$FTP_BASE/$repo/os" + +if ! check_repo_permission $repo; then + die "You don't have permission to remove packages from ${repo}" +fi + +if [ "$arch" == "any" ]; then + tarches=(${ARCHES[@]}) +else + tarches=("$arch") +fi + +for tarch in ${tarches[@]}; do + repo_lock $repo $tarch || exit 1 +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}" + repo_unlock $repo $tarch +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-remove') 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 From af06266bf8d7eb0377dd6dcfad7bf1b9c1f79825 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 30 Jan 2011 12:17:42 +0100 Subject: Try to remove a package even if it is no longer in svn --- db-remove | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db-remove') diff --git a/db-remove b/db-remove index cc65eb9..292af5d 100755 --- a/db-remove +++ b/db-remove @@ -37,7 +37,7 @@ if [ -d "${WORKDIR}/svn/$pkgbase/repos/$svnrepo" ]; then /usr/bin/svn rm --force -q "${WORKDIR}/svn/$pkgbase/repos/$svnrepo" /usr/bin/svn commit -q "${WORKDIR}/svn/$pkgbase" -m "$(basename $0): $pkgbase removed by $(id -un)" else - die "$pkgbase not found in $svnrepo" + warning "$pkgbase not found in $svnrepo" fi for tarch in ${tarches[@]}; do -- cgit v1.2.3-54-g00ecf