diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2010-02-21 16:54:10 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2010-02-21 16:54:10 +0100 |
commit | de0c93a652333b242e7ea282110619f25de7be8d (patch) | |
tree | 172a09b74679082c6655a78237107692b0a4c857 /db-functions | |
parent | dea6954635ff0eccd116c384065c1ad745fcd1d2 (diff) | |
download | dbscripts-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>
Diffstat (limited to 'db-functions')
-rw-r--r-- | db-functions | 34 |
1 files changed, 31 insertions, 3 deletions
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")" |