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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
#! /usr/bin/python
from __future__ import print_function
import atexit
import bz2
from contextlib import closing
from optparse import OptionParser
import shutil
import sys
import tempfile
try:
from urllib.request import urlretrieve
except ImportError:
from urllib import urlretrieve
import apt_pkg
from launchpadlib.launchpad import Launchpad
import lputils
tempdir = None
def ensure_tempdir():
global tempdir
if not tempdir:
tempdir = tempfile.mkdtemp(prefix="unsubscribed-packages")
atexit.register(shutil.rmtree, tempdir)
def decompress_open(tagfile):
if tagfile.startswith("http:") or tagfile.startswith("ftp:"):
url = tagfile
tagfile = urlretrieve(url)[0]
if tagfile.endswith(".bz2"):
ensure_tempdir()
decompressed = tempfile.mktemp(dir=tempdir)
with closing(bz2.BZ2File(tagfile)) as fin:
with open(decompressed, "wb") as fout:
fout.write(fin.read())
return open(decompressed, "r")
else:
return open(tagfile, "r")
def archive_base(archtag):
if archtag in ("amd64", "i386", "src"):
return "http://archive.ubuntu.com/ubuntu"
else:
return "http://ports.ubuntu.com/ubuntu-ports"
def source_names(options):
sources = set()
for suite in options.suites:
for component in ["main", "restricted"]:
url = "%s/dists/%s/%s/source/Sources.bz2" % (
archive_base("src"), suite, component)
print("Reading %s ..." % url, file=sys.stderr)
for section in apt_pkg.TagFile(decompress_open(url)):
sources.add(section["Package"])
return sorted(sources)
def main():
parser = OptionParser(
description="Check for source packages in main or restricted in "
"active distro series without a team subscribed.")
parser.add_option(
"-l", "--launchpad", dest="launchpad_instance", default="production")
options, _ = parser.parse_args()
options.suite = None
options.distribution = "ubuntu"
options.launchpad = Launchpad.login_with(
"unsubscribed-packages", options.launchpad_instance)
launchpad = options.launchpad
ubuntu = launchpad.distributions[options.distribution]
options.suites = []
for series in ubuntu.series:
# very few lucid packages are supported
if series.name == 'lucid':
continue
if series.active:
options.suites.append(series.name)
lputils.setup_location(options)
team_names = [
'checkbox-bugs',
'desktop-packages',
'documentation-packages',
'dx-packages',
'edubuntu-bugs',
'foundations-bugs',
'kernel-packages',
'kubuntu-bugs',
'lubuntu-packaging',
'translators-packages',
'ubuntu-apps-bugs',
'ubuntu-phonedations-bugs',
'ubuntu-sdk-bugs',
'ubuntu-security-bugs',
'ubuntu-server',
'ubuntuone-hackers',
'unity-api-bugs',
'unity-ui-bugs',
'xubuntu-bugs',
]
subscriptions = set()
for team_name in team_names:
team = launchpad.people[team_name]
team_subs = team.getBugSubscriberPackages()
for src_pkg in team_subs:
subscriptions.add(src_pkg.name)
source_packages = source_names(options)
for source_package in source_packages:
if source_package not in subscriptions:
print("No team is subscribed to: %s" % source_package)
if __name__ == '__main__':
main()
|