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
|
#!/usr/bin/python
#
# this is part of langpack-o-matic
#
# (C) 2007, 2008 Canonical Ltd.
# Author: Martin Pitt <martin.pitt@canonical.com>
#
# Find all language packs which are in one PPA/pocket of a distro release and
# newer than in another pocket and generate a list of copy-package.py
# commands to copy them.
#
# Usage: copy-packages <release> <source pocket> <target pocket>
# pockets can be: ppa, proposed, updates, release
import sys, os.path
import warnings
warnings.filterwarnings('ignore', 'apt API not stable yet', FutureWarning)
from apt import VersionCompare
if len(sys.argv) != 4:
print >> sys.stderr, 'Usage: %s <release> <source pocket> <target pocket>' % sys.argv[0]
sys.exit(1)
(release, src, dest) = sys.argv[1:]
ppa_archive = 'http://ppa.launchpad.net/ubuntu-langpack/ubuntu'
ubuntu_archive = 'http://archive.ubuntu.com/ubuntu'
pockets = {
'ppa': {
'archive': '%s/dists/%s/main/source/Sources.gz' % (ppa_archive, release),
'cpoptions': ['-p', 'ubuntu-langpack'],
'cpdist': release,
},
'proposed': {
'archive': '%s/dists/%s-proposed/main/source/Sources.gz' % (ubuntu_archive, release),
'cpoptions': ['-b'],
'cpdist': release + '-proposed',
},
'updates': {
'archive': '%s/dists/%s-updates/main/source/Sources.gz' % (ubuntu_archive, release),
'cpoptions': ['-b'],
'cpdist': release + '-updates',
},
'release': {
'archive': '%s/dists/%s/main/source/Sources.gz' % (ubuntu_archive, release),
'cpoptions': [],
'cpdist': release,
},
}
# import our own libraries
sys.path.append(os.path.join(os.path.dirname(sys.argv[0]), 'lib'))
import pkg_classify
# get maps of current source and target pockets
release_info = pkg_classify.package_list_map(pockets['release']['archive'])
src_info = pkg_classify.package_list_map(pockets[src]['archive'])
dest_info = pkg_classify.package_list_map(pockets[dest]['archive'])
# find language-pack-* which are newer in dest
for k in src_info:
if not k.startswith('language-pack-'):
continue
try:
old_version = dest_info[k]['Version']
except KeyError:
# we disable new packages for post-release updates
if dest == 'release':
old_version = ''
else:
try:
old_version = release_info[k]['Version']
except KeyError:
# package is NEW
print >> sys.stderr, k, 'is NEW'
continue
if VersionCompare(src_info[k]['Version'], old_version) <= 0:
print >> sys.stderr, k, 'is already current in archive'
continue
print 'copy-package.py -y %s -s %s --to-suite %s %s' % (
' '.join(pockets[src]['cpoptions']),
pockets[src]['cpdist'], pockets[dest]['cpdist'], k)
|