~cjwatson/langpack-o-matic/focal

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
#!/bin/bash -e

# this is part of langpack-o-matic, by Martin Pitt <martin.pitt@canonical.com>
#
# (C) 2005 Canonical Ltd.
#
# Process all packages in "updated-packages": Build source packages and
# optionally upload them. Generated source tar.gz/dsc/changes files are deleted
# after successful upload. Entries from updated-packages are removed after
# successful processing.

cd $(dirname $0)

while [ -n "$1" ]; do
    case "$1" in
	ppa)
	    DEST=ppa:ubuntu-langpack/ubuntu/ppa
	    ;;
	rtm)
	    DEST=ppa:ci-train-ppa-service/ubuntu/stable-phone-overlay
	    ;;
	upload)
	    UPLOAD=1
	    ;;
	'')
	    break
	    ;;
	*)
	    echo "Invalid option! Usage: $0 [ppa|rtm] [upload]"
	    exit 1
	    ;;
    esac
    shift
done

[ -f updated-packages ] || {
    echo "updated-packages does not exist, nothing to do" >&2
    exit 1
}

for i in $(< updated-packages); do
    pushd $i >/dev/null
    p=$(basename $i)
    chmod 755 debian/rules
    dpkg-buildpackage -rfakeroot -S -us -uc

    # PPAs only accept release pockets, fudge the .changes
    if [ "${DEST#ppa}" != "${DEST}" ]; then
        sed -ri '/^Distribution:/ s/-(proposed|updates|security)$//' ../${p}_*_source.changes
    fi
    debsign ../${p}_*_source.changes

    if [ -n "$UPLOAD" ]; then
	cd ..
        dput $DEST ${p}_*_source.changes
	rm -f ${p}_*_source.changes ${p}_*.upload ${p}_*.dsc ${p}_*.tar.gz
	cd -
    fi

    cd ..
    rm -f ${p}_*.build *[^r][^c][^e].changes

    popd >/dev/null

    # this seems to be overly complicated, but it allows us to run this script
    # again if dput fails for a single package
    sed -i -e "s#^$i\$##" -e '/^$/d'  updated-packages
done