summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Griffin <aaronmgriffin@gmail.com>2009-02-20 19:01:27 +0100
committerAaron Griffin <aaronmgriffin@gmail.com>2009-03-11 16:27:10 +0100
commit1ef058dad91a5ca82db2744776251a2ab68bcf90 (patch)
treeaa6a8925d9a9f0d6673d1b0ac016959f53d9870e
parent891e4f353d098a639c3b1d09d45987f0908b0d38 (diff)
downloaddbscripts-1ef058dad91a5ca82db2744776251a2ab68bcf90.tar.gz
dbscripts-1ef058dad91a5ca82db2744776251a2ab68bcf90.tar.xz
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 <aaronmgriffin@gmail.com>
-rw-r--r--config1
-rwxr-xr-xdb-core2
-rwxr-xr-xdb-core643
-rwxr-xr-xdb-extra2
-rwxr-xr-xdb-extra643
-rwxr-xr-xdb-testing2
-rwxr-xr-xdb-testing643
-rwxr-xr-xdb-update206
8 files changed, 110 insertions, 112 deletions
diff --git a/config b/config
index 5c39919..07cf783 100644
--- a/config
+++ b/config
@@ -3,5 +3,6 @@ FTP_BASE="/srv/ftp"
SVN_PATH="file:///srv/svn-packages"
STAGING="$HOME/staging"
TMPDIR="/srv/tmp"
+ARCHES=(i686 x86_64)
# To be used if $BUILDSCRIPT is removed from makepkg.conf
#BUILDSCRIPT="PKGBUILD"
diff --git a/db-core b/db-core
index b88fcae..eaa5032 100755
--- a/db-core
+++ b/db-core
@@ -1,3 +1,3 @@
#!/bin/bash
-$(dirname $0)/db-update "core" "i686"
+$(dirname $0)/db-update "core"
diff --git a/db-core64 b/db-core64
deleted file mode 100755
index e080004..0000000
--- a/db-core64
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-$(dirname $0)/db-update "core" "x86_64"
diff --git a/db-extra b/db-extra
index 1375b13..d14b50e 100755
--- a/db-extra
+++ b/db-extra
@@ -1,3 +1,3 @@
#!/bin/bash
-$(dirname $0)/db-update "extra" "i686"
+$(dirname $0)/db-update "extra"
diff --git a/db-extra64 b/db-extra64
deleted file mode 100755
index cfa20a2..0000000
--- a/db-extra64
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-$(dirname $0)/db-update "extra" "x86_64"
diff --git a/db-testing b/db-testing
index 69b5376..579ae37 100755
--- a/db-testing
+++ b/db-testing
@@ -1,3 +1,3 @@
#!/bin/bash
-$(dirname $0)/db-update "testing" "i686"
+$(dirname $0)/db-update "testing"
diff --git a/db-testing64 b/db-testing64
deleted file mode 100755
index d75a456..0000000
--- a/db-testing64
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-$(dirname $0)/db-update "testing" "x86_64"
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) <reponame> <arch>"
+if [ $# -ne 1 ]; then
+ echo "usage: $(basename $0) <reponame>"
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/<reponame>/{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/<reponame>/{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: