summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2010-02-21 16:54:10 +0100
committerPierre Schmitz <pierre@archlinux.de>2010-02-21 16:54:10 +0100
commitde0c93a652333b242e7ea282110619f25de7be8d (patch)
tree172a09b74679082c6655a78237107692b0a4c857
parentdea6954635ff0eccd116c384065c1ad745fcd1d2 (diff)
downloaddbscripts-de0c93a652333b242e7ea282110619f25de7be8d.tar.gz
dbscripts-de0c93a652333b242e7ea282110619f25de7be8d.tar.xz
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 <pierre@archlinux.de>
-rw-r--r--config2
-rw-r--r--db-functions34
-rwxr-xr-xdb-move11
-rwxr-xr-xdb-update12
4 files changed, 44 insertions, 15 deletions
diff --git a/config b/config
index 7864532..8e582d9 100644
--- a/config
+++ b/config
@@ -13,7 +13,7 @@ TMPDIR="/srv/tmp"
ARCHES=(i686 x86_64)
BUILDSCRIPT="PKGBUILD"
DBEXT=".db.tar.gz"
-PKGEXT=".pkg.tar.gz"
+PKGEXT=".pkg.tar.*"
SRCEXT=".src.tar.gz"
# Allowed licenses: get sourceballs only for licenses in this array
diff --git a/db-functions b/db-functions
index a4cffd7..c27366c 100644
--- a/db-functions
+++ b/db-functions
@@ -19,12 +19,12 @@ repo_lock () { #repo_lock repo-name arch
LOCKFILE="$TMPDIR/.repolock.$1.$2"
if [ -f "$LOCKFILE" ]; then
owner="$(/usr/bin/stat -c %U $LOCKFILE)"
- echo "error: db generation is already in progress (started by $owner)"
+ echo "error: db generation is already in progress (started by $owner)" >&2
exit 1
else
/bin/touch "$LOCKFILE"
if [ ! -f "$LOCKFILE" ]; then
- echo "error: could not create repo lock... something went wrong!"
+ echo "error: could not create repo lock... something went wrong!" >&2
fi
set_umask
fi
@@ -33,7 +33,7 @@ repo_lock () { #repo_lock repo-name arch
repo_unlock () { #repo_unlock repo-name arch
LOCKFILE="$TMPDIR/.repolock.$1.$2"
if [ ! -f "$LOCKFILE" ]; then
- echo "error: repo lock doesn't exist... something went terribly wrong!"
+ echo "error: repo lock doesn't exist... something went terribly wrong!" >&2
else
rm -f "$LOCKFILE"
fi
@@ -87,6 +87,34 @@ getpkgver() {
echo "$_ver"
}
+getpkgfile() {
+ if [[ ${#} -ne 1 ]]; then
+ echo 'ERROR: No canonical package found!' >&2
+ exit 1
+ elif [ ! -f "${1}" ]; then
+ echo "ERROR: Package ${1} not found!" >&2
+ exit 1
+ fi
+
+ echo ${1}
+}
+
+getpkgfiles() {
+ if [ ! -z "$(echo ${@%\.*} | sed "s/ /\n/g" | sort | uniq -D)" ]; then
+ echo 'ERROR: Duplicate packages found!'>&2
+ exit 1
+ fi
+
+ for f in ${@}; do
+ if [ ! -f "${f}" ]; then
+ echo "ERROR: Package ${f} not found!" >&2
+ exit 1
+ fi
+ done
+
+ echo ${@}
+}
+
check_pkg_arch () { #check_pkg_arch pkgfile arch
local _arch
_arch="$(_grep_pkginfo "$1" "^arch")"
diff --git a/db-move b/db-move
index efd54e0..c5bd32e 100755
--- a/db-move
+++ b/db-move
@@ -59,9 +59,7 @@ if [ -d "$packagebase/repos/$svnrepo_from" ]; then
for i in ${pkgname[@]}; do
_pkgfile="$i-$pkgver-$pkgrel-$_arch$PKGEXT"
- if [ ! -f "$ftppath_from/${_arch}/$_pkgfile" ]; then
- die "error: package file '$_pkgfile' not found in repo '$repofrom'"
- fi
+ getpkgfile "$ftppath_from/${_arch}/"$_pkgfile >/dev/null
done
if [ -d "$packagebase/repos/$svnrepo_to" ]; then
@@ -101,13 +99,16 @@ if [ -d "$packagebase/repos/$svnrepo_from" ]; then
for i in ${pkgname[@]}; do
_pkgfile="$i-$pkgver-$pkgrel-$_arch$PKGEXT"
- /bin/cp "$ftppath_from/$architecture/$_pkgfile" .
+ _cpkgfile=$(getpkgfile "$ftppath_from/$architecture/"$_pkgfile)
+ [ $? -gt 0 ] && die
+ /bin/cp $_cpkgfile .
/usr/bin/repo-add -q "$repoto$DBEXT" $_pkgfile || die "Error in repo-add $_pkgfile"
done
#use '*' to move the old DB too
mv $repoto$DBEXT* $ftppath_to/$architecture
for i in ${pkgname[@]}; do
- _pkgfile="$i-$pkgver-$pkgrel-$_arch$PKGEXT"
+ _pkgfile=$(getpkgfile "$i-$pkgver-$pkgrel-$_arch"$PKGEXT)
+ [ $? -gt 0 ] && die
if [ "${_arch}" == "any" ]; then
mv ${_pkgfile} $ftppath_to/any
ln -s ../any/${_pkgfile} $ftppath_to/$architecture/
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