blob: b0cfb1efcdb016c154f405832faa2e2e8234b9db (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
#!/bin/sh
MAINTDBDIR="<%= dbdir %>"
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
|