summaryrefslogtreecommitdiffstats
path: root/mga-move-backports-nosync
blob: 773a2fcdb269076d266598ec287690198aff8946 (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
#!/bin/sh

. /usr/share/mgatools/functions

if [ $# != 3 ]
then
    echo 'Usage: mga-move-update distrorelease section srcname' >&2
    exit 1
fi

distrorelease="$1"
section="$2"
srcname="$3"

if ! inlist "$distrorelease" "$distroreleases"
then
    echo "Incorrect distrorelease $distrorelease" >&2
    exit 1
fi

if ! inlist "$section" "$distrosections"
then
    echo "Incorrect section $section" >&2
    exit 1
fi

for file in "$distribdir/$distrorelease/SRPMS/$section/backports_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/backports_testing repository." >&2
    exit 2
fi

# safety check
echo " This SRPM (and matching binarys) will be moved from backports_testing to backports: $srcpkg"  >&2

read -p " Are you sure ? " yn  >&2

case $yn in
    [Yy]* ) continue;;
        * ) exit;;
esac

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"
	    echo "$(basename $file)<br/>"
	fi
    done
}

#function post()
#{
#    for arch in $arches
#    do
#	update_hdlist "$distribdir/$distrorelease/$arch/media/$section/backports_testing"
#	update_hdlist "$distribdir/$distrorelease/$arch/media/$section/backports"
#	update_hdlist "$distribdir/$distrorelease/$arch/media/debug/$section/backports_testing"
#	update_hdlist "$distribdir/$distrorelease/$arch/media/debug/$section/backports"
#    done
#    update_hdlist "$distribdir/$distrorelease/SRPMS/$section/backports_testing"
#    update_hdlist "$distribdir/$distrorelease/SRPMS/$section/backports"
#    update_common_MD5SUM $distrorelease
#    mirror_repository $distrorelease
#}

echo ""
echo "moving binary and source rpms:"
mailcontent=$(mktemp)
for arch in $arches
do
    echo ""
    echo "$arch:<br/>"
    movepkg "$distribdir/$distrorelease/$arch/media/$section/backports_testing" "$distribdir/$distrorelease/$arch/media/$section/backports/" "$srcpkg" "$mailcontent"
    movepkg "$distribdir/$distrorelease/$arch/media/debug/$section/backports_testing" "$distribdir/$distrorelease/$arch/media/debug/$section/backports/" "$srcpkg" "$mailcontent"
done
echo ""
echo "SRPMS:<br/>"
echo "$srcpkg<br/>"
echo ""
$dryrun mv -v -f "$distribdir/$distrorelease/SRPMS/$section/backports_testing/$srcpkg" "$distribdir/$distrorelease/SRPMS/$section/backports/" >> "$output"

if [ -n "$dryrun" ]
then
    cat "$mailcontent"
else
    /usr/bin/mailx -s "mga-move-update $distrorelease $section $srcname" -S "from=moveupdate_mailfrom" "$moveupdate_mailto" < "$mailcontent"
#
# (tmb) dont do post before all rpms are moved, call update_hdlists manually
#    post
fi
rm -f "$mailcontent"