aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorNicolas Vigier <boklm@mageia.org>2011-07-11 23:10:31 +0000
committerNicolas Vigier <boklm@mageia.org>2011-07-11 23:10:31 +0000
commit150236cda4516e5ff57b96c906a25fb95a83f3b2 (patch)
treeba465546d6078be25a93861b116055445b1094ce /modules
parent90ab5160354ffafe6aa4c3d4ecda631f16a8166a (diff)
downloadpuppet-150236cda4516e5ff57b96c906a25fb95a83f3b2.tar
puppet-150236cda4516e5ff57b96c906a25fb95a83f3b2.tar.gz
puppet-150236cda4516e5ff57b96c906a25fb95a83f3b2.tar.bz2
puppet-150236cda4516e5ff57b96c906a25fb95a83f3b2.tar.xz
puppet-150236cda4516e5ff57b96c906a25fb95a83f3b2.zip
add small maintdb script
Diffstat (limited to 'modules')
-rwxr-xr-xmodules/buildsystem/templates/maintdb112
1 files changed, 112 insertions, 0 deletions
diff --git a/modules/buildsystem/templates/maintdb b/modules/buildsystem/templates/maintdb
new file mode 100755
index 00000000..7d504b77
--- /dev/null
+++ b/modules/buildsystem/templates/maintdb
@@ -0,0 +1,112 @@
+#!/bin/sh
+
+MAINTDBDIR=/tmp/maintdb
+
+function checkname()
+{
+ if [ -z "$1" ] ||
+ echo "$1" | grep -q '[/*{}%]' ||
+ echo "$1" | fgrep -q '..'
+ then
+ echo "Error: invalid package name." >&2
+ exit 1
+ fi
+}
+
+function maintnew()
+{
+ if [ a"$user" != "aroot" ]
+ then
+ echo "Error: new is only allowed to root." >&2
+ exit 1
+ fi
+ checkname "$1"
+ maintfile="$MAINTDBDIR/$1"
+ if [ -f "$maintfile" ]
+ then
+ exit 0
+ fi
+ echo "$2" > "$maintfile"
+}
+
+function maintset()
+{
+ checkname "$1"
+ maintfile="$MAINTDBDIR/$1"
+ newmaint="$2"
+ 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
+ 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
+ echo "$newmaint" > "$maintfile"
+ exit 0
+ else
+ echo "Error: cannot set maintainer for $1." >&2
+ exit 1
+ fi
+ else
+ echo "Error: cannot set someone else as maintainer." >&2
+ exit 1
+ fi
+}
+
+function maintgetall()
+{
+ cd "$MAINTDBDIR"
+ for file in *
+ do
+ echo "$file:$(cat $file)"
+ done
+ exit 0
+}
+
+function maintget()
+{
+ if [ -z "$1" ]
+ then
+ maintgetall
+ fi
+ checkname "$1"
+ maintfile="$MAINTDBDIR/$1"
+ if [ -f "$maintfile" ]
+ then
+ cat "$maintfile"
+ else
+ echo "Error: package $1 does not exist in maintdb." >&2
+ exit 1
+ fi
+}
+
+user="$1"
+action="$2"
+
+if [ a"$action" = "anew" ]
+then
+ maintnew "$3" "$4"
+elif [ a"$action" = "aset" ]
+then
+ maintset "$3" "$4"
+elif [ a"$action" = "aget" ]
+then
+ maintget "$3"
+else
+ echo "Error: unknow command." >&2
+ exit 2
+fi
+