diff options
author | Aaron Griffin <aaronmgriffin@gmail.com> | 2008-05-15 00:49:20 +0200 |
---|---|---|
committer | Aaron Griffin <aaronmgriffin@gmail.com> | 2008-05-15 00:51:05 +0200 |
commit | 39298cf09e2e88b1f6aec779170990675baf8992 (patch) | |
tree | 653de4d1002b0be8a6b6111e88b7c4cc5df29203 /db-update | |
parent | e021dfb2c476c2841606e63e6ae58dfc45cd1b47 (diff) | |
download | dbscripts-39298cf09e2e88b1f6aec779170990675baf8992.tar.gz dbscripts-39298cf09e2e88b1f6aec779170990675baf8992.tar.xz |
Cron cleanup, and only copy DB files once
This would break all adds if there were any deletes.
We definitely don't want that.
Also, cleanup of cron scripts in the same commit because
I'm lazy
Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
Diffstat (limited to 'db-update')
-rwxr-xr-x | db-update | 50 |
1 files changed, 28 insertions, 22 deletions
@@ -83,7 +83,15 @@ trap cleanup 0 /bin/touch "$LOCKFILE" -/bin/mkdir -p "$WORKDIR" +/bin/mkdir -p "$WORKDIR/build" +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/ +else + touch "build/$reponame.db.tar.$DB_COMPRESSION" +fi echo "Updating DB for $reponame $arch" @@ -126,17 +134,15 @@ if [ -n "$ADDPKGS" ]; then done if [ -n "$to_add" ]; then + cd "$WORKDIR/build/" + /bin/cp $to_add . - cd "$WORKDIR" - [ -d build/ ] || mkdir build + pkgs="" + for pkg in $to_add; do pkgs="$pkgs $(basename $pkg)"; done - # copy the db file into our working area - [ -f "$ftppath/$reponame.db.tar.gz" ] && cp "$ftppath/$reponame.db.tar.gz" build/ - /bin/cp $to_add build/ - - cd build/ - /usr/bin/repo-add "$reponame.db.tar.$DB_COMPRESSION" $to_add + /usr/bin/repo-add "$reponame.db.tar.$DB_COMPRESSION" $pkgs else + rm -f "build/$reponame.db.tar.$DB_COMPRESSION" echo "Errors found when adding packages" fi else @@ -166,26 +172,22 @@ if [ -n "$REMPKGS" ]; then if [ -d "$_pkgname/repos/$svnrepo" ]; then echo " WARNING: $_pkgname still exists in $svnrepo" else - to_rem="$to_rem $pkg" + to_rem="$to_rem $_pkgname" fi done if [ -n "$to_rem" ]; then - cd "$WORKDIR" - [ -d build/ ] || mkdir build - - # copy the db file into our working area - [ -f "$ftppath/$reponame.db.tar.gz" ] && cp "$ftppath/$reponame.db.tar.gz" build/ + cd "$WORKDIR/build/" - cd build/ + #NOTE: to_rem consists of package NAMES only /usr/bin/repo-remove "$reponame.db.tar.$DB_COMPRESSION" $to_rem - for rem in $to_rem; do - if [ -f "$ftppath/$rem" ]; then - /bin/rm "$ftppath/$rem" - fi + for rem in $REMPKGS; do + rem="$(basename $rem)" + /bin/rm -f "$ftppath/$rem" done else + rm -f "build/$reponame.db.tar.$DB_COMPRESSION" echo "Errors found when removing packages" fi else @@ -196,11 +198,15 @@ fi if [ $(/bin/ls "$WORKDIR/build/" 2>/dev/null | wc -l) != 0 ]; then echo "Copying new files to '$ftppath'" /bin/cp -r "$WORKDIR/build/"* "$ftppath" - echo "Cleaning staging dir" - /bin/rm $to_add $to_rem + else echo "Nothing to copy, no work done" fi +if [ -n "$ADDPKGS" -o -n "$REMPKGS" ]; then + echo "Cleaning staging dir" + /bin/rm $ADDPKGS $REMPKGS +fi + cleanup # vim: set ts=4 sw=4 noet ft=sh: |