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-functions | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'db-functions') 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")" -- cgit v1.2.3-24-g4f1b