/[adm]/puppet/modules/buildsystem/templates/maintdb
ViewVC logotype

Contents of /puppet/modules/buildsystem/templates/maintdb

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1858 - (show annotations) (download)
Tue Jul 19 20:12:35 2011 UTC (9 years, 3 months ago) by misc
File size: 1836 byte(s)
fix the format, to make it similar to the one of mandriva ( compat with various tools,
a better format should be created later )
1 #!/bin/sh
2
3 MAINTDBDIR="<%= maintdb_dbdir %>"
4
5 function checkname()
6 {
7 if [ -z "$1" ] ||
8 echo "$1" | grep -q '[/*{}%]' ||
9 echo "$1" | fgrep -q '..'
10 then
11 echo "Error: invalid package name." >&2
12 exit 1
13 fi
14 }
15
16 function maintnew()
17 {
18 if [ a"$user" != "aroot" ]
19 then
20 echo "Error: new is only allowed to root." >&2
21 exit 1
22 fi
23 checkname "$1"
24 maintfile="$MAINTDBDIR/$1"
25 if [ -f "$maintfile" ]
26 then
27 exit 0
28 fi
29 echo "$2" > "$maintfile"
30 }
31
32 function maintset()
33 {
34 checkname "$1"
35 maintfile="$MAINTDBDIR/$1"
36 newmaint="$2"
37 if ! [ -f "$maintfile" ]
38 then
39 echo "Error: package $1 does not exist in maintdb." >&2
40 exit 1
41 fi
42 curmaint=$(cat "$maintfile")
43 if [ a"$newmaint" = "anobody" ]
44 then
45 if [ a"$curmaint" = a"$user" ]
46 then
47 echo "$newmaint" > "$maintfile"
48 exit 0
49 else
50 echo "Error: cannot set maintainer for $1." >&2
51 exit 1
52 fi
53 elif [ a"$newmaint" = a"$user" ]
54 then
55 if [ a"$curmaint" = "anobody" ]
56 then
57 echo "$newmaint" > "$maintfile"
58 exit 0
59 else
60 echo "Error: cannot set maintainer for $1." >&2
61 exit 1
62 fi
63 else
64 echo "Error: cannot set someone else as maintainer." >&2
65 exit 1
66 fi
67 }
68
69 function maintgetall()
70 {
71 cd "$MAINTDBDIR"
72 for file in *
73 do
74 echo "$file $(cat $file)"
75 done
76 exit 0
77 }
78
79 function maintget()
80 {
81 if [ -z "$1" ]
82 then
83 maintgetall
84 fi
85 checkname "$1"
86 maintfile="$MAINTDBDIR/$1"
87 if [ -f "$maintfile" ]
88 then
89 cat "$maintfile"
90 else
91 echo "Error: package $1 does not exist in maintdb." >&2
92 exit 1
93 fi
94 }
95
96 user="$1"
97 action="$2"
98
99 if [ a"$action" = "anew" ]
100 then
101 maintnew "$3" "$4"
102 elif [ a"$action" = "aset" ]
103 then
104 maintset "$3" "$4"
105 elif [ a"$action" = "aget" ]
106 then
107 maintget "$3"
108 else
109 echo "Error: unknow command." >&2
110 exit 2
111 fi
112

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.28