~ubuntu-langpack/langpack-o-matic/main

407 by Martin Pitt
add copy-ppa-proposed
1
#!/usr/bin/python
2
#
3
# This is part of langpack-o-matic
4
#
5
# (C) 2011 Canonical Ltd.
6
# Author: Martin Pitt <martin.pitt@canonical.com>
7
#
8
# Copy all packages from the weekly PPA to -proposed.  This needs
9
# ~ubuntu-archive privilages.
10
# Usage: copy-ppa-proposed <release>
11
12
import sys
13
import apt
14
from launchpadlib.launchpad import Launchpad
15
16
if len(sys.argv) != 2:
17
    sys.stderr.write('Usage: %s <release>\n' % sys.argv[0])
18
    sys.exit(1)
19
release = sys.argv[1]
20
21
launchpad = Launchpad.login_with('langpack-o-matic', service_root='production')
22
ubuntu = launchpad.distributions['ubuntu']
23
archive = ubuntu.getArchive(name='primary')
24
distro_series = ubuntu.getSeries(name_or_version=release)
25
langpack_ppa = launchpad.people['ubuntu-langpack'].getPPAByName(name='ppa')
26
27
# get current versions in PPA for that series
28
for pub in langpack_ppa.getPublishedSources(source_name='language-pack-',
29
        exact_match=False, status='Published', pocket='Release',
30
        distro_series=distro_series):
31
32
    newer = True
33
    in_ubuntu = False
34
35
    # get current versions in Ubuntu
36
    for ubuntu_pub in archive.getPublishedSources(source_name=pub.source_package_name,
37
        exact_match=True, status='Published', distro_series=distro_series):
38
        in_ubuntu = True
39
        if ubuntu_pub.pocket not in ('Release', 'Proposed', 'Updates', 'Security'):
40
            # ignore backports
41
            continue
42
        if apt.apt_pkg.version_compare(ubuntu_pub.source_package_version,
43
                pub.source_package_version) >= 0:
44
            sys.stderr.write('%s already has the same/never version of %s: %s, PPA: %s\n' % (
45
                ubuntu_pub.pocket, pub.source_package_name, ubuntu_pub.source_package_version, pub.source_package_version))
46
            newer = False
47
            break
48
49
    if not in_ubuntu:
50
        sys.stderr.write('%s is not yet in Ubuntu, not copying\n' % pub.source_package_name)
51
        continue
52
53
    if newer:
54
        print('Copying %s %s from PPA to %s-proposed' % (pub.source_package_name, 
55
            pub.source_package_version, release))
457 by Martin Pitt
copy-ppa-proposed: skip over failures
56
        try:
57
            archive.syncSource(from_archive=langpack_ppa, include_binaries=True,
58
                    source_name=pub.source_package_name, to_series=release,
59
                    to_pocket='proposed', version=pub.source_package_version)
60
        except:
61
            continue
407 by Martin Pitt
add copy-ppa-proposed
62