-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrebuild-repo
executable file
·143 lines (119 loc) · 2.77 KB
/
rebuild-repo
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/bash
nodep=false
nolock=false
keep=false
for var in "$@"
do
if [[ "$var" == "-h" || "$var" == "--help" ]]; then
echo "Usage: rebuild-repo [koji tag]"
echo "Example: rebuild-repo centos6-rutgers-testing"
exit 0
fi
if [[ "$var" == "-nodep" ]]; then
nodep=true
fi
if [[ "$var" == "-nolock" ]]; then
nolock=true
fi
if [[ "$var" == "-k" ]]; then
keep=true
fi
done
if [[ $EUID -eq 0 ]]; then
echo "Error: Do not run this script as root" 1>&2
exit 1
fi
if ! id -nG "$USER" | grep -qw "packagepushers"; then
echo "ERROR: $USER does not belong to packagepushers"
exit 1
fi
source /etc/rutgers-repotools-2.cfg
if [[ ! -f "$MASHD$1.mash" ]]; then
echo "There is no mash file for that repo"
exit 1
fi
if [[ $nolock = false ]]; then
if [[ -f "$LOCK" ]]; then
echo "Operation on repository already occurring, try again later"
exit 1
fi
touch $LOCK
fi
# From Koji Set-up Guide: Kojira may need to be restarted when new tags are
# added in order to detect those tags correctly.
# echo "Restarting kojira"
# service kojira restart
if [[ -d "$TMPD" ]]; then
echo "Deleting old temp repository"
rm -rf $TMPD
fi
if [[ -d "$TGTD$1" ]]; then
echo "Deleting bad repository"
rm -rf $TGTD$1
fi
echo "Commence the mashing!"
mash -o $TGTD $1
if [[ "$?" != "0" ]]; then
echo "Mash failed to generate the repo"
if [[ $nolock = false ]]; then
rm $LOCK
fi
rm -rf /var/tmp/mash
exit 1
fi
rm -rf /var/tmp/mash
echo "Mash successfully generated the repository"
if [[ $nodep = false ]]; then
depcheck $1 -k
if [[ "$?" != "0" ]]; then
echo "Exiting due to dependency errors..."
if [[ $keep = false ]]; then
rm $RDPROB
rm $TMPRPL
rm $URDEPS
fi
if [[ $nolock = false ]]; then
rm $LOCK
fi
exit 1
fi
if [[ $keep = false ]]; then
rm $RDPROB
rm $TMPRPL
rm $URDEPS
fi
fi
echo "Switching repo directory names"
if [[ -d "$ACTD" ]]; then
mv $ACTD $TMPD
fi
mv $TGTD$1 $ACTD
if [[ "$?" != "0" ]]; then
echo "FAILED TO SWITCH REPO NAMES: PLEASE FIX MANUALLY"
if [[ $nolock = false ]]; then
rm $LOCK
fi
exit 1
fi
echo "Setting correct group and permissions"
find $ACTD -type d -exec chown $USER:packagepushers {} +
if [[ "$?" != "0" ]]; then
echo "FAILED TO SET NEW OWNER PERMISSIONS: PLEASE FIX MANUALLY"
if [[ $nolock = false ]]; then
rm $LOCK
fi
exit 1
fi
find $ACTD -type d -exec chmod 775 {} +
if [[ "$?" != "0" ]]; then
echo "FAILED TO CHMOD 775 ON $ACTD: PLEASE FIX MANUALLY"
if [[ $nolock = false ]]; then
rm $LOCK
fi
exit 1
fi
if [[ $nolock = false ]]; then
rm $LOCK
fi
echo "Successfully regenerated repo!"
exit 0