diff options
Diffstat (limited to 'modules/buildsystem/templates/maintdb/maintdb.bin')
-rwxr-xr-x | modules/buildsystem/templates/maintdb/maintdb.bin | 43 |
1 files changed, 15 insertions, 28 deletions
diff --git a/modules/buildsystem/templates/maintdb/maintdb.bin b/modules/buildsystem/templates/maintdb/maintdb.bin index 9fef3c64..6c40046c 100755 --- a/modules/buildsystem/templates/maintdb/maintdb.bin +++ b/modules/buildsystem/templates/maintdb/maintdb.bin @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash MAINTDBDIR="<%= scope.lookupvar('buildsystem::var::maintdb::dbdir') %>" @@ -15,15 +15,13 @@ function checkname() function maintnew() { - if [ a"$user" != "aroot" ] - then + if [ "$user" != "root" ]; then echo "Error: new is only allowed to root." >&2 exit 1 fi checkname "$1" maintfile="$MAINTDBDIR/$1" - if [ -f "$maintfile" ] - then + if [ -f "$maintfile" ]; then exit 0 fi echo "$2" > "$maintfile" @@ -34,26 +32,21 @@ function maintset() checkname "$1" maintfile="$MAINTDBDIR/$1" newmaint="$2" - if ! [ -f "$maintfile" ] - then + if [ ! -f "$maintfile" ]; then echo "Error: package $1 does not exist in maintdb." >&2 exit 1 fi curmaint=$(cat "$maintfile") - if [ a"$newmaint" = "anobody" ] - then - if [ a"$curmaint" = a"$user" ] - then + if [ "$newmaint" = "nobody" ]; then + if [ "$curmaint" = "$user" ]; then echo "$newmaint" > "$maintfile" exit 0 else echo "Error: cannot set maintainer for $1." >&2 exit 1 fi - elif [ a"$newmaint" = a"$user" ] - then - if [ a"$curmaint" = "anobody" ] - then + elif [ "$newmaint" = "$user" ]; then + if [ "$curmaint" = "nobody" ]; then echo "$newmaint" > "$maintfile" exit 0 else @@ -69,8 +62,7 @@ function maintset() function maintgetall() { cd "$MAINTDBDIR" - for file in * - do + for file in *; do echo "$file $(cat $file)" done exit 0 @@ -78,14 +70,12 @@ function maintgetall() function maintget() { - if [ -z "$1" ] - then + if [ -z "$1" ]; then maintgetall fi checkname "$1" maintfile="$MAINTDBDIR/$1" - if [ -f "$maintfile" ] - then + if [ -f "$maintfile" ]; then cat "$maintfile" else echo "Error: package $1 does not exist in maintdb." >&2 @@ -96,16 +86,13 @@ function maintget() user="$1" action="$2" -if [ a"$action" = "anew" ] -then +if [ "$action" = "new" ]; then maintnew "$3" "$4" -elif [ a"$action" = "aset" ] -then +elif [ "$action" = "set" ]; then maintset "$3" "$4" -elif [ a"$action" = "aget" ] -then +elif [ "$action" = "get" ]; then maintget "$3" else - echo "Error: unknow command." >&2 + echo "Error: unknown command." >&2 exit 2 fi |