blob: b648d34e81a14085db6a23fc8ac3b3779bf20d4b (
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
113
114
115
116
117
118
119
120
121
122
123
124
125
|
#!/bin/bash
#
# Marcelo Ricardo Leitner - Properly clean Iurt cache pool - 20070615
#
# Cache topdir
TOPDIR=/export/home/iurt_cache/
# Official distros topdir
OFFICIAL_DIR=/mnt/BIG/dis/
# Maximum number of days a package is allowed to be in the cache
AGE=4
# Email to be notified about wrong uploads
MAILTO=distrib-admin@mandrivalinux.org
#
# Remove all packages generated by a given .src.rpm
#
function clean_package() {
distro="$1"
section="$2"
srpm="$3"
echo -e "Cleaning all packages generated by\n $srpm."
find "$TOPDIR/$distro/"{,debug_}"$section" -name '*.rpm' ! -name '*.src.rpm' |\
xargs rpm -qp --qf '%{SOURCERPM} %{name}-%{version}-%{release}.%{arch}.rpm\n' |\
sed -n "s@^$srpm @$TOPDIR/$distro/$section/@p" |\
xargs rm -fv "$TOPDIR/$distro/$section/$srpm"
}
#
# Cleans a released package
#
function clean() {
distro="$1"
section="$2"
srpm="$3"
echo "Package released. We can remove it now."
clean_package "$distro" "$section" "$srpm"
}
#
# Cleans an aged package
#
function age_timeout() {
distro="$1"
section="$2"
srpm="$3"
echo "Package expired. We can remove it now."
clean_package "$distro" "$section" "$srpm"
}
#
# Send a warn about packages that goes to wrong sections.
#
function wrong_section() {
distro="$1"
section="$2"
srpm="$3"
hits="$4"
wrong_section=$(echo "$hits" | sed "s@$OFFICIAL_DIR/$distro/SRPMS/@@;s@/$srpm@@")
echo "Package uploaded to a wrong section!"
echo "It went to $wrong_section while should have hit $section!"
mail -s "Package $srpm uploaded to section for $distro" $MAILTO <<_EOF_
Distro: $distro
Package: $srpm
Wanted section: $section
Final section: $wrong_section
It happened again!
I'm holding it on the cache probably for more $AGE days.
_EOF_
}
#
# Search for the .src.rpm's
#
ls "$TOPDIR" |\
while read distro; do
find -L "$TOPDIR/$distro" -type f -name *.src.rpm |\
sed "s@$TOPDIR/$distro/@@;s@/\([^/]\+\)\$@ \1@" |\
while read section srpm; do
echo
echo "Checking $distro/$section/$srpm"
# Check if the package was released
if [ -e "$OFFICIAL_DIR/$distro/SRPMS/$section/$srpm" ]; then
clean "$distro" "$section" "$srpm"
continue
fi
# Check for age timeout
z=$(find "$OFFICIAL_DIR/$distro/SRPMS/$section/$srpm" -ctime +$AGE -name "$srpm" 2> /dev/null)
if [ -n "$z" ]; then
age_timeout "$distro" "$section" "$srpm"
continue
fi
# Check for wrong section
z=$(find "$OFFICIAL_DIR/$distro/SRPMS" -type f -name "$srpm")
if [ -n "$z" ]; then
wrong_section "$distro" "$section" "$srpm" "$z"
continue
fi
# Package should remain on cache
echo "Package should remain on cache."
done
done
# Check for unsupported archs, which are uploaded without .src.rpms
echo
echo "Cleaning unsupported archs.."
find "$TOPDIR" -type f -name '*.rpm' \
! -name '*.i586.rpm' ! -name '*.x86_64.rpm' \
! -name '*.noarch.rpm' ! -name '*.src.rpm' |\
xargs rm -fv
|