aboutsummaryrefslogtreecommitdiffstats
path: root/modules/buildsystem/templates/signbot/sign-check-package
blob: 4c6d193728c844fec83c1b88995a51a38d9d46f2 (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
#!/bin/sh

if [ $# != 3 ] ; then 
    echo "missing arguments"
    echo "usage : $0 file key_number key_directory"
    exit 1
fi
 
file="$1"
key="$2"
keydir="$3"

tmpfile=`mktemp`
cp -pf "$file" "$tmpfile"
rpm --delsign "$tmpfile"
/usr/bin/mga-signpackage "$tmpfile" "$key" "$keydir"
nbtry=0
while rpmsign -Kv "$tmpfile" 2>&1 | grep BAD
do
    nbtry=$(($nbtry + 1))
    if [ $nbtry -ge 30 ]
    then
	exit 1
    fi

    # Archive failed file for further analysis
    mkdir -p "/tmp/failed-sign/"
    failedfile="/tmp/failed-sign/$(basename "$file").$(date +%Y%m%d%H%M%S)"
    cp -pf "$file" "$failedfile"

    cp -pf "$file" "$tmpfile"
    rpm --delsign "$tmpfile"
    /usr/bin/mga-signpackage "$tmpfile" "$key" "$keydir"
done
mv -f "$tmpfile" "$file"