1 |
#!/bin/sh |
2 |
|
3 |
. /usr/share/mgatools/functions |
4 |
|
5 |
if [ $# != 3 ] |
6 |
then |
7 |
echo 'Usage: mga-move-update distrorelease section srcname' >&2 |
8 |
exit 1 |
9 |
fi |
10 |
|
11 |
distrorelease="$1" |
12 |
section="$2" |
13 |
srcname="$3" |
14 |
|
15 |
if ! inlist "$distrorelease" "$distroreleases" |
16 |
then |
17 |
echo "Incorrect distrorelease $distrorelease" >&2 |
18 |
exit 1 |
19 |
fi |
20 |
|
21 |
if ! inlist "$section" "$distrosections" |
22 |
then |
23 |
echo "Incorrect section $section" >&2 |
24 |
exit 1 |
25 |
fi |
26 |
|
27 |
for file in "$distribdir/$distrorelease/SRPMS/$section/updates_testing/"*.rpm |
28 |
do |
29 |
fname=$(rpm -qp --qf '%{NAME}' "$file") |
30 |
if [ a"$fname" = a"$srcname" ] |
31 |
then |
32 |
srcpkg=$(basename "$file") |
33 |
break |
34 |
fi |
35 |
done |
36 |
|
37 |
if [ -z $srcpkg ] |
38 |
then |
39 |
echo "The package $srcname could not be found in $distrorelease/$section/updates_testing repository." >&2 |
40 |
exit 2 |
41 |
fi |
42 |
|
43 |
function movepkg() |
44 |
{ |
45 |
srcdir="$1" |
46 |
destdir="$2" |
47 |
srcpkg="$3" |
48 |
output="$4" |
49 |
|
50 |
for file in "$srcdir/"*.rpm |
51 |
do |
52 |
fname=$(rpm -qp --qf '%{SOURCERPM}' "$file") |
53 |
if [ a"$fname" = a"$srcpkg" ] |
54 |
then |
55 |
$dryrun mv -v -f "$file" "$destdir" >> "$output" |
56 |
fi |
57 |
done |
58 |
} |
59 |
|
60 |
function post() |
61 |
{ |
62 |
for arch in $arches |
63 |
do |
64 |
update_hdlist "$distribdir/$distrorelease/$arch/media/$section/updates_testing" |
65 |
update_hdlist "$distribdir/$distrorelease/$arch/media/$section/updates" |
66 |
update_hdlist "$distribdir/$distrorelease/$arch/media/debug/$section/updates_testing" |
67 |
update_hdlist "$distribdir/$distrorelease/$arch/media/debug/$section/updates" |
68 |
done |
69 |
update_hdlist "$distribdir/$distrorelease/SRPMS/$section/updates_testing" |
70 |
update_hdlist "$distribdir/$distrorelease/SRPMS/$section/updates" |
71 |
update_common_MD5SUM $distrorelease |
72 |
mirror_repository $distrorelease |
73 |
} |
74 |
|
75 |
mailcontent=$(mktemp) |
76 |
for arch in $arches |
77 |
do |
78 |
movepkg "$distribdir/$distrorelease/$arch/media/$section/updates_testing" "$distribdir/$distrorelease/$arch/media/$section/updates/" "$srcpkg" "$mailcontent" |
79 |
movepkg "$distribdir/$distrorelease/$arch/media/debug/$section/updates_testing" "$distribdir/$distrorelease/$arch/media/debug/$section/updates/" "$srcpkg" "$mailcontent" |
80 |
done |
81 |
$dryrun mv -v -f "$distribdir/$distrorelease/SRPMS/$section/updates_testing/$srcpkg" "$distribdir/$distrorelease/SRPMS/$section/updates/" >> "$output" |
82 |
|
83 |
if [ -n "$dryrun" ] |
84 |
then |
85 |
cat "$mailcontent" |
86 |
else |
87 |
/usr/bin/mailx -s "mga-move-update $distrorelease $section $srcname" -S "from=$moveupdate_mailfrom" "$moveupdate_mailto" < "$mailcontent" |
88 |
post |
89 |
fi |
90 |
rm -f "$mailcontent" |
91 |
|