diff options
-rw-r--r-- | db-functions | 7 | ||||
-rwxr-xr-x | db-move | 6 | ||||
-rwxr-xr-x | db-remove | 4 | ||||
-rwxr-xr-x | db-update | 12 |
4 files changed, 19 insertions, 10 deletions
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: @@ -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 @@ -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" @@ -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" |