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> --- config | 2 +- db-functions | 28 ++++++++++++++++++++++++++++ db-move | 8 +++----- db-update | 10 +++++----- 4 files changed, 37 insertions(+), 11 deletions(-) diff --git a/config b/config index 92def37..6343bc0 100644 --- a/config +++ b/config @@ -12,7 +12,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..915d011 100644 --- a/db-functions +++ b/db-functions @@ -87,6 +87,34 @@ getpkgver() { echo "$_ver" } +getpkgfile() { + if [[ ${#} -ne 1 ]]; then + echo 'ERROR: No canonical package found!' + exit 1 + elif [ ! -f "${1}" ]; then + echo "ERROR: Package ${1} not found!" + exit 1 + fi + + return ${1} +} + +getpkgfiles() { + if [ ! -z "$(echo ${@%\.*} | sed "s/ /\n/g" | sort | uniq -D)" ]; then + echo 'ERROR: Duplicate packages found!' + exit 1 + fi + + for f in ${@}; do + if [ ! -f "${f}" ]; then + echo "ERROR: Package ${f} not found!" + exit 1 + fi + done + + return ${@} +} + 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..d405ef3 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 done if [ -d "$packagebase/repos/$svnrepo_to" ]; then @@ -101,13 +99,13 @@ if [ -d "$packagebase/repos/$svnrepo_from" ]; then for i in ${pkgname[@]}; do _pkgfile="$i-$pkgver-$pkgrel-$_arch$PKGEXT" - /bin/cp "$ftppath_from/$architecture/$_pkgfile" . + /bin/cp $(getpkgfile "$ftppath_from/$architecture/"$_pkgfile) . /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) 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..fc2bac6 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)" fi mkdir -p $WORKDIR @@ -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)" 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 | 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 | 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 -- 1.6.6.1 -- Pierre Schmitz, https://users.archlinux.de/~pierre