From c3c08ee41c01b0beb2f53d7e75cf089dfbae9f99 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Tue, 15 Apr 2008 13:19:30 -0400 Subject: Switch to proper script usage Switch to a callable script in place of an include file Signed-off-by: Aaron Griffin --- db-update | 187 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 187 insertions(+) create mode 100644 db-update (limited to 'db-update') diff --git a/db-update b/db-update new file mode 100644 index 0000000..24ca489 --- /dev/null +++ b/db-update @@ -0,0 +1,187 @@ +#!/bin/bash + +# where are the arch scripts located? +ARCHDIR="/arch" + +if [ $# -ne 2 ]; then + echo "usage: $(basename $0) " + exit 1 +fi + +#All this fun stuff used to be in the db-(whatever) files +# Let's make it cleaner +arch="$1" +reponame="$2" + +export CARCH="$arch" +ftppath="/home/ftp/$reponame/os/$arch/" +svnpath="/home/svn-packages" +svnrepo="$reponame-$arch" + +#Hacky for now +if [ "$arch" = "x86_64" ]; then + stagedir="$HOME/staging/${reponame}64" +else + stagedir="$HOME/staging/$reponame" +fi + +WORKDIR="~/.dbscripts" +CHECKOUTDIR="$WORKDIR/checkout" +LOCKFILE="/tmp/.repolck.$arch.$repoid" +DBFILE="$WORKDIR/$reponame.db.tar.gz" + +if [ ! `type -p fakeroot` ]; then + echo "error: fakeroot is missing" >&2 + exit 1 +fi + +if [ ! -d $stagedir ]; then + echo "error: staging directory missing: $stagedir" >&2 + exit 1 +fi + +# Get the package name from the filename +# hackish, but should work for now +getpkgname() { + local tmp + + tmp=${1##*/} + tmp=${tmp%.pkg.tar.gz} + tmp=${tmp%-i686} + tmp=${tmp%-x86_64} + echo ${tmp%-*-*} +} + +cleanup() { + # unlock + rm -f "$LOCKFILE" + [ "$1" ] && exit $1 +} + +ctrl_c() { + echo "Interrupted" >&2 + cleanup 0 +} + +die() { + echo "$*" >&2 + cleanup 1 +} + +# check for locks +if [ -f "$LOCKFILE" ]; then + owner=$(/bin/ls -l $LOCKFILE | /bin/awk '{print $3}') + echo "error: db generation is already in progress (started by $owner)" + exit 1 +fi + +# catch ^C breaks +trap ctrl_c SIGINT +# lock +touch "$LOCKFILE" + +if [ -d $CHECKOUTDIR ]; then + cd $CHECKOUTDIR + svn update + if [ $? -gt 0 ]; then + die "==> SVN update failed, aborting!" + fi +else + echo "==> Checking out repo: $svnrepo ($arch) - Please be patient" + svn checkout file://$svnpath $CHECKOUTDIR + if [ $? -gt 0 ]; then + die "==> SVN checkout failed, aborting!" + fi +fi + +cd $CHECKOUTDIR + +# Checkout the SVN module if we need to +updatelists= +if [ "`ls $stagedir/add 2>/dev/null`" -o "`ls $stagedir/del 2>/dev/null`" ]; then + updatelists=1 +else + echo "No files to process" + cleanup 0 +fi + +# Right-O, now we look through the "add" and "del" subdirectories of +# $stagedir and process the packages there accordingly -- all packages +# in the "add" dir are added/updated, all packages in the "del" dir +# are removed. +# +# This means the sync db could actually be unpacked/repacked twice in +# one db-* invocation, but it's not a huge performance hit. + +if [ -d $stagedir/add -a "`ls $stagedir/add`" ]; then + echo "==> Processing new/updated packages for repository '$reponame'..." >&2 + + # copy the db file into our working area + cp $ftppath/$reponame.db.tar.gz $DBFILE + + cd $stagedir/add + # run it thru fakeroot make sure everything is owned by root.root + echo "$ARCHDIR/updatesync-many add $DBFILE $CHECKOUTDIR $svnrepo" | fakeroot + + if [ $? -ne 0 ]; then + die "==> Error returned from updatesync-many" + fi + + cp $DBFILE $ftppath + + # only for i686 (for now) + if [ "$arch" = "i686" ]; then + echo "==> Scanning for New/Updated packages..." >&2 + cd $stagedir/add + $ARCHDIR/pkgdb1 $CHECKOUTDIR $svnrepo | $ARCHDIR/pkgdb2-add $repoid $stagedir/add + fi + + # move the package files into the ftp directory + mv -f $stagedir/add/*.pkg.tar.gz $ftppath +fi + +if [ -d $stagedir/del -a "`ls $stagedir/del`" ]; then + echo "==> Processing deleted packages for repository '$reponame'..." >&2 + + # copy the db file into our working area + cp $ftppath/$reponame.db.tar.gz $DBFILE + + cd $stagedir/del + # run it thru fakeroot make sure everything is owned by root.root + echo "$ARCHDIR/updatesync-many del $DBFILE NOT-USED ZOMGWOO" \ + | fakeroot + + if [ $? -ne 0 ]; then + die "==> Error returned from updatesync-many" + fi + + cp $DBFILE $ftppath + + # only for i686 (for now) + if [ "$arch" = "i686" ]; then + echo "==> Scanning for Deleted packages..." >&2 + cd $stagedir/del + ( + for i in *.pkg.tar.gz; do + pkgname=$(getpkgname $i) + echo $pkgname + done + ) | $ARCHDIR/pkgdb2-del $repoid $stagedir/del + fi + + # remove the package files + rm -f $stagedir/del/*.pkg.tar.gz +fi + +if [ "$updatelists" ]; then + echo "==> Generating Text Package List..." >&2 + cd $CHECKOUTDIR + $ARCHDIR/genpkglist $ftppath $svnrepo + if [ -f packages.txt ]; then + mv packages.txt $ftppath/packages.txt + fi +fi + +cleanup + +# vim: set ts=4 sw=4 noet ft=sh: -- cgit v1.2.3-2-g168b From 2e0364b61c96598191e75fb9556fe454d6a1fb5f Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Tue, 15 Apr 2008 13:20:32 -0400 Subject: Remove SQL database related tasks from these scripts Updating a SQL database should NOT be a task of these scripts. They should deal ONLY with the act of maintaining a pacman repo Signed-off-by: Aaron Griffin --- db-update | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) mode change 100644 => 100755 db-update (limited to 'db-update') diff --git a/db-update b/db-update old mode 100644 new mode 100755 index 24ca489..d17fab4 --- a/db-update +++ b/db-update @@ -27,7 +27,7 @@ fi WORKDIR="~/.dbscripts" CHECKOUTDIR="$WORKDIR/checkout" -LOCKFILE="/tmp/.repolck.$arch.$repoid" +LOCKFILE="/tmp/.repolck.$arch.$reponame" DBFILE="$WORKDIR/$reponame.db.tar.gz" if [ ! `type -p fakeroot` ]; then @@ -129,13 +129,6 @@ if [ -d $stagedir/add -a "`ls $stagedir/add`" ]; then cp $DBFILE $ftppath - # only for i686 (for now) - if [ "$arch" = "i686" ]; then - echo "==> Scanning for New/Updated packages..." >&2 - cd $stagedir/add - $ARCHDIR/pkgdb1 $CHECKOUTDIR $svnrepo | $ARCHDIR/pkgdb2-add $repoid $stagedir/add - fi - # move the package files into the ftp directory mv -f $stagedir/add/*.pkg.tar.gz $ftppath fi @@ -157,18 +150,6 @@ if [ -d $stagedir/del -a "`ls $stagedir/del`" ]; then cp $DBFILE $ftppath - # only for i686 (for now) - if [ "$arch" = "i686" ]; then - echo "==> Scanning for Deleted packages..." >&2 - cd $stagedir/del - ( - for i in *.pkg.tar.gz; do - pkgname=$(getpkgname $i) - echo $pkgname - done - ) | $ARCHDIR/pkgdb2-del $repoid $stagedir/del - fi - # remove the package files rm -f $stagedir/del/*.pkg.tar.gz fi -- cgit v1.2.3-2-g168b From 6cb8979c4e48ec86df7b0740cb49f0fe42997f1a Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Fri, 2 May 2008 19:07:06 -0400 Subject: Massive rewrite to make this script uber Yeah too much to write out. I basically rewrote it from scratch to use repo-add and all that fun stuff. --- db-update | 227 ++++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 123 insertions(+), 104 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index d17fab4..766a2d5 100755 --- a/db-update +++ b/db-update @@ -1,168 +1,187 @@ #!/bin/bash -# where are the arch scripts located? -ARCHDIR="/arch" - if [ $# -ne 2 ]; then - echo "usage: $(basename $0) " + 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 -#All this fun stuff used to be in the db-(whatever) files -# Let's make it cleaner arch="$1" reponame="$2" export CARCH="$arch" -ftppath="/home/ftp/$reponame/os/$arch/" -svnpath="/home/svn-packages" + +##### Arch specific stuff. TODO make this configurable ##### +#ftppath="/home/ftp/$reponame/os/$arch/" +ftppath="/home/aaron/dbscripts/ftp-$reponame" +svnpath="file:///home/svn-packages" svnrepo="$reponame-$arch" +#stagedir="$HOME/staging/$reponame" +stagedir="/home/aaron/dbscripts/staging/$reponame" +############################################################ -#Hacky for now -if [ "$arch" = "x86_64" ]; then - stagedir="$HOME/staging/${reponame}64" -else - stagedir="$HOME/staging/$reponame" -fi +[ "$UID" = "" ] && UID=$(uid) -WORKDIR="~/.dbscripts" -CHECKOUTDIR="$WORKDIR/checkout" +WORKDIR="/tmp/db-update.$svnrepo.$UID" LOCKFILE="/tmp/.repolck.$arch.$reponame" -DBFILE="$WORKDIR/$reponame.db.tar.gz" +ADDPKGS="" +REMPKGS="" if [ ! `type -p fakeroot` ]; then - echo "error: fakeroot is missing" >&2 - exit 1 + echo "error: fakeroot is missing" >&2 + exit 1 fi if [ ! -d $stagedir ]; then - echo "error: staging directory missing: $stagedir" >&2 - exit 1 + echo "error: staging directory missing: $stagedir" >&2 + exit 1 fi # Get the package name from the filename # hackish, but should work for now getpkgname() { - local tmp + local tmp - tmp=${1##*/} - tmp=${tmp%.pkg.tar.gz} - tmp=${tmp%-i686} - tmp=${tmp%-x86_64} - echo ${tmp%-*-*} + tmp=${1##*/} + tmp=${tmp%$PKGEXT} + tmp=${tmp%-$CARCH} + echo ${tmp%-*-*} } cleanup() { - # unlock - rm -f "$LOCKFILE" - [ "$1" ] && exit $1 + # unlock + rm -f "$LOCKFILE" + #rm -rf "$WORKDIR" + [ "$1" ] && exit $1 } ctrl_c() { - echo "Interrupted" >&2 - cleanup 0 + echo "Interrupted" >&2 + cleanup 0 } die() { - echo "$*" >&2 - cleanup 1 + echo "$*" >&2 + cleanup 1 } # check for locks if [ -f "$LOCKFILE" ]; then - owner=$(/bin/ls -l $LOCKFILE | /bin/awk '{print $3}') + owner="$(/usr/bin/stat -c %U $LOCKFILE)" echo "error: db generation is already in progress (started by $owner)" exit 1 fi -# catch ^C breaks -trap ctrl_c SIGINT -# lock -touch "$LOCKFILE" +trap ctrl_c 2 +trap cleanup 0 -if [ -d $CHECKOUTDIR ]; then - cd $CHECKOUTDIR - svn update - if [ $? -gt 0 ]; then - die "==> SVN update failed, aborting!" - fi -else - echo "==> Checking out repo: $svnrepo ($arch) - Please be patient" - svn checkout file://$svnpath $CHECKOUTDIR - if [ $? -gt 0 ]; then - die "==> SVN checkout failed, aborting!" - fi -fi +touch "$LOCKFILE" -cd $CHECKOUTDIR +mkdir -p "$WORKDIR" -# Checkout the SVN module if we need to -updatelists= -if [ "`ls $stagedir/add 2>/dev/null`" -o "`ls $stagedir/del 2>/dev/null`" ]; then - updatelists=1 -else - echo "No files to process" - cleanup 0 +to_add="" +if [ -d "$stagedir/add" ]; then + ADDPKGS="$(ls $stagedir{64,}/add/*-${arch}$PKGEXT 2>/dev/null)" fi -# Right-O, now we look through the "add" and "del" subdirectories of -# $stagedir and process the packages there accordingly -- all packages -# in the "add" dir are added/updated, all packages in the "del" dir -# are removed. -# -# This means the sync db could actually be unpacked/repacked twice in -# one db-* invocation, but it's not a huge performance hit. - -if [ -d $stagedir/add -a "`ls $stagedir/add`" ]; then - echo "==> Processing new/updated packages for repository '$reponame'..." >&2 - - # copy the db file into our working area - cp $ftppath/$reponame.db.tar.gz $DBFILE +if [ -n "$ADDPKGS" ]; then + echo "==> Processing new/updated packages for repository '$reponame'..." >&2 + + cd "$WORKDIR" + svn checkout -N $svnpath checkout + cd checkout + + for pkg in $ADDPKGS; do + _pkgfile=$(basename $pkg) + _pkgname="$(getpkgname $pkg)" + echo " Checking SVN for $_pkgname" + svn up -q $_pkgname + if [ -d "$_pkgname/repos/$svnrepo" ]; then + . "$_pkgname/repos/$svnrepo/$BUILDSCRIPT" + if [ "$_pkgfile" = "$pkgname-$pkgver-$pkgrel-$CARCH$PKGEXT" ]; then + to_add="$to_add $pkg" + else + echo " WARNING: $_pkgfile does not match $BUILDSCRIPT in $svnrepo" + fi + else + echo " WARNING: Package $_pkgname not found in $svnrepo" + fi + done - cd $stagedir/add - # run it thru fakeroot make sure everything is owned by root.root - echo "$ARCHDIR/updatesync-many add $DBFILE $CHECKOUTDIR $svnrepo" | fakeroot + cd "$WORKDIR" + [ -d build/ ] || mkdir build - if [ $? -ne 0 ]; then - die "==> Error returned from updatesync-many" - fi + # copy the db file into our working area + [ -f "$ftppath/$reponame.db.tar.gz" ] && cp "$ftppath/$reponame.db.tar.gz" build/ + cp $to_add build/ - cp $DBFILE $ftppath + cd build/ + /usr/bin/repo-add "$reponame.db.tar.$DB_COMPRESSION" $to_add +else + echo "No packages to add" +fi - # move the package files into the ftp directory - mv -f $stagedir/add/*.pkg.tar.gz $ftppath +to_rem="" +if [ -d "$stagedir/del" ]; then + REMPKGS="$(ls $stagedir{64,}/del/*-${arch}$PKGEXT 2>/dev/null)" fi -if [ -d $stagedir/del -a "`ls $stagedir/del`" ]; then - echo "==> Processing deleted packages for repository '$reponame'..." >&2 +if [ -n "$REMPKGS" ]; then + echo "==> Processing deleted packages for repository '$reponame'..." >&2 - # copy the db file into our working area - cp $ftppath/$reponame.db.tar.gz $DBFILE + if [ ! -d "$WORKDIR/checkout" ]; then + cd "$WORKDIR" + svn checkout -N $svnpath checkout + fi + cd "$WORKDIR/checkout" + + #TODO removal shouldn't require a package file + for pkg in $REMPKGS; do + _pkgfile=$(basename $pkg) + _pkgname="$(getpkgname $pkg)" + echo " Checking SVN for $_pkgname" + svn up -q $_pkgname + if [ -d "$_pkgname/repos/$svnrepo" ]; then + echo " WARNING: $_pkgname still exists in $svnrepo" + else + to_rem="$to_rem $pkg" + fi + done - cd $stagedir/del - # run it thru fakeroot make sure everything is owned by root.root - echo "$ARCHDIR/updatesync-many del $DBFILE NOT-USED ZOMGWOO" \ - | fakeroot + cd "$WORKDIR" + [ -d build/ ] || mkdir build - if [ $? -ne 0 ]; then - die "==> Error returned from updatesync-many" + # copy the db file into our working area + [ -f "$ftppath/$reponame.db.tar.gz" ] && cp "$ftppath/$reponame.db.tar.gz" build/ + for rem in $to_rem; do + if [ -f "build/$rem" ]; then + rm "build/$rem" fi + done - cp $DBFILE $ftppath + cd build/ + /usr/bin/repo-remove "$reponame.db.tar.$DB_COMPRESSION" $to_rem +else + echo "No packages to delete" +fi - # remove the package files - rm -f $stagedir/del/*.pkg.tar.gz +if [ $(ls "$WORKDIR/build/" 2>/dev/null | wc -l) != 0 ]; then + cp -r "$WORKDIR/build/"* "$ftppath" fi if [ "$updatelists" ]; then - echo "==> Generating Text Package List..." >&2 - cd $CHECKOUTDIR - $ARCHDIR/genpkglist $ftppath $svnrepo - if [ -f packages.txt ]; then - mv packages.txt $ftppath/packages.txt - fi + echo "==> Generating Text Package List..." >&2 + cd "$WORKDIR/checkout" + $ARCHDIR/genpkglist $ftppath $svnrepo + if [ -f packages.txt ]; then + mv packages.txt $ftppath/packages.txt + fi fi - -cleanup - # vim: set ts=4 sw=4 noet ft=sh: -- cgit v1.2.3-2-g168b From 79e7365c6afdd0010cc5b64d63099c673320fe6e Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Mon, 5 May 2008 17:18:39 -0400 Subject: Switch the params to be inline with archrelease Signed-off-by: Aaron Griffin --- db-update | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 766a2d5..6c9af1a 100755 --- a/db-update +++ b/db-update @@ -13,8 +13,8 @@ else exit 1 fi -arch="$1" -reponame="$2" +reponame="$1" +arch="$2" export CARCH="$arch" -- cgit v1.2.3-2-g168b From 382a2fd7c25dfa9769f1a945f692e938168a21b6 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Tue, 6 May 2008 18:21:54 -0400 Subject: Remove testing paths These snuck in in a previous commit Signed-off-by: Aaron Griffin --- db-update | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 6c9af1a..f9452b4 100755 --- a/db-update +++ b/db-update @@ -19,12 +19,10 @@ arch="$2" export CARCH="$arch" ##### Arch specific stuff. TODO make this configurable ##### -#ftppath="/home/ftp/$reponame/os/$arch/" -ftppath="/home/aaron/dbscripts/ftp-$reponame" +ftppath="/home/ftp/$reponame/os/$arch/" svnpath="file:///home/svn-packages" svnrepo="$reponame-$arch" -#stagedir="$HOME/staging/$reponame" -stagedir="/home/aaron/dbscripts/staging/$reponame" +stagedir="$HOME/staging/$reponame" ############################################################ [ "$UID" = "" ] && UID=$(uid) -- cgit v1.2.3-2-g168b From 1bdf5e2109a24997ec5f786d12486718492df0ef Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Tue, 6 May 2008 18:22:50 -0400 Subject: Remove usage of the 64bit dirs from the staging path Packages can be differentiated now by $CARCH in the filename. No need for this extra dir. Also, using absolute paths for binaries Signed-off-by: Aaron Griffin --- db-update | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index f9452b4..c3b4593 100755 --- a/db-update +++ b/db-update @@ -80,27 +80,36 @@ fi trap ctrl_c 2 trap cleanup 0 -touch "$LOCKFILE" +/bin/touch "$LOCKFILE" -mkdir -p "$WORKDIR" +/bin/mkdir -p "$WORKDIR" + +echo "Updating DB for $reponame $arch" + +if [ -d "${stagedir}64" ]; then + echo "It looks like you have an old staging dir" + echo "Packages are now differentiated by the arch in the filename." + echo "Please delete '${stagedir}64'" + /bin/cp -r "${stagedir}64/" "$stagedir" +fi to_add="" if [ -d "$stagedir/add" ]; then - ADDPKGS="$(ls $stagedir{64,}/add/*-${arch}$PKGEXT 2>/dev/null)" + ADDPKGS="$(/bin/ls $stagedir/add/*-${arch}$PKGEXT 2>/dev/null)" fi if [ -n "$ADDPKGS" ]; then echo "==> Processing new/updated packages for repository '$reponame'..." >&2 - cd "$WORKDIR" - svn checkout -N $svnpath checkout - cd checkout + /bin/cd "$WORKDIR" + /usr/bin/svn checkout -N $svnpath checkout + /bin/cd checkout for pkg in $ADDPKGS; do _pkgfile=$(basename $pkg) _pkgname="$(getpkgname $pkg)" echo " Checking SVN for $_pkgname" - svn up -q $_pkgname + /usr/bin/svn up -q $_pkgname if [ -d "$_pkgname/repos/$svnrepo" ]; then . "$_pkgname/repos/$svnrepo/$BUILDSCRIPT" if [ "$_pkgfile" = "$pkgname-$pkgver-$pkgrel-$CARCH$PKGEXT" ]; then @@ -118,7 +127,7 @@ if [ -n "$ADDPKGS" ]; then # copy the db file into our working area [ -f "$ftppath/$reponame.db.tar.gz" ] && cp "$ftppath/$reponame.db.tar.gz" build/ - cp $to_add build/ + /bin/cp $to_add build/ cd build/ /usr/bin/repo-add "$reponame.db.tar.$DB_COMPRESSION" $to_add @@ -128,17 +137,17 @@ fi to_rem="" if [ -d "$stagedir/del" ]; then - REMPKGS="$(ls $stagedir{64,}/del/*-${arch}$PKGEXT 2>/dev/null)" + REMPKGS="$(/bin/ls $stagedir/del/*-${arch}$PKGEXT 2>/dev/null)" fi if [ -n "$REMPKGS" ]; then echo "==> Processing deleted packages for repository '$reponame'..." >&2 if [ ! -d "$WORKDIR/checkout" ]; then - cd "$WORKDIR" - svn checkout -N $svnpath checkout + /bin/cd "$WORKDIR" + /usr/bin/svn checkout -N $svnpath checkout fi - cd "$WORKDIR/checkout" + /bin/cd "$WORKDIR/checkout" #TODO removal shouldn't require a package file for pkg in $REMPKGS; do @@ -160,7 +169,7 @@ if [ -n "$REMPKGS" ]; then [ -f "$ftppath/$reponame.db.tar.gz" ] && cp "$ftppath/$reponame.db.tar.gz" build/ for rem in $to_rem; do if [ -f "build/$rem" ]; then - rm "build/$rem" + /bin/rm "build/$rem" fi done -- cgit v1.2.3-2-g168b From 26b2f70e1d82f2a0e9a2127604a5bf610d37f404 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Tue, 6 May 2008 18:25:18 -0400 Subject: More absolute pathing Also, added a pretty comment. It's so pretty! Signed-off-by: Aaron Griffin --- db-update | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index c3b4593..1134b2d 100755 --- a/db-update +++ b/db-update @@ -179,8 +179,9 @@ else echo "No packages to delete" fi -if [ $(ls "$WORKDIR/build/" 2>/dev/null | wc -l) != 0 ]; then - cp -r "$WORKDIR/build/"* "$ftppath" +# if non empty, move all build dirs +if [ $(/bin/ls "$WORKDIR/build/" 2>/dev/null | wc -l) != 0 ]; then + /bin/cp -r "$WORKDIR/build/"* "$ftppath" fi if [ "$updatelists" ]; then -- cgit v1.2.3-2-g168b From 2d5b42fdd5ed2fa981c1122e040fd3974e79525e Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Tue, 6 May 2008 18:27:12 -0400 Subject: Remove genpkglists from the dbscripts This is silly and broken anyway. We can do this with a cron script later Signed-off-by: Aaron Griffin --- db-update | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 1134b2d..db96704 100755 --- a/db-update +++ b/db-update @@ -181,15 +181,9 @@ 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'" /bin/cp -r "$WORKDIR/build/"* "$ftppath" -fi - -if [ "$updatelists" ]; then - echo "==> Generating Text Package List..." >&2 - cd "$WORKDIR/checkout" - $ARCHDIR/genpkglist $ftppath $svnrepo - if [ -f packages.txt ]; then - mv packages.txt $ftppath/packages.txt - fi +else + echo "Nothing to copy, no work done" fi # vim: set ts=4 sw=4 noet ft=sh: -- cgit v1.2.3-2-g168b From e259c23bb739c3129e23e053cf1c5a846c6c3e76 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Tue, 6 May 2008 18:28:34 -0400 Subject: Fix file deletion on package removal Signed-off-by: Aaron Griffin --- db-update | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index db96704..2dfda2a 100755 --- a/db-update +++ b/db-update @@ -167,14 +167,16 @@ if [ -n "$REMPKGS" ]; then # copy the db file into our working area [ -f "$ftppath/$reponame.db.tar.gz" ] && cp "$ftppath/$reponame.db.tar.gz" build/ - for rem in $to_rem; do - if [ -f "build/$rem" ]; then - /bin/rm "build/$rem" - fi - done cd build/ /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" + /bin/rm "$rem" + fi + done else echo "No packages to delete" fi -- cgit v1.2.3-2-g168b From 516aece0d26fc3b36e49c2739286f2be5cc0aa01 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Wed, 7 May 2008 01:18:31 -0400 Subject: Whoops, 'cd' is a built in - who knew? I sure didn't Signed-off-by: Aaron Griffin --- db-update | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 2dfda2a..833abca 100755 --- a/db-update +++ b/db-update @@ -101,9 +101,9 @@ fi if [ -n "$ADDPKGS" ]; then echo "==> Processing new/updated packages for repository '$reponame'..." >&2 - /bin/cd "$WORKDIR" + cd "$WORKDIR" /usr/bin/svn checkout -N $svnpath checkout - /bin/cd checkout + cd checkout for pkg in $ADDPKGS; do _pkgfile=$(basename $pkg) @@ -144,10 +144,10 @@ if [ -n "$REMPKGS" ]; then echo "==> Processing deleted packages for repository '$reponame'..." >&2 if [ ! -d "$WORKDIR/checkout" ]; then - /bin/cd "$WORKDIR" + cd "$WORKDIR" /usr/bin/svn checkout -N $svnpath checkout fi - /bin/cd "$WORKDIR/checkout" + cd "$WORKDIR/checkout" #TODO removal shouldn't require a package file for pkg in $REMPKGS; do -- cgit v1.2.3-2-g168b From 054f2b100691c83ac9f99bfae0a823144c5460d9 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Wed, 7 May 2008 01:32:38 -0400 Subject: Make sure we copy old staging dir entries properly Signed-off-by: Aaron Griffin --- db-update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db-update') diff --git a/db-update b/db-update index 833abca..791207d 100755 --- a/db-update +++ b/db-update @@ -90,7 +90,7 @@ if [ -d "${stagedir}64" ]; then echo "It looks like you have an old staging dir" echo "Packages are now differentiated by the arch in the filename." echo "Please delete '${stagedir}64'" - /bin/cp -r "${stagedir}64/" "$stagedir" + /bin/cp -r "${stagedir}64/"* "$stagedir/" fi to_add="" -- cgit v1.2.3-2-g168b From aca168b4f23826d3dd5ad15d22ad9a564f69a40d Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Wed, 7 May 2008 01:34:19 -0400 Subject: Make sure we're actually adding/removing files We accidentally were calling repo-add/repo-remove with invalid (empty) params. Signed-off-by: Aaron Griffin --- db-update | 49 ++++++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 19 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 791207d..bde0ee9 100755 --- a/db-update +++ b/db-update @@ -122,15 +122,20 @@ if [ -n "$ADDPKGS" ]; then fi done - cd "$WORKDIR" - [ -d build/ ] || mkdir build + if [ -n "$to_add" ]; 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/ - /bin/cp $to_add build/ + # 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 + cd build/ + /usr/bin/repo-add "$reponame.db.tar.$DB_COMPRESSION" $to_add + else + echo "Errors found when adding packages" + fi else echo "No packages to add" fi @@ -162,21 +167,25 @@ if [ -n "$REMPKGS" ]; then fi done - cd "$WORKDIR" - [ -d build/ ] || mkdir build + 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/ + # copy the db file into our working area + [ -f "$ftppath/$reponame.db.tar.gz" ] && cp "$ftppath/$reponame.db.tar.gz" build/ - cd build/ - /usr/bin/repo-remove "$reponame.db.tar.$DB_COMPRESSION" $to_rem + cd build/ + /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" - /bin/rm "$rem" - fi - done + for rem in $to_rem; do + if [ -f "$ftppath/$rem" ]; then + /bin/rm "$ftppath/$rem" + /bin/rm "$rem" + fi + done + else + echo "Errors found when removing packages" + fi else echo "No packages to delete" fi @@ -188,4 +197,6 @@ if [ $(/bin/ls "$WORKDIR/build/" 2>/dev/null | wc -l) != 0 ]; then else echo "Nothing to copy, no work done" fi + +cleanup # vim: set ts=4 sw=4 noet ft=sh: -- cgit v1.2.3-2-g168b From 0cb6e7ab0840196c8b9c0dda64e50fa535b17707 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Wed, 7 May 2008 01:36:03 -0400 Subject: Fail loudly if ftp dir is missing This allows us to intuitively handle on-the-fly repos by calling `db-update foobar i686` for the foobar-i686 tag, and let us fail on the server side if the repo hasn't been approved/created by someone with admin rights. Signed-off-by: Aaron Griffin --- db-update | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'db-update') diff --git a/db-update b/db-update index bde0ee9..5d492fd 100755 --- a/db-update +++ b/db-update @@ -32,7 +32,13 @@ LOCKFILE="/tmp/.repolck.$arch.$reponame" ADDPKGS="" REMPKGS="" -if [ ! `type -p fakeroot` ]; then +if [ ! -d "$ftppath" ]; then + echo "FTP path for this repo ($reponame) is missing" + echo "Please contact a system administrator" + exit 1 +fi + +if [ ! $(type -p fakeroot) ]; then echo "error: fakeroot is missing" >&2 exit 1 fi -- cgit v1.2.3-2-g168b From cbd6533816b1c27aab268b5c8f823345be8e12ed Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Wed, 7 May 2008 01:40:02 -0400 Subject: Properly clean up stating dirs after a success Remove all package file we added or removed Signed-off-by: Aaron Griffin --- db-update | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'db-update') diff --git a/db-update b/db-update index 5d492fd..451d206 100755 --- a/db-update +++ b/db-update @@ -186,7 +186,6 @@ if [ -n "$REMPKGS" ]; then for rem in $to_rem; do if [ -f "$ftppath/$rem" ]; then /bin/rm "$ftppath/$rem" - /bin/rm "$rem" fi done else @@ -200,9 +199,14 @@ 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" + echo "/bin/rm $to_add $to_rem" + /bin/rm $to_add $to_rem else echo "Nothing to copy, no work done" fi + + cleanup # vim: set ts=4 sw=4 noet ft=sh: -- cgit v1.2.3-2-g168b From ebff7202e4c1c4d7e5f208659e9878082df73ced Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Wed, 7 May 2008 04:19:47 -0400 Subject: Cleanup some debugging output Leftovers - accidental commit Signed-off-by: Aaron Griffin --- db-update | 3 --- 1 file changed, 3 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 451d206..e88ab40 100755 --- a/db-update +++ b/db-update @@ -200,13 +200,10 @@ 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" - echo "/bin/rm $to_add $to_rem" /bin/rm $to_add $to_rem else echo "Nothing to copy, no work done" fi - - cleanup # vim: set ts=4 sw=4 noet ft=sh: -- cgit v1.2.3-2-g168b From 39256c685d1aee1e92e1b8f4595fa15d6ba94a23 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Wed, 14 May 2008 13:23:00 -0400 Subject: Remove a check for fakeroot We don't use fakeroot anymore in these scripts Signed-off-by: Aaron Griffin --- db-update | 5 ----- 1 file changed, 5 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index e88ab40..e616aba 100755 --- a/db-update +++ b/db-update @@ -38,11 +38,6 @@ if [ ! -d "$ftppath" ]; then exit 1 fi -if [ ! $(type -p fakeroot) ]; then - echo "error: fakeroot is missing" >&2 - exit 1 -fi - if [ ! -d $stagedir ]; then echo "error: staging directory missing: $stagedir" >&2 exit 1 -- cgit v1.2.3-2-g168b From 4a928ca7a0ed02f7be01655831eeac9158bacabe Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Wed, 14 May 2008 13:23:25 -0400 Subject: Make sure to clean up working temp dirs Left in a comment while debugging Signed-off-by: Aaron Griffin --- db-update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db-update') diff --git a/db-update b/db-update index e616aba..2e0e632 100755 --- a/db-update +++ b/db-update @@ -57,7 +57,7 @@ getpkgname() { cleanup() { # unlock rm -f "$LOCKFILE" - #rm -rf "$WORKDIR" + rm -rf "$WORKDIR" [ "$1" ] && exit $1 } -- cgit v1.2.3-2-g168b From e021dfb2c476c2841606e63e6ae58dfc45cd1b47 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Wed, 14 May 2008 15:09:04 -0400 Subject: Make the staging warning stand out more Signed-off-by: Aaron Griffin --- db-update | 2 ++ 1 file changed, 2 insertions(+) (limited to 'db-update') diff --git a/db-update b/db-update index 2e0e632..9d0ecad 100755 --- a/db-update +++ b/db-update @@ -88,9 +88,11 @@ trap cleanup 0 echo "Updating DB for $reponame $arch" if [ -d "${stagedir}64" ]; then + echo "--------------------------------------------------" echo "It looks like you have an old staging dir" echo "Packages are now differentiated by the arch in the filename." echo "Please delete '${stagedir}64'" + echo "--------------------------------------------------" /bin/cp -r "${stagedir}64/"* "$stagedir/" fi -- cgit v1.2.3-2-g168b From 39298cf09e2e88b1f6aec779170990675baf8992 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Wed, 14 May 2008 18:49:20 -0400 Subject: 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 --- db-update | 50 ++++++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 22 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 9d0ecad..93672f5 100755 --- a/db-update +++ b/db-update @@ -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: -- cgit v1.2.3-2-g168b From 41bf0372aacd5737f31968d6a274e813301b69cc Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Thu, 22 May 2008 12:53:47 -0400 Subject: Use 'mv' to shuffle files out of the *64 dirs This way, all package files get cleaned up properly at the end of the process. Signed-off-by: Aaron Griffin --- db-update | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'db-update') diff --git a/db-update b/db-update index 93672f5..7ff768e 100755 --- a/db-update +++ b/db-update @@ -101,7 +101,8 @@ if [ -d "${stagedir}64" ]; then echo "Packages are now differentiated by the arch in the filename." echo "Please delete '${stagedir}64'" echo "--------------------------------------------------" - /bin/cp -r "${stagedir}64/"* "$stagedir/" + /bin/mv "${stagedir}64/add/"* "$stagedir/add/" + /bin/mv "${stagedir}64/del/"* "$stagedir/del/" fi to_add="" -- cgit v1.2.3-2-g168b From 01d2e01a129a4ded9ccba2659250a94cb3fddd36 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Sat, 30 Aug 2008 21:08:15 -0500 Subject: Prevent staging cleanup if copy to repo fails This stops files being removed from the staging area if they were not successfully copied to the repo. This can happen due to permission issues with the database when multiple people update the repo in quick succession. Original-work-by: Allan McRae Signed-off-by: Aaron Griffin --- db-update | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'db-update') diff --git a/db-update b/db-update index 7ff768e..4b2571d 100755 --- a/db-update +++ b/db-update @@ -198,7 +198,9 @@ 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'" - /bin/cp -r "$WORKDIR/build/"* "$ftppath" + if ! /bin/cp -r "$WORKDIR/build/"* "$ftppath"; then + die "error: failure while copying files to $ftppath" + fi else echo "Nothing to copy, no work done" -- cgit v1.2.3-2-g168b 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-update | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'db-update') 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" -- cgit v1.2.3-2-g168b From a0f73ceca409fa8995af16eee8440c1467c5f1bf Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Sat, 13 Sep 2008 17:49:59 -0500 Subject: Validate a package file's architecture Apparently, people seem to be renaming files as a "hack" and breaking things. Let's make sure they edited the PKGINFO too Signed-off-by: Aaron Griffin --- db-update | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 5060449..d3fff2c 100755 --- a/db-update +++ b/db-update @@ -108,17 +108,23 @@ if [ -n "$ADDPKGS" ]; then for pkg in $ADDPKGS; do _pkgfile=$(basename $pkg) _pkgname="$(getpkgname $pkg)" - echo " Checking SVN for $_pkgname" - /usr/bin/svn up -q $_pkgname - if [ -d "$_pkgname/repos/$svnrepo" ]; then - . "$_pkgname/repos/$svnrepo/$BUILDSCRIPT" - if [ "$_pkgfile" = "$pkgname-$pkgver-$pkgrel-$CARCH$PKGEXT" ]; then - to_add="$to_add $pkg" + + echo " Validating package arch ($arch) $_pkgname" + if ! check_pkg_arch "$pkg" "$arch"; then + echo " ERROR: $_pkgfile was built for the wrong architecture" + else + echo " Checking SVN for $_pkgname" + /usr/bin/svn up -q $_pkgname + if [ -d "$_pkgname/repos/$svnrepo" ]; then + . "$_pkgname/repos/$svnrepo/$BUILDSCRIPT" + if [ "$_pkgfile" = "$pkgname-$pkgver-$pkgrel-$CARCH$PKGEXT" ]; then + to_add="$to_add $pkg" + else + echo " WARNING: $_pkgfile does not match $BUILDSCRIPT in $svnrepo" + fi else - echo " WARNING: $_pkgfile does not match $BUILDSCRIPT in $svnrepo" + echo " WARNING: Package $_pkgname not found in $svnrepo" fi - else - echo " WARNING: Package $_pkgname not found in $svnrepo" fi done -- cgit v1.2.3-2-g168b 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-update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db-update') 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="" -- cgit v1.2.3-2-g168b From 5d686fdacc99e34a2f1b6d510873be46433df7b2 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Thu, 16 Oct 2008 19:38:03 -0400 Subject: Fix a typo in db-update's usage output Signed-off-by: Aaron Griffin --- db-update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db-update') diff --git a/db-update b/db-update index dbfbe51..81b3905 100755 --- a/db-update +++ b/db-update @@ -1,7 +1,7 @@ #!/bin/bash if [ $# -ne 2 ]; then - echo "usage: $(basename $0) " + echo "usage: $(basename $0) " exit 1 fi -- cgit v1.2.3-2-g168b 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-update | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'db-update') 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-2-g168b 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-update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db-update') 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 -- cgit v1.2.3-2-g168b 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 --- db-update | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'db-update') 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" -- cgit v1.2.3-2-g168b 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 --- db-update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db-update') 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="" -- cgit v1.2.3-2-g168b 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-update | 1 + 1 file changed, 1 insertion(+) (limited to 'db-update') 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" -- cgit v1.2.3-2-g168b From 309e7c2e5d6f685c99307adfc78ab05939c72f8f Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Fri, 21 Nov 2008 13:43:40 -0800 Subject: Remove /del dir usage from db-update db-remove is superior and requiring package files is dumb. Kill off this dir and clean up some code, yay! Signed-off-by: Aaron Griffin --- db-update | 64 ++++++++++++++------------------------------------------------- 1 file changed, 14 insertions(+), 50 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 9aba199..397a046 100755 --- a/db-update +++ b/db-update @@ -22,7 +22,6 @@ stagedir="$STAGING/$reponame" WORKDIR="$TMPDIR/db-update.$svnrepo.$UID" ADDPKGS="" -REMPKGS="" if [ ! -d "$ftppath" ]; then echo "FTP path for this repo ($reponame) is missing" @@ -91,9 +90,19 @@ if [ -d "${stagedir}64" ]; then /bin/mv "${stagedir}64/del/"* "$stagedir/del/" fi +if [ -d "${stagedir}/add" ]; then + echo "--------------------------------------------------" + echo "It looks like you have an old staging dir" + echo "The 'add' and 'del' dirs are no longer used." + echo "Please delete staging//{add,del}" + echo " and ensure you are using the newest devtools" + echo "--------------------------------------------------" + /bin/mv "${stagedir}/add/"* "$stagedir/" +fi + to_add="" -if [ -d "$stagedir/add" ]; then - ADDPKGS="$(/bin/ls $stagedir/add/*-${arch}$PKGEXT 2>/dev/null)" +if [ -d "$stagedir" ]; then + ADDPKGS="$(/bin/ls $stagedir/*-${arch}$PKGEXT 2>/dev/null)" fi if [ -n "$ADDPKGS" ]; then @@ -142,51 +151,6 @@ else echo "No packages to add" fi -to_rem="" -if [ -d "$stagedir/del" ]; then - REMPKGS="$(/bin/ls $stagedir/del/*-${arch}$PKGEXT 2>/dev/null)" -fi - -if [ -n "$REMPKGS" ]; then - echo "==> Processing deleted packages for repository '$reponame'..." >&2 - - if [ ! -d "$WORKDIR/checkout" ]; then - cd "$WORKDIR" - /usr/bin/svn checkout -N $SVN_PATH checkout - fi - cd "$WORKDIR/checkout" - - #TODO removal shouldn't require a package file - for pkg in $REMPKGS; do - _pkgfile=$(basename $pkg) - _pkgname="$(getpkgname $pkg)" - echo " Checking SVN for $_pkgname" - svn up -q $_pkgname - if [ -d "$_pkgname/repos/$svnrepo" ]; then - echo " WARNING: $_pkgname still exists in $svnrepo" - else - to_rem="$to_rem $_pkgname" - fi - done - - if [ -n "$to_rem" ]; then - cd "$WORKDIR/build/" - - #NOTE: to_rem consists of package NAMES only - /usr/bin/repo-remove "$reponame.db.tar.$DB_COMPRESSION" $to_rem - - 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 - echo "No packages to delete" -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'" @@ -200,9 +164,9 @@ else echo "Nothing to copy, no work done" fi -if [ -n "$ADDPKGS" -o -n "$REMPKGS" ]; then +if [ -n "$ADDPKGS" ]; then echo "Cleaning staging dir" - /bin/rm $ADDPKGS $REMPKGS + /bin/rm $ADDPKGS fi cleanup -- cgit v1.2.3-2-g168b From 3606df775189459eef24fdec2bad5cab6ccc7ec6 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Fri, 21 Nov 2008 17:14:10 -0800 Subject: Fix a variable overwrite when sourcing PKGBUILDs The local variable 'arch' was being overwritten when we source PKGBUILDs. Change it to _arch wherever we deal with PKGBUILD files Signed-off-by: Aaron Griffin --- db-update | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 397a046..d98b60d 100755 --- a/db-update +++ b/db-update @@ -10,12 +10,12 @@ fi source_makepkg reponame="$1" -arch="$2" +_arch="$2" -export CARCH="$arch" +export CARCH="$_arch" -ftppath="$FTP_BASE/$reponame/os/$arch/" -svnrepo="$reponame-$arch" +ftppath="$FTP_BASE/$reponame/os/$_arch/" +svnrepo="$reponame-$_arch" stagedir="$STAGING/$reponame" [ "$UID" = "" ] && UID=$(uid) @@ -48,7 +48,7 @@ getpkgname() { cleanup() { trap '' 0 2 # unlock - repo_unlock $reponame $arch + repo_unlock $reponame $_arch rm -rf "$WORKDIR" [ "$1" ] && exit $1 } @@ -66,7 +66,7 @@ die() { trap ctrl_c 2 trap cleanup 0 -repo_lock $reponame $arch +repo_lock $reponame $_arch /bin/mkdir -p "$WORKDIR/build" cd "$WORKDIR" @@ -78,7 +78,7 @@ else touch "build/$reponame.db.tar.$DB_COMPRESSION" fi -echo "Updating DB for $reponame $arch" +echo "Updating DB for $reponame $_arch" if [ -d "${stagedir}64" ]; then echo "--------------------------------------------------" @@ -102,7 +102,7 @@ fi to_add="" if [ -d "$stagedir" ]; then - ADDPKGS="$(/bin/ls $stagedir/*-${arch}$PKGEXT 2>/dev/null)" + ADDPKGS="$(/bin/ls $stagedir/*-${_arch}$PKGEXT 2>/dev/null)" fi if [ -n "$ADDPKGS" ]; then @@ -116,15 +116,15 @@ if [ -n "$ADDPKGS" ]; then _pkgfile=$(basename $pkg) _pkgname="$(getpkgname $pkg)" - echo " Validating package arch ($arch) $_pkgname" - if ! check_pkg_arch "$pkg" "$arch"; then + echo " Validating package arch ($_arch) $_pkgname" + if ! check_pkg_arch "$pkg" "$_arch"; then echo " ERROR: $_pkgfile was built for the wrong architecture" else echo " Checking SVN for $_pkgname" /usr/bin/svn up -q $_pkgname if [ -d "$_pkgname/repos/$svnrepo" ]; then . "$_pkgname/repos/$svnrepo/$BUILDSCRIPT" - if [ "$_pkgfile" = "$pkgname-$pkgver-$pkgrel-$CARCH$PKGEXT" ]; then + if [ "$_pkgfile" = "$pkgname-$pkgver-$pkgrel-$_arch$PKGEXT" ]; then to_add="$to_add $pkg" else echo " WARNING: $_pkgfile does not match $BUILDSCRIPT in $svnrepo" -- cgit v1.2.3-2-g168b 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-update | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'db-update') 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-2-g168b From 252e11f0e5a4eba7859108e0fb4bb3593819276f Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Sun, 23 Nov 2008 02:17:39 -0600 Subject: Remove some harmless error messages If add/del dirs exist, we try to fix it all up and it can error quite loudly Signed-off-by: Aaron Griffin --- db-update | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'db-update') diff --git a/db-update b/db-update index c76337a..1d2efa2 100755 --- a/db-update +++ b/db-update @@ -97,7 +97,9 @@ if [ -d "${stagedir}/add" ]; then echo "Please delete staging//{add,del}" echo " and ensure you are using the newest devtools" echo "--------------------------------------------------" - /bin/mv "${stagedir}/add/"* "$stagedir/" + if [ -e "${stagedir}/add/"* ]; then + /bin/mv "${stagedir}/add/"* "$stagedir/" + fi fi to_add="" -- cgit v1.2.3-2-g168b From 3fb6203f79434d48954f6ef3c5be7067beaccd86 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Sun, 23 Nov 2008 03:22:15 -0500 Subject: Only copy DB file from repo if we have pkgs We were copying our DB file from the repo to our temp build dir all the time. We should only do this if there are packages to add Signed-off-by: Aaron Griffin --- db-update | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 1d2efa2..42f5430 100755 --- a/db-update +++ b/db-update @@ -71,13 +71,6 @@ repo_lock $reponame $_arch /bin/mkdir -p "$WORKDIR/build" 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/ -else - touch "build/$reponame.db.tar.$DB_COMPRESSION" -fi - echo "Updating DB for $reponame $_arch" if [ -d "${stagedir}64" ]; then @@ -108,6 +101,14 @@ if [ -d "$stagedir" ]; then fi if [ -n "$ADDPKGS" ]; 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/ + else + touch "build/$reponame.db.tar.$DB_COMPRESSION" + fi + echo "==> Processing new/updated packages for repository '$reponame'..." >&2 cd "$WORKDIR" -- cgit v1.2.3-2-g168b From 1f48eaf35eecd0b35208d29d6fe6c0a8af7796df Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Mon, 1 Dec 2008 19:02:09 -0600 Subject: Do not touch db file if it doesn't exist repo-add works fine if no db file exists Signed-off-by: Aaron Griffin --- db-update | 2 -- 1 file changed, 2 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 1d2efa2..0c2d1fe 100755 --- a/db-update +++ b/db-update @@ -74,8 +74,6 @@ 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/ -else - touch "build/$reponame.db.tar.$DB_COMPRESSION" fi echo "Updating DB for $reponame $_arch" -- cgit v1.2.3-2-g168b 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-update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db-update') 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-2-g168b From b0e7b12ed43b6614b6c32f1678edf53f1c668513 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Tue, 16 Dec 2008 08:50:53 -0800 Subject: Only remove packages that were successfully added This prevents some errors where packages where removed from the staging dir when they shouldn't have been. Original-idea-by: Pierre Schmitz Signed-off-by: Aaron Griffin --- db-update | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 40c5539..2a9dd6e 100755 --- a/db-update +++ b/db-update @@ -164,9 +164,9 @@ else echo "Nothing to copy, no work done" fi -if [ -n "$ADDPKGS" ]; then +if [ -n "$to_add" ]; then echo "Cleaning staging dir" - /bin/rm $ADDPKGS + /bin/rm $to_add fi cleanup -- cgit v1.2.3-2-g168b From 830f8f87e1ede09a8c827c1a93aa4ed5db66f0b6 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Mon, 29 Dec 2008 13:31:33 -0800 Subject: Remove an if check for old staging 'add' dirs Signed-off-by: Aaron Griffin --- db-update | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 2a9dd6e..254a6f9 100755 --- a/db-update +++ b/db-update @@ -95,9 +95,7 @@ if [ -d "${stagedir}/add" ]; then echo "Please delete staging//{add,del}" echo " and ensure you are using the newest devtools" echo "--------------------------------------------------" - if [ -e "${stagedir}/add/"* ]; then - /bin/mv "${stagedir}/add/"* "$stagedir/" - fi + /bin/mv "${stagedir}/add/"* "$stagedir/" fi to_add="" -- cgit v1.2.3-2-g168b From 1ef058dad91a5ca82db2744776251a2ab68bcf90 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Fri, 20 Feb 2009 10:01:27 -0800 Subject: Make db-update parse all architecutres ARCHES is defined in config. db-update should now loop over all arches on each run and update whatever is in the staging dir. Remove the db-*64 scripts due to this Signed-off-by: Aaron Griffin --- db-update | 206 ++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 106 insertions(+), 100 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 77af39f..ea57eed 100755 --- a/db-update +++ b/db-update @@ -1,7 +1,7 @@ #!/bin/bash -if [ $# -ne 2 ]; then - echo "usage: $(basename $0) " +if [ $# -ne 1 ]; then + echo "usage: $(basename $0) " exit 1 fi @@ -10,30 +10,39 @@ fi source_makepkg reponame="$1" -_arch="$2" - -export CARCH="$_arch" - -ftppath="$FTP_BASE/$reponame/os/$_arch/" -svnrepo="$reponame-$_arch" -stagedir="$STAGING/$reponame" +current_arch="" [ "$UID" = "" ] && UID=$(uid) WORKDIR="$TMPDIR/db-update.$svnrepo.$UID" ADDPKGS="" -if [ ! -d "$ftppath" ]; then - echo "FTP path for this repo ($reponame) is missing" - echo "Please contact a system administrator" - exit 1 -fi - +stagedir="$STAGING/$reponame" if [ ! -d $stagedir ]; then echo "error: staging directory missing: $stagedir" >&2 exit 1 fi +if [ -d "${stagedir}64" ]; then + echo "--------------------------------------------------" + echo "It looks like you have an old staging dir" + echo "Packages are now differentiated by the arch in the filename." + echo "Please delete '${stagedir}64'" + echo "--------------------------------------------------" + /bin/mv "${stagedir}64/add/"* "$stagedir/add/" + /bin/mv "${stagedir}64/del/"* "$stagedir/del/" +fi + +if [ -d "${stagedir}/add" ]; then + echo "--------------------------------------------------" + echo "It looks like you have an old staging dir" + echo "The 'add' and 'del' dirs are no longer used." + echo "Please delete staging//{add,del}" + echo " and ensure you are using the newest devtools" + echo "--------------------------------------------------" + /bin/mv "${stagedir}/add/"* "$stagedir/" +fi + # Get the package name from the filename # hackish, but should work for now getpkgname() { @@ -41,14 +50,14 @@ getpkgname() { tmp=${1##*/} tmp=${tmp%$PKGEXT} - tmp=${tmp%-$CARCH} + tmp=${tmp%-$current_arch} echo ${tmp%-*-*} } cleanup() { trap '' 0 2 # unlock - repo_unlock $reponame $_arch + repo_unlock $reponame $current_arch rm -rf "$WORKDIR" [ "$1" ] && exit $1 } @@ -66,114 +75,111 @@ die() { trap ctrl_c 2 trap cleanup 0 -repo_lock $reponame $_arch +for A in ${ARCHES[@]}; do + current_arch="$A" -/bin/mkdir -p "$WORKDIR/build" -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/ -fi + ftppath="$FTP_BASE/$reponame/os/$current_arch/" -echo "Updating DB for $reponame $_arch" - -if [ -d "${stagedir}64" ]; then - echo "--------------------------------------------------" - echo "It looks like you have an old staging dir" - echo "Packages are now differentiated by the arch in the filename." - echo "Please delete '${stagedir}64'" - echo "--------------------------------------------------" - /bin/mv "${stagedir}64/add/"* "$stagedir/add/" - /bin/mv "${stagedir}64/del/"* "$stagedir/del/" -fi + if [ ! -d "$ftppath" ]; then + echo "FTP path for this repo ($reponame) is missing" + echo " -> $ftppath" + echo "Please contact a system administrator" + exit 1 + fi -if [ -d "${stagedir}/add" ]; then - echo "--------------------------------------------------" - echo "It looks like you have an old staging dir" - echo "The 'add' and 'del' dirs are no longer used." - echo "Please delete staging//{add,del}" - echo " and ensure you are using the newest devtools" - echo "--------------------------------------------------" - /bin/mv "${stagedir}/add/"* "$stagedir/" -fi + svnrepo="$reponame-$current_arch" -to_add="" -if [ -d "$stagedir" ]; then - ADDPKGS="$(/bin/ls $stagedir/*-${_arch}$PKGEXT 2>/dev/null)" -fi + repo_lock $reponame $current_arch -if [ -n "$ADDPKGS" ]; then + /bin/mkdir -p "$WORKDIR/build" + cd "$WORKDIR" - echo "==> Copying DB file from '$reponame'..." >&2 + # 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/ - else - touch "build/$reponame.db.tar.$DB_COMPRESSION" fi - echo "==> Processing new/updated packages for repository '$reponame'..." >&2 + echo "Updating DB for $svnrepo" - cd "$WORKDIR" - /usr/bin/svn checkout -N $SVN_PATH checkout - cd checkout + to_add="" + if [ -d "$stagedir" ]; then + ADDPKGS="$(/bin/ls $stagedir/*-${current_arch}$PKGEXT 2>/dev/null)" + fi - for pkg in $ADDPKGS; do - _pkgfile=$(basename $pkg) - _pkgname="$(getpkgname $pkg)" + if [ -n "$ADDPKGS" ]; then - echo " Validating package arch ($_arch) $_pkgname" - if ! check_pkg_arch "$pkg" "$_arch"; then - echo " ERROR: $_pkgfile was built for the wrong architecture" + 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/ else - echo " Checking SVN for $_pkgname" - /usr/bin/svn up -q $_pkgname - if [ -d "$_pkgname/repos/$svnrepo" ]; then - . "$_pkgname/repos/$svnrepo/$BUILDSCRIPT" - if [ "$_pkgfile" = "$pkgname-$pkgver-$pkgrel-$_arch$PKGEXT" ]; then - to_add="$to_add $pkg" + touch "build/$reponame.db.tar.$DB_COMPRESSION" + fi + + echo "==> Processing new/updated packages for repository '$reponame'..." >&2 + + cd "$WORKDIR" + /usr/bin/svn checkout -N $SVN_PATH checkout + cd checkout + + for pkg in $ADDPKGS; do + _pkgfile=$(basename $pkg) + _pkgname="$(getpkgname $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 $_pkgname" + /usr/bin/svn up -q $_pkgname + if [ -d "$_pkgname/repos/$svnrepo" ]; then + . "$_pkgname/repos/$svnrepo/$BUILDSCRIPT" + if [ "$_pkgfile" = "$pkgname-$pkgver-$pkgrel-$current_arch$PKGEXT" ]; then + to_add="$to_add $pkg" + else + echo " WARNING: $_pkgfile does not match $BUILDSCRIPT in $svnrepo" + fi else - echo " WARNING: $_pkgfile does not match $BUILDSCRIPT in $svnrepo" + echo " WARNING: Package $_pkgname not found in $svnrepo" fi - else - echo " WARNING: Package $_pkgname not found in $svnrepo" fi - fi - done + done - if [ -n "$to_add" ]; then - cd "$WORKDIR/build/" - for f in $to_add; do /bin/cp "$f" .; done + if [ -n "$to_add" ]; then + cd "$WORKDIR/build/" + for f in $to_add; do /bin/cp "$f" .; done - pkgs="" - for pkg in $to_add; do pkgs="$pkgs $(basename $pkg)"; done + pkgs="" + for pkg in $to_add; do pkgs="$pkgs $(basename $pkg)"; done - /usr/bin/repo-add -q "$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" + fi else - rm -f "build/$reponame.db.tar.$DB_COMPRESSION" - echo "Errors found when adding packages" + echo "No packages to add" fi -else - echo "No packages to add" -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'" - for f in "$WORKDIR/build/"*; do - if ! /bin/cp "$f" "$ftppath"; then - die "error: failure while copying files to $ftppath" - fi - done + # 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'" + for f in "$WORKDIR/build/"*; do + if ! /bin/cp "$f" "$ftppath"; then + die "error: failure while copying files to $ftppath" + fi + done -else - echo "Nothing to copy, no work done" -fi + else + echo "Nothing to copy, no work done" + fi -if [ -n "$to_add" ]; then - echo "Cleaning staging dir" - /bin/rm $to_add -fi + if [ -n "$to_add" ]; then + echo "Cleaning staging dir" + /bin/rm $to_add + fi + + repo_unlock $reponame $current_arch +done cleanup # vim: set ts=4 sw=4 noet ft=sh: -- cgit v1.2.3-2-g168b 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 --- db-update | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'db-update') 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 -- cgit v1.2.3-2-g168b From d871e78664f303f9d138d7f46f6ad0c349336752 Mon Sep 17 00:00:00 2001 From: Abhishek Dasgupta Date: Wed, 11 Mar 2009 09:33:43 -0700 Subject: db-update: Add support for 'any' arch Signed-off-by: Aaron Griffin --- db-update | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 3f3b0cc..4797586 100755 --- a/db-update +++ b/db-update @@ -16,6 +16,7 @@ current_arch="" WORKDIR="$TMPDIR/db-update.$svnrepo.$UID" ADDPKGS="" +ANYPKGS="" stagedir="$STAGING/$reponame" if [ ! -d $stagedir ]; then @@ -79,6 +80,7 @@ for A in ${ARCHES[@]}; do current_arch="$A" ftppath="$FTP_BASE/$reponame/os/$current_arch/" + ftppath_any="$FTP_BASE/$reponame/os/any/" if [ ! -d "$ftppath" ]; then echo "FTP path for this repo ($reponame) is missing" @@ -105,6 +107,7 @@ for A in ${ARCHES[@]}; do to_add="" if [ -d "$stagedir" ]; then ADDPKGS="$(/bin/ls $stagedir/*-${current_arch}$PKGEXT 2>/dev/null)" + ANYPKGS="$(/bin/ls $stagedir/*-any$PKGEXT 2>/dev/null)" fi if [ -n "$ADDPKGS" ]; then @@ -145,6 +148,29 @@ for A in ${ARCHES[@]}; do fi done + for pkg in $ANYPKGS; do + _pkgfile=$(basename $pkg) + _pkgname="$(getpkgname $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 $_pkgname" + /usr/bin/svn up -q $_pkgname + if [ -d "$_pkgname/repos/$svnrepo" ]; then + . "$_pkgname/repos/$svnrepo/$BUILDSCRIPT" + if [ "$_pkgfile" = "$pkgname-$pkgver-$pkgrel-any$PKGEXT" ]; then + to_add="$to_add $pkg" + else + echo " WARNING: $_pkgfile does not match $BUILDSCRIPT in $svnrepo" + fi + else + echo " WARNING: Package $_pkgname not found in $svnrepo" + fi + fi + done + if [ -n "$to_add" ]; then cd "$WORKDIR/build/" for f in $to_add; do /bin/cp "$f" .; done @@ -164,12 +190,22 @@ for A in ${ARCHES[@]}; do # 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'" - for f in "$WORKDIR/build/"*; do + for f in "$WORKDIR/build/"*$current_arch$PKGEXT; do if ! /bin/cp "$f" "$ftppath"; then die "error: failure while copying files to $ftppath" fi done - + for f in "$WORKDIR/build/"*any.pkg.tar.gz; do + if ! /bin/cp "$f" "$ftppath_any"; then + die "error: failure while copying files to $ftppath_any" + fi + if ! ln -s "$ftppath_any/$f" "$ftppath/$f"; then + die "error: failed to make link for $f." + fi + done + if ! /bin/cp "$WORKDIR/build/$reponame.db"* "$ftppath"; then + die "failed to move repository $reponame-$A". + fi else echo "Nothing to copy, no work done" fi -- cgit v1.2.3-2-g168b From 60f7e2bf28bed7d18438d9378e19a82e8b6a2d24 Mon Sep 17 00:00:00 2001 From: Abhishek Dasgupta Date: Wed, 11 Mar 2009 23:55:38 +0530 Subject: Moved arch-independent processing out of the loop. Also fixes the bug in the previous commit, in which the arch-independent packages would be deleted from the staging directory after only one iteration. --- db-update | 109 +++++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 62 insertions(+), 47 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 4797586..3e9fbcf 100755 --- a/db-update +++ b/db-update @@ -76,6 +76,42 @@ die() { trap ctrl_c 2 trap cleanup 0 +# Process architecture-independent packages first. +if [ -d "$stagedir" ]; then + ANYPKGS="$(/bin/ls $stagedir/*-any$PKGEXT 2>/dev/null)" +fi + +echo "==> Processing new/updated arch-independent packages for '$reponame'..." >&2 +cd "$WORKDIR" +svnpath="$(get_svnpath $reponame)" +/usr/bin/svn checkout -N $svnpath checkout +cd checkout +to_add_any="" +if [ -n "$ANYPKGS" ]; then + for pkg in $ANYPKGS; do + _pkgfile=$(basename $pkg) + _pkgname="$(getpkgname $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 $_pkgname" + /usr/bin/svn up -q $_pkgname + if [ -d "$_pkgname/repos/$svnrepo" ]; then + . "$_pkgname/repos/$svnrepo/$BUILDSCRIPT" + if [ "$_pkgfile" = "$pkgname-$pkgver-$pkgrel-any$PKGEXT" ]; then + to_add_any="$to_add_any $pkg" + else + echo " WARNING: $_pkgfile does not match $BUILDSCRIPT in $svnrepo" + fi + else + echo " WARNING: Package $_pkgname not found in $svnrepo" + fi + fi + done +fi + for A in ${ARCHES[@]}; do current_arch="$A" @@ -107,10 +143,9 @@ for A in ${ARCHES[@]}; do to_add="" if [ -d "$stagedir" ]; then ADDPKGS="$(/bin/ls $stagedir/*-${current_arch}$PKGEXT 2>/dev/null)" - ANYPKGS="$(/bin/ls $stagedir/*-any$PKGEXT 2>/dev/null)" fi - if [ -n "$ADDPKGS" ]; then + if [ -n "$ADDPKGS" || -n "$ANYPKGS" ]; then echo "==> Copying DB file from '$reponame'..." >&2 if [ -f "$ftppath/$reponame.db.tar.$DB_COMPRESSION" ]; then @@ -124,59 +159,38 @@ for A in ${ARCHES[@]}; do cd "$WORKDIR" /usr/bin/svn checkout -N $svnpath checkout cd checkout - - for pkg in $ADDPKGS; do - _pkgfile=$(basename $pkg) - _pkgname="$(getpkgname $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 $_pkgname" - /usr/bin/svn up -q $_pkgname - if [ -d "$_pkgname/repos/$svnrepo" ]; then - . "$_pkgname/repos/$svnrepo/$BUILDSCRIPT" - if [ "$_pkgfile" = "$pkgname-$pkgver-$pkgrel-$current_arch$PKGEXT" ]; then - to_add="$to_add $pkg" - else - echo " WARNING: $_pkgfile does not match $BUILDSCRIPT in $svnrepo" - fi + + if [ -n "$ADDPKGS" ]; then + for pkg in $ADDPKGS; do + _pkgfile=$(basename $pkg) + _pkgname="$(getpkgname $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 " WARNING: Package $_pkgname not found in $svnrepo" - fi - fi - done - - for pkg in $ANYPKGS; do - _pkgfile=$(basename $pkg) - _pkgname="$(getpkgname $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 $_pkgname" - /usr/bin/svn up -q $_pkgname - if [ -d "$_pkgname/repos/$svnrepo" ]; then - . "$_pkgname/repos/$svnrepo/$BUILDSCRIPT" - if [ "$_pkgfile" = "$pkgname-$pkgver-$pkgrel-any$PKGEXT" ]; then - to_add="$to_add $pkg" + echo " Checking SVN for $_pkgname" + /usr/bin/svn up -q $_pkgname + if [ -d "$_pkgname/repos/$svnrepo" ]; then + . "$_pkgname/repos/$svnrepo/$BUILDSCRIPT" + if [ "$_pkgfile" = "$pkgname-$pkgver-$pkgrel-$current_arch$PKGEXT" ]; then + to_add="$to_add $pkg" + else + echo " WARNING: $_pkgfile does not match $BUILDSCRIPT in $svnrepo" + fi else - echo " WARNING: $_pkgfile does not match $BUILDSCRIPT in $svnrepo" + echo " WARNING: Package $_pkgname not found in $svnrepo" fi - else - echo " WARNING: Package $_pkgname not found in $svnrepo" fi - fi - done + done + fi - if [ -n "$to_add" ]; then + if [ -n "$to_add" || -n "$to_add_any" ]; then cd "$WORKDIR/build/" - for f in $to_add; do /bin/cp "$f" .; done + for f in $to_add $to_add_any; do /bin/cp "$f" .; done pkgs="" - for pkg in $to_add; do pkgs="$pkgs $(basename $pkg)"; done + 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 else @@ -218,5 +232,6 @@ for A in ${ARCHES[@]}; do repo_unlock $reponame $current_arch done +/bin/rm $to_add_any cleanup # vim: set ts=4 sw=4 noet ft=sh: -- cgit v1.2.3-2-g168b From 3ec1fcda1cc209360116b6548e29e86c22500ec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Charette?= Date: Wed, 6 May 2009 08:56:45 -0700 Subject: db-update: Use proper variable for WORKDIR Signed-off-by: Aaron Griffin --- db-update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db-update') diff --git a/db-update b/db-update index 3e9fbcf..fcd7388 100755 --- a/db-update +++ b/db-update @@ -14,7 +14,7 @@ current_arch="" [ "$UID" = "" ] && UID=$(uid) -WORKDIR="$TMPDIR/db-update.$svnrepo.$UID" +WORKDIR="$TMPDIR/db-update.$reponame.$UID" ADDPKGS="" ANYPKGS="" -- cgit v1.2.3-2-g168b From 1c4c32fe1fce12b7c7ea109529dc12dd39d7798a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Charette?= Date: Wed, 6 May 2009 08:57:06 -0700 Subject: db-update: Add if check before 'any' removal Signed-off-by: Aaron Griffin --- db-update | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index fcd7388..426a236 100755 --- a/db-update +++ b/db-update @@ -231,7 +231,8 @@ for A in ${ARCHES[@]}; do repo_unlock $reponame $current_arch done - -/bin/rm $to_add_any +if [ -n "$to_add_any" ]; then + /bin/rm $to_add_any +fi cleanup # vim: set ts=4 sw=4 noet ft=sh: -- cgit v1.2.3-2-g168b From 787ec348cf0143b658e0252766e9e415950534a2 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Wed, 6 May 2009 12:29:04 -0700 Subject: db-update: remove 'touch' of empty db file repo-add handles this on its own Signed-off-by: Aaron Griffin --- db-update | 2 -- 1 file changed, 2 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 426a236..ae99cb0 100755 --- a/db-update +++ b/db-update @@ -150,8 +150,6 @@ for A in ${ARCHES[@]}; do 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/ - else - touch "build/$reponame.db.tar.$DB_COMPRESSION" fi echo "==> Processing new/updated packages for repository '$reponame'..." >&2 -- cgit v1.2.3-2-g168b From a86adff4ee619d90b5c7d49797cc77bd550e7dd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Charette?= Date: Wed, 6 May 2009 12:30:02 -0700 Subject: db-update: Replace || with -o in if statements Signed-off-by: Aaron Griffin --- db-update | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index ae99cb0..507d40a 100755 --- a/db-update +++ b/db-update @@ -145,7 +145,7 @@ for A in ${ARCHES[@]}; do ADDPKGS="$(/bin/ls $stagedir/*-${current_arch}$PKGEXT 2>/dev/null)" fi - if [ -n "$ADDPKGS" || -n "$ANYPKGS" ]; then + if [ -n "$ADDPKGS" -o -n "$ANYPKGS" ]; then echo "==> Copying DB file from '$reponame'..." >&2 if [ -f "$ftppath/$reponame.db.tar.$DB_COMPRESSION" ]; then @@ -183,7 +183,7 @@ for A in ${ARCHES[@]}; do done fi - if [ -n "$to_add" || -n "$to_add_any" ]; then + if [ -n "$to_add" -o -n "$to_add_any" ]; then cd "$WORKDIR/build/" for f in $to_add $to_add_any; do /bin/cp "$f" .; done -- cgit v1.2.3-2-g168b From 09e204f873e3f5e4c4bfe966fa1188bdefac3bb6 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Wed, 6 May 2009 12:47:09 -0700 Subject: db-update: Add some total counts to output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Original-work-by: François Charette Signed-off-by: Aaron Griffin --- db-update | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 507d40a..cb00f39 100755 --- a/db-update +++ b/db-update @@ -81,7 +81,8 @@ if [ -d "$stagedir" ]; then ANYPKGS="$(/bin/ls $stagedir/*-any$PKGEXT 2>/dev/null)" fi -echo "==> Processing new/updated arch-independent packages for '$reponame'..." >&2 +pkgtotal=$(echo "$ANYPKGS" | wc -w) +echo "==> Processing $pkgtotal new/updated arch-independent packages for '$reponame'..." >&2 cd "$WORKDIR" svnpath="$(get_svnpath $reponame)" /usr/bin/svn checkout -N $svnpath checkout @@ -152,7 +153,8 @@ for A in ${ARCHES[@]}; do /bin/cp "$ftppath/$reponame.db.tar.$DB_COMPRESSION" build/ fi - echo "==> Processing new/updated packages for repository '$reponame'..." >&2 + pkgtotal=$(echo "$ADDPKGS $ANYPKGS" | wc -w) + echo "==> Processing $pkgtotal new/updated packages for repository '$reponame'..." >&2 cd "$WORKDIR" /usr/bin/svn checkout -N $svnpath checkout -- cgit v1.2.3-2-g168b From 9925af8a8aa791026f0f51a9be601bfbc15d0a40 Mon Sep 17 00:00:00 2001 From: Francois Charette Date: Tue, 12 May 2009 10:35:33 +0200 Subject: Check whether packages exist in build dirs before attempting to copy them Signed-off-by: Aaron Griffin --- db-update | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index cb00f39..132049f 100755 --- a/db-update +++ b/db-update @@ -204,19 +204,23 @@ for A in ${ARCHES[@]}; do # 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'" - for f in "$WORKDIR/build/"*$current_arch$PKGEXT; do - if ! /bin/cp "$f" "$ftppath"; then - die "error: failure while copying files to $ftppath" - fi - done - for f in "$WORKDIR/build/"*any.pkg.tar.gz; do - if ! /bin/cp "$f" "$ftppath_any"; then - die "error: failure while copying files to $ftppath_any" - fi - if ! ln -s "$ftppath_any/$f" "$ftppath/$f"; then - die "error: failed to make link for $f." - fi - done + if [ $(/bin/ls "$WORKDIR/build/"*$current_arch$PKGEXT 2>/dev/null | wc -l) != 0 ]; then + for f in "$WORKDIR/build/"*$current_arch$PKGEXT; do + if ! /bin/cp "$f" "$ftppath"; then + die "error: failure while copying files to $ftppath" + fi + done + fi + if [ $(/bin/ls "$WORKDIR/build/"*any$PKGEXT 2>/dev/null | wc -l) != 0 ]; then + for f in "$WORKDIR/build/"*any$PKGEXT; do + if ! /bin/cp "$f" "$ftppath_any"; then + die "error: failure while copying files to $ftppath_any" + fi + if ! ln -s "$ftppath_any/$f" "$ftppath/$f"; then + die "error: failed to make link for $f." + fi + done + fi if ! /bin/cp "$WORKDIR/build/$reponame.db"* "$ftppath"; then die "failed to move repository $reponame-$A". fi -- cgit v1.2.3-2-g168b From 61053b6c98723488454eaeaf105a77dc0c3f8bbc Mon Sep 17 00:00:00 2001 From: Francois Charette Date: Tue, 12 May 2009 11:29:44 +0200 Subject: create $WORKDIR before cding to it Signed-off-by: Aaron Griffin --- db-update | 1 + 1 file changed, 1 insertion(+) (limited to 'db-update') diff --git a/db-update b/db-update index 132049f..ace0d0e 100755 --- a/db-update +++ b/db-update @@ -83,6 +83,7 @@ fi pkgtotal=$(echo "$ANYPKGS" | wc -w) echo "==> Processing $pkgtotal new/updated arch-independent packages for '$reponame'..." >&2 +mkdir -p $WORKDIR cd "$WORKDIR" svnpath="$(get_svnpath $reponame)" /usr/bin/svn checkout -N $svnpath checkout -- cgit v1.2.3-2-g168b From b65fd05078fab48c4352609b2d7befa118a75b0f Mon Sep 17 00:00:00 2001 From: Francois Charette Date: Tue, 12 May 2009 11:42:27 +0200 Subject: fixed filename in creation of symlinks Signed-off-by: Aaron Griffin --- db-update | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index ace0d0e..5b011c2 100755 --- a/db-update +++ b/db-update @@ -217,8 +217,9 @@ for A in ${ARCHES[@]}; do if ! /bin/cp "$f" "$ftppath_any"; then die "error: failure while copying files to $ftppath_any" fi - if ! ln -s "$ftppath_any/$f" "$ftppath/$f"; then - die "error: failed to make link for $f." + bf=$(basename $f) + if ! ln -s "$ftppath_any/$bf" "$ftppath/$bf"; then + die "error: failed to make link for $bf." fi done fi -- cgit v1.2.3-2-g168b From 052b35e8e0d4aec5c2936f4fea21a29fa24d233e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 9 Jul 2009 17:29:31 +0200 Subject: remove redefined function Signed-off-by: Aaron Griffin --- db-update | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 5b011c2..1883a58 100755 --- a/db-update +++ b/db-update @@ -44,17 +44,6 @@ if [ -d "${stagedir}/add" ]; then /bin/mv "${stagedir}/add/"* "$stagedir/" fi -# Get the package name from the filename -# hackish, but should work for now -getpkgname() { - local tmp - - tmp=${1##*/} - tmp=${tmp%$PKGEXT} - tmp=${tmp%-$current_arch} - echo ${tmp%-*-*} -} - cleanup() { trap '' 0 2 # unlock -- cgit v1.2.3-2-g168b From 45dc03f5f91f1940a83a11472ff872478aeef099 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 9 Jul 2009 17:44:15 +0200 Subject: use pkgbase to get pkgbuild in db-update Signed-off-by: Aaron Griffin --- db-update | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 1883a58..ba8c3b5 100755 --- a/db-update +++ b/db-update @@ -82,22 +82,23 @@ if [ -n "$ANYPKGS" ]; then for pkg in $ANYPKGS; do _pkgfile=$(basename $pkg) _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 $_pkgname" - /usr/bin/svn up -q $_pkgname - if [ -d "$_pkgname/repos/$svnrepo" ]; then - . "$_pkgname/repos/$svnrepo/$BUILDSCRIPT" - if [ "$_pkgfile" = "$pkgname-$pkgver-$pkgrel-any$PKGEXT" ]; then + echo " Checking SVN for $_pkgbase" + /usr/bin/svn up -q $_pkgbase + if [ -d "$_pkgbase/repos/$svnrepo" ]; then + . "$_pkgbase/repos/$svnrepo/$BUILDSCRIPT" + if [ "$_pkgfile" = "$_pkgname-$pkgver-$pkgrel-any$PKGEXT" ]; then to_add_any="$to_add_any $pkg" else echo " WARNING: $_pkgfile does not match $BUILDSCRIPT in $svnrepo" fi else - echo " WARNING: Package $_pkgname not found in $svnrepo" + echo " WARNING: Package $_pkgbase not found in $svnrepo" fi fi done @@ -154,22 +155,23 @@ for A in ${ARCHES[@]}; do for pkg in $ADDPKGS; do _pkgfile=$(basename $pkg) _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 $_pkgname" - /usr/bin/svn up -q $_pkgname - if [ -d "$_pkgname/repos/$svnrepo" ]; then - . "$_pkgname/repos/$svnrepo/$BUILDSCRIPT" - if [ "$_pkgfile" = "$pkgname-$pkgver-$pkgrel-$current_arch$PKGEXT" ]; then + echo " Checking SVN for $_pkgbase" + /usr/bin/svn up -q $_pkgbase + if [ -d "$_pkgbase/repos/$svnrepo" ]; then + . "$_pkgbase/repos/$svnrepo/$BUILDSCRIPT" + if [ "$_pkgfile" = "$_pkgname-$pkgver-$pkgrel-$current_arch$PKGEXT" ]; then to_add="$to_add $pkg" else echo " WARNING: $_pkgfile does not match $BUILDSCRIPT in $svnrepo" fi else - echo " WARNING: Package $_pkgname not found in $svnrepo" + echo " WARNING: Package $_pkgbase not found in $svnrepo" fi fi done -- cgit v1.2.3-2-g168b From 0f54cbe863f057eb197476c24e693441414e8c67 Mon Sep 17 00:00:00 2001 From: Francois Charette Date: Mon, 20 Jul 2009 11:41:35 +0200 Subject: Fix final "cleanup" to avoid spurious error msg * When calling cleanup at the end of db-update, the function repo_unlock is called, but the repo-locks have already been unlocked! So we get a spurious error message. This commit replaces "cleanup" by "rm -rf $WORKDIR". Signed-off-by: Aaron Griffin --- db-update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db-update') diff --git a/db-update b/db-update index ba8c3b5..67f8782 100755 --- a/db-update +++ b/db-update @@ -231,5 +231,5 @@ done if [ -n "$to_add_any" ]; then /bin/rm $to_add_any fi -cleanup +rm -rf $WORKDIR # vim: set ts=4 sw=4 noet ft=sh: -- cgit v1.2.3-2-g168b From e53a4351d72d2a175d5342b71c1f19304840cd8e Mon Sep 17 00:00:00 2001 From: Francois Charette Date: Mon, 20 Jul 2009 14:17:53 +0200 Subject: simple syntactic improvements [Aaron: Don't remove quotes around $WORKDIR] Signed-off-by: Aaron Griffin --- db-update | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 67f8782..b530987 100755 --- a/db-update +++ b/db-update @@ -196,15 +196,16 @@ for A in ${ARCHES[@]}; do # 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/ls "$WORKDIR/build/"*$current_arch$PKGEXT 2>/dev/null | wc -l) != 0 ]; then - for f in "$WORKDIR/build/"*$current_arch$PKGEXT; do + if [ $(/bin/ls "$WORKDIR/build/"*-$current_arch$PKGEXT 2>/dev/null | wc -l) != 0 ]; then + for f in "$WORKDIR/build/"*-$current_arch$PKGEXT; do if ! /bin/cp "$f" "$ftppath"; then die "error: failure while copying files to $ftppath" fi done fi - if [ $(/bin/ls "$WORKDIR/build/"*any$PKGEXT 2>/dev/null | wc -l) != 0 ]; then - for f in "$WORKDIR/build/"*any$PKGEXT; do + if [ $(/bin/ls "$WORKDIR/build/"*-any$PKGEXT 2>/dev/null | wc -l) != 0 ]; then + echo "Copying new files to '$ftppath_any' and symlinking" + for f in "$WORKDIR/build/"*-any$PKGEXT; do if ! /bin/cp "$f" "$ftppath_any"; then die "error: failure while copying files to $ftppath_any" fi @@ -214,7 +215,7 @@ for A in ${ARCHES[@]}; do fi done fi - if ! /bin/cp "$WORKDIR/build/$reponame.db"* "$ftppath"; then + if ! /bin/cp "$WORKDIR/build/$reponame.db"* "$ftppath/"; then die "failed to move repository $reponame-$A". fi else @@ -228,8 +229,10 @@ for A in ${ARCHES[@]}; do repo_unlock $reponame $current_arch done + if [ -n "$to_add_any" ]; then /bin/rm $to_add_any fi + rm -rf $WORKDIR # vim: set ts=4 sw=4 noet ft=sh: -- cgit v1.2.3-2-g168b From ce9a9b1951cefbdf6b2df93b07eb9120295bec7a Mon Sep 17 00:00:00 2001 From: Francois Charette Date: Mon, 20 Jul 2009 09:47:08 -0700 Subject: Minor syntactic improvements in db-update * also added error msg for repo_lock in db-functions [Aaron: keep quotes around $WORKDIR] Signed-off-by: Aaron Griffin --- db-update | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index b530987..9d9f7eb 100755 --- a/db-update +++ b/db-update @@ -104,8 +104,7 @@ if [ -n "$ANYPKGS" ]; then done fi -for A in ${ARCHES[@]}; do - current_arch="$A" +for current_arch in ${ARCHES[@]}; do ftppath="$FTP_BASE/$reponame/os/$current_arch/" ftppath_any="$FTP_BASE/$reponame/os/any/" @@ -195,8 +194,8 @@ for A in ${ARCHES[@]}; do # 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/ls "$WORKDIR/build/"*-$current_arch$PKGEXT 2>/dev/null | wc -l) != 0 ]; then + echo "Copying new files to '$ftppath'" for f in "$WORKDIR/build/"*-$current_arch$PKGEXT; do if ! /bin/cp "$f" "$ftppath"; then die "error: failure while copying files to $ftppath" @@ -216,7 +215,7 @@ for A in ${ARCHES[@]}; do done fi if ! /bin/cp "$WORKDIR/build/$reponame.db"* "$ftppath/"; then - die "failed to move repository $reponame-$A". + die "failed to move repository $reponame-$current_arch". fi else echo "Nothing to copy, no work done" -- cgit v1.2.3-2-g168b From 798a2cb73ce68ecb1068be1f5a6e93d54150f0c4 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Mon, 20 Jul 2009 19:16:53 -0400 Subject: any support: use relative symlinks Signed-off-by: Aaron Griffin --- db-update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db-update') diff --git a/db-update b/db-update index 9d9f7eb..1c6739a 100755 --- a/db-update +++ b/db-update @@ -209,7 +209,7 @@ for current_arch in ${ARCHES[@]}; do die "error: failure while copying files to $ftppath_any" fi bf=$(basename $f) - if ! ln -s "$ftppath_any/$bf" "$ftppath/$bf"; then + if ! ln -s "../any/$bf" "$ftppath/$bf"; then die "error: failed to make link for $bf." fi done -- cgit v1.2.3-2-g168b From 8ea36dcd83222e960086bbcd114ca538d89db09c Mon Sep 17 00:00:00 2001 From: Francois Charette Date: Mon, 20 Jul 2009 19:54:23 +0200 Subject: remove trailing slash from ftppath[_any] Signed-off-by: Aaron Griffin --- db-update | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 1c6739a..338fb5b 100755 --- a/db-update +++ b/db-update @@ -106,8 +106,8 @@ fi for current_arch in ${ARCHES[@]}; do - ftppath="$FTP_BASE/$reponame/os/$current_arch/" - ftppath_any="$FTP_BASE/$reponame/os/any/" + ftppath="$FTP_BASE/$reponame/os/$current_arch" + ftppath_any="$FTP_BASE/$reponame/os/any" if [ ! -d "$ftppath" ]; then echo "FTP path for this repo ($reponame) is missing" @@ -197,7 +197,7 @@ for current_arch in ${ARCHES[@]}; do if [ $(/bin/ls "$WORKDIR/build/"*-$current_arch$PKGEXT 2>/dev/null | wc -l) != 0 ]; then echo "Copying new files to '$ftppath'" for f in "$WORKDIR/build/"*-$current_arch$PKGEXT; do - if ! /bin/cp "$f" "$ftppath"; then + if ! /bin/cp "$f" "$ftppath/"; then die "error: failure while copying files to $ftppath" fi done -- cgit v1.2.3-2-g168b From fc49cf28729722a2e617f3347f70c542f834d82d Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Tue, 21 Jul 2009 18:39:48 -0400 Subject: db-update: Fix final repo_unlock Because we lock/unlock in a loop, simply remove the cleanup trap at the end of the process, and manually clean up the work dir Signed-off-by: Aaron Griffin --- db-update | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 338fb5b..525c21e 100755 --- a/db-update +++ b/db-update @@ -46,7 +46,6 @@ fi cleanup() { trap '' 0 2 - # unlock repo_unlock $reponame $current_arch rm -rf "$WORKDIR" [ "$1" ] && exit $1 @@ -54,7 +53,7 @@ cleanup() { ctrl_c() { echo "Interrupted" >&2 - cleanup 0 + cleanup 1 } die() { @@ -233,5 +232,6 @@ if [ -n "$to_add_any" ]; then /bin/rm $to_add_any fi +trap '' 0 2 rm -rf $WORKDIR # vim: set ts=4 sw=4 noet ft=sh: -- cgit v1.2.3-2-g168b From e4346ab8404ee32a69848d4f55bb0d09664c7d75 Mon Sep 17 00:00:00 2001 From: Francois Charette Date: Tue, 21 Jul 2009 18:43:12 -0400 Subject: db-update: Move some steps inside an 'if' [Aaron: keep WORKDIR creation outside the loop, as its removed at the end] Signed-off-by: Aaron Griffin --- db-update | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 525c21e..ade7a39 100755 --- a/db-update +++ b/db-update @@ -69,15 +69,17 @@ if [ -d "$stagedir" ]; then ANYPKGS="$(/bin/ls $stagedir/*-any$PKGEXT 2>/dev/null)" fi -pkgtotal=$(echo "$ANYPKGS" | wc -w) -echo "==> Processing $pkgtotal new/updated arch-independent packages for '$reponame'..." >&2 mkdir -p $WORKDIR cd "$WORKDIR" -svnpath="$(get_svnpath $reponame)" -/usr/bin/svn checkout -N $svnpath checkout -cd checkout -to_add_any="" + 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 + cd checkout + to_add_any="" for pkg in $ANYPKGS; do _pkgfile=$(basename $pkg) _pkgname="$(getpkgname $pkg)" -- cgit v1.2.3-2-g168b 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 --- db-update | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'db-update') 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 -- cgit v1.2.3-2-g168b 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 --- db-update | 1 + 1 file changed, 1 insertion(+) (limited to 'db-update') 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-2-g168b 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 --- db-update | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'db-update') 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-2-g168b 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 --- db-update | 2 -- 1 file changed, 2 deletions(-) (limited to 'db-update') 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="" -- cgit v1.2.3-2-g168b 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 --- db-update | 1 + 1 file changed, 1 insertion(+) (limited to 'db-update') 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="" -- cgit v1.2.3-2-g168b From ade48254bbe2ee2cedc7773dd5299fa2208f66ca Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 13 Sep 2009 18:25:14 -0500 Subject: Ensure you don't update DBs on the wrong server Signed-off-by: Dan McGee --- db-update | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'db-update') diff --git a/db-update b/db-update index 577a028..aa1cb95 100755 --- a/db-update +++ b/db-update @@ -11,7 +11,18 @@ fi reponame="$1" current_arch="" -[ "$UID" = "" ] && UID=$(uid) +# 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 + echo "error: you shouldn't be updating $reponame on this server!" + exit 1 +fi WORKDIR="$TMPDIR/db-update.$reponame.$UID" ADDPKGS="" -- cgit v1.2.3-2-g168b From 954b699c84cd0b6211bf4ffb83bcd8affd7d8875 Mon Sep 17 00:00:00 2001 From: Francois Charette Date: Tue, 15 Sep 2009 09:20:14 +0200 Subject: Remove pkg from $stagedir if already in FTP repo Signed-off-by: Aaron Griffin --- db-update | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'db-update') diff --git a/db-update b/db-update index aa1cb95..c68cf84 100755 --- a/db-update +++ b/db-update @@ -74,6 +74,29 @@ die() { trap ctrl_c 2 trap cleanup 0 +# Remove any package from $stagedir that is already in the FTP repository +for f in $stagedir/*-any$PKGEXT; do + bf=$(basename $f) + ftppath_any="$FTP_BASE/$reponame/os/any" + if [[ -f $ftppath_any/$bf ]]; then + echo " WARNING: Package file $bf already exists in FTP repo" + echo " Removing from $stagedir" + /bin/rm $f + fi +done + +for current_arch in ${ARCHES[@]}; do + ftppath="$FTP_BASE/$reponame/os/$current_arch" + 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" + /bin/rm $f + fi + done +done + # Process architecture-independent packages first. if [ -d "$stagedir" ]; then ANYPKGS="$(/bin/ls $stagedir/*-any$PKGEXT 2>/dev/null)" -- cgit v1.2.3-2-g168b From 953d9d8ea616a9505c9e13813241dee455a580dc Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Fri, 18 Sep 2009 10:33:11 -0700 Subject: Collapse duplicate loops for staging removal Add 'any' to the items looped over in the ${ARCHES[@]} loop Signed-off-by: Aaron Griffin --- db-update | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index c68cf84..17d3b71 100755 --- a/db-update +++ b/db-update @@ -75,17 +75,7 @@ trap ctrl_c 2 trap cleanup 0 # Remove any package from $stagedir that is already in the FTP repository -for f in $stagedir/*-any$PKGEXT; do - bf=$(basename $f) - ftppath_any="$FTP_BASE/$reponame/os/any" - if [[ -f $ftppath_any/$bf ]]; then - echo " WARNING: Package file $bf already exists in FTP repo" - echo " Removing from $stagedir" - /bin/rm $f - fi -done - -for current_arch in ${ARCHES[@]}; do +for current_arch in ${ARCHES[@]} any; do ftppath="$FTP_BASE/$reponame/os/$current_arch" for f in $stagedir/*-$current_arch$PKGEXT; do bf=$(basename $f) -- cgit v1.2.3-2-g168b From de0c93a652333b242e7ea282110619f25de7be8d Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 21 Feb 2010 16:54:10 +0100 Subject: Accept any *.pkg.tar.* package file name With this patch packages with different compressions are accepted. It is ensured that one cannot have the same package with different compression extensions. The new functions getpkgfile{,s} are used to sanitize globed filenames. Signed-off-by: Pierre Schmitz --- db-update | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 17d3b71..0973bf3 100755 --- a/db-update +++ b/db-update @@ -89,7 +89,7 @@ done # Process architecture-independent packages first. if [ -d "$stagedir" ]; then - ANYPKGS="$(/bin/ls $stagedir/*-any$PKGEXT 2>/dev/null)" + ANYPKGS="$(getpkgfiles $stagedir/*-any$PKGEXT 2>/dev/null)" fi mkdir -p $WORKDIR @@ -115,7 +115,7 @@ if [ -n "$ANYPKGS" ]; then /usr/bin/svn up -q $_pkgbase if [ -d "$_pkgbase/repos/$svnrepo" ]; then . "$_pkgbase/repos/$svnrepo/$BUILDSCRIPT" - if [ "$_pkgfile" = "$_pkgname-$pkgver-$pkgrel-any$PKGEXT" ]; then + if echo "$_pkgfile" | grep -q "$_pkgname-$pkgver-$pkgrel-any"; then to_add_any="$to_add_any $pkg" else echo " WARNING: $_pkgfile does not match $BUILDSCRIPT in $svnrepo" @@ -155,7 +155,7 @@ for current_arch in ${ARCHES[@]}; do to_add="" if [ -d "$stagedir" ]; then - ADDPKGS="$(/bin/ls $stagedir/*-${current_arch}$PKGEXT 2>/dev/null)" + ADDPKGS="$(getpkgfiles $stagedir/*-${current_arch}$PKGEXT 2>/dev/null)" fi if [ -n "$ADDPKGS" -o -n "$ANYPKGS" ]; then @@ -186,7 +186,7 @@ for current_arch in ${ARCHES[@]}; do /usr/bin/svn up -q $_pkgbase if [ -d "$_pkgbase/repos/$svnrepo" ]; then . "$_pkgbase/repos/$svnrepo/$BUILDSCRIPT" - if [ "$_pkgfile" = "$_pkgname-$pkgver-$pkgrel-$current_arch$PKGEXT" ]; then + if echo "$_pkgfile" | grep -q "$_pkgname-$pkgver-$pkgrel-$current_arch"; then to_add="$to_add $pkg" else echo " WARNING: $_pkgfile does not match $BUILDSCRIPT in $svnrepo" @@ -216,7 +216,7 @@ for current_arch in ${ARCHES[@]}; do # if non empty, move all build dirs if [ $(/bin/ls "$WORKDIR/build/" 2>/dev/null | wc -l) != 0 ]; then - if [ $(/bin/ls "$WORKDIR/build/"*-$current_arch$PKGEXT 2>/dev/null | wc -l) != 0 ]; then + if [ $(getpkgfiles "$WORKDIR/build/"*-$current_arch$PKGEXT 2>/dev/null | wc -l) != 0 ]; then echo "Copying new files to '$ftppath'" for f in "$WORKDIR/build/"*-$current_arch$PKGEXT; do if ! /bin/cp "$f" "$ftppath/"; then @@ -224,7 +224,7 @@ for current_arch in ${ARCHES[@]}; do fi done fi - if [ $(/bin/ls "$WORKDIR/build/"*-any$PKGEXT 2>/dev/null | wc -l) != 0 ]; then + if [ $(getpkgfiles "$WORKDIR/build/"*-any$PKGEXT 2>/dev/null | wc -l) != 0 ]; then echo "Copying new files to '$ftppath_any' and symlinking" for f in "$WORKDIR/build/"*-any$PKGEXT; do if ! /bin/cp "$f" "$ftppath_any"; then -- cgit v1.2.3-2-g168b From 57987ae42fb58c58e044bfd7d3486010b32bb313 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 31 Mar 2010 23:09:57 +0200 Subject: don't publish *.old files --- db-update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db-update') diff --git a/db-update b/db-update index 0973bf3..82d2e25 100755 --- a/db-update +++ b/db-update @@ -236,7 +236,7 @@ for current_arch in ${ARCHES[@]}; do fi done fi - if ! /bin/cp "$WORKDIR/build/$reponame.db"* "$ftppath/"; then + if ! /bin/cp "$WORKDIR/build/$reponame$DBEXT" "$ftppath/"; then die "failed to move repository $reponame-$current_arch". fi else -- cgit v1.2.3-2-g168b From 154b5301ff08ef29ff69afc17789a4f1a6a00c20 Mon Sep 17 00:00:00 2001 From: Andrea Scarpino Date: Wed, 31 Mar 2010 23:44:06 +0200 Subject: fix permissions of incoming packages Signed-off-by: Pierre Schmitz --- db-update | 2 ++ 1 file changed, 2 insertions(+) (limited to 'db-update') diff --git a/db-update b/db-update index 82d2e25..e4f8020 100755 --- a/db-update +++ b/db-update @@ -219,6 +219,7 @@ for current_arch in ${ARCHES[@]}; do if [ $(getpkgfiles "$WORKDIR/build/"*-$current_arch$PKGEXT 2>/dev/null | wc -l) != 0 ]; then echo "Copying new files to '$ftppath'" for f in "$WORKDIR/build/"*-$current_arch$PKGEXT; do + /bin/chmod 664 "$f" &>/dev/null if ! /bin/cp "$f" "$ftppath/"; then die "error: failure while copying files to $ftppath" fi @@ -227,6 +228,7 @@ for current_arch in ${ARCHES[@]}; do if [ $(getpkgfiles "$WORKDIR/build/"*-any$PKGEXT 2>/dev/null | wc -l) != 0 ]; then echo "Copying new files to '$ftppath_any' and symlinking" for f in "$WORKDIR/build/"*-any$PKGEXT; do + /bin/chmod 664 "$f" &>/dev/null if ! /bin/cp "$f" "$ftppath_any"; then die "error: failure while copying files to $ftppath_any" fi -- cgit v1.2.3-2-g168b 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-update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db-update') 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" -- cgit v1.2.3-2-g168b From cbf6a9877dcbc8478f41d60a55f3fa2bfca63831 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Sat, 6 Feb 2010 19:47:48 -0600 Subject: db-update: Use a master package pool and symlinks This should save lots of transfer time with the mirrors :) Signed-off-by: Aaron Griffin --- db-update | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 418c680..a178996 100755 --- a/db-update +++ b/db-update @@ -131,6 +131,11 @@ for current_arch in ${ARCHES[@]}; do ftppath="$FTP_BASE/$reponame/os/$current_arch" ftppath_any="$FTP_BASE/$reponame/os/any" + poolpath="$FTP_BASE/packages/os/$current_arch" + poolpath_any="$FTP_BASE/packages/os/any" + # The following is used to create relative symlinks + poolrel="../../../packages/os/$current_arch" + poolrel_any="../../../packages/os/any" if [ ! -d "$ftppath" ]; then echo "FTP path for this repo ($reponame) is missing" @@ -220,8 +225,12 @@ for current_arch in ${ARCHES[@]}; do echo "Copying new files to '$ftppath'" for f in "$WORKDIR/build/"*-$current_arch$PKGEXT; do /bin/chmod 664 "$f" &>/dev/null - if ! /bin/cp "$f" "$ftppath/"; then - die "error: failure while copying files to $ftppath" + if ! /bin/cp "$f" "$poolpath/"; then + die "error: 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" fi done fi @@ -229,12 +238,15 @@ for current_arch in ${ARCHES[@]}; do echo "Copying new files to '$ftppath_any' and symlinking" for f in "$WORKDIR/build/"*-any$PKGEXT; do /bin/chmod 664 "$f" &>/dev/null - if ! /bin/cp "$f" "$ftppath_any"; then - die "error: failure while copying files to $ftppath_any" + if ! /bin/cp "$f" "$poolpath_any/"; then + die "error: failure while copying files to $poolpath_any" + fi + fname="$(basename $f)" + if ! ln -s "$poolrel_any/$fname" "$ftppath_any/$fname"; then + die "error: failure symlinking $fname to $ftppath_any" fi - bf=$(basename $f) - if ! ln -s "../any/$bf" "$ftppath/$bf"; then - die "error: failed to make link for $bf." + if ! ln -s "$poolrel_any/$fname" "$ftppath/$fname"; then + die "error: failure symlinking $fname to $ftppath" fi done fi -- cgit v1.2.3-2-g168b From ee4074de910df5c637691ace06ec5a9d475fb4a3 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Mon, 3 May 2010 09:17:04 -0700 Subject: Add PKGPOOL_DIR config variable This is a relative var, descendent from FTP_BASE. We do this because we also need a relative path to the package pool dir --- db-update | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index a178996..bcfb882 100755 --- a/db-update +++ b/db-update @@ -131,11 +131,11 @@ for current_arch in ${ARCHES[@]}; do ftppath="$FTP_BASE/$reponame/os/$current_arch" ftppath_any="$FTP_BASE/$reponame/os/any" - poolpath="$FTP_BASE/packages/os/$current_arch" - poolpath_any="$FTP_BASE/packages/os/any" + poolpath="$FTP_BASE/$PKGPOOL_DIR/os/$current_arch" + poolpath_any="$FTP_BASE/$PKGPOOL_DIR/os/any" # The following is used to create relative symlinks - poolrel="../../../packages/os/$current_arch" - poolrel_any="../../../packages/os/any" + poolrel="../../../$PKGPOOL_DIR/os/$current_arch" + poolrel_any="../../../$PKGPOOL_DIR/os/any" if [ ! -d "$ftppath" ]; then echo "FTP path for this repo ($reponame) is missing" -- cgit v1.2.3-2-g168b From 5034b4e644c55631dfd5c88b491873389fc52e50 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 20 Jun 2010 17:29:40 +0200 Subject: Replace PKGPOOL_DIR by a function call The package pool dir depends on the host; so we solve this similar to get_repos_for_host() Note: There is no "os" subdir for the package pool. --- db-update | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index bcfb882..28095d8 100755 --- a/db-update +++ b/db-update @@ -131,11 +131,11 @@ for current_arch in ${ARCHES[@]}; do ftppath="$FTP_BASE/$reponame/os/$current_arch" ftppath_any="$FTP_BASE/$reponame/os/any" - poolpath="$FTP_BASE/$PKGPOOL_DIR/os/$current_arch" - poolpath_any="$FTP_BASE/$PKGPOOL_DIR/os/any" + poolpath="$FTP_BASE/$(get_pkgpool_for_host)/$current_arch" + poolpath_any="$FTP_BASE/$(get_pkgpool_for_host)/any" # The following is used to create relative symlinks - poolrel="../../../$PKGPOOL_DIR/os/$current_arch" - poolrel_any="../../../$PKGPOOL_DIR/os/any" + poolrel="../../../$(get_pkgpool_for_host)/$current_arch" + poolrel_any="../../../$(get_pkgpool_for_host)/any" if [ ! -d "$ftppath" ]; then echo "FTP path for this repo ($reponame) is missing" -- cgit v1.2.3-2-g168b From f67f54fa2412e68fc02c6048f7dcee6223ccbc18 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Tue, 29 Jun 2010 10:41:50 +0200 Subject: don't mix db files of different arches --- db-update | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 28095d8..64265d0 100755 --- a/db-update +++ b/db-update @@ -153,7 +153,7 @@ for current_arch in ${ARCHES[@]}; do # copy the db file into our working area if [ -f "$ftppath/$reponame$DBEXT" ]; then - /bin/cp "$ftppath/$reponame$DBEXT" build/ + /bin/cp "$ftppath/$reponame$DBEXT" build/$reponame-$current_arch$DBEXT fi echo "Updating DB for $svnrepo" @@ -166,8 +166,9 @@ 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/ + /bin/cp "$ftppath/$reponame$DBEXT" build/$reponame-$current_arch$DBEXT fi pkgtotal=$(echo "$ADDPKGS $ANYPKGS" | wc -w) @@ -210,9 +211,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$DBEXT" $pkgs + /usr/bin/repo-add -q "$reponame-$current_arch$DBEXT" $pkgs else - rm -f "build/$reponame$DBEXT" + rm -f "build/$reponame-$current_arch$DBEXT" echo "Errors found when adding packages" fi else @@ -250,7 +251,7 @@ for current_arch in ${ARCHES[@]}; do fi done fi - if ! /bin/cp "$WORKDIR/build/$reponame$DBEXT" "$ftppath/"; then + if ! /bin/cp "$WORKDIR/build/$reponame-$current_arch$DBEXT" "$ftppath/$reponame$DBEXT"; then die "failed to move repository $reponame-$current_arch". fi else -- cgit v1.2.3-2-g168b From d989142a17315f20f038d025008350fc413ca5f1 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Tue, 29 Jun 2010 10:59:16 +0200 Subject: don't fail if any package already exists --- db-update | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 64265d0..f05246b 100755 --- a/db-update +++ b/db-update @@ -239,12 +239,16 @@ for current_arch in ${ARCHES[@]}; do echo "Copying new files to '$ftppath_any' and symlinking" for f in "$WORKDIR/build/"*-any$PKGEXT; do /bin/chmod 664 "$f" &>/dev/null - if ! /bin/cp "$f" "$poolpath_any/"; then - die "error: failure while copying files to $poolpath_any" - fi fname="$(basename $f)" - if ! ln -s "$poolrel_any/$fname" "$ftppath_any/$fname"; then - die "error: failure symlinking $fname to $ftppath_any" + if [ ! -f "$poolrel_any/$fname" ]; then + if ! /bin/cp "$f" "$poolpath_any/"; then + die "error: failure while copying files to $poolpath_any" + fi + fi + if [ ! -f "$ftppath_any/$fname" ]; then + if ! ln -s "$poolrel_any/$fname" "$ftppath_any/$fname"; then + die "error: failure symlinking $fname to $ftppath_any" + fi fi if ! ln -s "$poolrel_any/$fname" "$ftppath/$fname"; then die "error: failure symlinking $fname to $ftppath" -- cgit v1.2.3-2-g168b From 23d4669b8e330d131b2f78cd5858b30a07478c8a Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 8 Aug 2010 00:33:46 +0200 Subject: Use package pool instead of $repo/os/any dirs --- db-update | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index f05246b..9e641d2 100755 --- a/db-update +++ b/db-update @@ -223,7 +223,7 @@ for current_arch in ${ARCHES[@]}; do # if non empty, move all build dirs if [ $(/bin/ls "$WORKDIR/build/" 2>/dev/null | wc -l) != 0 ]; then if [ $(getpkgfiles "$WORKDIR/build/"*-$current_arch$PKGEXT 2>/dev/null | wc -l) != 0 ]; then - echo "Copying new files to '$ftppath'" + echo "Copying new files to '$poolpath' and symlinking" for f in "$WORKDIR/build/"*-$current_arch$PKGEXT; do /bin/chmod 664 "$f" &>/dev/null if ! /bin/cp "$f" "$poolpath/"; then @@ -236,20 +236,14 @@ for current_arch in ${ARCHES[@]}; do done fi if [ $(getpkgfiles "$WORKDIR/build/"*-any$PKGEXT 2>/dev/null | wc -l) != 0 ]; then - echo "Copying new files to '$ftppath_any' and symlinking" + echo "Copying new files to '$poolpath_any' and symlinking" for f in "$WORKDIR/build/"*-any$PKGEXT; do /bin/chmod 664 "$f" &>/dev/null fname="$(basename $f)" - if [ ! -f "$poolrel_any/$fname" ]; then - if ! /bin/cp "$f" "$poolpath_any/"; then - die "error: failure while copying files to $poolpath_any" - fi - fi - if [ ! -f "$ftppath_any/$fname" ]; then - if ! ln -s "$poolrel_any/$fname" "$ftppath_any/$fname"; then - die "error: failure symlinking $fname to $ftppath_any" - fi + if ! /bin/cp "$f" "$poolpath_any/"; then + die "error: failure while copying files to $poolpath_any" fi + if ! ln -s "$poolrel_any/$fname" "$ftppath/$fname"; then die "error: failure symlinking $fname to $ftppath" fi -- cgit v1.2.3-2-g168b 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-update | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'db-update') 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: -- cgit v1.2.3-2-g168b From 3eb0f6abdb822ae15bcc72626dcdad37c0313927 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 8 Aug 2010 11:42:27 +0200 Subject: Remove check for old staging dirs devtools take care of this anyway --- db-update | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 057de39..9dd5c9d 100755 --- a/db-update +++ b/db-update @@ -34,26 +34,6 @@ if [ ! -d $stagedir ]; then exit 1 fi -if [ -d "${stagedir}64" ]; then - echo "--------------------------------------------------" - echo "It looks like you have an old staging dir" - echo "Packages are now differentiated by the arch in the filename." - echo "Please delete '${stagedir}64'" - echo "--------------------------------------------------" - /bin/mv "${stagedir}64/add/"* "$stagedir/add/" - /bin/mv "${stagedir}64/del/"* "$stagedir/del/" -fi - -if [ -d "${stagedir}/add" ]; then - echo "--------------------------------------------------" - echo "It looks like you have an old staging dir" - echo "The 'add' and 'del' dirs are no longer used." - echo "Please delete staging//{add,del}" - echo " and ensure you are using the newest devtools" - echo "--------------------------------------------------" - /bin/mv "${stagedir}/add/"* "$stagedir/" -fi - cleanup() { trap '' 0 2 repo_unlock $reponame $current_arch -- cgit v1.2.3-2-g168b 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. --- db-update | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'db-update') 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" -- cgit v1.2.3-2-g168b From ff0745c50507f0cea48dbf97b8f55734698e3c13 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 8 Aug 2010 12:47:06 +0200 Subject: Prepare for variable db file compression --- db-update | 1 + 1 file changed, 1 insertion(+) (limited to 'db-update') diff --git a/db-update b/db-update index a08bee2..d08c96d 100755 --- a/db-update +++ b/db-update @@ -222,6 +222,7 @@ for current_arch in ${ARCHES[@]}; do if ! /bin/cp "$WORKDIR/build/$reponame-$current_arch$DBEXT" "$ftppath/$reponame$DBEXT"; then die "failed to move repository $reponame-$current_arch". fi + ln -sf "$reponame$DBEXT" "$ftppath/$reponame${DBEXT%.tar.*}" else echo "Nothing to copy, no work done" fi -- cgit v1.2.3-2-g168b 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-update | 2 -- 1 file changed, 2 deletions(-) (limited to 'db-update') 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 -- cgit v1.2.3-2-g168b 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. --- db-update | 22 ---------------------- 1 file changed, 22 deletions(-) (limited to 'db-update') 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: -- cgit v1.2.3-2-g168b 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-update | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'db-update') 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 -- cgit v1.2.3-2-g168b From af4f86808e8cd45cc171f55a1ec15bf30d858a0d Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Tue, 10 Aug 2010 21:40:24 +0200 Subject: Use more consitent naming for package pool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are no longer architecture-specific subdirs and the structure was switch to this: ftp └── pool ├── community └── packages packages contains all packages from core, extra and testing; this naming is in sync with the svn repo naming: svn-packages and svn-community --- db-update | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 375ed02..46becac 100755 --- a/db-update +++ b/db-update @@ -89,11 +89,9 @@ for current_arch in ${ARCHES[@]}; do ftppath="$FTP_BASE/$reponame/os/$current_arch" ftppath_any="$FTP_BASE/$reponame/os/any" - poolpath="$FTP_BASE/$(get_pkgpool_for_host)/$current_arch" - poolpath_any="$FTP_BASE/$(get_pkgpool_for_host)/any" + poolpath="$FTP_BASE/$(get_pkgpool_for_host)" # The following is used to create relative symlinks - poolrel="../../../$(get_pkgpool_for_host)/$current_arch" - poolrel_any="../../../$(get_pkgpool_for_host)/any" + poolrel="../../../$(get_pkgpool_for_host)" if [ ! -d "$ftppath" ]; then echo "FTP path for this repo ($reponame) is missing" @@ -190,11 +188,11 @@ for current_arch in ${ARCHES[@]}; do for f in "$WORKDIR/build/"*-any$PKGEXT; do /bin/chmod 664 "$f" &>/dev/null fname="$(basename $f)" - if ! /bin/cp "$f" "$poolpath_any/"; then - die "error: failure while copying files to $poolpath_any" + if ! /bin/cp "$f" "$poolpath/"; then + die "error: failure while copying files to $poolpath" fi - if ! ln -s "$poolrel_any/$fname" "$ftppath/$fname"; then + if ! ln -s "$poolrel/$fname" "$ftppath/$fname"; then die "error: failure symlinking $fname to $ftppath" fi done -- cgit v1.2.3-2-g168b 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-update | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'db-update') 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 -- cgit v1.2.3-2-g168b 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 --- db-update | 48 +++++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 25 deletions(-) (limited to 'db-update') 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: -- cgit v1.2.3-2-g168b From 53fd8f019acfb8c3fa994d964a92a48660c9f4ab Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 13 Aug 2010 11:14:02 +0200 Subject: Abort if package already exists in repo Don't try to be smart and remove packages from the staging dir without asking. --- db-update | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index b56a70f..f70bdb9 100755 --- a/db-update +++ b/db-update @@ -27,15 +27,13 @@ fi msg "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" for f in $stagedir/*-$current_arch$PKGEXT; do bf=$(basename $f) if [[ -f $ftppath/$bf ]]; then - warning " Package file $bf already exists in FTP repo" \ - " Removing from $stagedir" - /bin/rm $f + error "Package $bf already exists in $ftppath" + exit 1 fi done done -- cgit v1.2.3-2-g168b From 480544ebe82512afc536a7aa50bb0449446f6a87 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 13 Aug 2010 11:18:50 +0200 Subject: Remove check which was already covered by check_repo_permission --- db-update | 7 ------- 1 file changed, 7 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index f70bdb9..e4bf25d 100755 --- a/db-update +++ b/db-update @@ -83,13 +83,6 @@ for current_arch in ${ARCHES[@]}; do # The following is used to create relative symlinks poolrel="../../../$(get_pkgpool_for_host)" - if [ ! -d "$ftppath" ]; then - error "FTP path for this repo ($reponame) is missing" \ - " -> $ftppath" \ - "Please contact a system administrator" - exit 1 - fi - svnrepo="$reponame-$current_arch" repo_lock $reponame $current_arch || continue -- cgit v1.2.3-2-g168b From 2f7415d9e0383dc9f86defdb9e41e397b0ae4cde Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 13 Aug 2010 11:30:06 +0200 Subject: removed useless statements --- db-update | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index e4bf25d..3372dfb 100755 --- a/db-update +++ b/db-update @@ -39,15 +39,11 @@ for current_arch in ${ARCHES[@]} any; do done # Process architecture-independent packages first. -if [ -d "$stagedir" ]; then - ANYPKGS="$(getpkgfiles $stagedir/*-any$PKGEXT 2>/dev/null)" -fi +ANYPKGS="$(getpkgfiles $stagedir/*-any$PKGEXT 2>/dev/null)" cd "$WORKDIR" if [ -n "$ANYPKGS" ]; then - pkgtotal=$(echo "$ANYPKGS" | wc -w) - /usr/bin/svn checkout -q -N $SVNREPO checkout >/dev/null cd checkout to_add_any="" @@ -76,13 +72,11 @@ if [ -n "$ANYPKGS" ]; then fi for current_arch in ${ARCHES[@]}; do - ftppath="$FTP_BASE/$reponame/os/$current_arch" ftppath_any="$FTP_BASE/$reponame/os/any" poolpath="$FTP_BASE/$(get_pkgpool_for_host)" # The following is used to create relative symlinks poolrel="../../../$(get_pkgpool_for_host)" - svnrepo="$reponame-$current_arch" repo_lock $reponame $current_arch || continue @@ -106,8 +100,6 @@ for current_arch in ${ARCHES[@]}; do /bin/cp "$ftppath/$reponame$DBEXT" build/$reponame-$current_arch$DBEXT fi - pkgtotal=$(echo "$ADDPKGS $ANYPKGS" | wc -w) - cd "$WORKDIR" /usr/bin/svn checkout -N $SVNREPO checkout >/dev/null cd checkout -- cgit v1.2.3-2-g168b From 27abfce26dc4f667fb4702db40acf27317ecfd9f Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 13 Aug 2010 11:38:31 +0200 Subject: Simplify check for existing packages --- db-update | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 3372dfb..78a08b5 100755 --- a/db-update +++ b/db-update @@ -9,7 +9,6 @@ fi . "$(dirname $0)/config" reponame="$1" -current_arch="" if ! check_repo_permission "$reponame"; then error "you shouldn't be updating $reponame on this server!" @@ -27,15 +26,11 @@ fi msg "Updating $reponame..." -for current_arch in ${ARCHES[@]} any; do - ftppath="$FTP_BASE/$reponame/os/$current_arch" - for f in $stagedir/*-$current_arch$PKGEXT; do - bf=$(basename $f) - if [[ -f $ftppath/$bf ]]; then - error "Package $bf already exists in $ftppath" - exit 1 - fi - done +for f in $stagedir/*$PKGEXT; do + if [ -f "$FTP_BASE/$(get_pkgpool_for_host)/$(basename f)" ]; then + error "Package $(basename f) already exists" + exit 1 + fi done # Process architecture-independent packages first. -- cgit v1.2.3-2-g168b From cdf17a4c4c83c1363a59fa688654276c3d807eae Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 14 Aug 2010 20:15:50 +0200 Subject: Rewrite of db-update * db-update now updates all repos with packages in its staging dirs * sanity checks are performed before any repo is touched * improved performance * less code; easier to maintain --- db-update | 227 ++++++++++++++++---------------------------------------------- 1 file changed, 58 insertions(+), 169 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 78a08b5..43c44f7 100755 --- a/db-update +++ b/db-update @@ -1,189 +1,78 @@ #!/bin/bash -if [ $# -ne 1 ]; then - msg "usage: $(basename $0) " - exit 1 -fi - . "$(dirname $0)/db-functions" . "$(dirname $0)/config" -reponame="$1" - -if ! check_repo_permission "$reponame"; then - error "you shouldn't be updating $reponame on this server!" +if [ $# -ge 1 ]; then + warning "Calling $(basename $0) with a specific repository is no longer supported" exit 1 fi -ADDPKGS="" -ANYPKGS="" - -stagedir="$STAGING/$reponame" -if [ ! -d $stagedir ]; then - error "staging directory missing: $stagedir" +# Find repos with packages to release +repos=($(find "${STAGING}" -mindepth 1 -type d ! -empty -printf '%f ' 2>/dev/null)) +if [ $? -ge 1 ]; then + error "Could not read ${STAGING}" exit 1 fi -msg "Updating $reponame..." - -for f in $stagedir/*$PKGEXT; do - if [ -f "$FTP_BASE/$(get_pkgpool_for_host)/$(basename f)" ]; then - error "Package $(basename f) already exists" +for repo in ${repos[@]}; do + if ! check_repo_permission "${repo}"; then + error "You don't have permission to update packages in ${repo}" exit 1 fi -done - -# Process architecture-independent packages first. -ANYPKGS="$(getpkgfiles $stagedir/*-any$PKGEXT 2>/dev/null)" - -cd "$WORKDIR" - -if [ -n "$ANYPKGS" ]; then - /usr/bin/svn checkout -q -N $SVNREPO checkout >/dev/null - cd checkout - to_add_any="" - for pkg in $ANYPKGS; do - pkgfile=$(basename $pkg) - pkgname="$(getpkgname $pkg)" - pkgbase="$(getpkgbase $pkg)" - svnrepo="$reponame-any" - if ! check_pkg_arch "$pkg" "any"; then - error "$pkgfile is not architecture independent!" - else - /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 - warning "$pkgfile does not match PKGBUILD in $svnrepo" - fi - else - warning "Package $pkgbase not found in $svnrepo" + pkgs=($(getpkgfiles "${STAGING}/${repo}/"*${PKGEXT})) + if [ $? -eq 0 ]; then + for pkg in ${pkgs[@]}; do + if ! check_pkgfile "${pkg}"; then + error "Package ${repo}/$(basename ${pkg}) is not consistent with its meta data" + exit 1 fi - fi - done -fi - -for current_arch in ${ARCHES[@]}; do - ftppath="$FTP_BASE/$reponame/os/$current_arch" - ftppath_any="$FTP_BASE/$reponame/os/any" - poolpath="$FTP_BASE/$(get_pkgpool_for_host)" - # The following is used to create relative symlinks - poolrel="../../../$(get_pkgpool_for_host)" - svnrepo="$reponame-$current_arch" - - repo_lock $reponame $current_arch || continue - - /bin/mkdir -p "$WORKDIR/build" - cd "$WORKDIR" - - # copy the db file into our working area - if [ -f "$ftppath/$reponame$DBEXT" ]; then - /bin/cp "$ftppath/$reponame$DBEXT" build/$reponame-$current_arch$DBEXT - fi - - to_add="" - if [ -d "$stagedir" ]; then - ADDPKGS="$(getpkgfiles $stagedir/*-${current_arch}$PKGEXT 2>/dev/null)" - fi - - if [ -n "$ADDPKGS" -o -n "$ANYPKGS" ]; then - - if [ -f "$ftppath/$reponame$DBEXT" ]; then - /bin/cp "$ftppath/$reponame$DBEXT" build/$reponame-$current_arch$DBEXT - fi - - 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) - pkgname="$(getpkgname $pkg)" - pkgbase="$(getpkgbase $pkg)" - - if ! check_pkg_arch "$pkg" "$current_arch"; then - error "$pkgfile was built for the wrong architecture" - else - /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 - warning "$pkgfile does not match PKGBUILD in $svnrepo" - fi - else - warning "Package $pkgbase not found in $svnrepo" - fi - fi - done - fi - - if [ -n "$to_add" -o -n "$to_add_any" ]; then - cd "$WORKDIR/build/" - for f in $to_add $to_add_any; do /bin/cp "$f" .; done - - 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 >/dev/null - else - rm -f "build/$reponame-$current_arch$DBEXT" - error "Errors found when adding packages" - fi - else - warning "No packages to add" - fi - - # 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 - for f in "$WORKDIR/build/"*-$current_arch$PKGEXT; do - /bin/chmod 664 "$f" &>/dev/null - if ! /bin/cp "$f" "$poolpath/"; then - die "failure while copying files to $poolpath" - fi - fname="$(basename $f)" - if ! ln -s "$poolrel/$fname" "$ftppath/$fname"; then - die "failure symlinking $fname to $ftppath" - fi - done - fi - if [ $(getpkgfiles "$WORKDIR/build/"*-any$PKGEXT 2>/dev/null | wc -l) != 0 ]; then - for f in "$WORKDIR/build/"*-any$PKGEXT; do - /bin/chmod 664 "$f" &>/dev/null - fname="$(basename $f)" - if ! /bin/cp "$f" "$poolpath/"; then - die "failure while copying files to $poolpath" - fi - - if ! ln -s "$poolrel/$fname" "$ftppath/$fname"; then - die "failure symlinking $fname to $ftppath" - fi - done - fi - if ! /bin/cp "$WORKDIR/build/$reponame-$current_arch$DBEXT" "$ftppath/$reponame$DBEXT"; then - die "failed to move repository $reponame-$current_arch". - fi - ln -sf "$reponame$DBEXT" "$ftppath/$reponame${DBEXT%.tar.*}" + if ! check_pkgsvn "${pkg}" "${repo}"; then + error "Package ${repo}/$(basename ${pkg}) is not consistent with svn repository" + exit 1 + fi + if [ -f "${FTP_BASE}/$(get_pkgpool_for_host)/$(basename ${pkg})" ]; then + error "Package ${repo}/$(basename pkg) already exists in ${FTP_BASE}/$(get_pkgpool_for_host)" + exit 1 + fi + done else - warning "Nothing to copy, no work done" - fi - - if [ -n "$to_add" ]; then - /bin/rm $to_add + exit 1 fi +done - repo_unlock $reponame $current_arch +# TODO: this might lock too much (architectures) +for repo in ${repos[@]}; do + for pkgarch in ${ARCHES[@]}; do + repo_lock ${repo} ${pkgarch} || exit 1 + done done -if [ -n "$to_add_any" ]; then - /bin/rm $to_add_any -fi +for repo in ${repos[@]}; do + 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}" + # any packages might have been moved by the previous run + if [ -f "${pkg}" ]; then + mv "${pkg}" "$FTP_BASE/$(get_pkgpool_for_host)" + fi + ln -s "../../../$(get_pkgpool_for_host)/${pkgfile}" "$FTP_BASE/$repo/os/${pkgarch}" + add_pkgs[${#add_pkgs[*]}]=${pkgfile} + done + pushd "$FTP_BASE/$repo/os/${pkgarch}" >/dev/null + /usr/bin/repo-add -q "$repo$DBEXT" ${add_pkgs[@]} >/dev/null \ + || die "Could not add packages" + popd >/dev/null + done +done -# vim: set ts=4 sw=4 noet ft=sh: +for repo in ${repos[@]}; do + for pkgarch in ${ARCHES[@]}; do + repo_unlock ${repo} ${pkgarch} + done +done -- cgit v1.2.3-2-g168b 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-update | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'db-update') 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)" -- cgit v1.2.3-2-g168b From b5fb2927cde513dc0fd82e4fd4dfe3836cf35728 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 15 Aug 2010 20:55:26 +0200 Subject: Lock repos before checking --- db-update | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 73897f3..b11face 100755 --- a/db-update +++ b/db-update @@ -11,43 +11,39 @@ fi # Find repos with packages to release repos=($(find "${STAGING}" -mindepth 1 -type d ! -empty -printf '%f ' 2>/dev/null)) if [ $? -ge 1 ]; then - error "Could not read ${STAGING}" - exit 1 + die "Could not read ${STAGING}" fi +# TODO: this might lock too much (architectures) +for repo in ${repos[@]}; do + for pkgarch in ${ARCHES[@]}; do + repo_lock ${repo} ${pkgarch} || exit 1 + done +done + +# check if packages are valid for repo in ${repos[@]}; do if ! check_repo_permission "${repo}"; then - error "You don't have permission to update packages in ${repo}" - exit 1 + die "You don't have permission to update packages in ${repo}" fi pkgs=($(getpkgfiles "${STAGING}/${repo}/"*${PKGEXT})) if [ $? -eq 0 ]; then for pkg in ${pkgs[@]}; do if ! check_pkgfile "${pkg}"; then - error "Package ${repo}/$(basename ${pkg}) is not consistent with its meta data" - exit 1 + die "Package ${repo}/$(basename ${pkg}) is not consistent with its meta data" fi if ! check_pkgsvn "${pkg}" "${repo}"; then - error "Package ${repo}/$(basename ${pkg}) is not consistent with svn repository" - exit 1 + die "Package ${repo}/$(basename ${pkg}) is not consistent with svn repository" fi if [ -f "${FTP_BASE}/$(get_pkgpool_for_host)/$(basename ${pkg})" ]; then - error "Package ${repo}/$(basename pkg) already exists in ${FTP_BASE}/$(get_pkgpool_for_host)" - exit 1 + die "Package ${repo}/$(basename pkg) already exists in ${FTP_BASE}/$(get_pkgpool_for_host)" fi done else - exit 1 + die "Could not read ${STAGING}" fi done -# TODO: this might lock too much (architectures) -for repo in ${repos[@]}; do - for pkgarch in ${ARCHES[@]}; do - repo_lock ${repo} ${pkgarch} || exit 1 - done -done - for repo in ${repos[@]}; do msg "Updating [${repo}]..." any_pkgs=($(getpkgfiles "${STAGING}/${repo}/"*-any${PKGEXT} 2>/dev/null)) -- cgit v1.2.3-2-g168b From cb39feaff074c5e08ff2dfce8dfa04c545233b7e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Tue, 17 Aug 2010 16:41:31 +0200 Subject: Don't try to update no package Check if there are packages to update for given architecure. Previously db-update quit when only one arch of a package was available. --- db-update | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index b11face..74abea8 100755 --- a/db-update +++ b/db-update @@ -60,10 +60,12 @@ for repo in ${repos[@]}; do ln -s "../../../$(get_pkgpool_for_host)/${pkgfile}" "$FTP_BASE/$repo/os/${pkgarch}" add_pkgs[${#add_pkgs[*]}]=${pkgfile} done - pushd "$FTP_BASE/$repo/os/${pkgarch}" >/dev/null - /usr/bin/repo-add -q "$repo$DBEXT" ${add_pkgs[@]} >/dev/null \ - || die "Could not add packages" - popd >/dev/null + if [ ${#add_pkgs[@]} -ge 1 ]; then + pushd "$FTP_BASE/$repo/os/${pkgarch}" >/dev/null + /usr/bin/repo-add -q "$repo$DBEXT" ${add_pkgs[@]} >/dev/null \ + || die "Could not add packages" + popd >/dev/null + fi done done -- cgit v1.2.3-2-g168b From a2b3b2bb2bde44289d41b956dde1f5bca61e581b Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Tue, 17 Aug 2010 22:42:15 +1000 Subject: minor fix to error message Signed-off-by: Allan McRae Signed-off-by: Pierre Schmitz --- db-update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db-update') diff --git a/db-update b/db-update index 74abea8..dd8d1c0 100755 --- a/db-update +++ b/db-update @@ -36,7 +36,7 @@ for repo in ${repos[@]}; do die "Package ${repo}/$(basename ${pkg}) is not consistent with svn repository" fi if [ -f "${FTP_BASE}/$(get_pkgpool_for_host)/$(basename ${pkg})" ]; then - die "Package ${repo}/$(basename pkg) already exists in ${FTP_BASE}/$(get_pkgpool_for_host)" + die "Package ${repo}/$(basename ${pkg}) already exists in ${FTP_BASE}/$(get_pkgpool_for_host)" fi done else -- cgit v1.2.3-2-g168b From 17c9dab4b420ca55fd4fb3f277805af148159a4d Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Tue, 17 Aug 2010 20:32:47 +0200 Subject: Add additional checks when reading PKGBUILDs If reading from a PKGBUILD fails stop immediatly. Also put out more usefull error messages. --- db-update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db-update') diff --git a/db-update b/db-update index dd8d1c0..68450b4 100755 --- a/db-update +++ b/db-update @@ -63,7 +63,7 @@ for repo in ${repos[@]}; do if [ ${#add_pkgs[@]} -ge 1 ]; then pushd "$FTP_BASE/$repo/os/${pkgarch}" >/dev/null /usr/bin/repo-add -q "$repo$DBEXT" ${add_pkgs[@]} >/dev/null \ - || die "Could not add packages" + || die "repo-add $repo$DBEXT ${add_pkgs[@]}" popd >/dev/null fi done -- cgit v1.2.3-2-g168b From 476cce1c57a62821a2da8f5481e21e3e9c0d68fd Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Tue, 24 Aug 2010 13:10:58 +0200 Subject: db-update: Make sure there are no links in the staging directory --- db-update | 3 +++ 1 file changed, 3 insertions(+) (limited to 'db-update') diff --git a/db-update b/db-update index 68450b4..13c7441 100755 --- a/db-update +++ b/db-update @@ -29,6 +29,9 @@ for repo in ${repos[@]}; do pkgs=($(getpkgfiles "${STAGING}/${repo}/"*${PKGEXT})) if [ $? -eq 0 ]; then for pkg in ${pkgs[@]}; do + if [ -h "${pkg}" ]; then + die "Package ${repo}/$(basename ${pkg}) is a symbolic link" + fi if ! check_pkgfile "${pkg}"; then die "Package ${repo}/$(basename ${pkg}) is not consistent with its meta data" fi -- cgit v1.2.3-2-g168b 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-update | 1 + 1 file changed, 1 insertion(+) (limited to 'db-update') 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-2-g168b From 6f29ee2f02c2a8e2991599ce1d76a59b58a7ee67 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 5 Sep 2010 13:32:27 +0200 Subject: Check if package exists in any other repository on update This also checks if the sam package exists within the old package layout (without package pool) --- db-update | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 61d1636..70f0525 100755 --- a/db-update +++ b/db-update @@ -38,8 +38,8 @@ for repo in ${repos[@]}; do if ! check_pkgsvn "${pkg}" "${repo}"; then die "Package ${repo}/$(basename ${pkg}) is not consistent with svn repository" fi - if [ -f "${FTP_BASE}/$(get_pkgpool_for_host)/$(basename ${pkg})" ]; then - die "Package ${repo}/$(basename ${pkg}) already exists in ${FTP_BASE}/$(get_pkgpool_for_host)" + if ! check_pkgrepos "${pkg}"; then + die "Package ${repo}/$(basename ${pkg}) already exists in another repository" fi done else -- cgit v1.2.3-2-g168b From f121126f8166fb6dc261ea82f2890ba6693d047e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 11 Sep 2010 22:52:23 +0200 Subject: Use local config instead of guessing by hostname Using the hostname to decide which repos to use is not releiable and hard to test. Instead use config.local to configure these. config files for sigurd and gerolde were added which can be copied or symlinked to config.local on the specific host. --- db-update | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 70f0525..49ecbde 100755 --- a/db-update +++ b/db-update @@ -58,9 +58,9 @@ for repo in ${repos[@]}; do msg2 "${pkgfile} (${pkgarch})" # any packages might have been moved by the previous run if [ -f "${pkg}" ]; then - mv "${pkg}" "$FTP_BASE/$(get_pkgpool_for_host)" + mv "${pkg}" "$FTP_BASE/${PKGPOOL}" fi - ln -s "../../../$(get_pkgpool_for_host)/${pkgfile}" "$FTP_BASE/$repo/os/${pkgarch}" + ln -s "../../../${PKGPOOL}/${pkgfile}" "$FTP_BASE/$repo/os/${pkgarch}" add_pkgs[${#add_pkgs[*]}]=${pkgfile} done if [ ${#add_pkgs[@]} -ge 1 ]; then -- cgit v1.2.3-2-g168b From 6037b3e9aa414d94cd14b8c51b9b04be054c5e04 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 2 Dec 2010 18:06:45 +0100 Subject: db-update: Fail if a set of split packages is incomplete --- db-update | 3 +++ 1 file changed, 3 insertions(+) (limited to 'db-update') diff --git a/db-update b/db-update index 49ecbde..3a49f0a 100755 --- a/db-update +++ b/db-update @@ -42,6 +42,9 @@ for repo in ${repos[@]}; do die "Package ${repo}/$(basename ${pkg}) already exists in another repository" fi done + if ! check_splitpkgs ${repo} ${pkgs[@]}; then + die "Missing split packages for ${repo}" + fi else die "Could not read ${STAGING}" fi -- cgit v1.2.3-2-g168b 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-update | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'db-update') 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-2-g168b From 11db46275d14c9a9c2e59019fed3de4b8803f9f4 Mon Sep 17 00:00:00 2001 From: Parabola Date: Fri, 18 Feb 2011 15:42:59 -0800 Subject: Parabola specific changes --- db-update | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'db-update') diff --git a/db-update b/db-update index 5bdce5e..4740809 100755 --- a/db-update +++ b/db-update @@ -35,12 +35,9 @@ for repo in ${repos[@]}; do if ! check_pkgfile "${pkg}"; then die "Package ${repo}/$(basename ${pkg}) is not consistent with its meta data" fi - if ! check_pkgsvn "${pkg}" "${repo}"; then - die "Package ${repo}/$(basename ${pkg}) is not consistent with svn repository" - fi - if ! check_pkgrepos "${pkg}"; then - die "Package ${repo}/$(basename ${pkg}) already exists in another repository" - fi + #if ! check_pkgrepos "${pkg}"; then + # die "Package ${repo}/$(basename ${pkg}) already exists in another repository" + #fi done if ! check_splitpkgs ${repo} ${pkgs[@]}; then die "Missing split packages for ${repo}" -- cgit v1.2.3-2-g168b