Merge lp:~jml/pkgme-devportal/explicit-copyright into lp:pkgme-devportal

Proposed by Jonathan Lange
Status: Merged
Approved by: Jonathan Lange
Approved revision: 95
Merged at revision: 83
Proposed branch: lp:~jml/pkgme-devportal/explicit-copyright
Merge into: lp:pkgme-devportal
Diff against target: 259 lines (+122/-10)
6 files modified
devportalbinary/binary.py (+15/-0)
devportalbinary/metadata.py (+29/-8)
devportalbinary/pdf.py (+14/-0)
devportalbinary/tests/test_binary.py (+22/-1)
devportalbinary/tests/test_metadata.py (+20/-1)
devportalbinary/tests/test_pdf.py (+22/-0)
To merge this branch: bzr merge lp:~jml/pkgme-devportal/explicit-copyright
Reviewer Review Type Date Requested Status
James Westby Approve
Review via email: mp+120740@code.launchpad.net

Commit message

Provide an explicit copyright message for PDF and binary packages

Description of the change

This branch sets the copyright message for binary & PDF files as per
bug 1026121. See especially <https://bugs.launchpad.net/pkgme-devportal/+bug/1026121/comments/6>.

Implementation approach is pretty standard. It requires an as-yet-unreleased
version of pkgme in order to get the ExplicitCopyright info element.

While here, I cleaned up some of mvo's weird dict formatting and some trailing
whitespace business.

To post a comment you must log in.
Revision history for this message
James Westby (james-w) :
review: Approve
Revision history for this message
ISD Branch Mangler (isd-branches-mangler) wrote :

The attempt to merge lp:~jml/pkgme-devportal/explicit-copyright into lp:pkgme-devportal failed. Below is the output from the failed tests.

./bin/py -m testtools.run devportalbinary.tests.test_suite

Tree is up to date at revision 9 of branch bzr+ssh://bazaar.launchpad.net/+branch/ca-download-cache
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/tmp/eggs/testtools-0.9.16-py2.7.egg/testtools/run.py", line 332, in <module>
    main(sys.argv, sys.stdout)
  File "/tmp/eggs/testtools-0.9.16-py2.7.egg/testtools/run.py", line 329, in main
    program = TestProgram(argv=argv, testRunner=runner, stdout=stdout)
  File "/tmp/eggs/testtools-0.9.16-py2.7.egg/testtools/run.py", line 155, in __init__
    self.parseArgs(argv)
  File "/tmp/eggs/testtools-0.9.16-py2.7.egg/testtools/run.py", line 232, in parseArgs
    self.createTests()
  File "/tmp/eggs/testtools-0.9.16-py2.7.egg/testtools/run.py", line 241, in createTests
    self.module)
  File "/usr/lib/python2.7/unittest/loader.py", line 128, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/usr/lib/python2.7/unittest/loader.py", line 113, in loadTestsFromName
    test = obj()
  File "devportalbinary/tests/__init__.py", line 21, in test_suite
    tests.addTests(loader.loadTestsFromNames(module_names))
  File "/usr/lib/python2.7/unittest/loader.py", line 128, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/usr/lib/python2.7/unittest/loader.py", line 100, in loadTestsFromName
    parent, obj = obj, getattr(obj, part)
AttributeError: 'module' object has no attribute 'test_metadata'
make: *** [test] Error 255

95. By Jonathan Lange

Guard ExplicitCopyright in test code too.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'devportalbinary/binary.py'
2--- devportalbinary/binary.py 2012-07-26 12:48:35 +0000
3+++ devportalbinary/binary.py 2012-08-23 10:52:08 +0000
4@@ -354,6 +354,21 @@
5 executable = guess_executable(package_name, iter_executables(self.path))
6 return '/opt/%s/%s' % (package_name, executable)
7
8+ def get_explicit_copyright(self, metadata):
9+ # See https://bugs.launchpad.net/pkgme-devportal/+bug/1026121/.
10+ maintainer = self.get_maintainer(metadata)
11+ if maintainer:
12+ maintainer_suffix = (
13+ " or contact the submitter of the application, %s" % (
14+ maintainer,))
15+ else:
16+ maintainer_suffix = ''
17+ return """\
18+Please see the individual files in this archive for the exact copyright holders%s.
19+
20+This file was automatically generated.
21+""" % (maintainer_suffix,)
22+
23 def get_extra_targets(self, metadata):
24 package_name = self.get_package_name(metadata)
25 return guess_extra_debian_rules_targets(package_name, self.path)
26
27=== modified file 'devportalbinary/metadata.py'
28--- devportalbinary/metadata.py 2012-07-25 08:59:43 +0000
29+++ devportalbinary/metadata.py 2012-08-23 10:52:08 +0000
30@@ -50,6 +50,18 @@
31 from .utils import get_latest_stable_ubuntu_distroseries
32
33
34+# Temporary conditional code to allow us to deploy new pkgme-devportal without
35+# relying on unreleased pkgme changes. When ExplicitCopyright is in a
36+# releasea version of pkgme, we should bump our minimum dependency to that
37+# released version and delete this conditional, importing ExplicitCopyright
38+# directly.
39+try:
40+ from pkgme.info_elements import ExplicitCopyright as EC_pyflakes_sucks
41+ ExplicitCopyright = EC_pyflakes_sucks
42+except ImportError:
43+ ExplicitCopyright = None
44+
45+
46 # XXX: is this the right place?
47 LINTIAN_OVERRIDES_TEMPLATE = """
48 #Partner package contents belong in /opt
49@@ -170,7 +182,7 @@
50
51 def convert_icon(icon_path, new_size):
52 """Takes a icon_path and converts it to the new size
53-
54+
55 :return: path of the newly created icon of the requested size
56 """
57 im = Image.open(icon_path)
58@@ -184,8 +196,8 @@
59 def get_icon_size_from_string(s):
60 """Return a integer size from a string of the form 'WxH' ('48x48')
61
62- Raises a Value error
63-
64+ :raise ValueError: if we're given a non-square size.
65+
66 :return: The size of the icon.
67 """
68 w, h = s.split("x")
69@@ -275,13 +287,15 @@
70 """Return the path to the executable."""
71 raise NotImplementedError(self.get_executable)
72
73+ def get_explicit_copyright(self, metadata):
74+ return None
75+
76 def get_extra_targets(self, metadata):
77 """Return any extra debian/rules targets. """
78 return ""
79
80 def _get_lintian_overrides(self, package_name):
81- return LINTIAN_OVERRIDES_TEMPLATE % { 'package_name' : package_name,
82- }
83+ return LINTIAN_OVERRIDES_TEMPLATE % {'package_name' : package_name,}
84
85 def get_extra_files(self, metadata, package_name):
86 """Get the extra files for the package.
87@@ -345,8 +359,8 @@
88
89 def _ensure_required_icon_size(self, metadata, required_size):
90 """ Ensure that the size "required_size" is part of the ICONS
91- metadata and create a new icon if needed.
92-
93+ metadata and create a new icon if needed.
94+
95 Note that this modifies metadata[self.ICONS].
96 """
97 icons = metadata.get(self.ICONS, {})
98@@ -357,7 +371,7 @@
99 new_path = convert_icon(icons[best_resolution], required_size)
100 icons[required_size] = new_path
101 metadata[self.ICONS] = icons
102-
103+
104 def _get_icon_map(self, metadata, package_name):
105 """Return a dict mapping resolutions to paths.
106
107@@ -448,6 +462,13 @@
108 Version,
109 Homepage,
110 ]
111+ # Temporary conditional code to allow us to deploy new pkgme-devportal
112+ # without relying on unreleased pkgme changes. When ExplicitCopyright
113+ # is in a releasea version of pkgme, we should bump our minimum
114+ # dependency to that released version and delete this conditional,
115+ # including ExplicitCopyright in the OPTIONAL_ELEMENTS list.
116+ if ExplicitCopyright:
117+ OPTIONAL_ELEMENTS.append(ExplicitCopyright)
118 info = {}
119 for element in COMPULSORY_ELEMENTS:
120 info[element] = self._calculate_info_element(element, metadata)
121
122=== modified file 'devportalbinary/pdf.py'
123--- devportalbinary/pdf.py 2012-03-30 18:46:30 +0000
124+++ devportalbinary/pdf.py 2012-08-23 10:52:08 +0000
125@@ -15,6 +15,20 @@
126 def get_build_depends(self, metadata):
127 return 'debhelper (>=7)'
128
129+ def get_explicit_copyright(self, metadata):
130+ # See https://bugs.launchpad.net/pkgme-devportal/+bug/1026121/.
131+ maintainer = self.get_maintainer(metadata)
132+ if maintainer:
133+ maintainer_suffix = (
134+ " or contact the submitter of the PDF, %s" % (maintainer,))
135+ else:
136+ maintainer_suffix = ''
137+ return """\
138+Please see the enclosed PDF file for the exact copyright holders%s.
139+
140+This file was automatically generated.
141+""" % (maintainer_suffix,)
142+
143 def get_depends(self, metadata):
144 return 'xdg-utils, ${misc:Depends}'
145
146
147=== modified file 'devportalbinary/tests/test_binary.py'
148--- devportalbinary/tests/test_binary.py 2012-08-10 15:32:32 +0000
149+++ devportalbinary/tests/test_binary.py 2012-08-23 10:52:08 +0000
150@@ -260,7 +260,6 @@
151
152 def test_guess_dependencies_error_on_unknown_dependency(self):
153 self.useFixture(DatabaseConfig(self.db_fixture))
154- db = PackageDatabase(self.db_fixture.conn)
155 e = self.assertRaises(UnknownDependency,
156 guess_dependencies, get_test_data_dir_path('hello'))
157 self.assertEqual('Can\'t find dependency for "libc.so.6".', str(e))
158@@ -400,3 +399,25 @@
159 package_name, package_name, ld_search_path[0])),
160 guess_extra_debian_rules_targets(
161 package_name, path, lambda l: ld_search_path))
162+
163+ def test_copyright_no_maintainer(self):
164+ metadata = self.make_metadata()
165+ backend = self.make_backend()
166+ expected = """\
167+Please see the individual files in this archive for the exact copyright holders.
168+
169+This file was automatically generated.
170+"""
171+ self.assertEqual(expected, backend.get_explicit_copyright(metadata))
172+
173+ def test_copyright_with_maintainer(self):
174+ metadata = self.make_metadata()
175+ submitter = 'Jonathan Lange <jml@mumak.net>'
176+ metadata[MetadataBackend.MAINTAINER] = submitter
177+ backend = self.make_backend()
178+ expected = """\
179+Please see the individual files in this archive for the exact copyright holders or contact the submitter of the application, %s.
180+
181+This file was automatically generated.
182+""" % (submitter,)
183+ self.assertEqual(expected, backend.get_explicit_copyright(metadata))
184
185=== modified file 'devportalbinary/tests/test_metadata.py'
186--- devportalbinary/tests/test_metadata.py 2012-08-10 15:37:50 +0000
187+++ devportalbinary/tests/test_metadata.py 2012-08-23 10:52:08 +0000
188@@ -26,7 +26,11 @@
189 DEBIAN_DIR,
190 )
191 from pkgme.testing import AreDesktopValuesFor
192-from testtools import TestCase
193+from testtools import (
194+ skipUnless,
195+ TestCase,
196+ try_import,
197+ )
198 from treeshape import FileTree
199
200 from devportalbinary.metadata import (
201@@ -43,6 +47,13 @@
202 MetadataFixture,
203 )
204
205+# Temporary conditional code to allow us to deploy new pkgme-devportal without
206+# relying on unreleased pkgme changes. When ExplicitCopyright is in a
207+# releasea version of pkgme, we should bump our minimum dependency to that
208+# released version and delete this conditional, importing ExplicitCopyright
209+# directly.
210+ExplicitCopyright = try_import('pkgme.info_element.ExplicitCopyright')
211+
212
213 class DummyBackend(MetadataBackend):
214 """Dummy implementations of MetadataBackend's abstract methods."""
215@@ -309,6 +320,14 @@
216 backend = self.make_backend()
217 self.assertEqual(maintainer, backend.get_info(metadata)[Maintainer])
218
219+ @skipUnless(ExplicitCopyright, "pkgme doesn't support explicit copyright")
220+ def test_copyright(self):
221+ metadata = self.make_metadata()
222+ backend = self.make_backend()
223+ info = backend.get_info(metadata)
224+ marker = object()
225+ self.assertIs(marker, info.get(ExplicitCopyright, marker))
226+
227 def test_homepage(self):
228 metadata = self.make_metadata()
229 homepage = 'http://www.pkgme-rocks.com/'
230
231=== modified file 'devportalbinary/tests/test_pdf.py'
232--- devportalbinary/tests/test_pdf.py 2012-08-10 15:55:46 +0000
233+++ devportalbinary/tests/test_pdf.py 2012-08-23 10:52:08 +0000
234@@ -104,3 +104,25 @@
235 self.assertEqual(
236 '/usr/bin/xdg-open /opt/%s/%s' % (package_name, 'foo.pdf'),
237 executable)
238+
239+ def test_copyright_no_maintainer(self):
240+ metadata = self.make_metadata()
241+ backend = self.make_backend()
242+ expected = """\
243+Please see the enclosed PDF file for the exact copyright holders.
244+
245+This file was automatically generated.
246+"""
247+ self.assertEqual(expected, backend.get_explicit_copyright(metadata))
248+
249+ def test_copyright_with_maintainer(self):
250+ metadata = self.make_metadata()
251+ submitter = 'Jonathan Lange <jml@mumak.net>'
252+ metadata[MetadataBackend.MAINTAINER] = submitter
253+ backend = self.make_backend()
254+ expected = """\
255+Please see the enclosed PDF file for the exact copyright holders or contact the submitter of the PDF, Jonathan Lange <jml@mumak.net>.
256+
257+This file was automatically generated.
258+"""
259+ self.assertEqual(expected, backend.get_explicit_copyright(metadata))

Subscribers

People subscribed via source and target branches