-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqt-remove-binaries
executable file
·88 lines (72 loc) · 2.09 KB
/
qt-remove-binaries
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
#!/bin/sh
# Remove all binaries corresponding to a given source rpm file
# from the /repos and /stage areas
#
########################################################################
# Change Log
# 04/14/14 shubes - created, from qt-stage-rpms
########################################################################
########################################################################
# Remove each log file and it's corresponding binary rpms
a5_remove_each_log(){
logpath=${logfile%/*}
while read wrotestring; do
b55_remove_binary_rpm
done << !EOF!
$(grep ^Wrote $logfile)
!EOF!
echo "$me - removing $logfile"
find $rootdir/ -samefile $logfile -exec rm {} \;
# if it's in a yum repo, we need to recreate the repodata (not /stage)
if [ -d $logpath/repodata ]; then
touch $logpath/$flagfile
fi
}
########################################################################
# Remove a binary rpm file, including hard links in /repos
#
b55_remove_binary_rpm(){
rpmfile=${wrotestring#Wrote: }
# there's a \r at the end of this string that we need to get rid of
rpmfile=${rpmfile%.rpm*}
rpmfile=${rpmfile}.rpm
rpmfile=${rpmfile##*/}
binrpm=$logpath/$rpmfile
if [ -f "$binrpm" ]; then
echo "$me - removing $binrpm"
find $rootdir/ -samefile $binrpm -exec rm {} \;
else
echo "$me - $binrpm not found to remove"
fi
}
########################################################################
# main process begins here
#
me=${0##*/}
myver=v1.0
echo "$me - $myver started"
if [ -z "$1" ]; then
echo "$me - usage: $me .src.rpm file"
exit 1
fi
stagdir=/stage
repodir=/repos
srcsfx=.src.rpm
logsfx=.buildlog.txt
flagfile=.needs-update
stagfile=$1
stagstat=${stagfile#$stagdir/}
stagstat=${stagstat%%/*}
stagname=${stagfile##*/}
stagpvr=${stagname%$srcsfx}
for rootdir in $repodir $stagdir; do
for logfile in $(find $rootdir/$stagstat/ -name "$stagpvr*$logsfx"); do
a5_remove_each_log
done
done
# remove corresponding src.rpm in /repos if it exists
repofile=$(echo $stagfile | sed -e "s|$stagdir/|$repodir/|")
echo "$me - removing $repofile"
find $repodir/ -samefile $repofile -exec rm {} \;
echo "$me - ended"
exit 0