summaryrefslogtreecommitdiffstats
path: root/mga-move-update
blob: 3d5e3d9bb2f4396edf2e11eea5131be01977df2d (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
#!/bin/sh

. /usr/share/mgatools/functions
moveupdate_allowed_group=mga-qa

dryrun=echo

if ! isingroup "$allowed_group"
then
    echo "You are not in group $allowed_group"
    exit 1
fi

distrorelease="$1"
section="$2"
srcname="$3"
if test -z $distrorelease || test -z $section || test -z $srcname
then
    echo 'Missing argument' >&2
    exit 1
fi

for file in "$distribdir/$distrorelease/SRPMS/$section/updates_testing/"*.rpm
do
    fname=$(rpm -qp --qf '%{NAME}' "$file")
    if [ a"$fname" = a"$srcname" ]
    then
	srcpkg=$(basename "$file")
	break
    fi
done

if [ -z $srcpkg ]
then
    echo "The package $srcname could not be found in $distrorelease/$section/updates_testing repository." >&2
    exit 2
fi

function movepkg()
{
    srcdir="$1"
    destdir="$2"
    srcpkg="$3"
    output="$4"

    for file in "$srcdir/"*.rpm
    do
	fname=$(rpm -qp --qf '%{SOURCERPM}' "$file")
	if [ a"$fname" = a"$srcpkg" ]
	then
	    $dryrun mv -v -f "$file" "$destdir" >> "$output"
	fi
    done
}

mailcontent=$(mktemp)
for arch in $arches
do
    movepkg "$distribdir/$distrorelease/$arch/media/$section/updates_testing" "$distribdir/$distrorelease/$arch/media/$section/updates/" "$srcpkg" "$mailcontent"
    movepkg "$distribdir/$distrorelease/$arch/media/debug/$section/updates_testing" "$distribdir/$distrorelease/$arch/media/debug/$section/updates/" "$srcpkg" "$mailcontent"
done

rm -f "$mailcontent"