-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpushpackage
executable file
·101 lines (87 loc) · 2.45 KB
/
pushpackage
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
#!/bin/bash
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
echo "Usage: pushpackage [koji tag] [RPM name in nvr format]"
echo "Example: pushpackage centos6-rutgers-testing test-3.0-2.ru6"
exit 0
fi
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 [[ -f "$LOCK" ]]; then
echo "Operation on repository already occurring, try again later"
exit 1
fi
touch $LOCK
echo "Tagging packages"
for var in "$@"
do
# probably don't need an if to skip first arg, but too lazy to find another
# way lol
if [[ $var != $1 ]]; then
koji call tagBuildBypass $1 $var > /dev/null 2>&1
if [[ "$?" != "0" ]]; then
echo "Failed to tag package $var!"
rm $LOCK
exit 1
fi
fi
done
echo "Called rebuild-repo"
rebuild-repo $1 -nolock -k
if [[ "$?" != "0" ]]; then
echo "Rebuild-Repo failed!! Untagging packages and exiting..."
for var in "$@"
do
# probably don't need an if to skip first arg, but too lazy to find another
# way lol
if [[ $var != $1 ]]; then
koji untag-pkg $1 $var
if [[ "$?" != "0" ]]; then
echo "Failed to untag package $var!"
fi
fi
done
echo "Sending Mail"
echo -e "Pushpackage failed with the following output:\n\nDependency Errors detected:\n$(cat $RDPROB)\n\nOutput from repoclosure:\n$(cat $TMPRPL)" | \
mailx -r "[email protected]" -s "CentOS Broken Dependencies" "$EMAIL"
rm $RDPROB
rm $TMPRPL
rm $URDEPS
rm $LOCK
exit 1
fi
if [[ $RPMDB = true ]]; then
echo "Updating rpmdb"
input=$1
ver=${input//[^0-9]/}
populate-rpmfind-db -d $ver
fi
echo "Sending email(s)"
for var in "$@"
do
# probably don't need an if to skip first arg, but too lazy to find another
# way lol
if [[ $var != $1 ]]; then
echo -e "Pushpackage successfully pushed $var to $1 along with its breakout packages" | \
mailx -r "[email protected]" -s "CentOS Push Successful - $var" "$EMAIL"
if [[ "$?" != "0" ]]; then
echo "Failed to send email for package $var"
fi
fi
done
rm $RDPROB
rm $TMPRPL
rm $URDEPS
rm $LOCK
echo "Successfully pushed package!"
exit 0