Merge lp:~unity-api-team/click/scope-facing-apis into lp:click

Proposed by Pete Woods on 2014-09-05
Status: Superseded
Proposed branch: lp:~unity-api-team/click/scope-facing-apis
Merge into: lp:click
Diff against target: 1045 lines (+356/-118)
21 files modified
click/chroot.py (+11/-0)
click/commands/build.py (+20/-0)
click/install.py (+9/-0)
click/tests/integration/helpers.py (+37/-8)
click/tests/integration/test_build_core_apps.py (+11/-6)
click/tests/integration/test_chroot.py (+14/-5)
click/tests/integration/test_contents.py (+1/-1)
click/tests/integration/test_frameworks.py (+10/-11)
click/tests/integration/test_hook.py (+8/-11)
click/tests/integration/test_info.py (+13/-2)
click/tests/integration/test_install.py (+41/-39)
click/tests/integration/test_list.py (+33/-0)
click/tests/integration/test_signatures.py (+32/-16)
click/tests/integration/test_verify.py (+42/-2)
click/tests/test_build.py (+13/-13)
debian/changelog (+43/-0)
debian/control (+2/-1)
debian/tests/control (+1/-1)
debian/tests/run-tests.sh (+8/-1)
doc/manpage.rst (+2/-0)
pk-plugin/pk-plugin-click.c (+5/-1)
To merge this branch: bzr merge lp:~unity-api-team/click/scope-facing-apis
Reviewer Review Type Date Requested Status
Colin Watson Resubmit on 2014-09-09
Michael Vogt 2014-09-05 Approve on 2014-09-09
PS Jenkins bot (community) continuous-integration Approve on 2014-09-05
Review via email: mp+233539@code.launchpad.net

This proposal has been superseded by a proposal from 2014-09-09.

Commit message

Add scope-facing APIs to chroot build

Description of the change

Add scope-facing APIs to chroot build

To post a comment you must log in.
Pete Woods (pete-woods) wrote :

I've tried creating a new chroot from this, and it successfully builds the new scopes template from the SDK: https://code.launchpad.net/~pete-woods/qtcreator-plugin-ubuntu/new-scope-template/+merge/233218

512. By Daniel Holbach on 2014-09-05

Run click-review from click-reviewers-tools as part of the "click build" run. Offer --no-validate option.

Approved by PS Jenkins bot, zbenjamin, Colin Watson.

513. By Colin Watson on 2014-09-05

typo

514. By Michael Vogt on 2014-09-05

Make the PackageKit plugin honour the PK_TRANSACTION_FLAG_ENUM_ONLY_TRUSTED flag. Fixes: https://bugs.launchpad.net/bugs/1360582.

Approved by Colin Watson, PS Jenkins bot.

Michael Vogt (mvo) wrote :

This looks good, however there are two libraries that are in universe right now, I'm not sure what our policy is here and if we need a MIR (Colin will know).

515. By Colin Watson on 2014-09-09

merge 0.4.32 release

516. By Colin Watson on 2014-09-09

[r=cjwatson] Fix autopkgtests

Colin Watson (cjwatson) wrote :

We don't need an MIR for these at this point - we have other things in universe.

Michael Vogt (mvo) :
review: Approve
Sergio Schvezov (sergiusens) wrote :

isn't this supposed to target the staging/devel click?

Colin Watson (cjwatson) wrote :

Er, yes, please resubmit this against lp:click/devel.

review: Resubmit
517. By Pete Woods on 2014-09-09

Add scope-facing libraries

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'click/chroot.py'
2--- click/chroot.py 2014-08-06 22:38:57 +0000
3+++ click/chroot.py 2014-09-09 18:07:23 +0000
4@@ -77,6 +77,11 @@
5 ],
6 "ubuntu-sdk-14.04": [
7 "cmake",
8+ "google-mock:TARGET",
9+ "libboost1.55-dev:TARGET",
10+ "libjsoncpp-dev:TARGET",
11+ "libprocess-cpp-dev:TARGET",
12+ "libproperties-cpp-dev:TARGET",
13 "libqt5svg5-dev:TARGET",
14 "libqt5webkit5-dev:TARGET",
15 "libqt5xmlpatterns5-dev:TARGET",
16@@ -99,7 +104,13 @@
17 ],
18 "ubuntu-sdk-14.10": [
19 "cmake",
20+ "google-mock:TARGET",
21+ "libboost1.55-dev:TARGET",
22 "libcontent-hub-dev:TARGET",
23+ "libjsoncpp-dev:TARGET",
24+ "libnet-cpp-dev:TARGET",
25+ "libprocess-cpp-dev:TARGET",
26+ "libproperties-cpp-dev:TARGET",
27 "libqt5keychain0:TARGET",
28 "libqt5sensors5-dev:TARGET",
29 "libqt5svg5-dev:TARGET",
30
31=== modified file 'click/commands/build.py'
32--- click/commands/build.py 2013-12-06 11:04:47 +0000
33+++ click/commands/build.py 2014-09-09 18:07:23 +0000
34@@ -20,7 +20,9 @@
35 from optparse import OptionParser
36 import os
37 import sys
38+import subprocess
39
40+from gi.repository import Click
41 from click.build import ClickBuildError, ClickBuilder
42
43
44@@ -29,6 +31,9 @@
45 parser.add_option(
46 "-m", "--manifest", metavar="PATH", default="manifest.json",
47 help="read package manifest from PATH (default: manifest.json)")
48+ parser.add_option(
49+ "--no-validate", action="store_false", default=True, dest="validate",
50+ help="Don't run click-reviewers-tools check on resulting .click")
51 options, args = parser.parse_args(argv)
52 if len(args) < 1:
53 parser.error("need directory")
54@@ -48,5 +53,20 @@
55 except ClickBuildError as e:
56 print(e, file=sys.stderr)
57 return 1
58+ if options.validate and Click.find_on_path('click-review'):
59+ print("Now executing: click-review %s" % path)
60+ try:
61+ subprocess.check_call(['click-review', path])
62+ except subprocess.CalledProcessError:
63+ # qtcreator-plugin-ubuntu relies on return code 0
64+ # to establish if a .click package has been built
65+ # at all.
66+ #
67+ # If we want to distinguish between
68+ # - click build failed
69+ # - click build succeeded, but validation failed
70+ # both tools will have to learn this at the same
71+ # time.
72+ pass
73 print("Successfully built package in '%s'." % path)
74 return 0
75
76=== modified file 'click/install.py'
77--- click/install.py 2014-08-20 17:45:26 +0000
78+++ click/install.py 2014-09-09 18:07:23 +0000
79@@ -177,6 +177,15 @@
80 logging.warning(
81 "debsig-verify not available; cannot check signatures")
82
83+ # fail early if the file cannot be opened
84+ try:
85+ with closing(DebFile(filename=path)) as package:
86+ pass
87+ except Exception as e:
88+ raise ClickInstallerError("Failed to read %s: %s" % (
89+ path, str(e)))
90+
91+ # then perform the audit
92 with closing(DebFile(filename=path)) as package:
93 control_fields = package.control.debcontrol()
94
95
96=== renamed directory 'tests/integration' => 'click/tests/integration'
97=== modified file 'click/tests/integration/helpers.py'
98--- tests/integration/helpers.py 2014-08-03 13:10:48 +0000
99+++ click/tests/integration/helpers.py 2014-09-09 18:07:23 +0000
100@@ -27,13 +27,17 @@
101 import unittest
102
103
104-def is_root():
105- return os.getuid() == 0
106-
107-
108-def has_network():
109- return subprocess.call(
110- ["ping", "-c1", "archive.ubuntu.com"]) == 0
111+def require_root():
112+ if os.getuid() != 0:
113+ raise unittest.SkipTest("This test needs to run as root")
114+
115+
116+def require_network():
117+ try:
118+ if subprocess.call(["ping", "-c1", "archive.ubuntu.com"]) != 0:
119+ raise unittest.SkipTest("Need network")
120+ except Exception:
121+ pass
122
123
124 @contextlib.contextmanager
125@@ -46,10 +50,21 @@
126 os.chdir(curdir)
127
128
129+def cmdline_for_user(username):
130+ """Helper to get the click commandline for the given username"""
131+ if username == "@all":
132+ user = "--all-users"
133+ else:
134+ user = "--user=%s" % username
135+ return user
136+
137+
138 class ClickTestCase(unittest.TestCase):
139
140 @classmethod
141 def setUpClass(cls):
142+ if "TEST_INTEGRATION" not in os.environ:
143+ raise unittest.SkipTest("Skipping integration tests")
144 cls.click_binary = os.environ.get("CLICK_BINARY", "/usr/bin/click")
145
146 def setUp(self):
147@@ -63,6 +78,20 @@
148 self.doCleanups()
149 shutil.rmtree(self.temp_dir)
150
151+ def click_install(self, path_to_click, click_name, username,
152+ allow_unauthenticated=True):
153+ cmd = [self.click_binary, "install", cmdline_for_user(username)]
154+ if allow_unauthenticated:
155+ cmd.append("--allow-unauthenticated")
156+ cmd.append(path_to_click)
157+ subprocess.check_call(cmd)
158+ self.addCleanup(self.click_unregister, click_name, username)
159+
160+ def click_unregister(self, click_name, username):
161+ subprocess.check_call(
162+ [self.click_binary, "unregister", cmdline_for_user(username),
163+ click_name])
164+
165 def _create_manifest(self, target, name, version, framework, hooks={}):
166 with open(target, "w") as f:
167 json.dump({
168@@ -77,7 +106,7 @@
169 def _make_click(self, name=None, version=1.0,
170 framework="ubuntu-sdk-13.10", hooks={}):
171 if name is None:
172- name = "com.ubuntu.%s" % "".join(
173+ name = "com.example.%s" % "".join(
174 random.choice(string.ascii_lowercase) for i in range(10))
175 tmpdir = tempfile.mkdtemp()
176 self.addCleanup(lambda: shutil.rmtree(tmpdir))
177
178=== modified file 'click/tests/integration/test_build_core_apps.py'
179--- tests/integration/test_build_core_apps.py 2014-08-03 13:10:48 +0000
180+++ click/tests/integration/test_build_core_apps.py 2014-09-09 18:07:23 +0000
181@@ -20,12 +20,13 @@
182 import os
183 import shutil
184 import subprocess
185-import unittest
186+
187+from six import with_metaclass
188
189 from .helpers import (
190 chdir,
191- has_network,
192- is_root,
193+ require_network,
194+ require_root,
195 ClickTestCase,
196 )
197
198@@ -63,9 +64,13 @@
199 return type.__new__(cls, name, bases, dct)
200
201
202-@unittest.skipIf(not is_root(), "This tests needs to run as root")
203-@unittest.skipIf(not has_network(), "Need network")
204-class TestBuildCoreApps(ClickTestCase, metaclass=AddBranchTestFunctions):
205+class TestBuildCoreApps(with_metaclass(AddBranchTestFunctions, ClickTestCase)):
206+
207+ @classmethod
208+ def setUpClass(cls):
209+ super(TestBuildCoreApps, cls).setUpClass()
210+ require_root()
211+ require_network()
212
213 def _run_in_chroot(self, cmd):
214 """Run the given cmd in a click chroot"""
215
216=== modified file 'click/tests/integration/test_chroot.py'
217--- tests/integration/test_chroot.py 2014-08-03 13:10:48 +0000
218+++ click/tests/integration/test_chroot.py 2014-09-09 18:07:23 +0000
219@@ -16,22 +16,21 @@
220 """Integration tests for the click chroot feature."""
221
222 import subprocess
223-import unittest
224
225 from .helpers import (
226- has_network,
227- is_root,
228+ require_network,
229+ require_root,
230 ClickTestCase,
231 )
232
233
234-@unittest.skipIf(not is_root(), "This tests needs to run as root")
235-@unittest.skipIf(not has_network(), "Need network")
236 class TestChroot(ClickTestCase):
237
238 @classmethod
239 def setUpClass(cls):
240 super(TestChroot, cls).setUpClass()
241+ require_root()
242+ require_network()
243 cls.arch = subprocess.check_output(
244 ["dpkg", "--print-architecture"], universal_newlines=True).strip()
245 subprocess.check_call([
246@@ -67,3 +66,13 @@
247 self.click_binary, "chroot", "-a", self.arch,
248 "maint", "id"], universal_newlines=True)
249 self.assertEqual(output, "uid=0(root) gid=0(root) groups=0(root)\n")
250+
251+ def test_exists_ok(self):
252+ subprocess.check_call([
253+ self.click_binary, "chroot", "-a", self.arch, "exists"])
254+
255+ def test_exists_no(self):
256+ with self.assertRaises(subprocess.CalledProcessError):
257+ subprocess.check_call([
258+ self.click_binary,
259+ "chroot", "-a", "arch-that-does-not-exist"])
260
261=== modified file 'click/tests/integration/test_contents.py'
262--- tests/integration/test_contents.py 2014-06-26 12:00:09 +0000
263+++ click/tests/integration/test_contents.py 2014-09-09 18:07:23 +0000
264@@ -23,7 +23,7 @@
265
266 class TestContents(ClickTestCase):
267 def test_contents(self):
268- name = "com.ubuntu.contents"
269+ name = "com.example.contents"
270 path_to_click = self._make_click(name)
271 output = subprocess.check_output([
272 self.click_binary, "contents", path_to_click],
273
274=== modified file 'click/tests/integration/test_frameworks.py'
275--- tests/integration/test_frameworks.py 2014-06-26 12:00:09 +0000
276+++ click/tests/integration/test_frameworks.py 2014-09-09 18:07:23 +0000
277@@ -17,18 +17,17 @@
278
279 import os
280 import subprocess
281-import unittest
282-
283-from .helpers import (
284- ClickTestCase,
285-)
286-
287-
288-@unittest.skipIf(
289- (not os.path.exists("/usr/share/click/frameworks") or
290- not os.listdir("/usr/share/click/frameworks")),
291- "Please install ubuntu-sdk-libs")
292+
293+from .helpers import ClickTestCase
294+
295+
296 class TestFrameworks(ClickTestCase):
297+ def setUp(self):
298+ super(TestFrameworks, self).setUp()
299+ if (not os.path.exists("/usr/share/click/frameworks") or
300+ not os.listdir("/usr/share/click/frameworks")):
301+ self.skipTest("Please install ubuntu-sdk-libs")
302+
303 def test_framework_list(self):
304 output = subprocess.check_output([
305 self.click_binary, "framework", "list"], universal_newlines=True)
306
307=== modified file 'click/tests/integration/test_hook.py'
308--- tests/integration/test_hook.py 2014-08-22 17:01:08 +0000
309+++ click/tests/integration/test_hook.py 2014-09-09 18:07:23 +0000
310@@ -18,16 +18,20 @@
311 import os
312 import subprocess
313 from textwrap import dedent
314-import unittest
315
316 from .helpers import (
317- is_root,
318 ClickTestCase,
319+ require_root,
320 )
321
322
323-@unittest.skipIf(not is_root(), "This tests needs to run as root")
324 class TestHook(ClickTestCase):
325+
326+ @classmethod
327+ def setUpClass(cls):
328+ super(TestHook, cls).setUpClass()
329+ require_root()
330+
331 def _make_hook(self, name):
332 hook_fname = "/usr/share/click/hooks/%s.hook" % name
333 canary_fname = os.path.join(self.temp_dir, "canary.sh")
334@@ -63,14 +67,7 @@
335 click_pkg = self._make_click(
336 click_pkg_name, framework="", hooks=hooks)
337 user = os.environ.get("USER", "root")
338- subprocess.check_call(
339- [self.click_binary, "install", "--allow-unauthenticated",
340- "--user=%s" % user, click_pkg],
341- universal_newlines=True)
342- self.addCleanup(
343- subprocess.check_call,
344- [self.click_binary, "unregister", "--user=%s" % user,
345- click_pkg_name])
346+ self.click_install(click_pkg, click_pkg_name, user)
347 # ensure we have the hook
348 generated_hook_file = os.path.expanduser(
349 "~/com.example.hook-1_app1_1.0.test-hook")
350
351=== modified file 'click/tests/integration/test_info.py'
352--- tests/integration/test_info.py 2014-08-22 17:01:08 +0000
353+++ click/tests/integration/test_info.py 2014-09-09 18:07:23 +0000
354@@ -16,19 +16,30 @@
355 """Integration tests for the click CLI info command."""
356
357 import json
358+import os
359 import subprocess
360
361 from .helpers import ClickTestCase
362
363
364 class TestInfo(ClickTestCase):
365- def test_info(self):
366- name = "com.ubuntu.foo"
367+ def test_info_from_path(self):
368+ name = "com.example.foo"
369 path_to_click = self._make_click(name)
370 output = subprocess.check_output([
371 self.click_binary, "info", path_to_click], universal_newlines=True)
372 self.assertEqual(name, json.loads(output)["name"])
373
374+
375+ def test_info_installed_click(self):
376+ name = "com.example.foo"
377+ user = os.environ.get("USER", "root")
378+ path_to_click = self._make_click(name, framework="")
379+ self.click_install(path_to_click, name, user)
380+ output = subprocess.check_output([
381+ self.click_binary, "info", name], universal_newlines=True)
382+ self.assertEqual(json.loads(output)["name"], name)
383+
384 def test_info_file_in_package(self):
385 name = "org.example.info"
386 version = "1.0"
387
388=== modified file 'click/tests/integration/test_install.py'
389--- tests/integration/test_install.py 2014-08-22 17:01:08 +0000
390+++ click/tests/integration/test_install.py 2014-09-09 18:07:23 +0000
391@@ -15,11 +15,12 @@
392
393 """Integration tests for the click install feature."""
394
395-import os
396 import subprocess
397-import unittest
398
399-from .helpers import ClickTestCase
400+from .helpers import (
401+ require_root,
402+ ClickTestCase,
403+)
404
405
406 def add_user(name):
407@@ -31,13 +32,12 @@
408 subprocess.check_call(["userdel", "-r", name])
409
410
411-@unittest.skipIf(
412- os.getuid() != 0, "This tests needs to run as root")
413 class TestClickInstall(ClickTestCase):
414
415 @classmethod
416 def setUpClass(cls):
417 super(TestClickInstall, cls).setUpClass()
418+ require_root()
419 cls.USER_1 = add_user("click-test-user-1")
420 cls.USER_2 = add_user("click-test-user-2")
421
422@@ -47,27 +47,16 @@
423 del_user(cls.USER_1)
424 del_user(cls.USER_2)
425
426- def click_unregister(self, username, click_name):
427- if username == "@all":
428- user = "--all-users"
429- else:
430- user = "--user=%s" % username
431- subprocess.check_call(
432- [self.click_binary, "unregister", user, click_name])
433-
434 def test_install_for_single_user(self):
435- click_pkg = self._make_click(name="foo-1", framework="")
436+ name = "foo-1"
437+ click_pkg = self._make_click(name=name, framework="")
438 # install it
439- subprocess.check_call([
440- self.click_binary, "install", "--user=%s" % self.USER_1,
441- "--allow-unauthenticated",
442- click_pkg], universal_newlines=True)
443- self.addCleanup(self.click_unregister, self.USER_1, "foo-1")
444+ self.click_install(click_pkg, name, self.USER_1)
445 # ensure that user-1 has it
446 output = subprocess.check_output([
447 "sudo", "-u", self.USER_1,
448 self.click_binary, "list"], universal_newlines=True)
449- self.assertEqual(output, "foo-1\t1.0\n")
450+ self.assertEqual(output, "%s\t1.0\n" % name)
451 # but not user-2
452 output = subprocess.check_output([
453 "sudo", "-u", self.USER_2,
454@@ -77,40 +66,53 @@
455 output = subprocess.check_output(
456 [self.click_binary, "list", "--user=%s" % self.USER_1],
457 universal_newlines=True)
458- self.assertEqual(output, "foo-1\t1.0\n")
459+ self.assertEqual(output, "%s\t1.0\n" % name)
460+
461+ def test_install_for_single_user_and_register(self):
462+ name = "foo-1"
463+ click_pkg = self._make_click(name=name, framework="")
464+ self.click_install(click_pkg, name, self.USER_1)
465+ # not available for user2
466+ output = subprocess.check_output([
467+ "sudo", "-u", self.USER_2,
468+ self.click_binary, "list"], universal_newlines=True)
469+ self.assertEqual(output, "")
470+ # register it
471+ subprocess.check_call(
472+ [self.click_binary, "register", "--user=%s" % self.USER_2,
473+ name, "1.0", ])
474+ self.addCleanup(self.click_unregister, name, self.USER_2)
475+ # and ensure its available for user2
476+ output = subprocess.check_output([
477+ "sudo", "-u", self.USER_2,
478+ self.click_binary, "list"], universal_newlines=True)
479+ self.assertEqual(output, "%s\t1.0\n" % name)
480
481 def test_install_for_all_users(self):
482- click_pkg = self._make_click(name="foo-2", framework="")
483- # install it
484- subprocess.check_call(
485- [self.click_binary, "install", "--all-users",
486- "--allow-unauthenticated", click_pkg],
487- universal_newlines=True)
488- self.addCleanup(self.click_unregister, "@all", "foo-2")
489+ name = "foo-2"
490+ click_pkg = self._make_click(name=name, framework="")
491+ self.click_install(click_pkg, name, "@all")
492 # ensure all users see it
493 for user in (self.USER_1, self.USER_2):
494 output = subprocess.check_output(
495 ["sudo", "-u", user, self.click_binary, "list"],
496 universal_newlines=True)
497- self.assertEqual(output, "foo-2\t1.0\n")
498+ self.assertEqual(output, "%s\t1.0\n" % name)
499
500 def test_pkgdir_after_install(self):
501- click_pkg = self._make_click(name="foo-2", version="1.2", framework="")
502- subprocess.check_call(
503- [self.click_binary, "install", "--all-users",
504- "--allow-unauthenticated", click_pkg],
505- universal_newlines=True)
506- self.addCleanup(self.click_unregister, "@all", "foo-2")
507+ name = "foo-3"
508+ click_pkg = self._make_click(name=name, version="1.2", framework="")
509+ self.click_install(click_pkg, name, "@all")
510 # from the path
511 output = subprocess.check_output(
512 [self.click_binary, "pkgdir",
513- "/opt/click.ubuntu.com/foo-2/1.2/README"],
514+ "/opt/click.ubuntu.com/%s/1.2/README" % name],
515 universal_newlines=True).strip()
516- self.assertEqual(output, "/opt/click.ubuntu.com/foo-2/1.2")
517+ self.assertEqual(output, "/opt/click.ubuntu.com/%s/1.2" % name)
518 # now test from the click package name
519 output = subprocess.check_output(
520- [self.click_binary, "pkgdir", "foo-2"],
521+ [self.click_binary, "pkgdir", name],
522 universal_newlines=True).strip()
523 # note that this is different from above
524 self.assertEqual(
525- output, "/opt/click.ubuntu.com/.click/users/@all/foo-2")
526+ output, "/opt/click.ubuntu.com/.click/users/@all/%s" % name)
527
528=== added file 'click/tests/integration/test_list.py'
529--- click/tests/integration/test_list.py 1970-01-01 00:00:00 +0000
530+++ click/tests/integration/test_list.py 2014-09-09 18:07:23 +0000
531@@ -0,0 +1,33 @@
532+# Copyright (C) 2014 Canonical Ltd.
533+# Author: Michael Vogt <michael.vogt@ubuntu.com>
534+
535+# This program is free software: you can redistribute it and/or modify
536+# it under the terms of the GNU General Public License as published by
537+# the Free Software Foundation; version 3 of the License.
538+#
539+# This program is distributed in the hope that it will be useful,
540+# but WITHOUT ANY WARRANTY; without even the implied warranty of
541+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
542+# GNU General Public License for more details.
543+#
544+# You should have received a copy of the GNU General Public License
545+# along with this program. If not, see <http://www.gnu.org/licenses/>.
546+
547+"""Integration tests for the click CLI list command."""
548+
549+import os
550+import subprocess
551+
552+from .helpers import ClickTestCase
553+
554+
555+class TestList(ClickTestCase):
556+ def test_list_simple(self):
557+ name = "com.ubuntu.verify-ok"
558+ path_to_click = self._make_click(name, framework="")
559+ user = os.environ.get("USER", "root")
560+ self.click_install(path_to_click, name, user)
561+ output = subprocess.check_output(
562+ [self.click_binary, "list", "--user=%s" % user],
563+ universal_newlines=True)
564+ self.assertIn(name, output)
565
566=== modified file 'click/tests/integration/test_signatures.py'
567--- tests/integration/test_signatures.py 2014-08-22 17:01:08 +0000
568+++ click/tests/integration/test_signatures.py 2014-09-09 18:07:23 +0000
569@@ -20,20 +20,21 @@
570 import shutil
571 import subprocess
572 import tarfile
573-import unittest
574 from textwrap import dedent
575
576 from .helpers import (
577- is_root,
578+ require_root,
579 ClickTestCase,
580 )
581
582+
583 def makedirs(path):
584 try:
585 os.makedirs(path)
586 except OSError:
587 pass
588
589+
590 def get_keyid_from_gpghome(gpg_home):
591 """Return the public keyid of a given gpg home dir"""
592 output = subprocess.check_output(
593@@ -56,7 +57,7 @@
594 def sign(self, filepath, signature_type="origin"):
595 """Sign the click at filepath"""
596 env = copy.copy(os.environ)
597- env["GNUPGHOME"] = os.path.abspath(self.gpghome)
598+ env["GNUPGHOME"] = os.path.abspath(self.gpghome)
599 subprocess.check_call(
600 ["debsigs",
601 "--sign=%s" % signature_type,
602@@ -74,7 +75,7 @@
603 <Selection>
604 <Required Type="origin" File="{filename}" id="{keyid}"/>
605 </Selection>
606-
607+
608 <Verification>
609 <Required Type="origin" File="{filename}" id="{keyid}"/>
610 </Verification>
611@@ -86,7 +87,8 @@
612 self.pubkey_path = (
613 "/usr/share/debsig/keyrings/%s/origin.pub" % self.keyid)
614 makedirs(os.path.dirname(self.pubkey_path))
615- shutil.copy(os.path.join(self.gpghome, "pubring.gpg"), self.pubkey_path)
616+ shutil.copy(
617+ os.path.join(self.gpghome, "pubring.gpg"), self.pubkey_path)
618
619 def uninstall_signature_policy(self):
620 # FIXME: update debsig-verify so that it can work from a different
621@@ -96,8 +98,13 @@
622 os.remove(self.pubkey_path)
623
624
625-@unittest.skipIf(not is_root(), "This tests needs to run as root")
626 class ClickSignaturesTestCase(ClickTestCase):
627+
628+ @classmethod
629+ def setUpClass(cls):
630+ super(ClickSignaturesTestCase, cls).setUpClass()
631+ require_root()
632+
633 def assertClickNoSignatureError(self, cmd_args):
634 with self.assertRaises(subprocess.CalledProcessError) as cm:
635 output = subprocess.check_output(
636@@ -120,8 +127,13 @@
637 self.assertIn(expected_error_message, output)
638
639
640-@unittest.skipIf(not is_root(), "This tests needs to run as root")
641 class TestSignatureVerificationNoSignature(ClickSignaturesTestCase):
642+
643+ @classmethod
644+ def setUpClass(cls):
645+ super(TestSignatureVerificationNoSignature, cls).setUpClass()
646+ require_root()
647+
648 def test_debsig_verify_no_sig(self):
649 name = "org.example.debsig-no-sig"
650 path_to_click = self._make_click(name, framework="")
651@@ -145,8 +157,13 @@
652 "--user=%s" % user, name])
653
654
655-@unittest.skipIf(not is_root(), "This tests needs to run as root")
656 class TestSignatureVerification(ClickSignaturesTestCase):
657+
658+ @classmethod
659+ def setUpClass(cls):
660+ super(TestSignatureVerification, cls).setUpClass()
661+ require_root()
662+
663 def setUp(self):
664 super(TestSignatureVerification, self).setUp()
665 self.user = os.environ.get("USER", "root")
666@@ -176,7 +193,7 @@
667 [self.click_binary, "list", "--user=%s" % self.user],
668 universal_newlines=True)
669 self.assertIn(name, output)
670-
671+
672 def test_debsig_install_signature_not_in_keyring(self):
673 name = "org.example.debsig-no-keyring-sig"
674 path_to_click = self._make_click(name, framework="")
675@@ -245,7 +262,7 @@
676 # NOTE: that right now this will not be caught by debsig-verify
677 # but later in audit() by debian.debfile.DebFile()
678 subprocess.check_call(["ar",
679- "-r",
680+ "-r",
681 "-b", "data.tar.gz",
682 path_to_click,
683 new_data])
684@@ -274,12 +291,12 @@
685 new_data = self.make_nasty_data_tar("bz2")
686 # replace data.tar.gz with data.tar.bz2 and ensure this is caught
687 subprocess.check_call(["ar",
688- "-d",
689+ "-d",
690 path_to_click,
691 "data.tar.gz",
692 ])
693 subprocess.check_call(["ar",
694- "-r",
695+ "-r",
696 path_to_click,
697 new_data])
698 output = subprocess.check_output(
699@@ -290,7 +307,7 @@
700 "control.tar.gz",
701 "_gpgorigin",
702 "data.tar.bz2",
703- ])
704+ ])
705 with self.assertRaises(subprocess.CalledProcessError) as cm:
706 output = subprocess.check_output(
707 [self.click_binary, "install", path_to_click],
708@@ -305,7 +322,7 @@
709 # this test is probably not really needed, it tries to trick
710 # the system by prepending a valid signature that is not
711 # in the keyring. But given that debsig-verify only reads
712- # the first packet of any given _gpg$foo signature its
713+ # the first packet of any given _gpg$foo signature it's
714 # equivalent to test_debsig_install_signature_not_in_keyring test
715 name = "org.example.debsig-replaced-data-prepend-sig-click"
716 path_to_click = self._make_click(name, framework="")
717@@ -313,7 +330,7 @@
718 new_data = self.make_nasty_data_tar("gz")
719 # replace data.tar.gz
720 subprocess.check_call(["ar",
721- "-r",
722+ "-r",
723 path_to_click,
724 new_data,
725 ])
726@@ -345,4 +362,3 @@
727 [self.click_binary, "list", "--user=%s" % self.user],
728 universal_newlines=True)
729 self.assertNotIn(name, output)
730-
731
732=== modified file 'click/tests/integration/test_verify.py'
733--- tests/integration/test_verify.py 2014-08-07 21:51:27 +0000
734+++ click/tests/integration/test_verify.py 2014-09-09 18:07:23 +0000
735@@ -15,14 +15,15 @@
736
737 """Integration tests for the click CLI verify command."""
738
739+import os
740 import subprocess
741
742 from .helpers import ClickTestCase
743
744
745 class TestVerify(ClickTestCase):
746- def test_verify_ok(self):
747- name = "com.example.verify-ok"
748+ def test_verify_force_missing_framework_ok(self):
749+ name = "com.example.verify-missing-framework"
750 path_to_click = self._make_click(name)
751 output = subprocess.check_output([
752 self.click_binary, "verify",
753@@ -30,3 +31,42 @@
754 "--allow-unauthenticated",
755 path_to_click], universal_newlines=True)
756 self.assertEqual(output, "")
757+
758+ def test_verify_force_ok(self):
759+ name = "com.example.verify-ok"
760+ path_to_click = self._make_click(name, framework="")
761+ output = subprocess.check_output([
762+ self.click_binary, "verify", "--allow-unauthenticated",
763+ path_to_click], universal_newlines=True)
764+ self.assertEqual(output, "")
765+
766+ def test_verify_missing_framework(self):
767+ name = "com.example.verify-really-missing-framework"
768+ path_to_click = self._make_click(name, framework="missing")
769+ with self.assertRaises(subprocess.CalledProcessError) as cm:
770+ subprocess.check_output(
771+ [self.click_binary, "verify",
772+ "--allow-unauthenticated",
773+ path_to_click],
774+ universal_newlines=True, stderr=subprocess.STDOUT)
775+ expected_error = (
776+ 'click.framework.ClickFrameworkInvalid: Framework '
777+ '"missing" not present on system (use '
778+ '--force-missing-framework option to override)')
779+ self.assertIn(expected_error, cm.exception.output)
780+
781+ def test_verify_no_click_but_invalid(self):
782+ name = "com.example.verify-no-click"
783+ path_to_click = os.path.join(self.temp_dir, name+".click")
784+ with open(path_to_click, "w") as f:
785+ f.write("something-that-is-not-a-click")
786+ with self.assertRaises(subprocess.CalledProcessError) as cm:
787+ subprocess.check_output(
788+ [self.click_binary, "verify", "--allow-unauthenticated",
789+ path_to_click],
790+ universal_newlines=True, stderr=subprocess.STDOUT)
791+ expected_error = (
792+ 'click.install.DebsigVerifyError: Signature verification error: '
793+ 'debsig: %s does not appear to be a deb format package'
794+ ) % path_to_click
795+ self.assertIn(expected_error, cm.exception.output)
796
797=== modified file 'click/tests/test_build.py'
798--- click/tests/test_build.py 2014-05-13 18:56:57 +0000
799+++ click/tests/test_build.py 2014-09-09 18:07:23 +0000
800@@ -63,14 +63,14 @@
801 with mkfile(manifest_path) as manifest:
802 print(dedent("""\
803 {
804- "name": "com.ubuntu.test",
805+ "name": "com.example.test",
806 "version": "1.0",
807 "maintainer": "Foo Bar <foo@example.org>",
808 "title": "test title",
809 "framework": "ubuntu-sdk-13.10"
810 }"""), file=manifest)
811 self.builder.read_manifest(manifest_path)
812- self.assertEqual("com.ubuntu.test", self.builder.name)
813+ self.assertEqual("com.example.test", self.builder.name)
814 self.assertEqual("1.0", self.builder.version)
815 self.assertEqual("Foo Bar <foo@example.org>", self.builder.maintainer)
816 self.assertEqual("test title", self.builder.title)
817@@ -90,7 +90,7 @@
818 with mkfile(manifest_path) as manifest:
819 print(dedent("""\
820 {
821- "name": "com.ubuntu.test",
822+ "name": "com.example.test",
823 "version": "%s",
824 "maintainer": "Foo Bar <foo@example.org>",
825 "title": "test title",
826@@ -106,7 +106,7 @@
827 # The comma after the "name" entry is intentionally missing.
828 print(dedent("""\
829 {
830- "name": "com.ubuntu.test"
831+ "name": "com.example.test"
832 "version": "1.0"
833 }"""), file=manifest)
834 self.assertRaises(
835@@ -136,7 +136,7 @@
836 f.write("test /toplevel\n")
837 with mkfile(os.path.join(scratch, "manifest.json")) as f:
838 json.dump({
839- "name": "com.ubuntu.test",
840+ "name": "com.example.test",
841 "version": "1.0",
842 "maintainer": "Foo Bar <foo@example.org>",
843 "title": "test title",
844@@ -146,11 +146,11 @@
845 # build() overrides this back to 0o644
846 os.fchmod(f.fileno(), 0o600)
847 self.builder.add_file(scratch, "/")
848- path = os.path.join(self.temp_dir, "com.ubuntu.test_1.0_all.click")
849+ path = os.path.join(self.temp_dir, "com.example.test_1.0_all.click")
850 self.assertEqual(path, self.builder.build(self.temp_dir))
851 self.assertTrue(os.path.exists(path))
852 for key, value in (
853- ("Package", "com.ubuntu.test"),
854+ ("Package", "com.example.test"),
855 ("Version", "1.0"),
856 ("Click-Version", "0.4"),
857 ("Architecture", "all"),
858@@ -212,7 +212,7 @@
859 touch(os.path.join(scratch, ".click", "evil-file"))
860 with mkfile(os.path.join(scratch, "manifest.json")) as f:
861 json.dump({
862- "name": "com.ubuntu.test",
863+ "name": "com.example.test",
864 "version": "1.0",
865 "maintainer": "Foo Bar <foo@example.org>",
866 "title": "test title",
867@@ -231,7 +231,7 @@
868 scratch = os.path.join(self.temp_dir, "scratch")
869 with mkfile(os.path.join(scratch, "manifest.json")) as f:
870 json.dump({
871- "name": "com.ubuntu.test",
872+ "name": "com.example.test",
873 "version": "1.0",
874 "maintainer": "Foo Bar <foo@example.org>",
875 "title": "test title",
876@@ -239,7 +239,7 @@
877 "framework": "ubuntu-sdk-13.10",
878 }, f)
879 self.builder.add_file(scratch, "/")
880- path = os.path.join(self.temp_dir, "com.ubuntu.test_1.0_multi.click")
881+ path = os.path.join(self.temp_dir, "com.example.test_1.0_multi.click")
882 self.assertEqual(path, self.builder.build(self.temp_dir))
883 self.assertTrue(os.path.exists(path))
884 self.assertEqual("multi", self.extract_field(path, "Architecture"))
885@@ -260,7 +260,7 @@
886 scratch = os.path.join(self.temp_dir, "scratch")
887 with mkfile(os.path.join(scratch, "manifest.json")) as f:
888 json.dump({
889- "name": "com.ubuntu.test",
890+ "name": "com.example.test",
891 "version": "1.0",
892 "maintainer": "Foo Bar <foo@example.org>",
893 "title": "test title",
894@@ -322,7 +322,7 @@
895 touch(os.path.join(scratch, ".git", "config"))
896 with mkfile(os.path.join(scratch, "manifest.json")) as f:
897 json.dump({
898- "name": "com.ubuntu.test",
899+ "name": "com.example.test",
900 "version": "1.0",
901 "maintainer": "Foo Bar <foo@example.org>",
902 "title": "test title",
903@@ -332,7 +332,7 @@
904 # build() overrides this back to 0o644
905 os.fchmod(f.fileno(), 0o600)
906 self.builder.add_file(scratch, "./")
907- path = os.path.join(self.temp_dir, "com.ubuntu.test_1.0.tar.gz")
908+ path = os.path.join(self.temp_dir, "com.example.test_1.0.tar.gz")
909 self.assertEqual(path, self.builder.build(self.temp_dir))
910 self.assertTrue(os.path.exists(path))
911 with tarfile.open(path, mode="r:gz") as tar:
912
913=== modified file 'debian/changelog'
914--- debian/changelog 2014-08-22 17:19:06 +0000
915+++ debian/changelog 2014-09-09 18:07:23 +0000
916@@ -1,3 +1,46 @@
917+click (0.4.32.1) UNRELEASED; urgency=low
918+
919+ * fix autopkgtest failure found in 0.4.32
920+
921+ -- Michael Vogt <michael.vogt@ubuntu.com> Tue, 09 Sep 2014 09:56:57 +0200
922+
923+click (0.4.32) utopic; urgency=medium
924+
925+ [ Daniel Holbach ]
926+ * Run click-review after a successful build of a click package. Offer
927+ --no-validate as an option.
928+
929+ [ Colin Watson ]
930+ * Move integration tests to a location where they won't end up being
931+ installed into inappropriate places on the system module path
932+ (LP: #1337696).
933+ * Use six.with_metaclass for TestBuildCoreApps, so that it doesn't make
934+ pyflakes angry when running tests under Python 2.
935+
936+ [ Michael Vogt ]
937+ * Add more integration tests for "click {list,register,verify,info}".
938+ * Only install trusted click packages by default. To override you
939+ can run "pkcon --allow-untrusted" (LP: #1360582)
940+
941+ -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Mon, 08 Sep 2014 09:50:43 +0000
942+
943+click (0.4.31.3) utopic; urgency=medium
944+
945+ * Reinstate most of 0.4.31.2; instead, just always pass
946+ --allow-unauthenticated to "click install" from the PackageKit plugin
947+ for now, until we can sort out sideloading (see LP #1360582).
948+
949+ -- Colin Watson <cjwatson@ubuntu.com> Mon, 25 Aug 2014 12:25:21 -0700
950+
951+click (0.4.31.2.is.0.4.30) utopic; urgency=medium
952+
953+ * Temporary everting to previous version as the current one makes installing
954+ click packages locally through pkcon install-local impossible, which is
955+ breaking some other projects relying on this functionality. Needs to be
956+ revisited.
957+
958+ -- Ɓukasz 'sil2100' Zemczak <lukasz.zemczak@canonical.com> Mon, 25 Aug 2014 17:34:07 +0200
959+
960 click (0.4.31.2) utopic; urgency=medium
961
962 [ Michael Vogt ]
963
964=== modified file 'debian/control'
965--- debian/control 2014-06-10 17:18:00 +0000
966+++ debian/control 2014-09-09 18:07:23 +0000
967@@ -3,7 +3,7 @@
968 Priority: optional
969 Maintainer: Colin Watson <cjwatson@ubuntu.com>
970 Standards-Version: 3.9.5
971-Build-Depends: debhelper (>= 9~), dh-autoreconf, intltool, python3:any (>= 3.2), python3-all:any, python3-setuptools, python3-apt, python3-debian, python3-gi, python3:any (>= 3.3) | python3-mock, pep8, python3-pep8, pyflakes, python3-sphinx, pkg-config, valac, gobject-introspection (>= 0.6.7), libgirepository1.0-dev (>= 0.6.7), libglib2.0-dev (>= 2.34), gir1.2-glib-2.0, libjson-glib-dev (>= 0.10), libgee-0.8-dev, libpackagekit-glib2-dev (>= 0.7.2), python3-coverage
972+Build-Depends: debhelper (>= 9~), dh-autoreconf, intltool, python3:any (>= 3.2), python3-all:any, python3-setuptools, python3-apt, python3-debian, python3-gi, python3:any (>= 3.3) | python3-mock, pep8, python3-pep8, pyflakes, python3-sphinx, pkg-config, valac, gobject-introspection (>= 0.6.7), libgirepository1.0-dev (>= 0.6.7), libglib2.0-dev (>= 2.34), gir1.2-glib-2.0, libjson-glib-dev (>= 0.10), libgee-0.8-dev, libpackagekit-glib2-dev (>= 0.7.2), python3-coverage, python3-six
973 Vcs-Bzr: https://code.launchpad.net/~ubuntu-managed-branches/click/click
974 Vcs-Browser: http://bazaar.launchpad.net/~ubuntu-managed-branches/click/click/files
975 X-Auto-Uploader: no-rewrite-version
976@@ -16,6 +16,7 @@
977 Pre-Depends: ${misc:Pre-Depends}
978 Depends: ${shlibs:Depends}, ${misc:Depends}, ${python3:Depends}, python3-click (= ${binary:Version}), adduser
979 Recommends: click-apparmor, ubuntu-app-launch-tools | upstart-app-launch-tools
980+Suggests: click-reviewers-tools (>= 0.9)
981 Conflicts: click-package
982 Replaces: click-package
983 Provides: click-package
984
985=== modified file 'debian/tests/control'
986--- debian/tests/control 2014-07-14 09:10:39 +0000
987+++ debian/tests/control 2014-09-09 18:07:23 +0000
988@@ -1,3 +1,3 @@
989 Tests: run-tests.sh
990-Depends: @, iputils-ping, click-dev, schroot, debootstrap, sudo, bzr, debsigs, debsig-verify
991+Depends: @, @builddeps@, iputils-ping, click-dev, schroot, debootstrap, sudo, bzr, debsigs, debsig-verify, python3-six
992 Restrictions: needs-root allow-stderr
993
994=== modified file 'debian/tests/run-tests.sh'
995--- debian/tests/run-tests.sh 2014-06-11 12:40:44 +0000
996+++ debian/tests/run-tests.sh 2014-09-09 18:07:23 +0000
997@@ -2,4 +2,11 @@
998
999 set -e
1000
1001-python3 -m unittest discover tests.integration
1002+# some files like config.py are generated from config.py.in
1003+./autogen.sh
1004+./configure --prefix=/usr \
1005+ --sysconfdir=/etc \
1006+ --with-systemdsystemunitdir=/lib/systemd/system \
1007+ --with-systemduserunitdir=/usr/lib/systemd/user
1008+
1009+TEST_INTEGRATION=1 python3 -m unittest discover -vv click.tests.integration
1010
1011=== modified file 'doc/manpage.rst'
1012--- doc/manpage.rst 2014-05-20 09:04:03 +0000
1013+++ doc/manpage.rst 2014-09-09 18:07:23 +0000
1014@@ -73,6 +73,8 @@
1015
1016 -m PATH, --manifest=PATH Read package manifest from PATH
1017 (default: ``manifest.json``).
1018+--no-validate Don't run checks from click-reviewers-tools on
1019+ the resulting .click file.
1020
1021 click buildsource DIRECTORY
1022 ---------------------------
1023
1024=== modified file 'pk-plugin/pk-plugin-click.c'
1025--- pk-plugin/pk-plugin-click.c 2014-08-19 07:06:25 +0000
1026+++ pk-plugin/pk-plugin-click.c 2014-09-09 18:07:23 +0000
1027@@ -515,10 +515,14 @@
1028 JsonObject *manifest;
1029 gchar *pkid = NULL;
1030
1031- argv = g_malloc0_n (6, sizeof (*argv));
1032+ argv = g_malloc0_n (7, sizeof (*argv));
1033 i = 0;
1034 argv[i++] = g_strdup ("click");
1035 argv[i++] = g_strdup ("install");
1036+ if (!pk_bitfield_contain (pk_transaction_get_transaction_flags (transaction),
1037+ PK_TRANSACTION_FLAG_ENUM_ONLY_TRUSTED)) {
1038+ argv[i++] = g_strdup ("--allow-unauthenticated");
1039+ }
1040 username = click_get_username_for_uid
1041 (pk_transaction_get_uid (transaction));
1042 if (username)
1043
1044=== removed directory 'tests'
1045=== removed file 'tests/__init__.py'

Subscribers

People subscribed via source and target branches

to all changes: