Merge lp:~jdstrand/click-reviewers-tools/refactor into lp:click-reviewers-tools

Proposed by Jamie Strandboge
Status: Merged
Merged at revision: 573
Proposed branch: lp:~jdstrand/click-reviewers-tools/refactor
Merge into: lp:click-reviewers-tools
Diff against target: 6120 lines (+1198/-1500)
53 files modified
README (+1/-1)
bin/click-check-bin-path (+2/-2)
bin/click-check-content-hub (+2/-2)
bin/click-check-desktop (+2/-2)
bin/click-check-framework (+2/-2)
bin/click-check-functional (+2/-2)
bin/click-check-lint (+2/-2)
bin/click-check-online-accounts (+2/-2)
bin/click-check-push-helper (+2/-2)
bin/click-check-scope (+2/-2)
bin/click-check-security (+2/-2)
bin/click-check-skeleton (+2/-2)
bin/click-check-systemd (+2/-2)
bin/click-check-url-dispatcher (+2/-2)
bin/click-review (+4/-4)
bin/click-run-checks (+6/-6)
bin/click-show-files (+15/-18)
bin/detect-package (+15/-0)
bin/download-click (+12/-12)
bin/repack-click (+12/-12)
bin/unpack-package (+3/-3)
check-names.list (+0/-3)
clickreviews/common.py (+514/-0)
clickreviews/cr_bin_path.py (+14/-8)
clickreviews/cr_common.py (+35/-468)
clickreviews/cr_content_hub.py (+8/-0)
clickreviews/cr_desktop.py (+61/-0)
clickreviews/cr_framework.py (+13/-7)
clickreviews/cr_functional.py (+11/-0)
clickreviews/cr_lint.py (+66/-100)
clickreviews/cr_online_accounts.py (+20/-0)
clickreviews/cr_push_helper.py (+12/-0)
clickreviews/cr_scope.py (+6/-0)
clickreviews/cr_security.py (+94/-92)
clickreviews/cr_skeleton.py (+12/-0)
clickreviews/cr_systemd.py (+21/-18)
clickreviews/cr_tests.py (+24/-63)
clickreviews/cr_url_dispatcher.py (+12/-0)
clickreviews/modules.py (+5/-5)
clickreviews/tests/test_cr_bin_path.py (+4/-1)
clickreviews/tests/test_cr_content_hub.py (+0/-13)
clickreviews/tests/test_cr_desktop.py (+0/-14)
clickreviews/tests/test_cr_framework.py (+4/-1)
clickreviews/tests/test_cr_lint.py (+74/-383)
clickreviews/tests/test_cr_online_accounts.py (+0/-12)
clickreviews/tests/test_cr_push_helper.py (+0/-10)
clickreviews/tests/test_cr_scope.py (+0/-12)
clickreviews/tests/test_cr_security.py (+74/-187)
clickreviews/tests/test_cr_systemd.py (+3/-0)
clickreviews/tests/test_cr_url_dispatcher.py (+0/-12)
clickreviews/tests/test_modules.py (+7/-7)
clickreviews/tests/utils.py (+4/-2)
debian/changelog (+6/-0)
To merge this branch: bzr merge lp:~jdstrand/click-reviewers-tools/refactor
Reviewer Review Type Date Requested Status
James Tait (community) Approve
Daniel Holbach (community) Approve
Review via email: mp+285542@code.launchpad.net

Description of the change

This is just the refactor MP. The snap.yaml MP will be based on this.

- rename bin/unpack-click as bin/unpack-package
- add common.py
  + refactor non-click and non-snap1 bits from cr_common.py
  + add proper package detection API and variables for click, snap1 and snap2
- clickreviews/cr_* (and tests)
  + adjust for common.py
  + use new detection variables and only run on click and snap1 snaps
  + cleanup cr_common.py to remove snap2 support (will be added in a later
    commit)
- clickreviews/cr_tests.py:
  + remove snap2 support (will be added in a later commit)
  + add detect_package support
  + various cleanups for refactoring
- adjust bin/*, clickreviews/* and clickreviews/tests/* to use common instead
  of cr_common
- bin/click-run-checks, clickreviews/modules.py: don't assume 'click' in
  variable names, etc
- pull existing snap v2 tests out of cr_*
- add bin/detect-package

# click
PYTHONPATH=./ ./bin/click-review -v ../rottentomatoes/rottentomatoes.jdstrand_0.11.2_all.click | grep 'OK' |wc -l
120

(previous showed 121-- this is because 'framework:obsolete_declaration' is not needed on click but was previously being tested)

# snap v1
$ PYTHONPATH=./ ./bin/click-review -v ../ufw-trunk/ufw_0.35_all.snap | grep OK|wc -l
264

(previous shows 264)

# snap v2 (no checks run)
$ PYTHONPATH=./ ./bin/click-review -v ../snappy-debug/snappy-debug_0.12_all.snap | grep OK|wc -l
0

I also checked click-review -v output against current trunk and this branch and all the tests are still run (excepting 'framework:obsolete_declaration' on click, see above).

To post a comment you must log in.
Revision history for this message
Daniel Holbach (dholbach) wrote :

Great work!

review: Approve
580. By Jamie Strandboge

clickreviews/cr_security.py: clarify logic of package detection in two tests

581. By Jamie Strandboge

clickreviews/cr_lint.py: don't run check_contents_for_hardcoded_paths() on
snap v2

Revision history for this message
James Tait (jamestait) wrote :

Fantastic job! So much clearer!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README'
2--- README 2015-06-10 21:56:24 +0000
3+++ README 2016-02-10 19:30:47 +0000
4@@ -1,4 +1,4 @@
5-Runnable tests:
6+Runnable click and snap v1 tests:
7 - bin/click-check-bin-path: snappy bin-path tests
8 - bin/click-check-content-hub: content-hub hook tests
9 - bin/click-check-desktop: desktop hook tests
10
11=== modified file 'bin/click-check-bin-path'
12--- bin/click-check-bin-path 2015-03-18 19:57:47 +0000
13+++ bin/click-check-bin-path 2016-02-10 19:30:47 +0000
14@@ -17,8 +17,8 @@
15
16 from __future__ import print_function
17
18-import clickreviews.cr_common as cr_common
19+import clickreviews.common as common
20 import clickreviews.cr_bin_path as cr_bin_path
21
22 if __name__ == "__main__":
23- cr_common.run_click_check(cr_bin_path.ClickReviewBinPath)
24+ common.run_check(cr_bin_path.ClickReviewBinPath)
25
26=== modified file 'bin/click-check-content-hub'
27--- bin/click-check-content-hub 2015-03-18 19:57:47 +0000
28+++ bin/click-check-content-hub 2016-02-10 19:30:47 +0000
29@@ -17,8 +17,8 @@
30
31 from __future__ import print_function
32
33-import clickreviews.cr_common as cr_common
34+import clickreviews.common as common
35 import clickreviews.cr_content_hub as cr_content_hub
36
37 if __name__ == "__main__":
38- cr_common.run_click_check(cr_content_hub.ClickReviewContentHub)
39+ common.run_check(cr_content_hub.ClickReviewContentHub)
40
41=== modified file 'bin/click-check-desktop'
42--- bin/click-check-desktop 2015-03-18 19:57:47 +0000
43+++ bin/click-check-desktop 2016-02-10 19:30:47 +0000
44@@ -17,8 +17,8 @@
45
46 from __future__ import print_function
47
48-from clickreviews import cr_common
49+from clickreviews import common
50 from clickreviews import cr_desktop
51
52 if __name__ == "__main__":
53- cr_common.run_click_check(cr_desktop.ClickReviewDesktop)
54+ common.run_check(cr_desktop.ClickReviewDesktop)
55
56=== modified file 'bin/click-check-framework'
57--- bin/click-check-framework 2015-03-18 19:57:47 +0000
58+++ bin/click-check-framework 2016-02-10 19:30:47 +0000
59@@ -17,8 +17,8 @@
60
61 from __future__ import print_function
62
63-import clickreviews.cr_common as cr_common
64+import clickreviews.common as common
65 import clickreviews.cr_framework as cr_framework
66
67 if __name__ == "__main__":
68- cr_common.run_click_check(cr_framework.ClickReviewFramework)
69+ common.run_check(cr_framework.ClickReviewFramework)
70
71=== modified file 'bin/click-check-functional'
72--- bin/click-check-functional 2015-03-18 19:57:47 +0000
73+++ bin/click-check-functional 2016-02-10 19:30:47 +0000
74@@ -17,8 +17,8 @@
75
76 from __future__ import print_function
77
78-import clickreviews.cr_common as cr_common
79+import clickreviews.common as common
80 import clickreviews.cr_functional as cr_functional
81
82 if __name__ == "__main__":
83- cr_common.run_click_check(cr_functional.ClickReviewFunctional)
84+ common.run_check(cr_functional.ClickReviewFunctional)
85
86=== modified file 'bin/click-check-lint'
87--- bin/click-check-lint 2015-03-18 19:57:47 +0000
88+++ bin/click-check-lint 2016-02-10 19:30:47 +0000
89@@ -17,8 +17,8 @@
90
91 from __future__ import print_function
92
93-import clickreviews.cr_common as cr_common
94+import clickreviews.common as common
95 import clickreviews.cr_lint as cr_lint
96
97 if __name__ == "__main__":
98- cr_common.run_click_check(cr_lint.ClickReviewLint)
99+ common.run_check(cr_lint.ClickReviewLint)
100
101=== modified file 'bin/click-check-online-accounts'
102--- bin/click-check-online-accounts 2015-03-18 19:57:47 +0000
103+++ bin/click-check-online-accounts 2016-02-10 19:30:47 +0000
104@@ -17,8 +17,8 @@
105
106 from __future__ import print_function
107
108-import clickreviews.cr_common as cr_common
109+import clickreviews.common as common
110 import clickreviews.cr_online_accounts as cr_online_accounts
111
112 if __name__ == "__main__":
113- cr_common.run_click_check(cr_online_accounts.ClickReviewAccounts)
114+ common.run_check(cr_online_accounts.ClickReviewAccounts)
115
116=== modified file 'bin/click-check-push-helper'
117--- bin/click-check-push-helper 2015-03-18 19:57:47 +0000
118+++ bin/click-check-push-helper 2016-02-10 19:30:47 +0000
119@@ -17,8 +17,8 @@
120
121 from __future__ import print_function
122
123-import clickreviews.cr_common as cr_common
124+import clickreviews.common as common
125 import clickreviews.cr_push_helper as cr_push_helper
126
127 if __name__ == "__main__":
128- cr_common.run_click_check(cr_push_helper.ClickReviewPushHelper)
129+ common.run_check(cr_push_helper.ClickReviewPushHelper)
130
131=== modified file 'bin/click-check-scope'
132--- bin/click-check-scope 2015-03-18 19:57:47 +0000
133+++ bin/click-check-scope 2016-02-10 19:30:47 +0000
134@@ -17,8 +17,8 @@
135
136 from __future__ import print_function
137
138-import clickreviews.cr_common as cr_common
139+import clickreviews.common as common
140 import clickreviews.cr_scope as cr_scope
141
142 if __name__ == "__main__":
143- cr_common.run_click_check(cr_scope.ClickReviewScope)
144+ common.run_check(cr_scope.ClickReviewScope)
145
146=== modified file 'bin/click-check-security'
147--- bin/click-check-security 2015-03-18 19:57:47 +0000
148+++ bin/click-check-security 2016-02-10 19:30:47 +0000
149@@ -17,8 +17,8 @@
150
151 from __future__ import print_function
152
153-import clickreviews.cr_common as cr_common
154+import clickreviews.common as common
155 import clickreviews.cr_security as cr_security
156
157 if __name__ == "__main__":
158- cr_common.run_click_check(cr_security.ClickReviewSecurity)
159+ common.run_check(cr_security.ClickReviewSecurity)
160
161=== modified file 'bin/click-check-skeleton'
162--- bin/click-check-skeleton 2015-03-18 19:57:47 +0000
163+++ bin/click-check-skeleton 2016-02-10 19:30:47 +0000
164@@ -17,8 +17,8 @@
165
166 from __future__ import print_function
167
168-import clickreviews.cr_common as cr_common
169+import clickreviews.common as common
170 import clickreviews.cr_skeleton as cr_skeleton
171
172 if __name__ == "__main__":
173- cr_common.run_click_check(cr_skeleton.ClickReviewSkeleton)
174+ common.run_check(cr_skeleton.ClickReviewSkeleton)
175
176=== modified file 'bin/click-check-systemd'
177--- bin/click-check-systemd 2015-03-18 20:01:56 +0000
178+++ bin/click-check-systemd 2016-02-10 19:30:47 +0000
179@@ -17,8 +17,8 @@
180
181 from __future__ import print_function
182
183-import clickreviews.cr_common as cr_common
184+import clickreviews.common as common
185 import clickreviews.cr_systemd as cr_systemd
186
187 if __name__ == "__main__":
188- cr_common.run_click_check(cr_systemd.ClickReviewSystemd)
189+ common.run_check(cr_systemd.ClickReviewSystemd)
190
191=== modified file 'bin/click-check-url-dispatcher'
192--- bin/click-check-url-dispatcher 2015-03-18 19:57:47 +0000
193+++ bin/click-check-url-dispatcher 2016-02-10 19:30:47 +0000
194@@ -17,8 +17,8 @@
195
196 from __future__ import print_function
197
198-import clickreviews.cr_common as cr_common
199+import clickreviews.common as common
200 import clickreviews.cr_url_dispatcher as cr_url_dispatcher
201
202 if __name__ == "__main__":
203- cr_common.run_click_check(cr_url_dispatcher.ClickReviewUrlDispatcher)
204+ common.run_check(cr_url_dispatcher.ClickReviewUrlDispatcher)
205
206=== modified file 'bin/click-review'
207--- bin/click-review 2014-11-22 04:33:00 +0000
208+++ bin/click-review 2016-02-10 19:30:47 +0000
209@@ -33,7 +33,7 @@
210 def __init__(self, args):
211 self.args = args
212 self.click_fn = self.args.filename
213- self.cr_modules = modules.get_modules()
214+ self.modules = modules.get_modules()
215
216 def _sumarise_results(self):
217 for module in self.results:
218@@ -96,12 +96,12 @@
219
220 def run_all_checks(self):
221 if self.args.sdk:
222- for module in self.cr_modules:
223+ for module in self.modules:
224 section = self._run_module_checks(module)
225 if section:
226 self._report_module(section)
227 else:
228- for module in self.cr_modules:
229+ for module in self.modules:
230 self._run_module_checks(module)
231 self._complete_report()
232
233@@ -125,7 +125,7 @@
234 sys.exit(1)
235
236 results = Results(args)
237- if not results.cr_modules:
238+ if not results.modules:
239 print("No 'clickreviews' modules found.")
240 sys.exit(1)
241
242
243=== modified file 'bin/click-run-checks'
244--- bin/click-run-checks 2015-03-18 20:49:03 +0000
245+++ bin/click-run-checks 2016-02-10 19:30:47 +0000
246@@ -11,10 +11,10 @@
247 fi
248
249 # prefer local script for testing, otherwise use system location
250-CLICK_CHECKS_BIN_PATH="$(dirname $(readlink -f "$0"))"
251+CHECKS_BIN_PATH="$(dirname $(readlink -f "$0"))"
252
253 prefer_local() {
254- path="${CLICK_CHECKS_BIN_PATH}/$1"
255+ path="${CHECKS_BIN_PATH}/$1"
256 if [ -x $path ]; then
257 "$path" "$2" || set_rc "$?"
258 return
259@@ -37,10 +37,10 @@
260
261 prefer_local click-show-files "$c"
262
263-CLICK_CHECKS=$(ls ${CLICK_CHECKS_BIN_PATH}/click-check-* | grep -v click-check-skeleton | grep -v click-check-lint)
264-CLICK_CHECKS="click-check-lint ${CLICK_CHECKS}"
265-for check_path in ${CLICK_CHECKS}; do
266- check=$(basename ${check_path} ${CLICK_CHECKS_BIN_PATH})
267+CHECKS=$(ls ${CHECKS_BIN_PATH}/click-check-* | egrep -v '(click-check-skeleton|click-check-lint)')
268+CHECKS="click-check-lint ${CHECKS}"
269+for check_path in ${CHECKS}; do
270+ check=$(basename ${check_path} ${CHECKS_BIN_PATH})
271 echo ""
272 echo "=" $check "="
273 prefer_local $check "$c"
274
275=== modified file 'bin/click-show-files'
276--- bin/click-show-files 2015-04-01 23:31:56 +0000
277+++ bin/click-show-files 2016-02-10 19:30:47 +0000
278@@ -19,7 +19,7 @@
279 import os
280 import sys
281
282-from clickreviews import cr_common
283+from clickreviews import common
284 from clickreviews import cr_desktop
285 from clickreviews import cr_lint
286 from clickreviews import cr_security
287@@ -36,12 +36,12 @@
288
289 if __name__ == "__main__":
290 if len(sys.argv) < 2:
291- cr_common.error("Must give path to click package")
292+ common.error("Must give path to package")
293
294 review = cr_lint.ClickReviewLint(sys.argv[1])
295
296 for i in sorted(review.control_files):
297- fh = cr_common.open_file_read(review.control_files[i])
298+ fh = common.open_file_read(review.control_files[i])
299 print("= %s =" % os.path.basename(i))
300 for line in fh.readlines():
301 print(line, end="")
302@@ -51,7 +51,7 @@
303 fn = os.path.join(review.unpack_dir, "meta", "package.yaml")
304 if os.path.exists(fn):
305 print("= %s =" % os.path.basename(fn))
306- fh = cr_common.open_file_read(fn)
307+ fh = common.open_file_read(fn)
308 for line in fh.readlines():
309 print(line, end="")
310 fh.close()
311@@ -62,7 +62,7 @@
312 review_content_hub = cr_content_hub.ClickReviewContentHub(sys.argv[1])
313 for app in sorted(review_content_hub.content_hub_files):
314 f = review_content_hub.content_hub_files[app]
315- fh = cr_common.open_file_read(os.path.join(
316+ fh = common.open_file_read(os.path.join(
317 review_content_hub.unpack_dir, f))
318 print("== content_hub: %s ==" % os.path.basename(f))
319 for line in fh.readlines():
320@@ -73,8 +73,7 @@
321 review_desktop = cr_desktop.ClickReviewDesktop(sys.argv[1])
322 for app in sorted(review_desktop.desktop_files):
323 f = review_desktop.desktop_files[app]
324- fh = cr_common.open_file_read(os.path.join(review_desktop.unpack_dir,
325- f))
326+ fh = common.open_file_read(os.path.join(review_desktop.unpack_dir, f))
327 print("== desktop: %s ==" % os.path.basename(f))
328 for line in fh.readlines():
329 print(line, end="")
330@@ -87,7 +86,7 @@
331 if account_type not in review_accounts.accounts_files[app]:
332 continue
333 f = review_accounts.accounts_files[app][account_type]
334- fh = cr_common.open_file_read(os.path.join(
335+ fh = common.open_file_read(os.path.join(
336 review_accounts.unpack_dir, f))
337 print("== online %s: %s ==" % (account_type, os.path.basename(f)))
338 for line in fh.readlines():
339@@ -98,7 +97,7 @@
340 review_push_helper = cr_push_helper.ClickReviewPushHelper(sys.argv[1])
341 for app in sorted(review_push_helper.push_helper_files):
342 f = review_push_helper.push_helper_files[app]
343- fh = cr_common.open_file_read(os.path.join(
344+ fh = common.open_file_read(os.path.join(
345 review_push_helper.unpack_dir, f))
346 print("== push_helper: %s ==" % os.path.basename(f))
347 for line in fh.readlines():
348@@ -109,7 +108,7 @@
349 review_scope = cr_scope.ClickReviewScope(sys.argv[1])
350 for app in sorted(review_scope.scopes):
351 f = review_scope.scopes[app]["ini_file"]
352- fh = cr_common.open_file_read(os.path.join(review_scope.unpack_dir, f))
353+ fh = common.open_file_read(os.path.join(review_scope.unpack_dir, f))
354 print("== scope .INI: %s ==" % os.path.basename(f))
355 for line in fh.readlines():
356 print(line, end="")
357@@ -120,7 +119,7 @@
358 for app in sorted(review_framework.frameworks_file):
359 f = os.path.join(review_framework.unpack_dir,
360 review_framework.frameworks_file[app])
361- fh = cr_common.open_file_read(os.path.join(review_framework.unpack_dir, f))
362+ fh = common.open_file_read(os.path.join(review_framework.unpack_dir, f))
363 print("== click .framework: %s ==" % os.path.basename(f))
364 for line in fh.readlines():
365 print(line, end="")
366@@ -135,8 +134,7 @@
367
368 review_apparmor = cr_security.ClickReviewSecurity(sys.argv[1])
369 for f in sorted(review_apparmor.security_manifests):
370- fh = cr_common.open_file_read(os.path.join(review_apparmor.unpack_dir,
371- f))
372+ fh = common.open_file_read(os.path.join(review_apparmor.unpack_dir, f))
373 print("== security: %s ==" % os.path.basename(f))
374 for line in fh.readlines():
375 print(line, end="")
376@@ -146,8 +144,7 @@
377 review_systemd = cr_systemd.ClickReviewSystemd(sys.argv[1])
378 for app in sorted(review_systemd.systemd_files):
379 f = review_systemd.systemd_files[app]
380- fh = cr_common.open_file_read(os.path.join(review_systemd.unpack_dir,
381- f))
382+ fh = common.open_file_read(os.path.join(review_systemd.unpack_dir, f))
383 print("== systemd: %s ==" % os.path.basename(f))
384 for line in fh.readlines():
385 print(line, end="")
386@@ -157,8 +154,8 @@
387 review_url_dispatcher = cr_url_dispatcher.ClickReviewUrlDispatcher(sys.argv[1])
388 for app in sorted(review_url_dispatcher.url_dispatcher_files):
389 f = review_url_dispatcher.url_dispatcher_files[app]
390- fh = cr_common.open_file_read(os.path.join(review_url_dispatcher.unpack_dir,
391- f))
392+ fh = common.open_file_read(os.path.join(review_url_dispatcher.unpack_dir,
393+ f))
394 print("== url_dispatcher: %s ==" % os.path.basename(f))
395 for line in fh.readlines():
396 print(line, end="")
397@@ -166,4 +163,4 @@
398 print("")
399
400 # Cleanup our unpack directory
401- cr_common.cleanup_unpack()
402+ common.cleanup_unpack()
403
404=== added file 'bin/detect-package'
405--- bin/detect-package 1970-01-01 00:00:00 +0000
406+++ bin/detect-package 2016-02-10 19:30:47 +0000
407@@ -0,0 +1,15 @@
408+#!/usr/bin/python3
409+
410+import os
411+import sys
412+
413+from clickreviews import common
414+
415+if __name__ == '__main__':
416+ if len(sys.argv) != 2:
417+ common.error("%s <pkg>" % os.path.basename(sys.argv[0]))
418+
419+ pkg = sys.argv[1]
420+
421+ (t, v) = common.detect_package(pkg)
422+ print ("%s\t%d" % (t, v))
423
424=== modified file 'bin/download-click'
425--- bin/download-click 2013-10-02 14:02:34 +0000
426+++ bin/download-click 2016-02-10 19:30:47 +0000
427@@ -23,7 +23,7 @@
428 import sys
429 import time
430
431-from clickreviews import cr_common
432+from clickreviews import common
433
434 top_url = "https://search.apps.ubuntu.com"
435
436@@ -40,12 +40,12 @@
437 def download(entry, download_dir=None):
438 '''Download a click app'''
439 if 'resource_url' not in entry:
440- cr_common.error("Could not find 'resource_url' in:\n%s" % entry)
441+ common.error("Could not find 'resource_url' in:\n%s" % entry)
442 resource_url = top_url + entry['resource_url']
443
444 res = get_store_json(resource_url)
445 if 'download_url' not in res:
446- cr_common.error("Could not find 'download_url' in:\n%s" % res)
447+ common.error("Could not find 'download_url' in:\n%s" % res)
448 download_url = res['download_url']
449
450 if download_dir is None:
451@@ -55,12 +55,12 @@
452
453 fn = os.path.join(download_dir, download_url.split('/')[-1])
454 if os.path.exists(fn):
455- cr_common.warn("'%s' already exists, skipping" % os.path.basename(fn))
456+ common.warn("'%s' already exists, skipping" % os.path.basename(fn))
457 return True
458- cr_common.msg("Downloading %s" % os.path.basename(fn))
459+ common.msg("Downloading %s" % os.path.basename(fn))
460 # FIXME: on 2013-10-15 this will break
461 url = download_url + "?noauth=1"
462- cr_common.msg("-- Downloading %s" % url)
463+ common.msg("-- Downloading %s" % url)
464
465 # attempt to deal with intermittent failures
466 count = 0
467@@ -72,14 +72,14 @@
468 (tmp, headers) = urllib.request.urlretrieve(url)
469 shutil.move(tmp, fn)
470 result = True
471- cr_common.msg("-- Success!")
472+ common.msg("-- Success!")
473 except urllib.error.HTTPError as error:
474 err_str = "-- urlretrieve() failed: %d: %s" % (error.code,
475 error.reason)
476 count += 1
477 time.sleep(5)
478 if not result:
479- cr_common.warn("%s (tried %d times)" % (err_str, max_tries))
480+ common.warn("%s (tried %d times)" % (err_str, max_tries))
481 return result
482
483 if __name__ == "__main__":
484@@ -96,12 +96,12 @@
485 (opt, args) = parser.parse_args()
486
487 if not opt.all and len(args) < 1:
488- cr_common.error("%s --all|<pkgname>" % os.path.basename(sys.argv[0]))
489+ common.error("%s --all|<pkgname>" % os.path.basename(sys.argv[0]))
490
491 url = top_url + "/api/v1/search?q="
492 items = get_store_json(url)
493 if not isinstance(items, list):
494- cr_common.error("Didn't get valid result from: %s" % url)
495+ common.error("Didn't get valid result from: %s" % url)
496
497 errors = False
498 if opt.all:
499@@ -117,10 +117,10 @@
500 break
501
502 if not entry:
503- cr_common.warn("Could not find '%s', skipping" % pkgname)
504+ common.warn("Could not find '%s', skipping" % pkgname)
505 continue
506
507 if not download(entry, opt.download_dir):
508 errors = True
509 if errors:
510- cr_common.error("problem downloading")
511+ common.error("problem downloading")
512
513=== modified file 'bin/repack-click'
514--- bin/repack-click 2014-06-27 18:58:30 +0000
515+++ bin/repack-click 2016-02-10 19:30:47 +0000
516@@ -6,7 +6,7 @@
517 import sys
518 import os
519
520-from clickreviews import cr_common
521+from clickreviews import common
522 from debian.deb822 import Deb822
523 import glob
524 import shutil
525@@ -16,45 +16,45 @@
526 def repack_click(unpack_dir, click_package):
527 '''Repack the click package'''
528 if not os.path.isdir(unpack_dir):
529- cr_common.error("'%s' does not exist" % unpack_dir)
530+ common.error("'%s' does not exist" % unpack_dir)
531 if os.path.exists(click_package):
532- cr_common.error("'%s' exists" % click_package)
533+ common.error("'%s' exists" % click_package)
534
535 control_fn = os.path.join(unpack_dir, "DEBIAN/control")
536 if not os.path.exists(control_fn):
537- cr_common.error("Could not find '%s'" % control_fn)
538- fh = cr_common.open_file_read(control_fn)
539+ common.error("Could not find '%s'" % control_fn)
540+ fh = common.open_file_read(control_fn)
541 tmp = list(Deb822.iter_paragraphs(fh.readlines()))
542 fh.close()
543 if len(tmp) != 1:
544- cr_common.error("malformed control file: too many paragraphs")
545+ common.error("malformed control file: too many paragraphs")
546 control = tmp[0]
547
548 click_fn = "%s_%s_%s.click" % (control['Package'],
549 control['Version'],
550 control['Architecture'])
551 if os.path.basename(click_package) != click_fn:
552- cr_common.warn("'%s' should be '%s'" % (click_package, click_fn))
553+ common.warn("'%s' should be '%s'" % (click_package, click_fn))
554
555 tmpdir = tempfile.mkdtemp(prefix='clickreview-')
556 curdir = os.getcwd()
557 os.chdir(tmpdir)
558- (rc, out) = cr_common.cmd(['dpkg-deb', '-b', '--nocheck', '-Zgzip',
559+ (rc, out) = common.cmd(['dpkg-deb', '-b', '--nocheck', '-Zgzip',
560 os.path.abspath(unpack_dir),
561 os.path.join(tmpdir, click_fn)])
562 os.chdir(curdir)
563 if rc != 0:
564- cr_common.recursive_rm(tmpdir)
565- cr_common.error("dpkg-deb -b failed with '%d':\n%s" % (rc, out))
566+ common.recursive_rm(tmpdir)
567+ common.error("dpkg-deb -b failed with '%d':\n%s" % (rc, out))
568
569 debfile = glob.glob("%s/*.click" % tmpdir)[0]
570 shutil.move(debfile, os.path.abspath(click_package))
571- cr_common.recursive_rm(tmpdir)
572+ common.recursive_rm(tmpdir)
573
574
575 if __name__ == '__main__':
576 if len(sys.argv) != 3:
577- cr_common.error("%s <unpacked dir> <clickpkg>" %
578+ common.error("%s <unpacked dir> <clickpkg>" %
579 os.path.basename(sys.argv[0]))
580
581 dir = sys.argv[1]
582
583=== renamed file 'bin/unpack-click' => 'bin/unpack-package'
584--- bin/unpack-click 2013-09-26 11:47:37 +0000
585+++ bin/unpack-package 2016-02-10 19:30:47 +0000
586@@ -3,14 +3,14 @@
587 import os
588 import sys
589
590-from clickreviews import cr_common
591+from clickreviews import common
592
593 if __name__ == '__main__':
594 if len(sys.argv) != 3:
595- cr_common.error("%s <clickpkg> <dir>" % os.path.basename(sys.argv[0]))
596+ common.error("%s <clickpkg> <dir>" % os.path.basename(sys.argv[0]))
597
598 pkg = sys.argv[1]
599 dir = sys.argv[2]
600
601- cr_common.unpack_click(pkg, dir)
602+ common.unpack_pkg(pkg, dir)
603 print("Successfully unpacked to '%s'" % dir)
604
605=== modified file 'check-names.list'
606--- check-names.list 2016-02-01 19:12:30 +0000
607+++ check-names.list 2016-02-10 19:30:47 +0000
608@@ -45,7 +45,6 @@
609 framework:policy_unknown|
610 framework:policy_valid_name|
611 lint:architecture_specified_needed|
612-lint:check_squashfs_uses_snap_yaml|
613 lint:click_local_extensions|
614 lint:control_architecture_match|
615 lint:control_architecture_valid|
616@@ -71,7 +70,6 @@
617 lint:hooks_multiple_apps|
618 lint:hooks_redflag|
619 lint:hooks_valid|
620-lint:is_squashfs|
621 lint:maintainer_format|http://askubuntu.com/questions/417351/what-does-lint-maintainer-format-mean/417352
622 lint:maintainer_present|
623 lint:manifest_architecture_valid|
624@@ -159,7 +157,6 @@
625 security:yaml_combinations|
626 security:yaml_override_click|
627 security:yaml_override_format|
628-security:yaml_override_present|https://developer.ubuntu.com/en/snappy/guides/security-policy/
629 security:yaml_policy_format|
630 security:yaml_policy_present|https://developer.ubuntu.com/en/snappy/guides/security-policy/
631 security:yaml_security-template|
632
633=== added file 'clickreviews/common.py'
634--- clickreviews/common.py 1970-01-01 00:00:00 +0000
635+++ clickreviews/common.py 2016-02-10 19:30:47 +0000
636@@ -0,0 +1,514 @@
637+'''common.py: common classes and functions'''
638+#
639+# Copyright (C) 2013-2016 Canonical Ltd.
640+#
641+# This program is free software: you can redistribute it and/or modify
642+# it under the terms of the GNU General Public License as published by
643+# the Free Software Foundation; version 3 of the License.
644+#
645+# This program is distributed in the hope that it will be useful,
646+# but WITHOUT ANY WARRANTY; without even the implied warranty of
647+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
648+# GNU General Public License for more details.
649+#
650+# You should have received a copy of the GNU General Public License
651+# along with this program. If not, see <http://www.gnu.org/licenses/>.
652+
653+from __future__ import print_function
654+import atexit
655+import codecs
656+import inspect
657+import json
658+import logging
659+import magic
660+import os
661+import re
662+import shutil
663+import subprocess
664+import sys
665+import tempfile
666+import types
667+
668+
669+DEBUGGING = False
670+UNPACK_DIR = None
671+RAW_UNPACK_DIR = None
672+
673+
674+def cleanup_unpack():
675+ global UNPACK_DIR
676+ if UNPACK_DIR is not None and os.path.isdir(UNPACK_DIR):
677+ recursive_rm(UNPACK_DIR)
678+ UNPACK_DIR = None
679+ global RAW_UNPACK_DIR
680+ if RAW_UNPACK_DIR is not None and os.path.isdir(RAW_UNPACK_DIR):
681+ recursive_rm(RAW_UNPACK_DIR)
682+ RAW_UNPACK_DIR = None
683+atexit.register(cleanup_unpack)
684+
685+
686+#
687+# Utility classes
688+#
689+class ReviewException(Exception):
690+ '''This class represents Review exceptions'''
691+ def __init__(self, value):
692+ self.value = value
693+
694+ def __str__(self):
695+ return repr(self.value)
696+
697+
698+class Review(object):
699+ '''Common review class'''
700+ magic_binary_file_descriptions = [
701+ 'application/x-executable; charset=binary',
702+ 'application/x-sharedlib; charset=binary',
703+ 'application/x-object; charset=binary',
704+ 'application/octet-stream; charset=binary'
705+ ]
706+
707+ def __init__(self, fn, review_type, overrides=None):
708+ self.pkg_filename = fn
709+ self._check_package_exists()
710+
711+ self.review_type = review_type
712+ # TODO: rename as pkg_report
713+ self.click_report = dict()
714+
715+ self.result_types = ['info', 'warn', 'error']
716+ for r in self.result_types:
717+ self.click_report[r] = dict()
718+
719+ self.click_report_output = "json"
720+
721+ global UNPACK_DIR
722+ if UNPACK_DIR is None:
723+ UNPACK_DIR = unpack_pkg(fn)
724+ self.unpack_dir = UNPACK_DIR
725+
726+ global RAW_UNPACK_DIR
727+ if RAW_UNPACK_DIR is None:
728+ RAW_UNPACK_DIR = raw_unpack_pkg(fn)
729+ self.raw_unpack_dir = RAW_UNPACK_DIR
730+
731+ self.is_click = False
732+ self.is_snap1 = False
733+ self.is_snap2 = False
734+ self.pkgfmt = {"type": "", "version": ""}
735+
736+ (self.pkgfmt["type"], pkgver) = detect_package(fn, self.unpack_dir)
737+
738+ if self._pkgfmt_type() == "snap":
739+ if pkgver < 2:
740+ self.is_snap1 = True
741+ self.pkgfmt["version"] = "15.04"
742+ else:
743+ self.is_snap2 = True
744+ self.pkgfmt["version"] = "16.04"
745+ elif self._pkgfmt_type() == "click":
746+ self.pkgfmt["version"] = "0.4"
747+ self.is_click = True
748+ else:
749+ error("Unknown package type: '%s'" % self._pkgfmt_type())
750+
751+ # Get a list of all unpacked files
752+ self.pkg_files = []
753+ self._list_all_files()
754+
755+ # Setup what is needed to get a list of all unpacked compiled binaries
756+ self.mime = magic.open(magic.MAGIC_MIME)
757+ self.mime.load()
758+ self.pkg_bin_files = []
759+ # Don't run this here since only cr_lint.py and cr_functional.py need
760+ # it now
761+ # self._list_all_compiled_binaries()
762+
763+ self.overrides = overrides if overrides is not None else {}
764+
765+ def _check_innerpath_executable(self, fn):
766+ '''Check that the provided path exists and is executable'''
767+ return os.access(fn, os.X_OK)
768+
769+ def _extract_statinfo(self, fn):
770+ '''Extract statinfo from file'''
771+ try:
772+ st = os.stat(fn)
773+ except Exception:
774+ return None
775+ return st
776+
777+ def _path_join(self, dirname, rest):
778+ return os.path.join(dirname, rest)
779+
780+ def _get_sha512sum(self, fn):
781+ '''Get sha512sum of file'''
782+ (rc, out) = cmd(['sha512sum', fn])
783+ if rc != 0:
784+ return None
785+ return out.split()[0]
786+
787+ def _pkgfmt_type(self):
788+ '''Return the package format type'''
789+ if "type" not in self.pkgfmt:
790+ return ""
791+ return self.pkgfmt["type"]
792+
793+ def _pkgfmt_version(self):
794+ '''Return the package format version'''
795+ if "version" not in self.pkgfmt:
796+ return ""
797+ return self.pkgfmt["version"]
798+
799+ def _check_package_exists(self):
800+ '''Check that the provided package exists'''
801+ if not os.path.exists(self.pkg_filename):
802+ error("Could not find '%s'" % self.pkg_filename)
803+
804+ def _list_all_files(self):
805+ '''List all files included in this click package.'''
806+ for root, dirnames, filenames in os.walk(self.unpack_dir):
807+ for f in filenames:
808+ self.pkg_files.append(os.path.join(root, f))
809+
810+ def _check_if_message_catalog(self, fn):
811+ '''Check if file is a message catalog (.mo file).'''
812+ if fn.endswith('.mo'):
813+ return True
814+ return False
815+
816+ def _list_all_compiled_binaries(self):
817+ '''List all compiled binaries in this click package.'''
818+ for i in self.pkg_files:
819+ res = self.mime.file(i)
820+ if res in self.magic_binary_file_descriptions and \
821+ not self._check_if_message_catalog(i):
822+ self.pkg_bin_files.append(i)
823+
824+ def _get_check_name(self, name, app='', extra=''):
825+ name = ':'.join([self.review_type, name])
826+ if app:
827+ name += ':' + app
828+ if extra:
829+ name += ':' + extra
830+ return name
831+
832+ def _verify_pkgversion(self, v):
833+ '''Verify package name'''
834+ if not isinstance(v, (str, int, float)):
835+ return False
836+ re_valid_version = re.compile(r'^((\d+):)?' # epoch
837+ '([A-Za-z0-9.+:~-]+?)' # upstream
838+ '(-([A-Za-z0-9+.~]+))?$') # debian
839+ if re_valid_version.match(str(v)):
840+ return True
841+ return False
842+
843+ # click_report[<result_type>][<review_name>] = <result>
844+ # result_type: info, warn, error
845+ # review_name: name of the check (prefixed with self.review_type)
846+ # result: contents of the review
847+ def _add_result(self, result_type, review_name, result, link=None,
848+ manual_review=False):
849+ '''Add result to report'''
850+ if result_type not in self.result_types:
851+ error("Invalid result type '%s'" % result_type)
852+
853+ if review_name not in self.click_report[result_type]:
854+ # log info about check so it can be collected into the
855+ # check-names.list file
856+ # format should be
857+ # CHECK|<review_type:check_name>|<link>
858+ msg = 'CHECK|{}|{}'
859+ name = ':'.join(review_name.split(':')[:2])
860+ link_text = link if link is not None else ""
861+ logging.debug(msg.format(name, link_text))
862+ self.click_report[result_type][review_name] = dict()
863+
864+ self.click_report[result_type][review_name].update({
865+ 'text': result,
866+ 'manual_review': manual_review,
867+ })
868+ if link is not None:
869+ self.click_report[result_type][review_name]["link"] = link
870+
871+ def do_report(self):
872+ '''Print report'''
873+ if self.click_report_output == "console":
874+ # TODO: format better
875+ import pprint
876+ pprint.pprint(self.click_report)
877+ elif self.click_report_output == "json":
878+ import json
879+ msg(json.dumps(self.click_report,
880+ sort_keys=True,
881+ indent=2,
882+ separators=(',', ': ')))
883+
884+ rc = 0
885+ if len(self.click_report['error']):
886+ rc = 2
887+ elif len(self.click_report['warn']):
888+ rc = 1
889+ return rc
890+
891+ def do_checks(self):
892+ '''Run all methods that start with check_'''
893+ methodList = [name for name, member in
894+ inspect.getmembers(self, inspect.ismethod)
895+ if isinstance(member, types.MethodType)]
896+ for methodname in methodList:
897+ if not methodname.startswith("check_"):
898+ continue
899+ func = getattr(self, methodname)
900+ func()
901+
902+ def set_review_type(self, name):
903+ '''Set review name'''
904+ self.review_type = name
905+
906+
907+#
908+# Utility functions
909+#
910+
911+def error(out, exit_code=1, do_exit=True):
912+ '''Print error message and exit'''
913+ try:
914+ print("ERROR: %s" % (out), file=sys.stderr)
915+ except IOError:
916+ pass
917+
918+ if do_exit:
919+ sys.exit(exit_code)
920+
921+
922+def warn(out):
923+ '''Print warning message'''
924+ try:
925+ print("WARN: %s" % (out), file=sys.stderr)
926+ except IOError:
927+ pass
928+
929+
930+def msg(out, output=sys.stdout):
931+ '''Print message'''
932+ try:
933+ print("%s" % (out), file=output)
934+ except IOError:
935+ pass
936+
937+
938+def debug(out):
939+ '''Print debug message'''
940+ global DEBUGGING
941+ if DEBUGGING:
942+ try:
943+ print("DEBUG: %s" % (out), file=sys.stderr)
944+ except IOError:
945+ pass
946+
947+
948+def cmd(command):
949+ '''Try to execute the given command.'''
950+ debug(command)
951+ try:
952+ sp = subprocess.Popen(command, stdout=subprocess.PIPE,
953+ stderr=subprocess.STDOUT)
954+ except OSError as ex:
955+ return [127, str(ex)]
956+
957+ if sys.version_info[0] >= 3:
958+ out = sp.communicate()[0].decode('ascii', 'ignore')
959+ else:
960+ out = sp.communicate()[0]
961+
962+ return [sp.returncode, out]
963+
964+
965+def cmd_pipe(command1, command2):
966+ '''Try to pipe command1 into command2.'''
967+ try:
968+ sp1 = subprocess.Popen(command1, stdout=subprocess.PIPE)
969+ sp2 = subprocess.Popen(command2, stdin=sp1.stdout)
970+ except OSError as ex:
971+ return [127, str(ex)]
972+
973+ if sys.version_info[0] >= 3:
974+ out = sp2.communicate()[0].decode('ascii', 'ignore')
975+ else:
976+ out = sp2.communicate()[0]
977+
978+ return [sp2.returncode, out]
979+
980+
981+def _unpack_cmd(cmd_args, d, dest):
982+ '''Low level unpack helper'''
983+ curdir = os.getcwd()
984+ os.chdir(d)
985+
986+ (rc, out) = cmd(cmd_args)
987+ os.chdir(curdir)
988+
989+ if rc != 0:
990+ if os.path.isdir(d):
991+ recursive_rm(d)
992+ error("unpacking failed with '%d':\n%s" % (rc, out))
993+
994+ if dest is None:
995+ dest = d
996+ else:
997+ shutil.move(d, dest)
998+
999+ return dest
1000+
1001+
1002+def _unpack_snap_squashfs(snap_pkg, dest):
1003+ '''Unpack a squashfs based snap package to dest'''
1004+ d = tempfile.mkdtemp(prefix='clickreview-')
1005+ return _unpack_cmd(['unsquashfs', '-f', '-d', d,
1006+ os.path.abspath(snap_pkg)], d, dest)
1007+
1008+
1009+def _unpack_click_deb(pkg, dest):
1010+ d = tempfile.mkdtemp(prefix='clickreview-')
1011+ return _unpack_cmd(['dpkg-deb', '-R',
1012+ os.path.abspath(pkg), d], d, dest)
1013+
1014+
1015+def unpack_pkg(fn, dest=None):
1016+ '''Unpack package'''
1017+ if not os.path.isfile(fn):
1018+ error("Could not find '%s'" % fn)
1019+ pkg = fn
1020+ if not pkg.startswith('/'):
1021+ pkg = os.path.abspath(pkg)
1022+
1023+ if dest is not None and os.path.exists(dest):
1024+ error("'%s' exists. Aborting." % dest)
1025+
1026+ # check if its a squashfs based snap
1027+ if is_squashfs(pkg):
1028+ return _unpack_snap_squashfs(fn, dest)
1029+
1030+ return _unpack_click_deb(fn, dest)
1031+
1032+
1033+def is_squashfs(filename):
1034+ '''Return true if the given filename as a squashfs header'''
1035+ with open(filename, 'rb') as f:
1036+ header = f.read(10)
1037+ return header.startswith(b"hsqs")
1038+
1039+
1040+def raw_unpack_pkg(fn, dest=None):
1041+ '''Unpack raw package'''
1042+ if not os.path.isfile(fn):
1043+ error("Could not find '%s'" % fn)
1044+ pkg = fn
1045+ if not pkg.startswith('/'):
1046+ pkg = os.path.abspath(pkg)
1047+ # nothing to do for squashfs images
1048+ if is_squashfs(pkg):
1049+ return ""
1050+
1051+ if dest is not None and os.path.exists(dest):
1052+ error("'%s' exists. Aborting." % dest)
1053+
1054+ d = tempfile.mkdtemp(prefix='review-')
1055+
1056+ curdir = os.getcwd()
1057+ os.chdir(d)
1058+ (rc, out) = cmd(['ar', 'x', pkg])
1059+ os.chdir(curdir)
1060+
1061+ if rc != 0:
1062+ if os.path.isdir(d):
1063+ recursive_rm(d)
1064+ error("'ar x' failed with '%d':\n%s" % (rc, out))
1065+
1066+ if dest is None:
1067+ dest = d
1068+ else:
1069+ shutil.move(d, dest)
1070+
1071+ return dest
1072+
1073+
1074+def open_file_read(path):
1075+ '''Open specified file read-only'''
1076+ try:
1077+ orig = codecs.open(path, 'r', "UTF-8")
1078+ except Exception:
1079+ raise
1080+
1081+ return orig
1082+
1083+
1084+def recursive_rm(dirPath, contents_only=False):
1085+ '''recursively remove directory'''
1086+ names = os.listdir(dirPath)
1087+ for name in names:
1088+ path = os.path.join(dirPath, name)
1089+ if os.path.islink(path) or not os.path.isdir(path):
1090+ os.unlink(path)
1091+ else:
1092+ recursive_rm(path)
1093+ if contents_only is False:
1094+ os.rmdir(dirPath)
1095+
1096+
1097+def run_check(cls):
1098+ if len(sys.argv) < 2:
1099+ error("Must give path to package")
1100+
1101+ # extract args
1102+ fn = sys.argv[1]
1103+ if len(sys.argv) > 2:
1104+ overrides = json.loads(sys.argv[2])
1105+ else:
1106+ overrides = None
1107+
1108+ review = cls(fn, overrides=overrides)
1109+ review.do_checks()
1110+ rc = review.do_report()
1111+ sys.exit(rc)
1112+
1113+
1114+def detect_package(fn, dir=None):
1115+ '''Detect what type of package this is'''
1116+ pkgtype = None
1117+ pkgver = None
1118+
1119+ if not os.path.isfile(fn):
1120+ error("Could not find '%s'" % fn)
1121+
1122+ if dir is None:
1123+ unpack_dir = unpack_pkg(fn)
1124+ else:
1125+ unpack_dir = dir
1126+
1127+ if not os.path.isdir(unpack_dir):
1128+ error("Could not find '%s'" % unpack_dir)
1129+
1130+ pkg = fn
1131+ if not pkg.startswith('/'):
1132+ pkg = os.path.abspath(pkg)
1133+
1134+ # check if its a squashfs based snap
1135+ if is_squashfs(pkg):
1136+ # 16.04+ squashfs snaps
1137+ pkgtype = "snap"
1138+ pkgver = 2
1139+ elif os.path.exists(os.path.join(unpack_dir, "meta/package.yaml")):
1140+ # 15.04 ar-based snaps
1141+ pkgtype = "snap"
1142+ pkgver = 1
1143+ else:
1144+ pkgtype = "click"
1145+ pkgver = 1
1146+
1147+ if dir is None and os.path.isdir(unpack_dir):
1148+ recursive_rm(unpack_dir)
1149+
1150+ return (pkgtype, pkgver)
1151
1152=== modified file 'clickreviews/cr_bin_path.py'
1153--- clickreviews/cr_bin_path.py 2015-08-18 16:04:05 +0000
1154+++ clickreviews/cr_bin_path.py 2016-02-10 19:30:47 +0000
1155@@ -26,16 +26,19 @@
1156 # bin-path is ignored by snappy install so don't bother with peerhooks
1157 ClickReview.__init__(self, fn, "bin-path", overrides=overrides)
1158
1159+ self.bin_paths_files = dict()
1160+ self.bin_paths = dict()
1161+
1162+ if not self.is_snap1:
1163+ return
1164+
1165 # snappy yaml currently only allows specifying:
1166 # - exec (optional)
1167 # - description (optional)
1168 self.required_keys = []
1169 self.optional_keys = ['description', 'exec'] + self.snappy_exe_security
1170
1171- self.bin_paths_files = dict()
1172- self.bin_paths = dict()
1173-
1174- if self.is_snap and 'binaries' in self.pkg_yaml:
1175+ if self.is_snap1 and 'binaries' in self.pkg_yaml:
1176 if len(self.pkg_yaml['binaries']) == 0:
1177 error("package.yaml malformed: 'binaries' is empty")
1178 for binary in self.pkg_yaml['binaries']:
1179@@ -91,7 +94,7 @@
1180
1181 def check_snappy_required(self):
1182 '''Check for package.yaml required fields'''
1183- if not self.is_snap or 'binaries' not in self.pkg_yaml:
1184+ if not self.is_snap1 or 'binaries' not in self.pkg_yaml:
1185 return
1186 self._verify_required(self._create_dict(self.pkg_yaml['binaries']),
1187 'package_yaml')
1188@@ -121,7 +124,7 @@
1189
1190 def check_snappy_optional(self):
1191 '''Check snappy packate.yaml optional fields'''
1192- if not self.is_snap or 'binaries' not in self.pkg_yaml:
1193+ if not self.is_snap1 or 'binaries' not in self.pkg_yaml:
1194 return
1195 self._verify_optional(self._create_dict(self.pkg_yaml['binaries']),
1196 'package_yaml')
1197@@ -149,13 +152,16 @@
1198
1199 def check_snappy_unknown(self):
1200 '''Check snappy package.yaml unknown fields'''
1201- if not self.is_snap or 'binaries' not in self.pkg_yaml:
1202+ if not self.is_snap1 or 'binaries' not in self.pkg_yaml:
1203 return
1204 self._verify_unknown(self._create_dict(self.pkg_yaml['binaries']),
1205 'package_yaml')
1206
1207 def check_path(self):
1208 '''Check path exists'''
1209+ if not self.is_snap1:
1210+ return
1211+
1212 t = 'info'
1213 n = self._get_check_name('path_exists')
1214 s = "OK"
1215@@ -172,7 +178,7 @@
1216
1217 def check_binary_description(self):
1218 '''Check package.yaml binary description'''
1219- if not self.is_snap or 'binaries' not in self.pkg_yaml:
1220+ if not self.is_snap1 or 'binaries' not in self.pkg_yaml:
1221 return
1222
1223 my_dict = self._create_dict(self.pkg_yaml['binaries'])
1224
1225=== modified file 'clickreviews/cr_common.py'
1226--- clickreviews/cr_common.py 2016-02-01 17:29:56 +0000
1227+++ clickreviews/cr_common.py 2016-02-10 19:30:47 +0000
1228@@ -1,6 +1,6 @@
1229-'''common.py: common classes and functions'''
1230+'''cr_common.py: common classes and functions'''
1231 #
1232-# Copyright (C) 2013-2015 Canonical Ltd.
1233+# Copyright (C) 2013-2016 Canonical Ltd.
1234 #
1235 # This program is free software: you can redistribute it and/or modify
1236 # it under the terms of the GNU General Public License as published by
1237@@ -15,54 +15,31 @@
1238 # along with this program. If not, see <http://www.gnu.org/licenses/>.
1239
1240 from __future__ import print_function
1241-import atexit
1242-import codecs
1243 from debian.deb822 import Deb822
1244 import glob
1245-import inspect
1246 import json
1247-import logging
1248-import magic
1249 import os
1250 import pprint
1251 import re
1252-import shutil
1253-import subprocess
1254-import sys
1255-import tempfile
1256-import types
1257 import yaml
1258
1259-DEBUGGING = False
1260-UNPACK_DIR = None
1261-RAW_UNPACK_DIR = None
1262-
1263-
1264-def cleanup_unpack():
1265- global UNPACK_DIR
1266- if UNPACK_DIR is not None and os.path.isdir(UNPACK_DIR):
1267- recursive_rm(UNPACK_DIR)
1268- UNPACK_DIR = None
1269- global RAW_UNPACK_DIR
1270- if RAW_UNPACK_DIR is not None and os.path.isdir(RAW_UNPACK_DIR):
1271- recursive_rm(RAW_UNPACK_DIR)
1272- RAW_UNPACK_DIR = None
1273-atexit.register(cleanup_unpack)
1274+
1275+from clickreviews.common import(
1276+ Review,
1277+ ReviewException,
1278+ error,
1279+ open_file_read,
1280+)
1281
1282
1283 #
1284 # Utility classes
1285 #
1286-class ClickReviewException(Exception):
1287+class ClickReviewException(ReviewException):
1288 '''This class represents ClickReview exceptions'''
1289- def __init__(self, value):
1290- self.value = value
1291-
1292- def __str__(self):
1293- return repr(self.value)
1294-
1295-
1296-class ClickReview(object):
1297+
1298+
1299+class ClickReview(Review):
1300 '''This class represents click reviews'''
1301 # Convenience to break out common types of clicks (eg, app, scope,
1302 # click service)
1303@@ -124,8 +101,13 @@
1304
1305 def __init__(self, fn, review_type, peer_hooks=None, overrides=None,
1306 peer_hooks_link=None):
1307- self.pkg_filename = fn
1308- self._check_path_exists()
1309+ Review.__init__(self, fn, review_type, overrides=overrides)
1310+
1311+ # The cr_* scripts only support 15.04 snaps (v1). Use sr_* scripts for
1312+ # 16.04 (v2) or higher
1313+ if not self.is_click and not self.is_snap1:
1314+ return
1315+
1316 if not self.pkg_filename.endswith(".click") and \
1317 not self.pkg_filename.endswith(".snap"):
1318 if self.pkg_filename.endswith(".deb"):
1319@@ -134,67 +116,24 @@
1320 "how click packages are different.")
1321 error("filename does not end with '.click'")
1322
1323- self.review_type = review_type
1324- self.click_report = dict()
1325-
1326- self.result_types = ['info', 'warn', 'error']
1327- for r in self.result_types:
1328- self.click_report[r] = dict()
1329-
1330- self.click_report_output = "json"
1331-
1332- global UNPACK_DIR
1333- if UNPACK_DIR is None:
1334- UNPACK_DIR = unpack_click(fn)
1335- self.unpack_dir = UNPACK_DIR
1336-
1337- global RAW_UNPACK_DIR
1338- if RAW_UNPACK_DIR is None:
1339- RAW_UNPACK_DIR = raw_unpack_pkg(fn)
1340- self.raw_unpack_dir = RAW_UNPACK_DIR
1341-
1342- self.pkgfmt = {"type": "", "version": ""}
1343 self.manifest = None
1344 self.click_pkgname = None
1345 self.click_version = None
1346 self.pkg_arch = []
1347-
1348- # Parse and store the package.yaml, if it exists
1349- pkg_yaml = self._extract_package_yaml()
1350- snap_yaml = self._extract_snap_yaml()
1351- self.is_snap = False
1352- if pkg_yaml is None and snap_yaml is None:
1353- self.pkgfmt["type"] = "click"
1354- else:
1355- self.pkgfmt["type"] = "snap"
1356- # Some day we will be able to introspect the version, but not
1357- # today.... For now, decide on if it is a squashfs and if so,
1358- # assume it is 16.04
1359- if is_squashfs(fn):
1360- self.pkgfmt["version"] = "16.04"
1361- self.peer_hooks = None
1362- self.peer_hooks_link = None
1363- else:
1364- self.pkgfmt["version"] = "15.04"
1365-
1366- if snap_yaml:
1367- try:
1368- self.snap_yaml = yaml.safe_load(snap_yaml)
1369- except Exception:
1370- error("Could not load snap.yaml. Is it properly formatted?")
1371- # convert enough of snap_yaml too pkg.yaml to make
1372- # the basics of the review tools
1373- if self.snap_yaml:
1374- self.pkg_yaml = self.snap_yaml
1375- self.pkg_yaml["version"] = str(self.snap_yaml["version"])
1376-
1377+ self.is_snap_oem = False
1378+ self.peer_hooks = peer_hooks
1379+ self.peer_hooks_link = peer_hooks_link
1380+
1381+ if self.is_snap1:
1382+ pkg_yaml = self._extract_package_yaml()
1383 if pkg_yaml:
1384 try:
1385 self.pkg_yaml = yaml.safe_load(pkg_yaml)
1386 except Exception:
1387 error("Could not load package.yaml. Is it properly formatted?")
1388 self._verify_package_yaml_structure()
1389- self.is_snap = True
1390+ else:
1391+ error("Could not load package.yaml.")
1392
1393 # default to 'app'
1394 if 'type' not in self.pkg_yaml:
1395@@ -212,7 +151,10 @@
1396 else:
1397 self.pkg_arch = ['all']
1398
1399- if self._pkgfmt_type() == "click" or self._pkgfmt_version() == "15.04":
1400+ if 'type' in self.pkg_yaml and self.pkg_yaml['type'] == 'oem':
1401+ self.is_snap_oem = True
1402+
1403+ if self.is_click or self.is_snap1:
1404 # Get some basic information from the control file
1405 control_file = self._extract_control_file()
1406 tmp = list(Deb822.iter_paragraphs(control_file))
1407@@ -221,7 +163,7 @@
1408 control = tmp[0]
1409 self.click_pkgname = control['Package']
1410 self.click_version = control['Version']
1411- if self._pkgfmt_type() == "click":
1412+ if self.is_click:
1413 if control['Architecture'] not in self.pkg_arch:
1414 self.pkg_arch.append(control['Architecture'])
1415 self.pkgfmt["version"] = str(control['Click-Version'])
1416@@ -236,33 +178,6 @@
1417
1418 self.valid_frameworks = self._extract_click_frameworks()
1419
1420- self.peer_hooks = peer_hooks
1421- self.peer_hooks_link = peer_hooks_link
1422-
1423- self.is_snap_oem = False
1424- if self.is_snap and 'type' in self.pkg_yaml and \
1425- self.pkg_yaml['type'] == 'oem':
1426- self.is_snap_oem = True
1427-
1428- self.is_snap_gadget = False
1429- if self.is_snap and 'type' in self.pkg_yaml and \
1430- self.pkg_yaml['type'] == 'gadget':
1431- self.is_snap_gadget = True
1432-
1433- # Get a list of all unpacked files, except DEBIAN/
1434- self.pkg_files = []
1435- self._list_all_files()
1436-
1437- # Setup what is needed to get a list of all unpacked compiled binaries
1438- self.mime = magic.open(magic.MAGIC_MIME)
1439- self.mime.load()
1440- self.pkg_bin_files = []
1441- # Don't run this here since only cr_lint.py and cr_functional.py need
1442- # it now
1443- # self._list_all_compiled_binaries()
1444-
1445- self.overrides = overrides if overrides is not None else {}
1446-
1447 def _extract_click_frameworks(self):
1448 '''Extract installed click frameworks'''
1449 # TODO: update to use libclick API when available
1450@@ -291,78 +206,16 @@
1451 return None # snappy packaging is still optional
1452 return open_file_read(y)
1453
1454- def _extract_snap_yaml(self):
1455- '''Extract and read the snappy 16.04 snap.yaml'''
1456- y = os.path.join(self.unpack_dir, "meta/snap.yaml")
1457- if not os.path.isfile(y):
1458- return None # snappy packaging is still optional
1459- return open_file_read(y)
1460-
1461 def _extract_hashes_yaml(self):
1462 '''Extract and read the snappy hashes.yaml'''
1463 y = os.path.join(self.unpack_dir, "DEBIAN/hashes.yaml")
1464 return open_file_read(y)
1465
1466- def _extract_statinfo(self, fn):
1467- '''Extract statinfo from file'''
1468- try:
1469- st = os.stat(fn)
1470- except Exception:
1471- return None
1472- return st
1473-
1474- def _path_join(self, dirname, rest):
1475- return os.path.join(dirname, rest)
1476-
1477- def _get_sha512sum(self, fn):
1478- '''Get sha512sum of file'''
1479- (rc, out) = cmd(['sha512sum', fn])
1480- if rc != 0:
1481- return None
1482- return out.split()[0]
1483-
1484- def _pkgfmt_type(self):
1485- '''Return the package format type'''
1486- if "type" not in self.pkgfmt:
1487- return ""
1488- return self.pkgfmt["type"]
1489-
1490- def _pkgfmt_version(self):
1491- '''Return the package format version'''
1492- if "version" not in self.pkgfmt:
1493- return ""
1494- return self.pkgfmt["version"]
1495-
1496- def _check_path_exists(self):
1497- '''Check that the provided path exists'''
1498- if not os.path.exists(self.pkg_filename):
1499- error("Could not find '%s'" % self.pkg_filename)
1500-
1501 def _extract_control_file(self):
1502 '''Extract '''
1503 fh = open_file_read(os.path.join(self.unpack_dir, "DEBIAN/control"))
1504 return fh.readlines()
1505
1506- def _list_all_files(self):
1507- '''List all files included in this click package.'''
1508- for root, dirnames, filenames in os.walk(self.unpack_dir):
1509- for f in filenames:
1510- self.pkg_files.append(os.path.join(root, f))
1511-
1512- def _check_if_message_catalog(self, fn):
1513- '''Check if file is a message catalog (.mo file).'''
1514- if fn.endswith('.mo'):
1515- return True
1516- return False
1517-
1518- def _list_all_compiled_binaries(self):
1519- '''List all compiled binaries in this click package.'''
1520- for i in self.pkg_files:
1521- res = self.mime.file(i)
1522- if res in self.magic_binary_file_descriptions and \
1523- not self._check_if_message_catalog(i):
1524- self.pkg_bin_files.append(i)
1525-
1526 def _verify_manifest_structure(self):
1527 '''Verify manifest has the expected structure'''
1528 # lp:click doc/file-format.rst
1529@@ -506,7 +359,7 @@
1530
1531 def _verify_pkgname(self, n):
1532 '''Verify package name'''
1533- if self.is_snap:
1534+ if self.is_snap1:
1535 # snaps can't have '.' in the name
1536 pat = re.compile(r'^[a-z0-9][a-z0-9+-]+$')
1537 else:
1538@@ -515,15 +368,6 @@
1539 return True
1540 return False
1541
1542- def _verify_pkgversion(self, v):
1543- '''Verify package name'''
1544- re_valid_version = re.compile(r'^((\d+):)?' # epoch
1545- '([A-Za-z0-9.+:~-]+?)' # upstream
1546- '(-([A-Za-z0-9+.~]+))?$') # debian
1547- if re_valid_version.match(v):
1548- return True
1549- return False
1550-
1551 def _verify_maintainer(self, m):
1552 '''Verify maintainer email'''
1553 # Simple regex as used by python3-debian. If we wanted to be more
1554@@ -550,7 +394,7 @@
1555 def check_peer_hooks(self, hooks_sublist=[]):
1556 '''Check if peer hooks are valid'''
1557 # Nothing to verify
1558- if self.peer_hooks is None:
1559+ if not hasattr(self, 'peer_hooks') or self.peer_hooks is None:
1560 return
1561
1562 for hook in self.peer_hooks:
1563@@ -584,280 +428,3 @@
1564 link=self.peer_hooks_link)
1565 else:
1566 self._add_result(t, n, s)
1567-
1568- def set_review_type(self, name):
1569- '''Set review name'''
1570- self.review_type = name
1571-
1572- def _get_check_name(self, name, app='', extra=''):
1573- name = ':'.join([self.review_type, name])
1574- if app:
1575- name += ':' + app
1576- if extra:
1577- name += ':' + extra
1578- return name
1579-
1580- # click_report[<result_type>][<review_name>] = <result>
1581- # result_type: info, warn, error
1582- # review_name: name of the check (prefixed with self.review_type)
1583- # result: contents of the review
1584- def _add_result(self, result_type, review_name, result, link=None,
1585- manual_review=False):
1586- '''Add result to report'''
1587- if result_type not in self.result_types:
1588- error("Invalid result type '%s'" % result_type)
1589-
1590- if review_name not in self.click_report[result_type]:
1591- # log info about check so it can be collected into the
1592- # check-names.list file
1593- # format should be
1594- # CHECK|<review_type:check_name>|<link>
1595- msg = 'CHECK|{}|{}'
1596- name = ':'.join(review_name.split(':')[:2])
1597- link_text = link if link is not None else ""
1598- logging.debug(msg.format(name, link_text))
1599- self.click_report[result_type][review_name] = dict()
1600-
1601- self.click_report[result_type][review_name].update({
1602- 'text': result,
1603- 'manual_review': manual_review,
1604- })
1605- if link is not None:
1606- self.click_report[result_type][review_name]["link"] = link
1607-
1608- def do_report(self):
1609- '''Print report'''
1610- if self.click_report_output == "console":
1611- # TODO: format better
1612- import pprint
1613- pprint.pprint(self.click_report)
1614- elif self.click_report_output == "json":
1615- import json
1616- msg(json.dumps(self.click_report,
1617- sort_keys=True,
1618- indent=2,
1619- separators=(',', ': ')))
1620-
1621- rc = 0
1622- if len(self.click_report['error']):
1623- rc = 2
1624- elif len(self.click_report['warn']):
1625- rc = 1
1626- return rc
1627-
1628- def do_checks(self):
1629- '''Run all methods that start with check_'''
1630- methodList = [name for name, member in
1631- inspect.getmembers(self, inspect.ismethod)
1632- if isinstance(member, types.MethodType)]
1633- for methodname in methodList:
1634- if not methodname.startswith("check_"):
1635- continue
1636- func = getattr(self, methodname)
1637- func()
1638-
1639-
1640-#
1641-# Utility functions
1642-#
1643-def error(out, exit_code=1, do_exit=True):
1644- '''Print error message and exit'''
1645- try:
1646- print("ERROR: %s" % (out), file=sys.stderr)
1647- except IOError:
1648- pass
1649-
1650- if do_exit:
1651- sys.exit(exit_code)
1652-
1653-
1654-def warn(out):
1655- '''Print warning message'''
1656- try:
1657- print("WARN: %s" % (out), file=sys.stderr)
1658- except IOError:
1659- pass
1660-
1661-
1662-def msg(out, output=sys.stdout):
1663- '''Print message'''
1664- try:
1665- print("%s" % (out), file=output)
1666- except IOError:
1667- pass
1668-
1669-
1670-def debug(out):
1671- '''Print debug message'''
1672- global DEBUGGING
1673- if DEBUGGING:
1674- try:
1675- print("DEBUG: %s" % (out), file=sys.stderr)
1676- except IOError:
1677- pass
1678-
1679-
1680-def cmd(command):
1681- '''Try to execute the given command.'''
1682- debug(command)
1683- try:
1684- sp = subprocess.Popen(command, stdout=subprocess.PIPE,
1685- stderr=subprocess.STDOUT)
1686- except OSError as ex:
1687- return [127, str(ex)]
1688-
1689- if sys.version_info[0] >= 3:
1690- out = sp.communicate()[0].decode('ascii', 'ignore')
1691- else:
1692- out = sp.communicate()[0]
1693-
1694- return [sp.returncode, out]
1695-
1696-
1697-def cmd_pipe(command1, command2):
1698- '''Try to pipe command1 into command2.'''
1699- try:
1700- sp1 = subprocess.Popen(command1, stdout=subprocess.PIPE)
1701- sp2 = subprocess.Popen(command2, stdin=sp1.stdout)
1702- except OSError as ex:
1703- return [127, str(ex)]
1704-
1705- if sys.version_info[0] >= 3:
1706- out = sp2.communicate()[0].decode('ascii', 'ignore')
1707- else:
1708- out = sp2.communicate()[0]
1709-
1710- return [sp2.returncode, out]
1711-
1712-
1713-def _unpack_cmd(cmd_args, d, dest):
1714- '''Low level unpack helper'''
1715- curdir = os.getcwd()
1716- os.chdir(d)
1717-
1718- (rc, out) = cmd(cmd_args)
1719- os.chdir(curdir)
1720-
1721- if rc != 0:
1722- if os.path.isdir(d):
1723- recursive_rm(d)
1724- error("unpacking failed with '%d':\n%s" % (rc, out))
1725-
1726- if dest is None:
1727- dest = d
1728- else:
1729- shutil.move(d, dest)
1730-
1731- return dest
1732-
1733-
1734-def _unpack_snap_squashfs(snap_pkg, dest):
1735- '''Unpack a squashfs based snap package to dest'''
1736- d = tempfile.mkdtemp(prefix='clickreview-')
1737- return _unpack_cmd(['unsquashfs', '-f', '-d', d,
1738- os.path.abspath(snap_pkg)], d, dest)
1739-
1740-
1741-def _unpack_click_deb(click_pkg, dest):
1742- d = tempfile.mkdtemp(prefix='clickreview-')
1743- return _unpack_cmd(['dpkg-deb', '-R',
1744- os.path.abspath(click_pkg), d], d, dest)
1745-
1746-
1747-def unpack_click(fn, dest=None):
1748- '''Unpack click package'''
1749- if not os.path.isfile(fn):
1750- error("Could not find '%s'" % fn)
1751- click_pkg = fn
1752- if not click_pkg.startswith('/'):
1753- click_pkg = os.path.abspath(click_pkg)
1754-
1755- if dest is not None and os.path.exists(dest):
1756- error("'%s' exists. Aborting." % dest)
1757-
1758- # check if its a squashfs based snap
1759- if is_squashfs(click_pkg):
1760- return _unpack_snap_squashfs(fn, dest)
1761-
1762- return _unpack_click_deb(fn, dest)
1763-
1764-
1765-def is_squashfs(filename):
1766- '''Return true if the given filename as a squashfs header'''
1767- with open(filename, 'rb') as f:
1768- header = f.read(10)
1769- return header.startswith(b"hsqs")
1770-
1771-
1772-def raw_unpack_pkg(fn, dest=None):
1773- '''Unpack raw package'''
1774- if not os.path.isfile(fn):
1775- error("Could not find '%s'" % fn)
1776- pkg = fn
1777- if not pkg.startswith('/'):
1778- pkg = os.path.abspath(pkg)
1779- # nothing to do for squashfs images
1780- if is_squashfs(pkg):
1781- return ""
1782-
1783- if dest is not None and os.path.exists(dest):
1784- error("'%s' exists. Aborting." % dest)
1785-
1786- d = tempfile.mkdtemp(prefix='review-')
1787-
1788- curdir = os.getcwd()
1789- os.chdir(d)
1790- (rc, out) = cmd(['ar', 'x', pkg])
1791- os.chdir(curdir)
1792-
1793- if rc != 0:
1794- if os.path.isdir(d):
1795- recursive_rm(d)
1796- error("'ar x' failed with '%d':\n%s" % (rc, out))
1797-
1798- if dest is None:
1799- dest = d
1800- else:
1801- shutil.move(d, dest)
1802-
1803- return dest
1804-
1805-
1806-def open_file_read(path):
1807- '''Open specified file read-only'''
1808- try:
1809- orig = codecs.open(path, 'r', "UTF-8")
1810- except Exception:
1811- raise
1812-
1813- return orig
1814-
1815-
1816-def recursive_rm(dirPath, contents_only=False):
1817- '''recursively remove directory'''
1818- names = os.listdir(dirPath)
1819- for name in names:
1820- path = os.path.join(dirPath, name)
1821- if os.path.islink(path) or not os.path.isdir(path):
1822- os.unlink(path)
1823- else:
1824- recursive_rm(path)
1825- if contents_only is False:
1826- os.rmdir(dirPath)
1827-
1828-
1829-def run_click_check(cls):
1830- if len(sys.argv) < 2:
1831- error("Must give path to click package")
1832-
1833- # extract args
1834- fn = sys.argv[1]
1835- if len(sys.argv) > 2:
1836- overrides = json.loads(sys.argv[2])
1837- else:
1838- overrides = None
1839-
1840- review = cls(fn, overrides=overrides)
1841- review.do_checks()
1842- rc = review.do_report()
1843- sys.exit(rc)
1844
1845=== modified file 'clickreviews/cr_content_hub.py'
1846--- clickreviews/cr_content_hub.py 2015-11-13 23:21:27 +0000
1847+++ clickreviews/cr_content_hub.py 2016-02-10 19:30:47 +0000
1848@@ -32,6 +32,8 @@
1849
1850 ClickReview.__init__(self, fn, "content_hub", peer_hooks=peer_hooks,
1851 overrides=overrides)
1852+ if not self.is_click and not self.is_snap1:
1853+ return
1854
1855 self.valid_keys = ['destination', 'share', 'source']
1856
1857@@ -79,6 +81,9 @@
1858
1859 def check_valid(self):
1860 '''Check validity of content-hub entries'''
1861+ if not self.is_click and not self.is_snap1:
1862+ return
1863+
1864 for app in sorted(self.content_hub):
1865 for k in self.content_hub[app].keys():
1866 t = "info"
1867@@ -109,6 +114,9 @@
1868
1869 def check_unknown_keys(self):
1870 '''Check unknown'''
1871+ if not self.is_click and not self.is_snap1:
1872+ return
1873+
1874 for app in sorted(self.content_hub):
1875 unknown = []
1876 t = "info"
1877
1878=== modified file 'clickreviews/cr_desktop.py'
1879--- clickreviews/cr_desktop.py 2015-11-14 00:08:32 +0000
1880+++ clickreviews/cr_desktop.py 2016-02-10 19:30:47 +0000
1881@@ -37,6 +37,8 @@
1882
1883 ClickReview.__init__(self, fn, "desktop", peer_hooks=peer_hooks,
1884 overrides=overrides)
1885+ if not self.is_click and not self.is_snap1:
1886+ return
1887
1888 self.desktop_files = dict() # click-show-files and a couple tests
1889 self.desktop_entries = dict()
1890@@ -113,6 +115,9 @@
1891
1892 def check_desktop_file(self):
1893 '''Check desktop file'''
1894+ if not self.is_click and not self.is_snap1:
1895+ return
1896+
1897 t = 'info'
1898 n = self._get_check_name('files_usable')
1899 s = 'OK'
1900@@ -125,6 +130,9 @@
1901
1902 def check_desktop_file_valid(self):
1903 '''Check desktop file validates'''
1904+ if not self.is_click and not self.is_snap1:
1905+ return
1906+
1907 for app in sorted(self.desktop_entries):
1908 de = self._get_desktop_entry(app)
1909 t = 'info'
1910@@ -141,6 +149,9 @@
1911
1912 def check_desktop_required_keys(self):
1913 '''Check for required keys'''
1914+ if not self.is_click and not self.is_snap1:
1915+ return
1916+
1917 for app in sorted(self.desktop_entries):
1918 de = self._get_desktop_entry(app)
1919 t = 'info'
1920@@ -169,6 +180,9 @@
1921
1922 def check_desktop_blacklisted_keys(self):
1923 '''Check for blacklisted keys'''
1924+ if not self.is_click and not self.is_snap1:
1925+ return
1926+
1927 for app in sorted(self.desktop_entries):
1928 de = self._get_desktop_entry(app)
1929 t = 'info'
1930@@ -185,6 +199,9 @@
1931
1932 def check_desktop_exec(self):
1933 '''Check Exec entry'''
1934+ if not self.is_click and not self.is_snap1:
1935+ return
1936+
1937 for app in sorted(self.desktop_entries):
1938 de = self._get_desktop_entry(app)
1939 t = 'info'
1940@@ -218,6 +235,9 @@
1941
1942 def check_desktop_exec_webapp_container(self):
1943 '''Check Exec=webapp-container entry'''
1944+ if not self.is_click and not self.is_snap1:
1945+ return
1946+
1947 if self.manifest is None:
1948 return
1949
1950@@ -272,6 +292,9 @@
1951
1952 def check_desktop_exec_webbrowser(self):
1953 '''Check Exec=webbrowser-app entry'''
1954+ if not self.is_click and not self.is_snap1:
1955+ return
1956+
1957 for app in sorted(self.desktop_entries):
1958 de = self._get_desktop_entry(app)
1959 t = 'info'
1960@@ -307,6 +330,9 @@
1961
1962 def check_desktop_exec_webapp_args(self):
1963 '''Check Exec=web* args'''
1964+ if not self.is_click and not self.is_snap1:
1965+ return
1966+
1967 for app in sorted(self.desktop_entries):
1968 de = self._get_desktop_entry(app)
1969 t = 'info'
1970@@ -475,6 +501,9 @@
1971
1972 def check_desktop_exec_webbrowser_urlpatterns(self):
1973 '''Check Exec=webbrowser-app entry has valid --webappUrlPatterns'''
1974+ if not self.is_click and not self.is_snap1:
1975+ return
1976+
1977 for app in sorted(self.desktop_entries):
1978 de = self._get_desktop_entry(app)
1979 execline = de.getExec().split()
1980@@ -532,6 +561,9 @@
1981
1982 def check_desktop_exec_webbrowser_modelsearchpath(self):
1983 '''Check Exec=webbrowser-app entry has valid --webappModelSearchPath'''
1984+ if not self.is_click and not self.is_snap1:
1985+ return
1986+
1987 for app in sorted(self.desktop_entries):
1988 de = self._get_desktop_entry(app)
1989 execline = de.getExec().split()
1990@@ -637,6 +669,9 @@
1991
1992 def check_desktop_groups(self):
1993 '''Check Desktop Entry entry'''
1994+ if not self.is_click and not self.is_snap1:
1995+ return
1996+
1997 for app in sorted(self.desktop_entries):
1998 de = self._get_desktop_entry(app)
1999 t = 'info'
2000@@ -652,6 +687,9 @@
2001
2002 def check_desktop_type(self):
2003 '''Check Type entry'''
2004+ if not self.is_click and not self.is_snap1:
2005+ return
2006+
2007 for app in sorted(self.desktop_entries):
2008 de = self._get_desktop_entry(app)
2009 t = 'info'
2010@@ -667,6 +705,9 @@
2011
2012 def check_desktop_x_ubuntu_touch(self):
2013 '''Check X-Ubuntu-Touch entry'''
2014+ if not self.is_click and not self.is_snap1:
2015+ return
2016+
2017 for app in sorted(self.desktop_entries):
2018 de = self._get_desktop_entry(app)
2019 t = 'info'
2020@@ -683,6 +724,9 @@
2021
2022 def check_desktop_x_ubuntu_stagehint(self):
2023 '''Check X-Ubuntu-StageHint entry'''
2024+ if not self.is_click and not self.is_snap1:
2025+ return
2026+
2027 for app in sorted(self.desktop_entries):
2028 de = self._get_desktop_entry(app)
2029 t = 'info'
2030@@ -700,6 +744,9 @@
2031
2032 def check_desktop_x_ubuntu_gettext_domain(self):
2033 '''Check X-Ubuntu-Gettext-Domain entry'''
2034+ if not self.is_click and not self.is_snap1:
2035+ return
2036+
2037 for app in sorted(self.desktop_entries):
2038 de = self._get_desktop_entry(app)
2039 t = 'info'
2040@@ -722,6 +769,9 @@
2041
2042 def check_desktop_terminal(self):
2043 '''Check Terminal entry'''
2044+ if not self.is_click and not self.is_snap1:
2045+ return
2046+
2047 for app in sorted(self.desktop_entries):
2048 de = self._get_desktop_entry(app)
2049 t = 'info'
2050@@ -736,6 +786,9 @@
2051
2052 def check_desktop_version(self):
2053 '''Check Version entry'''
2054+ if not self.is_click and not self.is_snap1:
2055+ return
2056+
2057 for app in sorted(self.desktop_entries):
2058 de = self._get_desktop_entry(app)
2059 t = 'info'
2060@@ -754,6 +807,9 @@
2061
2062 def check_desktop_comment(self):
2063 '''Check Comment entry'''
2064+ if not self.is_click and not self.is_snap1:
2065+ return
2066+
2067 for app in sorted(self.desktop_entries):
2068 de = self._get_desktop_entry(app)
2069 t = 'info'
2070@@ -769,6 +825,8 @@
2071
2072 def check_desktop_icon(self):
2073 '''Check Icon entry'''
2074+ if not self.is_click and not self.is_snap1:
2075+ return
2076
2077 ICON_SUFFIXES = ['.svg',
2078 '.png',
2079@@ -805,6 +863,9 @@
2080
2081 def check_desktop_duplicate_entries(self):
2082 '''Check desktop for duplicate entries'''
2083+ if not self.is_click and not self.is_snap1:
2084+ return
2085+
2086 for app in sorted(self.desktop_entries):
2087 found = []
2088 dupes = []
2089
2090=== modified file 'clickreviews/cr_framework.py'
2091--- clickreviews/cr_framework.py 2015-11-13 23:21:27 +0000
2092+++ clickreviews/cr_framework.py 2016-02-10 19:30:47 +0000
2093@@ -30,6 +30,9 @@
2094 self.frameworks_file = dict()
2095 self.frameworks = dict()
2096
2097+ if not self.is_snap1:
2098+ return
2099+
2100 if self.manifest is not None:
2101 for app in self.manifest['hooks']:
2102 if 'framework' not in self.manifest['hooks'][app]:
2103@@ -98,7 +101,7 @@
2104
2105 def _has_framework_in_metadir(self):
2106 '''Check if snap has meta/<name>.framework'''
2107- if not self.is_snap:
2108+ if not self.is_snap1:
2109 return False
2110
2111 return os.path.exists(os.path.join(self.unpack_dir, 'meta',
2112@@ -107,6 +110,9 @@
2113
2114 def check_framework_hook_obsolete(self):
2115 '''Check manifest doesn't specify 'framework' hook'''
2116+ if not self.is_snap1:
2117+ return
2118+
2119 t = 'info'
2120 n = self._get_check_name("obsolete_declaration")
2121 s = "OK"
2122@@ -118,7 +124,7 @@
2123
2124 def check_snappy_framework_file_obsolete(self):
2125 '''Check snap doesn't ship .framework file'''
2126- if not self.is_snap or self.pkg_yaml['type'] != 'framework':
2127+ if not self.is_snap1 or self.pkg_yaml['type'] != 'framework':
2128 return
2129 t = 'info'
2130 n = self._get_check_name("obsolete_framework_file")
2131@@ -130,7 +136,7 @@
2132
2133 def check_snappy_framework_depends(self):
2134 '''Check framework doesn't depend on other frameworks'''
2135- if not self.is_snap or self.pkg_yaml['type'] != 'framework':
2136+ if not self.is_snap1 or self.pkg_yaml['type'] != 'framework':
2137 return
2138 t = 'info'
2139 n = self._get_check_name("dependency")
2140@@ -142,7 +148,7 @@
2141
2142 def check_snappy_framework_policy(self):
2143 '''Check framework ships at least some policy'''
2144- if not self.is_snap or self.pkg_yaml['type'] != 'framework':
2145+ if not self.is_snap1 or self.pkg_yaml['type'] != 'framework':
2146 return
2147
2148 t = 'info'
2149@@ -173,7 +179,7 @@
2150
2151 def check_snappy_framework_policy_metadata(self):
2152 '''Check framework policy has expected meta data'''
2153- if not self.is_snap or self.pkg_yaml['type'] != 'framework':
2154+ if not self.is_snap1 or self.pkg_yaml['type'] != 'framework':
2155 return
2156
2157 t = 'info'
2158@@ -201,7 +207,7 @@
2159
2160 def check_snappy_framework_policy_matching(self):
2161 '''Check framework policy ships apparmor and seccomp for each'''
2162- if not self.is_snap or self.pkg_yaml['type'] != 'framework':
2163+ if not self.is_snap1 or self.pkg_yaml['type'] != 'framework':
2164 return
2165
2166 t = 'info'
2167@@ -231,7 +237,7 @@
2168
2169 def check_snappy_framework_policy_filenames(self):
2170 '''Check framework policy file names'''
2171- if not self.is_snap or self.pkg_yaml['type'] != 'framework':
2172+ if not self.is_snap1 or self.pkg_yaml['type'] != 'framework':
2173 return
2174
2175 for i in self.framework_policy:
2176
2177=== modified file 'clickreviews/cr_functional.py'
2178--- clickreviews/cr_functional.py 2015-11-20 17:31:36 +0000
2179+++ clickreviews/cr_functional.py 2016-02-10 19:30:47 +0000
2180@@ -29,6 +29,8 @@
2181 '''This class represents click lint reviews'''
2182 def __init__(self, fn, overrides=None):
2183 ClickReview.__init__(self, fn, "functional", overrides=overrides)
2184+ if not self.is_click and not self.is_snap1:
2185+ return
2186
2187 self.qml_files = []
2188 for i in self.pkg_files:
2189@@ -39,6 +41,9 @@
2190
2191 def check_applicationName(self):
2192 '''Check applicationName matches click manifest'''
2193+ if not self.is_click and not self.is_snap1:
2194+ return
2195+
2196 if self.manifest is None:
2197 return
2198
2199@@ -120,6 +125,9 @@
2200
2201 def check_qtwebkit(self):
2202 '''Check that QML applications don't use QtWebKit'''
2203+ if not self.is_click and not self.is_snap1:
2204+ return
2205+
2206 t = 'info'
2207 n = self._get_check_name('qml_application_uses_QtWebKit')
2208 s = "OK"
2209@@ -169,6 +177,9 @@
2210
2211 def check_friends(self):
2212 '''Check that QML applications don't use deprecated Friends API'''
2213+ if not self.is_click and not self.is_snap1:
2214+ return
2215+
2216 t = 'info'
2217 n = self._get_check_name('qml_application_uses_friends')
2218 s = "OK"
2219
2220=== modified file 'clickreviews/cr_lint.py'
2221--- clickreviews/cr_lint.py 2016-02-01 19:12:30 +0000
2222+++ clickreviews/cr_lint.py 2016-02-10 19:30:47 +0000
2223@@ -26,12 +26,15 @@
2224 from clickreviews.frameworks import Frameworks
2225 from clickreviews.cr_common import (
2226 ClickReview,
2227+)
2228+
2229+from clickreviews.common import (
2230 open_file_read,
2231 cmd,
2232 error,
2233- is_squashfs,
2234 )
2235
2236+
2237 CONTROL_FILE_NAMES = ["control", "manifest", "preinst"]
2238 MINIMUM_CLICK_FRAMEWORK_VERSION = "0.4"
2239
2240@@ -42,9 +45,12 @@
2241 def __init__(self, fn, overrides=None):
2242 '''Set up the class.'''
2243 ClickReview.__init__(self, fn, "lint", overrides=overrides)
2244- if not self.is_snap and "md5sums" not in CONTROL_FILE_NAMES:
2245+ if not self.is_click and not self.is_snap1:
2246+ return
2247+
2248+ if self.is_click and "md5sums" not in CONTROL_FILE_NAMES:
2249 CONTROL_FILE_NAMES.append("md5sums")
2250- elif self.is_snap:
2251+ elif self.is_snap1:
2252 CONTROL_FILE_NAMES.append("hashes.yaml")
2253 self.control_files = dict()
2254 self._list_control_files()
2255@@ -152,8 +158,7 @@
2256
2257 def check_control_files(self):
2258 '''Check DEBIAN/* files'''
2259- if self._pkgfmt_type() == "snap" and \
2260- float(self._pkgfmt_version()) > 15.04:
2261+ if not self.is_click and not self.is_snap1:
2262 return
2263
2264 for f in self.control_files:
2265@@ -162,7 +167,7 @@
2266 'DEBIAN_has_files', extra=os.path.basename(f))
2267 s = "OK"
2268 if not os.path.isfile(self.control_files[os.path.basename(f)]):
2269- if self.is_snap and os.path.basename(f) == 'md5sums':
2270+ if self.is_snap1 and os.path.basename(f) == 'md5sums':
2271 s = "OK (skip md5sums with snap)"
2272 else:
2273 t = 'error'
2274@@ -183,8 +188,7 @@
2275
2276 def check_control(self):
2277 '''Check control()'''
2278- if self._pkgfmt_type() == "snap" and \
2279- float(self._pkgfmt_version()) > 15.04:
2280+ if not self.is_click and not self.is_snap1:
2281 return
2282
2283 fh = self._extract_control_file()
2284@@ -213,7 +217,7 @@
2285 n = self._get_check_name('control_has_field', extra=f)
2286 s = 'OK'
2287 if f not in control:
2288- if f == 'Maintainer' and self.is_snap:
2289+ if f == 'Maintainer' and self.is_snap1:
2290 s = 'OK (maintainer not required for snappy)'
2291 else:
2292 t = 'error'
2293@@ -269,7 +273,7 @@
2294 s = 'If arch=multi, manifest architecture needs to ' + \
2295 'comprise of only compiled architectures.'
2296 elif control['Architecture'] != self.manifest['architecture'] and \
2297- not self.is_snap: # snappy doesn't use this field; ignore
2298+ not self.is_snap1: # snappy doesn't use this field; ignore
2299 t = 'error'
2300 s = "Architecture=%s " % control['Architecture'] + \
2301 "does not match manifest architecture=%s" % \
2302@@ -333,7 +337,7 @@
2303
2304 def check_md5sums(self):
2305 '''Check md5sums()'''
2306- if self.is_snap:
2307+ if not self.is_click:
2308 return
2309 curdir = os.getcwd()
2310 fh = open_file_read(self.control_files["md5sums"])
2311@@ -358,8 +362,7 @@
2312
2313 def check_preinst(self):
2314 '''Check preinst()'''
2315- if self._pkgfmt_type() == "snap" and \
2316- float(self._pkgfmt_version()) > 15.04:
2317+ if not self.is_click and not self.is_snap1:
2318 return
2319
2320 expected = '''#! /bin/sh
2321@@ -383,17 +386,13 @@
2322
2323 def check_hooks(self):
2324 '''Check click manifest hooks'''
2325- if self._pkgfmt_type() == "snap" and \
2326- float(self._pkgfmt_version()) > 15.04:
2327+ if not self.is_click and not self.is_snap1:
2328 return
2329
2330 # oem snaps don't have a hooks entry
2331 if self.is_snap_oem:
2332 return
2333
2334- if self.is_snap_gadget:
2335- return
2336-
2337 # Some checks are already handled in
2338 # cr_common.py:_verify_manifest_structure()
2339
2340@@ -486,17 +485,13 @@
2341
2342 def check_hooks_unknown(self):
2343 '''Check if have any unknown hooks'''
2344- if self._pkgfmt_type() == "snap" and \
2345- float(self._pkgfmt_version()) > 15.04:
2346+ if not self.is_click and not self.is_snap1:
2347 return
2348
2349 # oem snaps don't have a hooks entry
2350 if self.is_snap_oem:
2351 return
2352
2353- if self.is_snap_gadget:
2354- return
2355-
2356 t = 'info'
2357 n = self._get_check_name('unknown_hooks')
2358 s = 'OK'
2359@@ -514,8 +509,7 @@
2360
2361 def check_hooks_redflagged(self):
2362 '''Check if have any redflagged hooks'''
2363- if self._pkgfmt_type() == "snap" and \
2364- float(self._pkgfmt_version()) > 15.04:
2365+ if not self.is_click and not self.is_snap1:
2366 return
2367
2368 t = 'info'
2369@@ -531,7 +525,7 @@
2370 for hook in self.manifest['hooks'][app]:
2371 if hook in self.redflagged_hooks:
2372 # This check is handled elsewhere
2373- if self.is_snap and hook == "apparmor-profile":
2374+ if self.is_snap1 and hook == "apparmor-profile":
2375 continue
2376 found.append(hook)
2377 if len(found) > 0:
2378@@ -542,7 +536,9 @@
2379
2380 def check_external_symlinks(self):
2381 '''Check if symlinks in the click package go out to the system.'''
2382- if self.is_snap and self.pkg_yaml['type'] not in ['app', 'framework']:
2383+ if not self.is_click and not self.is_snap1:
2384+ return
2385+ if self.is_snap1 and self.pkg_yaml['type'] not in ['app', 'framework']:
2386 return
2387
2388 t = 'info'
2389@@ -601,7 +597,7 @@
2390
2391 def check_pkgname(self):
2392 '''Check click package name valid'''
2393- if self.is_snap:
2394+ if not self.is_click:
2395 return
2396 p = self.manifest['name']
2397 # http://www.debian.org/doc/debian-policy/ch-controlfields.html
2398@@ -615,8 +611,7 @@
2399
2400 def check_version(self):
2401 '''Check click package version is valid'''
2402- if self._pkgfmt_type() == "snap" and \
2403- float(self._pkgfmt_version()) > 15.04:
2404+ if not self.is_click and not self.is_snap1:
2405 return
2406
2407 # deb-version(5)
2408@@ -634,8 +629,7 @@
2409
2410 def check_architecture(self):
2411 '''Check click package architecture in DEBIAN/control is valid'''
2412- if self._pkgfmt_type() == "snap" and \
2413- float(self._pkgfmt_version()) > 15.04:
2414+ if not self.is_click and not self.is_snap1:
2415 return
2416
2417 t = 'info'
2418@@ -648,6 +642,9 @@
2419
2420 def check_architecture_all(self):
2421 '''Check if actually architecture all'''
2422+ if not self.is_click and not self.is_snap1:
2423+ return
2424+
2425 t = 'info'
2426 n = self._get_check_name('control_architecture_valid_contents')
2427 s = 'OK'
2428@@ -667,6 +664,9 @@
2429
2430 def check_architecture_specified_needed(self):
2431 '''Check if the specified architecture is actually needed'''
2432+ if not self.is_click and not self.is_snap1:
2433+ return
2434+
2435 for arch in self.pkg_arch:
2436 t = 'info'
2437 n = self._get_check_name('architecture_specified_needed')
2438@@ -684,15 +684,14 @@
2439
2440 def check_maintainer(self):
2441 '''Check manifest maintainer()'''
2442- if self._pkgfmt_type() == "snap" and \
2443- float(self._pkgfmt_version()) > 15.04:
2444+ if not self.is_click and not self.is_snap1:
2445 return
2446
2447 t = 'info'
2448 n = self._get_check_name('maintainer_present')
2449 s = 'OK'
2450 if 'maintainer' not in self.manifest:
2451- if self.is_snap:
2452+ if self.is_snap1:
2453 s = 'Skipped optional maintainer field not specified in ' + \
2454 'manifest'
2455 else:
2456@@ -704,7 +703,7 @@
2457
2458 # Don't perform maintainer checks for snaps. They aren't used by
2459 # anything.
2460- if self.is_snap:
2461+ if self.is_snap1:
2462 return
2463
2464 # Simple regex as used by python3-debian. If we wanted to be more
2465@@ -728,8 +727,7 @@
2466
2467 def check_title(self):
2468 '''Check manifest title()'''
2469- if self._pkgfmt_type() == "snap" and \
2470- float(self._pkgfmt_version()) > 15.04:
2471+ if not self.is_click and not self.is_snap1:
2472 return
2473
2474 t = 'info'
2475@@ -752,8 +750,7 @@
2476
2477 def check_description(self):
2478 '''Check manifest description()'''
2479- if self._pkgfmt_type() == "snap" and \
2480- float(self._pkgfmt_version()) > 15.04:
2481+ if not self.is_click and not self.is_snap1:
2482 return
2483
2484 t = 'info'
2485@@ -771,8 +768,8 @@
2486 pkgname_base = self.click_pkgname.split('.')[-1]
2487 if len(self.manifest['description']) < len(pkgname_base):
2488 t = 'warn'
2489- if self.is_snap and (self.manifest['description'] == '\n' or
2490- self.manifest['description'] == ''):
2491+ if self.is_snap1 and (self.manifest['description'] == '\n' or
2492+ self.manifest['description'] == ''):
2493 s = "manifest description is empty. Is meta/readme.md " + \
2494 "formatted correctly?"
2495 else:
2496@@ -782,8 +779,7 @@
2497
2498 def check_framework(self):
2499 '''Check manifest framework()'''
2500- if self._pkgfmt_type() == "snap" and \
2501- float(self._pkgfmt_version()) > 15.04:
2502+ if not self.is_click and not self.is_snap1:
2503 return
2504
2505 n = self._get_check_name('framework')
2506@@ -791,7 +787,7 @@
2507 framework_overrides = self.overrides.get('framework', {})
2508 frameworks = Frameworks(overrides=framework_overrides)
2509
2510- if not self.is_snap and ',' in self.manifest['framework']:
2511+ if not self.is_snap1 and ',' in self.manifest['framework']:
2512 # click doesn't support multiple frameworks yet
2513 t = 'error'
2514 s = 'ERROR: multiple frameworks found in click manifest'
2515@@ -827,8 +823,7 @@
2516
2517 def check_click_local_extensions(self):
2518 '''Report any click local extensions'''
2519- if self._pkgfmt_type() == "snap" and \
2520- float(self._pkgfmt_version()) > 15.04:
2521+ if not self.is_click and not self.is_snap1:
2522 return
2523
2524 t = 'info'
2525@@ -855,6 +850,9 @@
2526
2527 def check_vcs(self):
2528 '''Check for VCS files in the package'''
2529+ if not self.is_click and not self.is_snap1:
2530+ return
2531+
2532 t = 'info'
2533 n = self._get_check_name('vcs_files')
2534 s = 'OK'
2535@@ -871,7 +869,7 @@
2536
2537 def check_click_in_package(self):
2538 '''Check for *.click files in the toplevel click package'''
2539- if self._pkgfmt_type() == "snap":
2540+ if not self.is_click:
2541 return
2542
2543 t = 'info'
2544@@ -889,8 +887,7 @@
2545
2546 def check_dot_click(self):
2547 '''Check for .click directory in the toplevel click package'''
2548- if self._pkgfmt_type() == "snap" and \
2549- float(self._pkgfmt_version()) > 15.04:
2550+ if not self.is_click and not self.is_snap1:
2551 return
2552
2553 t = 'info'
2554@@ -905,6 +902,9 @@
2555
2556 def check_contents_for_hardcoded_paths(self):
2557 '''Check for known hardcoded paths.'''
2558+ if not self.is_click and not self.is_snap1:
2559+ return
2560+
2561 PATH_BLACKLIST = ["/opt/click.ubuntu.com/"]
2562 t = 'info'
2563 n = self._get_check_name('hardcoded_paths')
2564@@ -938,14 +938,14 @@
2565 return
2566
2567 key = 'architecture'
2568- if self.is_snap and 'architectures' in my_dict:
2569+ if self.is_snap1 and 'architectures' in my_dict:
2570 # new yaml allows for 'architecture' and 'architectures'
2571 key = 'architectures'
2572
2573 archs_list = list(self.valid_control_architectures)
2574 archs_list.remove("multi")
2575
2576- if self.is_snap and key == 'architectures' and \
2577+ if self.is_snap1 and key == 'architectures' and \
2578 isinstance(my_dict[key], str):
2579 # new yaml uses 'architectures' that must be a list
2580 t = 'error'
2581@@ -954,7 +954,7 @@
2582 t = 'error'
2583 s = "not a valid architecture: %s" % my_dict[key]
2584 elif isinstance(my_dict[key], list):
2585- if not self.is_snap:
2586+ if not self.is_snap1:
2587 archs_list.remove("all")
2588 bad_archs = []
2589 for a in my_dict[key]:
2590@@ -968,8 +968,7 @@
2591
2592 def check_manifest_architecture(self):
2593 '''Check package architecture in manifest is valid'''
2594- if self._pkgfmt_type() == "snap" and \
2595- float(self._pkgfmt_version()) > 15.04:
2596+ if not self.is_click and not self.is_snap1:
2597 return
2598
2599 self._verify_architecture(self.manifest, "manifest")
2600@@ -1004,15 +1003,14 @@
2601
2602 def check_icon(self):
2603 '''Check icon()'''
2604- if self._pkgfmt_type() == "snap" and \
2605- float(self._pkgfmt_version()) > 15.04:
2606+ if not self.is_click and not self.is_snap1:
2607 return
2608
2609 self._verify_icon(self.manifest, "manifest")
2610
2611 def check_snappy_name(self):
2612 '''Check package name'''
2613- if not self.is_snap:
2614+ if self.is_click or not self.is_snap1:
2615 return
2616
2617 t = 'info'
2618@@ -1028,7 +1026,7 @@
2619
2620 def check_snappy_version(self):
2621 '''Check package version'''
2622- if not self.is_snap:
2623+ if self.is_click or not self.is_snap1:
2624 return
2625
2626 t = 'info'
2627@@ -1044,7 +1042,7 @@
2628
2629 def check_snappy_type(self):
2630 '''Check type'''
2631- if not self.is_snap:
2632+ if self.is_click or not self.is_snap1:
2633 return
2634
2635 t = 'info'
2636@@ -1059,7 +1057,7 @@
2637
2638 def check_snappy_type_redflagged(self):
2639 '''Check if snappy type is redflagged'''
2640- if not self.is_snap:
2641+ if self.is_click or not self.is_snap1:
2642 return
2643
2644 t = 'info'
2645@@ -1079,14 +1077,14 @@
2646
2647 def check_snappy_icon(self):
2648 '''Check icon()'''
2649- if not self.is_snap:
2650+ if self.is_click or not self.is_snap1:
2651 return
2652
2653 self._verify_icon(self.pkg_yaml, "package_yaml")
2654
2655 def check_snappy_architecture(self):
2656 '''Check package architecture in package.yaml is valid'''
2657- if not self.is_snap:
2658+ if self.is_click or not self.is_snap1:
2659 return
2660
2661 self._verify_architecture(self.pkg_yaml, "package yaml")
2662@@ -1104,7 +1102,7 @@
2663
2664 def check_snappy_unknown_entries(self):
2665 '''Check for any unknown fields'''
2666- if not self.is_snap:
2667+ if self.is_click or not self.is_snap1:
2668 return
2669
2670 t = 'info'
2671@@ -1136,10 +1134,7 @@
2672
2673 def check_snappy_readme_md(self):
2674 '''Check snappy readme.md'''
2675- if not self.is_snap:
2676- return
2677-
2678- if is_squashfs(self.pkg_filename):
2679+ if self.is_click or not self.is_snap1:
2680 return
2681
2682 contents = self._extract_readme_md()
2683@@ -1163,13 +1158,9 @@
2684 s = "meta/readme.md is too short"
2685 self._add_result(t, n, s)
2686
2687- def _check_innerpath_executable(self, fn):
2688- '''Check that the provided path exists and is executable'''
2689- return os.access(fn, os.X_OK)
2690-
2691 def check_snappy_config(self):
2692 '''Check snappy config'''
2693- if not self.is_snap:
2694+ if self.is_click or not self.is_snap1:
2695 return
2696
2697 fn = os.path.join(self.unpack_dir, 'meta/hooks/config')
2698@@ -1186,7 +1177,7 @@
2699
2700 def check_snappy_services_and_binaries(self):
2701 '''Services and binaries should not overlap'''
2702- if not self.is_snap:
2703+ if self.is_click or not self.is_snap1:
2704 return
2705 for exe_t in ['binaries', 'services']:
2706 if exe_t not in self.pkg_yaml:
2707@@ -1217,34 +1208,9 @@
2708 break
2709 self._add_result(t, n, s)
2710
2711- def check_is_squashfs(self):
2712- '''Check snapfs'''
2713- if is_squashfs(self.pkg_filename):
2714- t = 'error'
2715- n = self._get_check_name('is_squashfs')
2716- s = "(NEEDS REVIEW) squashfs pkg"
2717- manual_review = True
2718- self._add_result(t, n, s, manual_review=manual_review)
2719-
2720- def check_squashfs_uses_snap_yaml(self):
2721- '''Ensure that squashfs uses 16.04'''
2722- if is_squashfs(self.pkg_filename) and not getattr(self, "snap_yaml"):
2723- t = 'error'
2724- n = self._get_check_name('check_squashfs_uses_snap_yaml')
2725- s = "squashfs snaps must have a meta/snap.yaml"
2726- manual_review = False
2727- self._add_result(t, n, s, manual_review=manual_review)
2728-
2729 def check_snappy_hashes(self):
2730 '''Check snappy hashes.yaml'''
2731- if self._pkgfmt_type() == "snap" and \
2732- float(self._pkgfmt_version()) > 15.04:
2733- return
2734-
2735- if not self.is_snap:
2736- return
2737- # no hashes.yaml for squashfs images
2738- if is_squashfs(self.pkg_filename):
2739+ if self.is_click or not self.is_snap1:
2740 return
2741
2742 def _check_allowed_perms(mode, allowed):
2743
2744=== modified file 'clickreviews/cr_online_accounts.py'
2745--- clickreviews/cr_online_accounts.py 2015-12-14 22:00:37 +0000
2746+++ clickreviews/cr_online_accounts.py 2016-02-10 19:30:47 +0000
2747@@ -69,6 +69,8 @@
2748 peer_hooks=peer_hooks,
2749 overrides=overrides,
2750 peer_hooks_link="https://wiki.ubuntu.com/SecurityTeam/Specifications/OnlineAccountsConfinement")
2751+ if not self.is_click and not self.is_snap1:
2752+ return
2753
2754 self.accounts_files = dict()
2755 self.accounts = dict()
2756@@ -164,6 +166,9 @@
2757
2758 def check_hooks_versions(self):
2759 '''Check hooks versions'''
2760+ if not self.is_click and not self.is_snap1:
2761+ return
2762+
2763 if self.manifest is None:
2764 return
2765
2766@@ -247,6 +252,9 @@
2767
2768 def check_manifest(self):
2769 '''Check manifest'''
2770+ if not self.is_click and not self.is_snap1:
2771+ return
2772+
2773 for app in sorted(self.accounts.keys()):
2774 account_type = "accounts"
2775
2776@@ -278,6 +286,9 @@
2777
2778 def check_application(self):
2779 '''Check application'''
2780+ if not self.is_click and not self.is_snap1:
2781+ return
2782+
2783 for app in sorted(self.accounts.keys()):
2784 account_type = "account-application"
2785
2786@@ -325,6 +336,9 @@
2787
2788 def check_service(self):
2789 '''Check service'''
2790+ if not self.is_click and not self.is_snap1:
2791+ return
2792+
2793 for app in sorted(self.accounts.keys()):
2794 account_type = "account-service"
2795
2796@@ -366,6 +380,9 @@
2797
2798 def check_provider(self):
2799 '''Check provider'''
2800+ if not self.is_click and not self.is_snap1:
2801+ return
2802+
2803 for app in sorted(self.accounts.keys()):
2804 account_type = "account-provider"
2805
2806@@ -398,6 +415,9 @@
2807
2808 def check_qml_plugin(self):
2809 '''Check qml-plugin'''
2810+ if not self.is_click and not self.is_snap1:
2811+ return
2812+
2813 for app in sorted(self.accounts.keys()):
2814 account_type = "account-qml-plugin"
2815
2816
2817=== modified file 'clickreviews/cr_push_helper.py'
2818--- clickreviews/cr_push_helper.py 2015-11-13 23:21:27 +0000
2819+++ clickreviews/cr_push_helper.py 2016-02-10 19:30:47 +0000
2820@@ -33,6 +33,9 @@
2821 ClickReview.__init__(self, fn, "push_helper", peer_hooks=peer_hooks,
2822 overrides=overrides)
2823
2824+ if not self.is_click and not self.is_snap1:
2825+ return
2826+
2827 self.required_keys = ['exec']
2828 self.optional_keys = ['app_id']
2829
2830@@ -81,6 +84,9 @@
2831
2832 def check_valid(self):
2833 '''Check validity of push-helper entries'''
2834+ if not self.is_click and not self.is_snap1:
2835+ return
2836+
2837 for app in sorted(self.push_helper):
2838 for k in self.push_helper[app].keys():
2839 t = "info"
2840@@ -106,6 +112,9 @@
2841
2842 def check_unknown_keys(self):
2843 '''Check unknown'''
2844+ if not self.is_click and not self.is_snap1:
2845+ return
2846+
2847 for app in sorted(self.push_helper):
2848 unknown = []
2849 t = "info"
2850@@ -125,6 +134,9 @@
2851
2852 def check_hooks(self):
2853 '''Verify combinations of click hooks with the push-helper hook'''
2854+ if not self.is_click and not self.is_snap1:
2855+ return
2856+
2857 if self.manifest is None:
2858 return
2859
2860
2861=== modified file 'clickreviews/cr_scope.py'
2862--- clickreviews/cr_scope.py 2015-12-01 14:45:21 +0000
2863+++ clickreviews/cr_scope.py 2016-02-10 19:30:47 +0000
2864@@ -40,6 +40,9 @@
2865 ClickReview.__init__(self, fn, "scope", peer_hooks=peer_hooks,
2866 overrides=overrides)
2867
2868+ if not self.is_click and not self.is_snap1:
2869+ return
2870+
2871 self.scopes = dict()
2872
2873 if self.manifest is None:
2874@@ -85,6 +88,9 @@
2875
2876 def check_scope_ini(self):
2877 '''Check scope .ini file'''
2878+ if not self.is_click and not self.is_snap1:
2879+ return
2880+
2881 for app in sorted(self.scopes.keys()):
2882 t = 'info'
2883 n = self._get_check_name('ini_scope_section', app=app)
2884
2885=== modified file 'clickreviews/cr_security.py'
2886--- clickreviews/cr_security.py 2015-12-14 22:05:53 +0000
2887+++ clickreviews/cr_security.py 2016-02-10 19:30:47 +0000
2888@@ -47,6 +47,9 @@
2889 ClickReview.__init__(self, fn, "security", peer_hooks=peer_hooks,
2890 overrides=overrides)
2891
2892+ if not self.is_click and not self.is_snap1:
2893+ return
2894+
2895 # If local_copy is None, then this will check the server to see if
2896 # we are up to date. However, if we are working within the development
2897 # tree, use it unconditionally.
2898@@ -141,7 +144,7 @@
2899 self.security_profiles = dict()
2900 self.security_apps_profiles = []
2901
2902- if self.manifest is None and self.is_snap:
2903+ if self.manifest is None and self.is_snap1:
2904 for exe_t in ['services', 'binaries']:
2905 if exe_t not in self.pkg_yaml:
2906 continue
2907@@ -265,30 +268,19 @@
2908
2909 def _get_security_manifest(self, app):
2910 '''Get the security manifest for app'''
2911- if self._pkgfmt_type() == "click" or self._pkgfmt_version() == "15.04":
2912- if app not in self.manifest['hooks']:
2913- error("Could not find '%s' in click manifest" % app)
2914- elif 'apparmor' not in self.manifest['hooks'][app]:
2915- error("Could not find apparmor hook for '%s' in click manifest" %
2916- app)
2917- f = self.manifest['hooks'][app]['apparmor']
2918- m = self.security_manifests[f]
2919- else:
2920- f = app
2921- m = self.security_manifests[app]
2922+ if app not in self.manifest['hooks']:
2923+ error("Could not find '%s' in click manifest" % app)
2924+ elif 'apparmor' not in self.manifest['hooks'][app]:
2925+ error("Could not find apparmor hook for '%s' in click manifest" %
2926+ app)
2927+ f = self.manifest['hooks'][app]['apparmor']
2928+ m = self.security_manifests[f]
2929
2930 return (f, m)
2931
2932 def _extract_security_profile(self, app):
2933 '''Extract security profile'''
2934- if self._pkgfmt_type() == "click" or self._pkgfmt_version() == "15.04":
2935- rel_fn = self.manifest['hooks'][app]['apparmor-profile']
2936- else:
2937- exe_t, name = app.split('/')
2938- for item in self.pkg_yaml[exe_t]:
2939- if 'name' in item and item['name'] == name:
2940- rel_fn = item['security-policy']['apparmor']
2941- break
2942+ rel_fn = self.manifest['hooks'][app]['apparmor-profile']
2943
2944 fn = os.path.join(self.unpack_dir, rel_fn)
2945 if not os.path.exists(fn):
2946@@ -308,19 +300,12 @@
2947
2948 def _get_security_profile(self, app):
2949 '''Get the security profile for app'''
2950- if self._pkgfmt_type() == "click" or self._pkgfmt_version() == "15.04":
2951- if app not in self.manifest['hooks']:
2952- error("Could not find '%s' in click manifest" % app)
2953- elif 'apparmor-profile' not in self.manifest['hooks'][app]:
2954- error("Could not find apparmor-profile hook for '%s' in click "
2955- "manifest" % app)
2956- f = self.manifest['hooks'][app]['apparmor-profile']
2957- else:
2958- exe_t, name = app.split('/')
2959- for item in self.pkg_yaml[exe_t]:
2960- if 'name' in item and item['name'] == name:
2961- f = item['security-policy']['apparmor']
2962- break
2963+ if app not in self.manifest['hooks']:
2964+ error("Could not find '%s' in click manifest" % app)
2965+ elif 'apparmor-profile' not in self.manifest['hooks'][app]:
2966+ error("Could not find apparmor-profile hook for '%s' in click "
2967+ "manifest" % app)
2968+ f = self.manifest['hooks'][app]['apparmor-profile']
2969
2970 p = self.security_profiles[f]
2971 return (f, p)
2972@@ -394,6 +379,9 @@
2973
2974 def check_policy_vendor(self):
2975 '''Check policy_vendor'''
2976+ if not self.is_click and not self.is_snap1:
2977+ return
2978+
2979 for app in sorted(self.security_apps):
2980 (f, m) = self._get_security_manifest(app)
2981 t = 'info'
2982@@ -405,10 +393,6 @@
2983 s = "policy_vendor '%s' not found" % m['policy_vendor']
2984 self._add_result(t, n, s)
2985
2986- if self._pkgfmt_type() == "snap" and \
2987- float(self._pkgfmt_version()) >= 16.04:
2988- continue
2989-
2990 t = 'info'
2991 n = self._get_check_name('policy_vendor_matches_framework', extra=f)
2992 s = "OK"
2993@@ -418,7 +402,7 @@
2994 framework = self.manifest['framework']
2995 # snappy compat manifest supports comma-separated list
2996 # for framework
2997- if self.is_snap and ',' in framework:
2998+ if self.is_snap1 and ',' in framework:
2999 # For now, we know the release framework is appended.
3000 # TODO: fix for multiple frameworks
3001 framework = framework.split(',')[-1]
3002@@ -440,6 +424,9 @@
3003
3004 def check_policy_version(self):
3005 '''Check policy version'''
3006+ if not self.is_click and not self.is_snap1:
3007+ return
3008+
3009 for app in sorted(self.security_apps):
3010 (f, m) = self._get_security_manifest(app)
3011
3012@@ -474,10 +461,6 @@
3013 s = '%s != %s' % (str(m['policy_version']), str(highest))
3014 self._add_result(t, n, s, l)
3015
3016- if self._pkgfmt_type() == "snap" and \
3017- float(self._pkgfmt_version()) >= 16.04:
3018- continue
3019-
3020 t = 'info'
3021 n = self._get_check_name('policy_version_matches_framework', extra=f)
3022 s = "OK"
3023@@ -486,7 +469,7 @@
3024 framework = self.manifest['framework']
3025 # snappy compat manifest supports comma-separated list
3026 # for framework
3027- if self.is_snap and ',' in framework:
3028+ if self.is_snap1 and ',' in framework:
3029 # For now, we know the release framework is appended.
3030 # TODO: fix for multiple frameworks
3031 framework = framework.split(',')[-1]
3032@@ -506,6 +489,9 @@
3033
3034 def check_template(self):
3035 '''Check template'''
3036+ if not self.is_click and not self.is_snap1:
3037+ return
3038+
3039 for app in sorted(self.security_apps):
3040 (f, m) = self._get_security_manifest(app)
3041
3042@@ -556,7 +542,7 @@
3043 found = False
3044 if m['template'] in self._get_templates(vendor, version):
3045 found = True
3046- elif self.is_snap:
3047+ elif self.is_snap1:
3048 frameworks = []
3049 if 'framework' in self.pkg_yaml:
3050 frameworks = [x.strip() for x in
3051@@ -581,6 +567,9 @@
3052
3053 def check_policy_groups_webapps(self):
3054 '''Check policy_groups for webapps'''
3055+ if not self.is_click and not self.is_snap1:
3056+ return
3057+
3058 for app in sorted(self.security_apps):
3059 (f, m) = self._get_security_manifest(app)
3060 t = 'info'
3061@@ -617,6 +606,9 @@
3062
3063 def check_policy_groups_push_helpers(self):
3064 '''Check policy groups for push-helpers'''
3065+ if not self.is_click and not self.is_snap1:
3066+ return
3067+
3068 for app in sorted(self.security_apps):
3069 (f, m) = self._get_security_manifest(app)
3070 t = 'info'
3071@@ -647,6 +639,9 @@
3072
3073 def check_policy_groups_scopes(self):
3074 '''Check policy_groups for scopes'''
3075+ if not self.is_click and not self.is_snap1:
3076+ return
3077+
3078 for app in sorted(self.security_apps):
3079 (f, m) = self._get_security_manifest(app)
3080 t = 'info'
3081@@ -680,6 +675,9 @@
3082
3083 def check_policy_groups_ubuntu_account_plugin(self):
3084 '''Check policy_groups for ubuntu-account-plugin template'''
3085+ if not self.is_click and not self.is_snap1:
3086+ return
3087+
3088 for app in sorted(self.security_apps):
3089 (f, m) = self._get_security_manifest(app)
3090
3091@@ -719,6 +717,9 @@
3092
3093 def check_policy_groups(self):
3094 '''Check policy_groups'''
3095+ if not self.is_click and not self.is_snap1:
3096+ return
3097+
3098 for app in sorted(self.security_apps):
3099 (f, m) = self._get_security_manifest(app)
3100
3101@@ -762,7 +763,7 @@
3102 self._add_result(t, n, s)
3103
3104 frameworks = []
3105- if self.is_snap:
3106+ if self.is_snap1:
3107 if 'framework' in self.pkg_yaml:
3108 frameworks = [x.strip() for x in
3109 self.pkg_yaml['framework'].split(',')]
3110@@ -841,6 +842,9 @@
3111
3112 def check_ignored(self):
3113 '''Check ignored fields'''
3114+ if not self.is_click and not self.is_snap1:
3115+ return
3116+
3117 for app in sorted(self.security_apps):
3118 (f, m) = self._get_security_manifest(app)
3119
3120@@ -859,6 +863,9 @@
3121
3122 def check_redflag(self):
3123 '''Check redflag fields'''
3124+ if not self.is_click and not self.is_snap1:
3125+ return
3126+
3127 for app in sorted(self.security_apps):
3128 (f, m) = self._get_security_manifest(app)
3129
3130@@ -881,6 +888,9 @@
3131
3132 def check_required(self):
3133 '''Check required fields'''
3134+ if not self.is_click and not self.is_snap1:
3135+ return
3136+
3137 for app in sorted(self.security_apps):
3138 (f, m) = self._get_security_manifest(app)
3139
3140@@ -899,6 +909,9 @@
3141
3142 def check_apparmor_profile(self):
3143 '''Check apparmor-profile'''
3144+ if not self.is_click and not self.is_snap1:
3145+ return
3146+
3147 for app in sorted(self.security_apps_profiles):
3148 (f, p) = self._get_security_profile(app)
3149
3150@@ -908,9 +921,6 @@
3151 '@{APP_PKGNAME}',
3152 '@{APP_VERSION}',
3153 ]
3154- if self._pkgfmt_type() == 'snap' and \
3155- float(self._pkgfmt_version()) > 15.04:
3156- searches.append("@{INSTALL_DIR}")
3157
3158 for v in searches:
3159 t = 'info'
3160@@ -1145,9 +1155,10 @@
3161 '''Verify click and security yaml are in sync (not including
3162 override)
3163 '''
3164- if not self.is_snap or \
3165- self.pkg_yaml['type'] in self.sec_skipped_types or \
3166- float(self._pkgfmt_version()) > 15.04:
3167+ if not self.is_click and not self.is_snap1:
3168+ return
3169+
3170+ if self.is_click or self.pkg_yaml['type'] in self.sec_skipped_types:
3171 return
3172
3173 # setup a small dict that is a subset of self.pkg_yaml
3174@@ -1187,9 +1198,10 @@
3175
3176 def check_security_yaml_override_and_click(self):
3177 '''Verify click and security yaml override are in sync'''
3178- if not self.is_snap or \
3179- self.pkg_yaml['type'] in self.sec_skipped_types or \
3180- float(self._pkgfmt_version()) > 15.04:
3181+ if not self.is_click and not self.is_snap1:
3182+ return
3183+
3184+ if self.is_click or self.pkg_yaml['type'] in self.sec_skipped_types:
3185 return
3186
3187 for exe_t in ['services', 'binaries']:
3188@@ -1226,7 +1238,10 @@
3189
3190 def check_security_yaml_override(self):
3191 '''Verify security yaml override'''
3192- if not self.is_snap:
3193+ if not self.is_click and not self.is_snap1:
3194+ return
3195+
3196+ if not self.is_snap1:
3197 return
3198
3199 for exe_t in ['services', 'binaries']:
3200@@ -1248,7 +1263,7 @@
3201 s = "OK"
3202 if 'security-override' not in item:
3203 s = "OK (skipping unspecified override)"
3204- elif float(self._pkgfmt_version()) < 16.04:
3205+ else:
3206 if 'apparmor' not in item['security-override']:
3207 t = 'error'
3208 s = "'apparmor' not specified in 'security-override' " + \
3209@@ -1257,38 +1272,15 @@
3210 t = 'error'
3211 s = "'seccomp' not specified in 'security-override' " + \
3212 "for '%s'" % app
3213- else:
3214- allowed_fields = ['read-paths',
3215- 'write-paths',
3216- 'abstractions',
3217- 'syscalls']
3218- if len(item['security-override'].keys()) == 0:
3219- t = 'error'
3220- s = "nothing specified in 'security-override' " + \
3221- "for '%s'" % app
3222- else:
3223- for f in item['security-override'].keys():
3224- if f not in allowed_fields:
3225- t = 'error'
3226- s = "unknown field '%s' in " % f + \
3227- "'security-override' for '%s'" % app
3228
3229 self._add_result(t, n, s)
3230
3231- # security-override on 16.04 gives direct access to syscalls,
3232- # read-paths, etc so it always needs a manual override
3233- if 'security-override' in item and \
3234- float(self._pkgfmt_version()) > 15.04:
3235- t = 'error'
3236- n = self._get_check_name('yaml_override_present')
3237- s = "(NEEDS REVIEW) 'security-override' not allowed"
3238- l = 'https://developer.ubuntu.com/en/snappy/guides/security-policy/'
3239- m = True
3240- self._add_result(t, n, s, link=l, manual_review=m)
3241-
3242 def check_security_yaml_policy(self):
3243 '''Verify security yaml policy'''
3244- if not self.is_snap:
3245+ if not self.is_click and not self.is_snap1:
3246+ return
3247+
3248+ if not self.is_snap1:
3249 return
3250
3251 for exe_t in ['services', 'binaries']:
3252@@ -1330,7 +1322,10 @@
3253
3254 def check_security_yaml_combinations(self):
3255 '''Verify security yaml uses valid combinations'''
3256- if not self.is_snap or self.pkg_yaml['type'] in self.sec_skipped_types:
3257+ if not self.is_click and not self.is_snap1:
3258+ return
3259+
3260+ if not self.is_snap1 or self.pkg_yaml['type'] in self.sec_skipped_types:
3261 return
3262
3263 for exe_t in ['services', 'binaries']:
3264@@ -1367,7 +1362,10 @@
3265
3266 def check_security_template(self):
3267 '''Check snap security-template'''
3268- if not self.is_snap or self.pkg_yaml['type'] in self.sec_skipped_types:
3269+ if not self.is_click and not self.is_snap1:
3270+ return
3271+
3272+ if not self.is_snap1 or self.pkg_yaml['type'] in self.sec_skipped_types:
3273 return
3274
3275 for exe_t in ['services', 'binaries']:
3276@@ -1401,7 +1399,7 @@
3277 continue
3278 self._add_result(t, n, s)
3279
3280- if self._pkgfmt_version() == "15.04":
3281+ if self.is_snap1:
3282 t = 'info'
3283 n = self._get_check_name('yaml_security-template_in_manifest', app=app)
3284 s = "OK"
3285@@ -1421,7 +1419,10 @@
3286
3287 def check_security_caps(self):
3288 '''Check snap caps'''
3289- if not self.is_snap or self.pkg_yaml['type'] in self.sec_skipped_types:
3290+ if not self.is_click and not self.is_snap1:
3291+ return
3292+
3293+ if not self.is_snap1 or self.pkg_yaml['type'] in self.sec_skipped_types:
3294 return
3295
3296 for exe_t in ['services', 'binaries']:
3297@@ -1455,7 +1456,7 @@
3298 continue
3299 self._add_result(t, n, s)
3300
3301- if self._pkgfmt_version() == "15.04":
3302+ if self.is_snap1:
3303 t = 'info'
3304 n = self._get_check_name('yaml_caps_in_manifest', app=app)
3305 s = "OK"
3306@@ -1475,8 +1476,7 @@
3307
3308 def check_template_online_accounts_provider(self):
3309 '''Check template for online accounts account-provider'''
3310- if self._pkgfmt_type() == "snap" and \
3311- float(self._pkgfmt_version()) > 15.04:
3312+ if not self.is_click and not self.is_snap1:
3313 return
3314
3315 for app in sorted(self.security_apps):
3316@@ -1493,8 +1493,7 @@
3317
3318 def check_template_online_accounts_qml_plugin(self):
3319 '''Check template for online accounts account-qml-plugin'''
3320- if self._pkgfmt_type() == "snap" and \
3321- float(self._pkgfmt_version()) > 15.04:
3322+ if not self.is_click and not self.is_snap1:
3323 return
3324
3325 for app in sorted(self.security_apps):
3326@@ -1511,6 +1510,9 @@
3327
3328 def check_apparmor_profile_name_length(self):
3329 '''Check AppArmor profile name length'''
3330+ if not self.is_click and not self.is_snap1:
3331+ return
3332+
3333 # There are quite a few kernel interfaces that can cause problems with
3334 # long profile names. These are outlined in
3335 # https://launchpad.net/bugs/1499544. The big issue is that the audit
3336
3337=== modified file 'clickreviews/cr_skeleton.py'
3338--- clickreviews/cr_skeleton.py 2015-08-18 16:05:06 +0000
3339+++ clickreviews/cr_skeleton.py 2016-02-10 19:30:47 +0000
3340@@ -34,11 +34,17 @@
3341 ClickReview.__init__(self, fn, "skeleton", peer_hooks=peer_hooks,
3342 overrides=overrides)
3343
3344+ if not self.is_click and not self.is_snap1:
3345+ return
3346+
3347 # If not a hooks test, skip the above and omit peer_hooks like so:
3348 # ClickReview.__init__(self, fn, "skeleton")
3349
3350 def check_foo(self):
3351 '''Check foo'''
3352+ if not self.is_click and not self.is_snap1:
3353+ return
3354+
3355 t = 'info'
3356 n = self._get_check_name('foo')
3357 s = "OK"
3358@@ -49,6 +55,9 @@
3359
3360 def check_bar(self):
3361 '''Check bar'''
3362+ if not self.is_click and not self.is_snap1:
3363+ return
3364+
3365 t = 'info'
3366 n = self._get_check_name('bar')
3367 s = "OK"
3368@@ -59,6 +68,9 @@
3369
3370 def check_baz(self):
3371 '''Check baz'''
3372+ if not self.is_click and not self.is_snap1:
3373+ return
3374+
3375 n = self._get_check_name('baz')
3376 self._add_result('warn', n, 'TODO', link="http://example.com")
3377
3378
3379=== modified file 'clickreviews/cr_systemd.py'
3380--- clickreviews/cr_systemd.py 2015-11-11 16:05:23 +0000
3381+++ clickreviews/cr_systemd.py 2016-02-10 19:30:47 +0000
3382@@ -27,6 +27,12 @@
3383 # systemd isn't implemented as a hook any more so don't setup peerhooks
3384 ClickReview.__init__(self, fn, "snappy-systemd", overrides=overrides)
3385
3386+ self.systemd_files = dict() # click-show-files and tests
3387+ self.systemd = dict()
3388+
3389+ if not self.is_snap1:
3390+ return
3391+
3392 # snappy-systemd currently only allows specifying:
3393 # - start (required)
3394 # - description (required)
3395@@ -49,10 +55,7 @@
3396 'ports'
3397 ] + self.snappy_exe_security
3398
3399- self.systemd_files = dict() # click-show-files and tests
3400- self.systemd = dict()
3401-
3402- if self.is_snap and 'services' in self.pkg_yaml:
3403+ if self.is_snap1 and 'services' in self.pkg_yaml:
3404 if len(self.pkg_yaml['services']) == 0:
3405 error("package.yaml malformed: 'services' is empty")
3406 for service in self.pkg_yaml['services']:
3407@@ -91,7 +94,7 @@
3408
3409 def check_snappy_required(self):
3410 '''Check for package.yaml required fields'''
3411- if not self.is_snap or 'services' not in self.pkg_yaml:
3412+ if not self.is_snap1 or 'services' not in self.pkg_yaml:
3413 return
3414 self._verify_required(self._create_dict(self.pkg_yaml['services']),
3415 'package_yaml')
3416@@ -141,7 +144,7 @@
3417
3418 def check_snappy_optional(self):
3419 '''Check snappy packate.yaml optional fields'''
3420- if not self.is_snap or 'services' not in self.pkg_yaml:
3421+ if not self.is_snap1 or 'services' not in self.pkg_yaml:
3422 return
3423 self._verify_optional(self._create_dict(self.pkg_yaml['services']),
3424 'package_yaml')
3425@@ -168,7 +171,7 @@
3426
3427 def check_snappy_unknown(self):
3428 '''Check snappy package.yaml unknown fields'''
3429- if not self.is_snap or 'services' not in self.pkg_yaml:
3430+ if not self.is_snap1 or 'services' not in self.pkg_yaml:
3431 return
3432 self._verify_unknown(self._create_dict(self.pkg_yaml['services']),
3433 'package_yaml')
3434@@ -195,7 +198,7 @@
3435
3436 def check_snappy_service_description(self):
3437 '''Check snappy package.yaml description'''
3438- if not self.is_snap or 'services' not in self.pkg_yaml:
3439+ if not self.is_snap1 or 'services' not in self.pkg_yaml:
3440 return
3441 self._verify_service_description(self._create_dict(
3442 self.pkg_yaml['services']),
3443@@ -226,21 +229,21 @@
3444
3445 def check_snappy_service_start(self):
3446 '''Check snappy package.yaml start'''
3447- if not self.is_snap or 'services' not in self.pkg_yaml:
3448+ if not self.is_snap1 or 'services' not in self.pkg_yaml:
3449 return
3450 self._verify_entry(self._create_dict(self.pkg_yaml['services']),
3451 'start', 'package_yaml')
3452
3453 def check_snappy_service_stop(self):
3454 '''Check snappy package.yaml stop'''
3455- if not self.is_snap or 'services' not in self.pkg_yaml:
3456+ if not self.is_snap1 or 'services' not in self.pkg_yaml:
3457 return
3458 self._verify_entry(self._create_dict(self.pkg_yaml['services']),
3459 'stop', 'package_yaml')
3460
3461 def check_snappy_service_poststop(self):
3462 '''Check snappy package.yaml poststop'''
3463- if not self.is_snap or 'services' not in self.pkg_yaml:
3464+ if not self.is_snap1 or 'services' not in self.pkg_yaml:
3465 return
3466 self._verify_entry(self._create_dict(self.pkg_yaml['services']),
3467 'poststop', 'package_yaml')
3468@@ -282,7 +285,7 @@
3469
3470 def check_snappy_service_stop_timeout(self):
3471 '''Check snappy package.yaml stop-timeout'''
3472- if not self.is_snap or 'services' not in self.pkg_yaml:
3473+ if not self.is_snap1 or 'services' not in self.pkg_yaml:
3474 return
3475 self._verify_service_stop_timeout(self._create_dict(
3476 self.pkg_yaml['services']),
3477@@ -343,7 +346,7 @@
3478
3479 def check_snappy_service_bus_name(self):
3480 '''Check snappy package.yaml bus-name'''
3481- if not self.is_snap or 'services' not in self.pkg_yaml:
3482+ if not self.is_snap1 or 'services' not in self.pkg_yaml:
3483 return
3484 is_framework = False
3485 if 'type' in self.pkg_yaml and self.pkg_yaml['type'] == 'framework':
3486@@ -455,7 +458,7 @@
3487
3488 def check_snappy_service_ports(self):
3489 '''Check snappy package.yaml ports'''
3490- if not self.is_snap or 'services' not in self.pkg_yaml:
3491+ if not self.is_snap1 or 'services' not in self.pkg_yaml:
3492 return
3493 self._verify_service_ports(self.pkg_yaml['name'],
3494 self._create_dict(
3495@@ -512,7 +515,7 @@
3496
3497 def check_snappy_service_listen_stream(self):
3498 '''Check snappy package.yaml listen-stream'''
3499- if not self.is_snap or 'services' not in self.pkg_yaml:
3500+ if not self.is_snap1 or 'services' not in self.pkg_yaml:
3501 return
3502
3503 self._verify_service_listen_stream(self.pkg_yaml['name'],
3504@@ -522,7 +525,7 @@
3505
3506 def check_snappy_service_socket_user(self):
3507 '''Check snappy package.yaml socket-user'''
3508- if not self.is_snap or 'services' not in self.pkg_yaml:
3509+ if not self.is_snap1 or 'services' not in self.pkg_yaml:
3510 return
3511
3512 my_dict = self._create_dict(self.pkg_yaml['services'])
3513@@ -557,7 +560,7 @@
3514
3515 def check_snappy_service_socket_group(self):
3516 '''Check snappy package.yaml socket-group'''
3517- if not self.is_snap or 'services' not in self.pkg_yaml:
3518+ if not self.is_snap1 or 'services' not in self.pkg_yaml:
3519 return
3520
3521 my_dict = self._create_dict(self.pkg_yaml['services'])
3522@@ -592,7 +595,7 @@
3523
3524 def check_snappy_service_socket(self):
3525 '''Check snappy package.yaml socket'''
3526- if not self.is_snap or 'services' not in self.pkg_yaml:
3527+ if not self.is_snap1 or 'services' not in self.pkg_yaml:
3528 return
3529
3530 my_dict = self._create_dict(self.pkg_yaml['services'])
3531
3532=== modified file 'clickreviews/cr_tests.py'
3533--- clickreviews/cr_tests.py 2016-02-01 17:29:56 +0000
3534+++ clickreviews/cr_tests.py 2016-02-10 19:30:47 +0000
3535@@ -25,13 +25,12 @@
3536 from unittest import TestCase
3537
3538 from clickreviews.cr_lint import MINIMUM_CLICK_FRAMEWORK_VERSION
3539-import clickreviews.cr_common as cr_common
3540+import clickreviews.common as common
3541
3542 # These should be set in the test cases
3543 TEST_CONTROL = ""
3544 TEST_MANIFEST = ""
3545 TEST_PKG_YAML = ""
3546-TEST_SNAP_YAML = ""
3547 TEST_HASHES_YAML = ""
3548 TEST_README_MD = ""
3549 TEST_SECURITY = dict()
3550@@ -78,11 +77,6 @@
3551 return io.StringIO(TEST_PKG_YAML)
3552
3553
3554-def _extract_snap_yaml(self):
3555- '''Pretend we read the package.yaml file'''
3556- return io.StringIO(TEST_SNAP_YAML)
3557-
3558-
3559 def _extract_hashes_yaml(self):
3560 '''Pretend we read the hashes.yaml file'''
3561 return io.StringIO(TEST_HASHES_YAML)
3562@@ -95,7 +89,7 @@
3563
3564 def _get_sha512sum(self, fn):
3565 '''Pretend we found performed a sha512'''
3566- (rc, out) = cr_common.cmd(['sha512sum', os.path.realpath(__file__)])
3567+ (rc, out) = common.cmd(['sha512sum', os.path.realpath(__file__)])
3568 if rc != 0:
3569 return None
3570 return out.split()[0]
3571@@ -147,9 +141,6 @@
3572
3573 def _get_security_manifest(self, app):
3574 '''Pretend we read the security manifest file'''
3575- if TEST_PKGFMT_VERSION == "16.04":
3576- return (app, json.loads(TEST_SECURITY[app]))
3577-
3578 return ("%s.apparmor" % app, json.loads(TEST_SECURITY[app]))
3579
3580
3581@@ -265,9 +256,12 @@
3582 return TEST_PKGFMT_VERSION
3583
3584
3585-def _is_squashfs(self):
3586- '''Pretend we discovered if it is a squashfs or not'''
3587- return (TEST_PKGFMT_TYPE == "snap" and float(TEST_PKGFMT_VERSION) > 15.04)
3588+def _detect_package(self, fn):
3589+ '''Pretend we detected the package'''
3590+ ver = 1
3591+ if TEST_PKGFMT_TYPE == "snap" and TEST_PKGFMT_VERSION != "15.04":
3592+ ver = 2
3593+ return (TEST_PKGFMT_TYPE, ver)
3594
3595
3596 def create_patches():
3597@@ -275,7 +269,7 @@
3598 # Mock patching. Don't use decorators but instead patch in setUp() of the
3599 # child.
3600 patches = []
3601- patches.append(patch('clickreviews.cr_common.ClickReview._check_path_exists',
3602+ patches.append(patch('clickreviews.common.Review._check_package_exists',
3603 _mock_func))
3604 patches.append(patch(
3605 'clickreviews.cr_common.ClickReview._extract_control_file',
3606@@ -287,45 +281,34 @@
3607 'clickreviews.cr_common.ClickReview._extract_package_yaml',
3608 _extract_package_yaml))
3609 patches.append(patch(
3610- 'clickreviews.cr_common.ClickReview._extract_snap_yaml',
3611- _extract_snap_yaml))
3612- patches.append(patch(
3613 'clickreviews.cr_common.ClickReview._extract_hashes_yaml',
3614 _extract_hashes_yaml))
3615- patches.append(patch(
3616- 'clickreviews.cr_common.ClickReview._path_join',
3617- _path_join))
3618- patches.append(patch(
3619- 'clickreviews.cr_common.ClickReview._get_sha512sum',
3620- _get_sha512sum))
3621- patches.append(patch(
3622- 'clickreviews.cr_common.ClickReview._extract_statinfo',
3623- _extract_statinfo))
3624+ patches.append(patch('clickreviews.common.Review._path_join', _path_join))
3625+ patches.append(patch(
3626+ 'clickreviews.common.Review._get_sha512sum', _get_sha512sum))
3627+ patches.append(patch(
3628+ 'clickreviews.common.Review._extract_statinfo', _extract_statinfo))
3629 patches.append(patch(
3630 'clickreviews.cr_common.ClickReview._extract_click_frameworks',
3631 _extract_click_frameworks))
3632- patches.append(patch('clickreviews.cr_common.unpack_click', _mock_func))
3633- patches.append(patch('clickreviews.cr_common.raw_unpack_pkg', _mock_func))
3634- patches.append(patch('clickreviews.cr_common.ClickReview._list_all_files',
3635+ patches.append(patch('clickreviews.common.unpack_pkg', _mock_func))
3636+ patches.append(patch('clickreviews.common.raw_unpack_pkg', _mock_func))
3637+ patches.append(patch('clickreviews.common.detect_package',
3638+ _detect_package))
3639+ patches.append(patch('clickreviews.common.Review._list_all_files',
3640 _mock_func))
3641 patches.append(patch(
3642- 'clickreviews.cr_common.ClickReview._list_all_compiled_binaries',
3643- _mock_func))
3644+ 'clickreviews.common.Review._list_all_compiled_binaries', _mock_func))
3645
3646 # lint overrides
3647 patches.append(patch(
3648 'clickreviews.cr_lint.ClickReviewLint._list_control_files',
3649 _mock_func))
3650- patches.append(patch('clickreviews.cr_lint.ClickReviewLint._list_all_files',
3651- _mock_func))
3652- patches.append(patch(
3653- 'clickreviews.cr_lint.ClickReview._list_all_compiled_binaries',
3654- _mock_func))
3655 patches.append(patch(
3656 'clickreviews.cr_lint.ClickReviewLint._extract_readme_md',
3657 _extract_readme_md))
3658 patches.append(patch(
3659- 'clickreviews.cr_lint.ClickReviewLint._check_innerpath_executable',
3660+ 'clickreviews.common.Review._check_innerpath_executable',
3661 _check_innerpath_executable))
3662
3663 # security overrides
3664@@ -398,12 +381,10 @@
3665 _has_framework_in_metadir))
3666
3667 # pkgfmt
3668- patches.append(patch("clickreviews.cr_common.ClickReview._pkgfmt_type",
3669+ patches.append(patch("clickreviews.common.Review._pkgfmt_type",
3670 _pkgfmt_type))
3671- patches.append(patch("clickreviews.cr_common.ClickReview._pkgfmt_version",
3672+ patches.append(patch("clickreviews.common.Review._pkgfmt_version",
3673 _pkgfmt_version))
3674- patches.append(patch("clickreviews.cr_common.is_squashfs", _is_squashfs))
3675- patches.append(patch("clickreviews.cr_lint.is_squashfs", _is_squashfs))
3676
3677 return patches
3678
3679@@ -457,8 +438,6 @@
3680 [self.test_control['Architecture']])
3681 self._update_test_pkg_yaml()
3682
3683- self.test_snap_yaml = dict()
3684-
3685 self.test_hashes_yaml = dict()
3686 self._update_test_hashes_yaml()
3687
3688@@ -577,12 +556,6 @@
3689 default_flow_style=False,
3690 indent=4)
3691
3692- def _update_test_snap_yaml(self):
3693- global TEST_SNAP_YAML
3694- TEST_SNAP_YAML = yaml.dump(self.test_snap_yaml,
3695- default_flow_style=False,
3696- indent=4)
3697-
3698 def _update_test_hashes_yaml(self):
3699 global TEST_HASHES_YAML
3700 TEST_HASHES_YAML = yaml.dump(self.test_hashes_yaml,
3701@@ -811,16 +784,6 @@
3702 self.test_pkg_yaml[key] = value
3703 self._update_test_pkg_yaml()
3704
3705- def set_test_snap_yaml(self, key, value):
3706- '''Set key in meta/snap.yaml to value. If value is None, remove
3707- key'''
3708- if value is None:
3709- if key in self.test_snap_yaml:
3710- self.test_snap_yaml.pop(key, None)
3711- else:
3712- self.test_snap_yaml[key] = value
3713- self._update_test_snap_yaml()
3714-
3715 def set_test_hashes_yaml(self, yaml):
3716 '''Set hashes.yaml to yaml'''
3717 self.test_hashes_yaml = yaml
3718@@ -1164,8 +1127,6 @@
3719 TEST_MANIFEST = ""
3720 global TEST_PKG_YAML
3721 TEST_PKG_YAML = ""
3722- global TEST_SNAP_YAML
3723- TEST_SNAP_YAML = ""
3724 global TEST_HASHES_YAML
3725 TEST_HASHES_YAML = ""
3726 global TEST_README_MD
3727@@ -1208,4 +1169,4 @@
3728 TEST_PKGFMT_VERSION = "0.4"
3729
3730 self._reset_test_data()
3731- cr_common.recursive_rm(self.desktop_tmpdir)
3732+ common.recursive_rm(self.desktop_tmpdir)
3733
3734=== modified file 'clickreviews/cr_url_dispatcher.py'
3735--- clickreviews/cr_url_dispatcher.py 2015-12-04 14:17:55 +0000
3736+++ clickreviews/cr_url_dispatcher.py 2016-02-10 19:30:47 +0000
3737@@ -35,6 +35,9 @@
3738 ClickReview.__init__(self, fn, "url_dispatcher", peer_hooks=peer_hooks,
3739 overrides=overrides)
3740
3741+ if not self.is_click and not self.is_snap1:
3742+ return
3743+
3744 self.required_keys = ['protocol']
3745 self.optional_keys = ['domain-suffix']
3746
3747@@ -86,6 +89,9 @@
3748
3749 def check_required(self):
3750 '''Check url-dispatcher required fields'''
3751+ if not self.is_click and not self.is_snap1:
3752+ return
3753+
3754 for app in sorted(self.url_dispatcher):
3755 for r in self.required_keys:
3756 found = False
3757@@ -114,6 +120,9 @@
3758
3759 def check_optional(self):
3760 '''Check url-dispatcher optional fields'''
3761+ if not self.is_click and not self.is_snap1:
3762+ return
3763+
3764 for app in sorted(self.url_dispatcher):
3765 for o in self.optional_keys:
3766 found = False
3767@@ -141,6 +150,9 @@
3768
3769 def check_unknown(self):
3770 '''Check url-dispatcher unknown fields'''
3771+ if not self.is_click and not self.is_snap1:
3772+ return
3773+
3774 for app in sorted(self.url_dispatcher):
3775 unknown = []
3776 for entry in self.url_dispatcher[app]:
3777
3778=== modified file 'clickreviews/modules.py'
3779--- clickreviews/modules.py 2015-08-14 08:21:49 +0000
3780+++ clickreviews/modules.py 2016-02-10 19:30:47 +0000
3781@@ -4,7 +4,7 @@
3782 import os
3783 import pkgutil
3784
3785-IRRELEVANT_MODULES = ['cr_common', 'cr_tests', 'cr_skeleton']
3786+IRRELEVANT_MODULES = ['cr_common', 'cr_tests', 'cr_skeleton', 'common']
3787
3788
3789 def narrow_down_modules(modules):
3790@@ -49,14 +49,14 @@
3791
3792 classes = inspect.getmembers(module, inspect.isclass)
3793
3794- def find_cr_class(a):
3795+ def find_test_class(a):
3796 return a[0].startswith('Click') and \
3797 not a[0].endswith('Exception') and \
3798 a[1].__module__ == module_name
3799- cr_class = list(filter(find_cr_class, classes))
3800- if not cr_class:
3801+ test_class = list(filter(find_test_class, classes))
3802+ if not test_class:
3803 return None
3804- init_object = getattr(module, cr_class[0][0])
3805+ init_object = getattr(module, test_class[0][0])
3806 return init_object
3807
3808
3809
3810=== modified file 'clickreviews/tests/test_cr_bin_path.py'
3811--- clickreviews/tests/test_cr_bin_path.py 2015-10-16 02:54:07 +0000
3812+++ clickreviews/tests/test_cr_bin_path.py 2016-02-10 19:30:47 +0000
3813@@ -19,7 +19,10 @@
3814
3815
3816 class TestClickReviewBinPath(cr_tests.TestClickReview):
3817- """Tests for the lint review tool."""
3818+ """Tests for the bin-path review tool."""
3819+ def setUp(self):
3820+ super().setUp()
3821+ self.set_test_pkgfmt("snap", "15.04")
3822
3823 def _set_binary(self, entries, name=None):
3824 d = dict()
3825
3826=== modified file 'clickreviews/tests/test_cr_content_hub.py'
3827--- clickreviews/tests/test_cr_content_hub.py 2015-11-20 19:11:26 +0000
3828+++ clickreviews/tests/test_cr_content_hub.py 2016-02-10 19:30:47 +0000
3829@@ -167,16 +167,3 @@
3830 r = c.click_report
3831 expected_counts = {'info': 6, 'warn': 0, 'error': 0}
3832 self.check_results(r, expected_counts)
3833-
3834- def test_check_valid_snappy_1604(self):
3835- '''Test check_valid() - snappy 16.04'''
3836- self.set_test_pkgfmt("snap", "16.04")
3837- self.set_test_content_hub(self.default_appname, "destination", "pictures")
3838- self.set_test_content_hub(self.default_appname, "share", "pictures")
3839- self.set_test_content_hub(self.default_appname, "source", "pictures")
3840- c = ClickReviewContentHub(self.test_name)
3841- c.check_valid()
3842- r = c.click_report
3843- # should be empty with this pkgfmt
3844- expected_counts = {'info': 0, 'warn': 0, 'error': 0}
3845- self.check_results(r, expected_counts)
3846
3847=== modified file 'clickreviews/tests/test_cr_desktop.py'
3848--- clickreviews/tests/test_cr_desktop.py 2015-11-20 19:10:01 +0000
3849+++ clickreviews/tests/test_cr_desktop.py 2016-02-10 19:30:47 +0000
3850@@ -910,17 +910,3 @@
3851 name = c._get_check_name('files_usable')
3852 expected['info'][name] = {"text": "OK"}
3853 self.check_results(r, expected=expected)
3854-
3855- def test_check_desktop_file_snappy_1604(self):
3856- '''Test check_desktop_file() - snappy 16.04'''
3857- self.set_test_pkgfmt("snap", "16.04")
3858- c = ClickReviewDesktop(self.test_name)
3859- c.check_desktop_file()
3860- r = c.click_report
3861- expected = dict()
3862- expected['info'] = dict()
3863- expected['warn'] = dict()
3864- expected['error'] = dict()
3865- name = c._get_check_name('files_usable')
3866- expected['info'][name] = {"text": "Skipped: could not find any desktop files"}
3867- self.check_results(r, expected=expected)
3868
3869=== modified file 'clickreviews/tests/test_cr_framework.py'
3870--- clickreviews/tests/test_cr_framework.py 2015-10-16 02:54:07 +0000
3871+++ clickreviews/tests/test_cr_framework.py 2016-02-10 19:30:47 +0000
3872@@ -19,7 +19,10 @@
3873
3874
3875 class TestClickReviewFramework(cr_tests.TestClickReview):
3876- """Tests for the lint review tool."""
3877+ """Tests for the framework review tool."""
3878+ def setUp(self):
3879+ super().setUp()
3880+ self.set_test_pkgfmt("snap", "15.04")
3881
3882 def test_framework_hook_obsolete(self):
3883 '''Test check_framework_hook_obsolete()'''
3884
3885=== modified file 'clickreviews/tests/test_cr_lint.py'
3886--- clickreviews/tests/test_cr_lint.py 2016-02-01 19:07:58 +0000
3887+++ clickreviews/tests/test_cr_lint.py 2016-02-10 19:30:47 +0000
3888@@ -17,7 +17,7 @@
3889 from unittest import TestCase
3890 from unittest.mock import patch
3891
3892-from clickreviews.cr_common import cleanup_unpack
3893+from clickreviews.common import cleanup_unpack
3894 from clickreviews.cr_lint import ClickReviewLint
3895 from clickreviews.cr_lint import MINIMUM_CLICK_FRAMEWORK_VERSION
3896 from clickreviews.frameworks import FRAMEWORKS_DATA_URL, USER_DATA_FILE
3897@@ -168,16 +168,6 @@
3898 expected_counts = {'info': 15, 'warn': 0, 'error': 0}
3899 self.check_results(r, expected_counts)
3900
3901- def test_check_control_architecture_snappy_1604(self):
3902- '''Test check_control() (architecture) - snappy 16.04'''
3903- self.set_test_pkgfmt("snap", "16.04")
3904- c = ClickReviewLint(self.test_name)
3905- c.check_control()
3906- r = c.click_report
3907- # should be empty with this pkgfmt
3908- expected_counts = {'info': 0, 'warn': 0, 'error': 0}
3909- self.check_results(r, expected_counts)
3910-
3911 def test_check_control_architecture_missing(self):
3912 '''Test check_control() (architecture missing)'''
3913 self.set_test_control("Architecture", None)
3914@@ -202,7 +192,7 @@
3915 self.set_test_control("Architecture", "armhf")
3916 self.set_test_manifest("architecture", "amd64")
3917 c = ClickReviewLint(self.test_name)
3918- c.is_snap = False
3919+ c.is_snap1 = False
3920 c.check_control()
3921 r = c.click_report
3922 expected_counts = {'info': None, 'warn': 0, 'error': 1}
3923@@ -213,7 +203,7 @@
3924 self.set_test_control("Architecture", ["all"])
3925 self.set_test_manifest("architecture", "all")
3926 c = ClickReviewLint(self.test_name)
3927- c.is_snap = True
3928+ c.is_snap1 = True
3929 c.check_control()
3930 r = c.click_report
3931 expected_counts = {'info': 15, 'warn': 0, 'error': 0}
3932@@ -278,16 +268,6 @@
3933 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
3934 self.check_results(r, expected_counts)
3935
3936- def test_check_manifest_missing_arch_snappy_1604(self):
3937- '''Test check_manifest_architecture() - snappy 16.04'''
3938- self.set_test_pkgfmt("snap", "16.04")
3939- self.set_test_manifest("architecture", None)
3940- c = ClickReviewLint(self.test_name)
3941- c.check_manifest_architecture()
3942- r = c.click_report
3943- expected_counts = {'info': 0, 'warn': 0, 'error': 0}
3944- self.check_results(r, expected_counts)
3945-
3946 def test_check_manifest_arch_all(self):
3947 '''Test check_manifest_architecture() (all)'''
3948 self.set_test_manifest("architecture", "all")
3949@@ -393,7 +373,7 @@
3950 self.test_control['Version'],
3951 arch)
3952 c = ClickReviewLint(test_name)
3953- c.is_snap = False
3954+ c.is_snap1 = False
3955 c.check_manifest_architecture()
3956 r = c.click_report
3957 expected_counts = {'info': 0, 'warn': 0, 'error': 1}
3958@@ -416,7 +396,7 @@
3959 def test_check_control(self):
3960 """A very basic test to make sure check_control can be tested."""
3961 c = ClickReviewLint(self.test_name)
3962- c.is_snap = False
3963+ c.is_snap1 = False
3964 c.check_control()
3965 r = c.click_report
3966 expected_counts = {'info': 15, 'warn': 0, 'error': 0}
3967@@ -425,7 +405,7 @@
3968 def test_check_control_snap(self):
3969 """check_control with snap."""
3970 c = ClickReviewLint(self.test_name)
3971- c.is_snap = True
3972+ c.is_snap1 = True
3973 c.check_control()
3974 r = c.click_report
3975 expected_counts = {'info': 15, 'warn': 0, 'error': 0}
3976@@ -434,7 +414,7 @@
3977 def test_check_control_snap_missing_maintainer(self):
3978 """check_control with snap with missing maintainer."""
3979 c = ClickReviewLint(self.test_name)
3980- c.is_snap = True
3981+ c.is_snap1 = True
3982 self.set_test_control('Maintainer', None)
3983 c.check_control()
3984 r = c.click_report
3985@@ -474,7 +454,7 @@
3986 '''Test check_maintainer() - empty'''
3987 self.set_test_manifest("maintainer", "")
3988 c = ClickReviewLint(self.test_name)
3989- c.is_snap = False
3990+ c.is_snap1 = False
3991 c.check_maintainer()
3992 r = c.click_report
3993 expected_counts = {'info': None, 'warn': 0, 'error': 1}
3994@@ -484,7 +464,7 @@
3995 '''Test check_maintainer() - empty (snap)'''
3996 self.set_test_manifest("maintainer", "")
3997 c = ClickReviewLint(self.test_name)
3998- c.is_snap = True
3999+ c.is_snap1 = True
4000 c.check_maintainer()
4001 r = c.click_report
4002 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
4003@@ -494,7 +474,7 @@
4004 '''Test check_maintainer() - missing (click)'''
4005 self.set_test_manifest("maintainer", None)
4006 c = ClickReviewLint(self.test_name)
4007- c.is_snap = False
4008+ c.is_snap1 = False
4009 c.check_maintainer()
4010 r = c.click_report
4011 expected_counts = {'info': 0, 'warn': 0, 'error': 1}
4012@@ -504,7 +484,7 @@
4013 '''Test check_maintainer() - missing (snap)'''
4014 self.set_test_manifest("maintainer", None)
4015 c = ClickReviewLint(self.test_name)
4016- c.is_snap = True
4017+ c.is_snap1 = True
4018 c.check_maintainer()
4019 r = c.click_report
4020 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
4021@@ -514,7 +494,7 @@
4022 '''Test check_maintainer() - badly formatted'''
4023 self.set_test_manifest("maintainer", "$%^@*")
4024 c = ClickReviewLint(self.test_name)
4025- c.is_snap = False
4026+ c.is_snap1 = False
4027 c.check_maintainer()
4028 r = c.click_report
4029 expected_counts = {'info': None, 'warn': 0, 'error': 1}
4030@@ -524,7 +504,7 @@
4031 '''Test check_maintainer() - badly formatted (snap)'''
4032 self.set_test_manifest("maintainer", "$%^@*")
4033 c = ClickReviewLint(self.test_name)
4034- c.is_snap = True
4035+ c.is_snap1 = True
4036 c.check_maintainer()
4037 r = c.click_report
4038 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
4039@@ -536,7 +516,7 @@
4040 self.set_test_manifest("maintainer",
4041 "user@example.com")
4042 c = ClickReviewLint(self.test_name)
4043- c.is_snap = False
4044+ c.is_snap1 = False
4045 c.check_maintainer()
4046 r = c.click_report
4047 expected_counts = {'info': None, 'warn': 0, 'error': 1}
4048@@ -548,7 +528,7 @@
4049 self.set_test_manifest("maintainer",
4050 "user@example.com")
4051 c = ClickReviewLint(self.test_name)
4052- c.is_snap = True
4053+ c.is_snap1 = True
4054 c.check_maintainer()
4055 r = c.click_report
4056 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
4057@@ -585,16 +565,6 @@
4058 expected_counts = {'info': 3, 'warn': 0, 'error': 0}
4059 self.check_results(r, expected_counts)
4060
4061- def test_check_icon_snappy_1604(self):
4062- '''Test check_icon() - snappy 16.04'''
4063- self.set_test_pkgfmt("snap", "16.04")
4064- self.set_test_manifest("icon", "someicon")
4065- c = ClickReviewLint(self.test_name)
4066- c.check_icon()
4067- r = c.click_report
4068- expected_counts = {'info': 0, 'warn': 0, 'error': 0}
4069- self.check_results(r, expected_counts)
4070-
4071 def test_check_icon_unspecified(self):
4072 '''Test check_icon()'''
4073 self.set_test_manifest("icon", None)
4074@@ -685,20 +655,6 @@
4075 expected_counts = {'info': 0, 'warn': 1, 'error': 0}
4076 self.check_results(r, expected_counts)
4077
4078- def test_check_click_local_extensions_snappy_1604(self):
4079- '''Testeck_click_local_extensions() - snappy 16.04'''
4080- self.set_test_pkgfmt("snap", "16.04")
4081- for k in self.test_manifest.keys():
4082- if k.startswith("x-"):
4083- self.set_test_manifest(k, None)
4084- self.set_test_manifest("x-source", {"vcs-bzr": "lp:notes-app",
4085- "vcs-bzr-revno": "209"})
4086- c = ClickReviewLint(self.test_name)
4087- c.check_click_local_extensions()
4088- r = c.click_report
4089- expected_counts = {'info': 0, 'warn': 0, 'error': 0}
4090- self.check_results(r, expected_counts)
4091-
4092 def test_check_framework(self):
4093 '''Test check_framework()'''
4094 self.patch_frameworks()
4095@@ -715,7 +671,7 @@
4096 self.set_test_manifest("framework",
4097 "ubuntu-sdk-14.10-qml-dev2,ubuntu-core-15.04")
4098 c = ClickReviewLint(self.test_name)
4099- c.is_snap = False
4100+ c.is_snap1 = False
4101 c.check_framework()
4102 r = c.click_report
4103 expected_counts = {'info': 0, 'warn': 0, 'error': 1}
4104@@ -727,25 +683,12 @@
4105 self.set_test_manifest("framework",
4106 "ubuntu-sdk-14.10-qml-dev2,ubuntu-core-15.04")
4107 c = ClickReviewLint(self.test_name)
4108- c.is_snap = True
4109+ c.is_snap1 = True
4110 c.check_framework()
4111 r = c.click_report
4112 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
4113 self.check_results(r, expected_counts)
4114
4115- def test_check_framework_multiple_snappy_1604(self):
4116- '''Test check_framework() - snappy 16.04'''
4117- self.patch_frameworks()
4118- self.set_test_pkgfmt("snap", "16.04")
4119- self.set_test_manifest("framework",
4120- "ubuntu-sdk-14.10-qml-dev2,ubuntu-core-15.04")
4121- c = ClickReviewLint(self.test_name)
4122- c.is_snap = True
4123- c.check_framework()
4124- r = c.click_report
4125- expected_counts = {'info': 0, 'warn': 0, 'error': 0}
4126- self.check_results(r, expected_counts)
4127-
4128 @patch('clickreviews.remote.read_cr_file')
4129 def test_check_framework_fetches_remote_data(self, mock_read_cr_file):
4130 '''Test check_framework()'''
4131@@ -839,17 +782,6 @@
4132 expected_counts = {'info': 5, 'warn': 0, 'error': 0}
4133 self.check_results(r, expected_counts)
4134
4135- def test_check_hooks_snappy_1604(self):
4136- '''Test check_hooks() - snappy 16.04'''
4137- self.set_test_pkgfmt("snap", "16.04")
4138- self.set_test_manifest("framework", "ubuntu-sdk-13.10")
4139- c = ClickReviewLint(self.test_name)
4140- c.check_hooks()
4141- r = c.click_report
4142- # this should be 0 with this pkgfmt
4143- expected_counts = {'info': 0, 'warn': 0, 'error': 0}
4144- self.check_results(r, expected_counts)
4145-
4146 def test_check_hooks_multiple_desktop_apps(self):
4147 '''Test check_hooks() - multiple desktop apps'''
4148 self.set_test_manifest("framework", "ubuntu-sdk-13.10")
4149@@ -979,16 +911,6 @@
4150 expected_counts = {'info': 3, 'warn': 0, 'error': 0}
4151 self.check_results(r, expected_counts)
4152
4153- def test_check_hooks_unknown_nonexistent_snappy_1604(self):
4154- '''Test check_hooks_unknown() - nonexistent - snappy 16.04'''
4155- self.set_test_pkgfmt("snap", "16.04")
4156- self.set_test_manifest("framework", "ubuntu-sdk-13.10")
4157- c = ClickReviewLint(self.test_name)
4158- c.check_hooks_unknown()
4159- r = c.click_report
4160- expected_counts = {'info': 0, 'warn': 0, 'error': 0}
4161- self.check_results(r, expected_counts)
4162-
4163 def test_check_hooks_unknown_good(self):
4164 '''Test check_hooks_unknown()'''
4165 self.set_test_manifest("framework", "ubuntu-sdk-13.10")
4166@@ -1031,23 +953,13 @@
4167 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
4168 self.check_results(r, expected_counts)
4169
4170- def test_check_hooks_redflagged_payui_snappy_1604(self):
4171- '''Test check_hooks_redflagged() - pay-ui - snappy 16.04'''
4172- self.set_test_pkgfmt("snap", "16.04")
4173- self.set_test_manifest("framework", "ubuntu-sdk-13.10")
4174- c = ClickReviewLint(self.test_name)
4175- c.check_hooks_redflagged()
4176- r = c.click_report
4177- expected_counts = {'info': 0, 'warn': 0, 'error': 0}
4178- self.check_results(r, expected_counts)
4179-
4180 def test_check_hooks_redflagged_apparmor_profile(self):
4181 '''Test check_hooks_redflagged() - apparmor-profile'''
4182 self.set_test_manifest("framework", "ubuntu-sdk-13.10")
4183 c = ClickReviewLint(self.test_name)
4184 c.manifest['hooks'][self.default_appname]["apparmor-profile"] = "foo"
4185 # snap checks are handled elsewhere
4186- c.is_snap = False
4187+ c.is_snap1 = False
4188 c.check_hooks_redflagged()
4189 r = c.click_report
4190 expected_counts = {'info': None, 'warn': 0, 'error': 1}
4191@@ -1059,7 +971,6 @@
4192 '''Test check_pkgname - toplevel'''
4193 self.set_test_manifest("name", "foo")
4194 c = ClickReviewLint(self.test_name)
4195- c.is_snap = False
4196 c.check_pkgname()
4197 r = c.click_report
4198 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
4199@@ -1069,7 +980,7 @@
4200 '''Test check_pkgname - flat'''
4201 self.set_test_manifest("name", "foo.bar")
4202 c = ClickReviewLint(self.test_name)
4203- c.is_snap = False
4204+ c.is_snap1 = False
4205 c.check_pkgname()
4206 r = c.click_report
4207 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
4208@@ -1079,39 +990,17 @@
4209 '''Test check_pkgname - reverse domain'''
4210 self.set_test_manifest("name", "com.ubuntu.develeper.baz.foo")
4211 c = ClickReviewLint(self.test_name)
4212- c.is_snap = False
4213+ c.is_snap1 = False
4214 c.check_pkgname()
4215 r = c.click_report
4216 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
4217 self.check_results(r, expected_counts)
4218
4219- def test_snappy_name_toplevel(self):
4220- '''Test check_snappy_name - toplevel'''
4221- self.set_test_pkg_yaml("name", "foo")
4222- c = ClickReviewLint(self.test_name)
4223- c.is_snap = True
4224- c.check_snappy_name()
4225- r = c.click_report
4226- expected_counts = {'info': 1, 'warn': 0, 'error': 0}
4227- self.check_results(r, expected_counts)
4228-
4229 def test_snappy_name_toplevel_1504(self):
4230 '''Test check_snappy_name - toplevel - 15.04'''
4231 self.set_test_pkgfmt("snap", "15.04")
4232 self.set_test_pkg_yaml("name", "foo")
4233 c = ClickReviewLint(self.test_name)
4234- c.is_snap = True
4235- c.check_snappy_name()
4236- r = c.click_report
4237- expected_counts = {'info': 1, 'warn': 0, 'error': 0}
4238- self.check_results(r, expected_counts)
4239-
4240- def test_snappy_name_toplevel_1604(self):
4241- '''Test check_snappy_name - toplevel - 16.04'''
4242- self.set_test_pkgfmt("snap", "16.04")
4243- self.set_test_pkg_yaml("name", "foo")
4244- c = ClickReviewLint(self.test_name)
4245- c.is_snap = True
4246 c.check_snappy_name()
4247 r = c.click_report
4248 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
4249@@ -1119,9 +1008,9 @@
4250
4251 def test_snappy_name_flat(self):
4252 '''Test check_snappy_name - obsoleted flat'''
4253+ self.set_test_pkgfmt("snap", "15.04")
4254 self.set_test_pkg_yaml("name", "foo.bar")
4255 c = ClickReviewLint(self.test_name)
4256- c.is_snap = True
4257 c.check_snappy_name()
4258 r = c.click_report
4259 expected_counts = {'info': None, 'warn': 0, 'error': 1}
4260@@ -1129,9 +1018,9 @@
4261
4262 def test_snappy_name_reverse_domain(self):
4263 '''Test check_snappy_name - obsoleted reverse domain'''
4264+ self.set_test_pkgfmt("snap", "15.04")
4265 self.set_test_pkg_yaml("name", "com.ubuntu.develeper.baz.foo")
4266 c = ClickReviewLint(self.test_name)
4267- c.is_snap = True
4268 c.check_snappy_name()
4269 r = c.click_report
4270 expected_counts = {'info': None, 'warn': 0, 'error': 1}
4271@@ -1139,6 +1028,7 @@
4272
4273 def test_snappy_name_bad(self):
4274 '''Test check_snappy_name - bad'''
4275+ self.set_test_pkgfmt("snap", "15.04")
4276 self.set_test_pkg_yaml("name", "foo?bar")
4277 c = ClickReviewLint(self.test_name)
4278 c.check_snappy_name()
4279@@ -1148,6 +1038,7 @@
4280
4281 def test_snappy_name_bad2(self):
4282 '''Test check_snappy_name - empty'''
4283+ self.set_test_pkgfmt("snap", "15.04")
4284 self.set_test_pkg_yaml("name", "")
4285 c = ClickReviewLint(self.test_name)
4286 c.check_snappy_name()
4287@@ -1157,6 +1048,7 @@
4288
4289 def test_snappy_name_bad3(self):
4290 '''Test check_snappy_name - list'''
4291+ self.set_test_pkgfmt("snap", "15.04")
4292 self.set_test_pkg_yaml("name", [])
4293 c = ClickReviewLint(self.test_name)
4294 c.check_snappy_name()
4295@@ -1166,6 +1058,7 @@
4296
4297 def test_snappy_name_bad4(self):
4298 '''Test check_snappy_name - dict'''
4299+ self.set_test_pkgfmt("snap", "15.04")
4300 self.set_test_pkg_yaml("name", {})
4301 c = ClickReviewLint(self.test_name)
4302 c.check_snappy_name()
4303@@ -1183,18 +1076,9 @@
4304 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
4305 self.check_results(r, expected_counts)
4306
4307- def test_snappy_version_1604(self):
4308- '''Test check_snappy_version - 16.04'''
4309- self.set_test_pkgfmt("snap", "16.04")
4310- self.set_test_pkg_yaml("version", 1)
4311- c = ClickReviewLint(self.test_name)
4312- c.check_snappy_version()
4313- r = c.click_report
4314- expected_counts = {'info': 1, 'warn': 0, 'error': 0}
4315- self.check_results(r, expected_counts)
4316-
4317 def test_snappy_version1(self):
4318 '''Test check_snappy_version - integer'''
4319+ self.set_test_pkgfmt("snap", "15.04")
4320 self.set_test_pkg_yaml("version", 1)
4321 c = ClickReviewLint(self.test_name)
4322 c.check_snappy_version()
4323@@ -1204,6 +1088,7 @@
4324
4325 def test_snappy_version2(self):
4326 '''Test check_snappy_version - float'''
4327+ self.set_test_pkgfmt("snap", "15.04")
4328 self.set_test_pkg_yaml("version", 1.0)
4329 c = ClickReviewLint(self.test_name)
4330 c.check_snappy_version()
4331@@ -1213,6 +1098,7 @@
4332
4333 def test_snappy_version3(self):
4334 '''Test check_snappy_version - MAJOR.MINOR.MICRO'''
4335+ self.set_test_pkgfmt("snap", "15.04")
4336 self.set_test_pkg_yaml("version", "1.0.1")
4337 c = ClickReviewLint(self.test_name)
4338 c.check_snappy_version()
4339@@ -1222,6 +1108,7 @@
4340
4341 def test_snappy_version4(self):
4342 '''Test check_snappy_version - str'''
4343+ self.set_test_pkgfmt("snap", "15.04")
4344 self.set_test_pkg_yaml("version", "1.0a")
4345 c = ClickReviewLint(self.test_name)
4346 c.check_snappy_version()
4347@@ -1231,6 +1118,7 @@
4348
4349 def test_snappy_version5(self):
4350 '''Test check_snappy_version - alpha'''
4351+ self.set_test_pkgfmt("snap", "15.04")
4352 self.set_test_pkg_yaml("version", "a.b")
4353 c = ClickReviewLint(self.test_name)
4354 c.check_snappy_version()
4355@@ -1240,6 +1128,7 @@
4356
4357 def test_snappy_version_bad(self):
4358 '''Test check_snappy_version - bad'''
4359+ self.set_test_pkgfmt("snap", "15.04")
4360 self.set_test_pkg_yaml("version", "foo?bar")
4361 c = ClickReviewLint(self.test_name)
4362 c.check_snappy_version()
4363@@ -1249,6 +1138,7 @@
4364
4365 def test_snappy_version_bad2(self):
4366 '''Test check_snappy_version - empty'''
4367+ self.set_test_pkgfmt("snap", "15.04")
4368 self.set_test_pkg_yaml("version", "")
4369 c = ClickReviewLint(self.test_name)
4370 c.check_snappy_version()
4371@@ -1258,6 +1148,7 @@
4372
4373 def test_snappy_version_bad3(self):
4374 '''Test check_snappy_version - list'''
4375+ self.set_test_pkgfmt("snap", "15.04")
4376 self.set_test_pkg_yaml("version", [])
4377 c = ClickReviewLint(self.test_name)
4378 c.check_snappy_version()
4379@@ -1267,6 +1158,7 @@
4380
4381 def test_snappy_version_bad4(self):
4382 '''Test check_snappy_version - dict'''
4383+ self.set_test_pkgfmt("snap", "15.04")
4384 self.set_test_pkg_yaml("version", {})
4385 c = ClickReviewLint(self.test_name)
4386 c.check_snappy_version()
4387@@ -1276,6 +1168,7 @@
4388
4389 def test_snappy_type(self):
4390 '''Test check_snappy_type - unspecified'''
4391+ self.set_test_pkgfmt("snap", "15.04")
4392 self.set_test_pkg_yaml("type", None)
4393 c = ClickReviewLint(self.test_name)
4394 c.check_snappy_type()
4395@@ -1283,15 +1176,6 @@
4396 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
4397 self.check_results(r, expected_counts)
4398
4399- def test_snappy_type_app(self):
4400- '''Test check_snappy_type - app'''
4401- self.set_test_pkg_yaml("type", "app")
4402- c = ClickReviewLint(self.test_name)
4403- c.check_snappy_type()
4404- r = c.click_report
4405- expected_counts = {'info': 1, 'warn': 0, 'error': 0}
4406- self.check_results(r, expected_counts)
4407-
4408 def test_snappy_type_app_1504(self):
4409 '''Test check_snappy_type - app - 15.04'''
4410 self.set_test_pkgfmt("snap", "15.04")
4411@@ -1302,18 +1186,9 @@
4412 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
4413 self.check_results(r, expected_counts)
4414
4415- def test_snappy_type_app_1604(self):
4416- '''Test check_snappy_type - app - 16.04'''
4417- self.set_test_pkgfmt("snap", "16.04")
4418- self.set_test_pkg_yaml("type", "app")
4419- c = ClickReviewLint(self.test_name)
4420- c.check_snappy_type()
4421- r = c.click_report
4422- expected_counts = {'info': 1, 'warn': 0, 'error': 0}
4423- self.check_results(r, expected_counts)
4424-
4425 def test_snappy_type_framework(self):
4426 '''Test check_snappy_type - framework'''
4427+ self.set_test_pkgfmt("snap", "15.04")
4428 self.set_test_pkg_yaml("type", "framework")
4429 c = ClickReviewLint(self.test_name)
4430 c.check_snappy_type()
4431@@ -1323,6 +1198,7 @@
4432
4433 def test_snappy_type_oem(self):
4434 '''Test check_snappy_type - oem'''
4435+ self.set_test_pkgfmt("snap", "15.04")
4436 self.set_test_pkg_yaml("type", "oem")
4437 c = ClickReviewLint(self.test_name)
4438 c.check_snappy_type()
4439@@ -1330,42 +1206,6 @@
4440 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
4441 self.check_results(r, expected_counts)
4442
4443- def test_snappy_type_gadget(self):
4444- '''Test check_snappy_type - gadget'''
4445- self.set_test_pkg_yaml("type", "gadget")
4446- c = ClickReviewLint(self.test_name)
4447- c.check_snappy_type()
4448- r = c.click_report
4449- expected_counts = {'info': 1, 'warn': 0, 'error': 0}
4450- self.check_results(r, expected_counts)
4451-
4452- def test_snappy_type_os(self):
4453- '''Test check_snappy_type - os'''
4454- self.set_test_pkg_yaml("type", "os")
4455- c = ClickReviewLint(self.test_name)
4456- c.check_snappy_type()
4457- r = c.click_report
4458- expected_counts = {'info': 1, 'warn': 0, 'error': 0}
4459- self.check_results(r, expected_counts)
4460-
4461- def test_snappy_type_kernel(self):
4462- '''Test check_snappy_type - kernel'''
4463- self.set_test_pkg_yaml("type", "kernel")
4464- c = ClickReviewLint(self.test_name)
4465- c.check_snappy_type()
4466- r = c.click_report
4467- expected_counts = {'info': 1, 'warn': 0, 'error': 0}
4468- self.check_results(r, expected_counts)
4469-
4470- def test_snappy_type_redflagged(self):
4471- '''Test check_snappy_type_redflagged - unspecified'''
4472- self.set_test_pkg_yaml("type", None)
4473- c = ClickReviewLint(self.test_name)
4474- c.check_snappy_type_redflagged()
4475- r = c.click_report
4476- expected_counts = {'info': 1, 'warn': 0, 'error': 0}
4477- self.check_results(r, expected_counts)
4478-
4479 def test_snappy_type_redflagged_1504(self):
4480 '''Test check_snappy_type_redflagged - unspecified - 15.04'''
4481 self.set_test_pkgfmt("snap", "15.04")
4482@@ -1376,18 +1216,9 @@
4483 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
4484 self.check_results(r, expected_counts)
4485
4486- def test_snappy_type_redflagged_1604(self):
4487- '''Test check_snappy_type_redflagged - unspecified - 16.04'''
4488- self.set_test_pkgfmt("snap", "16.04")
4489- self.set_test_pkg_yaml("type", None)
4490- c = ClickReviewLint(self.test_name)
4491- c.check_snappy_type_redflagged()
4492- r = c.click_report
4493- expected_counts = {'info': 1, 'warn': 0, 'error': 0}
4494- self.check_results(r, expected_counts)
4495-
4496 def test_snappy_type_redflagged_app(self):
4497 '''Test check_snappy_type_redflagged - app'''
4498+ self.set_test_pkgfmt("snap", "15.04")
4499 self.set_test_pkg_yaml("type", "app")
4500 c = ClickReviewLint(self.test_name)
4501 c.check_snappy_type_redflagged()
4502@@ -1397,6 +1228,7 @@
4503
4504 def test_snappy_type_redflagged_framework(self):
4505 '''Test check_snappy_type_redflagged - framework'''
4506+ self.set_test_pkgfmt("snap", "15.04")
4507 self.set_test_pkg_yaml("type", "framework")
4508 c = ClickReviewLint(self.test_name)
4509 c.check_snappy_type_redflagged()
4510@@ -1406,6 +1238,7 @@
4511
4512 def test_snappy_type_redflagged_oem(self):
4513 '''Test check_snappy_type_redflagged - oem'''
4514+ self.set_test_pkgfmt("snap", "15.04")
4515 self.set_test_pkg_yaml("type", "oem")
4516 c = ClickReviewLint(self.test_name)
4517 c.check_snappy_type_redflagged()
4518@@ -1413,42 +1246,6 @@
4519 expected_counts = {'info': None, 'warn': 0, 'error': 1}
4520 self.check_results(r, expected_counts)
4521
4522- def test_snappy_type_redflagged_gadget(self):
4523- '''Test check_snappy_type_redflagged - gadget'''
4524- self.set_test_pkg_yaml("type", "gadget")
4525- c = ClickReviewLint(self.test_name)
4526- c.check_snappy_type_redflagged()
4527- r = c.click_report
4528- expected_counts = {'info': None, 'warn': 0, 'error': 1}
4529- self.check_results(r, expected_counts)
4530-
4531- def test_snappy_type_redflagged_os(self):
4532- '''Test check_snappy_type_redflagged - os'''
4533- self.set_test_pkg_yaml("type", "os")
4534- c = ClickReviewLint(self.test_name)
4535- c.check_snappy_type_redflagged()
4536- r = c.click_report
4537- expected_counts = {'info': None, 'warn': 0, 'error': 1}
4538- self.check_results(r, expected_counts)
4539-
4540- def test_snappy_type_redflagged_kernel(self):
4541- '''Test check_snappy_type_redflagged - kernel'''
4542- self.set_test_pkg_yaml("type", "kernel")
4543- c = ClickReviewLint(self.test_name)
4544- c.check_snappy_type_redflagged()
4545- r = c.click_report
4546- expected_counts = {'info': None, 'warn': 0, 'error': 1}
4547- self.check_results(r, expected_counts)
4548-
4549- def test_check_snappy_icon(self):
4550- '''Test check_snappy_icon()'''
4551- self.set_test_pkg_yaml("icon", "someicon")
4552- c = ClickReviewLint(self.test_name)
4553- c.check_snappy_icon()
4554- r = c.click_report
4555- expected_counts = {'info': 3, 'warn': 0, 'error': 0}
4556- self.check_results(r, expected_counts)
4557-
4558 def test_check_snappy_icon_1504(self):
4559 '''Test check_snappy_icon() - 15.04'''
4560 self.set_test_pkgfmt("snap", "15.04")
4561@@ -1459,18 +1256,9 @@
4562 expected_counts = {'info': 3, 'warn': 0, 'error': 0}
4563 self.check_results(r, expected_counts)
4564
4565- def test_check_snappy_icon_1604(self):
4566- '''Test check_snappy_icon() - 16.04'''
4567- self.set_test_pkgfmt("snap", "16.04")
4568- self.set_test_pkg_yaml("icon", "someicon")
4569- c = ClickReviewLint(self.test_name)
4570- c.check_snappy_icon()
4571- r = c.click_report
4572- expected_counts = {'info': 3, 'warn': 0, 'error': 0}
4573- self.check_results(r, expected_counts)
4574-
4575 def test_check_snappy_icon_unspecified(self):
4576 '''Test check_snappy_icon() - unspecified'''
4577+ self.set_test_pkgfmt("snap", "15.04")
4578 self.set_test_pkg_yaml("icon", None)
4579 c = ClickReviewLint(self.test_name)
4580 c.check_snappy_icon()
4581@@ -1480,6 +1268,7 @@
4582
4583 def test_check_snappy_icon_empty(self):
4584 '''Test check_snappy_icon() - empty'''
4585+ self.set_test_pkgfmt("snap", "15.04")
4586 self.set_test_pkg_yaml("icon", "")
4587 c = ClickReviewLint(self.test_name)
4588 c.check_snappy_icon()
4589@@ -1489,6 +1278,7 @@
4590
4591 def test_check_snappy_icon_absolute_path(self):
4592 '''Test check_snappy_icon() - absolute path'''
4593+ self.set_test_pkgfmt("snap", "15.04")
4594 self.set_test_pkg_yaml("icon", "/foo/bar/someicon")
4595 c = ClickReviewLint(self.test_name)
4596 c.check_snappy_icon()
4597@@ -1501,18 +1291,6 @@
4598 self.set_test_pkgfmt("snap", "15.04")
4599 self.set_test_pkg_yaml("architectures", None)
4600 c = ClickReviewLint(self.test_name)
4601- c.is_snap = True
4602- c.check_snappy_architecture()
4603- r = c.click_report
4604- expected_counts = {'info': 2, 'warn': 0, 'error': 0}
4605- self.check_results(r, expected_counts)
4606-
4607- def test_check_snappy_missing_arch_1604(self):
4608- '''Test check_snappy_architecture() (missing)'''
4609- self.set_test_pkgfmt("snap", "16.04")
4610- self.set_test_pkg_yaml("architectures", None)
4611- c = ClickReviewLint(self.test_name)
4612- c.is_snap = True
4613 c.check_snappy_architecture()
4614 r = c.click_report
4615 expected_counts = {'info': 2, 'warn': 0, 'error': 0}
4616@@ -1523,7 +1301,6 @@
4617 self.set_test_pkgfmt("snap", "15.04")
4618 self.set_test_pkg_yaml("architecture", "all")
4619 c = ClickReviewLint(self.test_name)
4620- c.is_snap = True
4621 c.check_snappy_architecture()
4622 r = c.click_report
4623 expected_counts = {'info': 1, 'warn': 1, 'error': 0}
4624@@ -1534,7 +1311,6 @@
4625 self.set_test_pkgfmt("snap", "15.04")
4626 self.set_test_pkg_yaml("architecture", "amd64")
4627 c = ClickReviewLint(self.test_name)
4628- c.is_snap = True
4629 c.check_snappy_architecture()
4630 r = c.click_report
4631 expected_counts = {'info': 1, 'warn': 1, 'error': 0}
4632@@ -1545,7 +1321,6 @@
4633 self.set_test_pkgfmt("snap", "15.04")
4634 self.set_test_pkg_yaml("architectures", ["all"])
4635 c = ClickReviewLint(self.test_name)
4636- c.is_snap = True
4637 c.check_snappy_architecture()
4638 r = c.click_report
4639 expected_counts = {'info': 2, 'warn': 0, 'error': 0}
4640@@ -1556,7 +1331,6 @@
4641 self.set_test_pkgfmt("snap", "15.04")
4642 self.set_test_pkg_yaml("architectures", ["armhf"])
4643 c = ClickReviewLint(self.test_name)
4644- c.is_snap = True
4645 c.check_snappy_architecture()
4646 r = c.click_report
4647 expected_counts = {'info': 2, 'warn': 0, 'error': 0}
4648@@ -1567,7 +1341,6 @@
4649 self.set_test_pkgfmt("snap", "15.04")
4650 self.set_test_pkg_yaml("architectures", ["arm64"])
4651 c = ClickReviewLint(self.test_name)
4652- c.is_snap = True
4653 c.check_snappy_architecture()
4654 r = c.click_report
4655 expected_counts = {'info': 2, 'warn': 0, 'error': 0}
4656@@ -1578,7 +1351,6 @@
4657 self.set_test_pkgfmt("snap", "15.04")
4658 self.set_test_pkg_yaml("architectures", ["i386"])
4659 c = ClickReviewLint(self.test_name)
4660- c.is_snap = True
4661 c.check_snappy_architecture()
4662 r = c.click_report
4663 expected_counts = {'info': 2, 'warn': 0, 'error': 0}
4664@@ -1589,7 +1361,6 @@
4665 self.set_test_pkgfmt("snap", "15.04")
4666 self.set_test_pkg_yaml("architectures", ["amd64"])
4667 c = ClickReviewLint(self.test_name)
4668- c.is_snap = True
4669 c.check_snappy_architecture()
4670 r = c.click_report
4671 expected_counts = {'info': 2, 'warn': 0, 'error': 0}
4672@@ -1600,7 +1371,6 @@
4673 self.set_test_pkgfmt("snap", "15.04")
4674 self.set_test_pkg_yaml("architectures", ["nonexistent"])
4675 c = ClickReviewLint(self.test_name)
4676- c.is_snap = True
4677 c.check_snappy_architecture()
4678 r = c.click_report
4679 expected_counts = {'info': None, 'warn': 0, 'error': 1}
4680@@ -1611,7 +1381,6 @@
4681 self.set_test_pkgfmt("snap", "15.04")
4682 self.set_test_pkg_yaml("architectures", "multi")
4683 c = ClickReviewLint(self.test_name)
4684- c.is_snap = True
4685 c.check_snappy_architecture()
4686 r = c.click_report
4687 expected_counts = {'info': None, 'warn': 0, 'error': 1}
4688@@ -1625,7 +1394,6 @@
4689 self.test_control['Version'],
4690 "armhf")
4691 c = ClickReviewLint(test_name)
4692- c.is_snap = True
4693 c.check_snappy_architecture()
4694 r = c.click_report
4695 expected_counts = {'info': 2, 'warn': 0, 'error': 0}
4696@@ -1640,7 +1408,6 @@
4697 self.test_control['Version'],
4698 arch)
4699 c = ClickReviewLint(test_name)
4700- c.is_snap = True
4701 c.check_snappy_architecture()
4702 r = c.click_report
4703 expected_counts = {'info': 2, 'warn': 0, 'error': 0}
4704@@ -1655,7 +1422,6 @@
4705 self.test_control['Version'],
4706 arch)
4707 c = ClickReviewLint(test_name)
4708- c.is_snap = True
4709 c.check_snappy_architecture()
4710 r = c.click_report
4711 expected_counts = {'info': None, 'warn': 0, 'error': 1}
4712@@ -1670,7 +1436,6 @@
4713 self.test_control['Version'],
4714 arch)
4715 c = ClickReviewLint(test_name)
4716- c.is_snap = True
4717 c.check_snappy_architecture()
4718 r = c.click_report
4719 expected_counts = {'info': 2, 'warn': 0, 'error': 0}
4720@@ -1685,7 +1450,6 @@
4721 self.test_control['Version'],
4722 arch)
4723 c = ClickReviewLint(test_name)
4724- c.is_snap = True
4725 c.check_snappy_architecture()
4726 r = c.click_report
4727 expected_counts = {'info': None, 'warn': 0, 'error': 1}
4728@@ -1693,15 +1457,6 @@
4729
4730 def test_check_snappy_unknown_entries(self):
4731 '''Test check_snappy_unknown_entries - none'''
4732- self.set_test_pkg_yaml("name", "foo")
4733- c = ClickReviewLint(self.test_name)
4734- c.check_snappy_unknown_entries()
4735- r = c.click_report
4736- expected_counts = {'info': 1, 'warn': 0, 'error': 0}
4737- self.check_results(r, expected_counts)
4738-
4739- def test_check_snappy_unknown_entries_1504(self):
4740- '''Test check_snappy_unknown_entries - none - 15.04'''
4741 self.set_test_pkgfmt("snap", "15.04")
4742 self.set_test_pkg_yaml("name", "foo")
4743 c = ClickReviewLint(self.test_name)
4744@@ -1710,18 +1465,9 @@
4745 expected_counts = {'info': 1, 'warn': 0, 'error': 0}
4746 self.check_results(r, expected_counts)
4747
4748- def test_check_snappy_unknown_entries_1604(self):
4749- '''Test check_snappy_unknown_entries - none - 16.04'''
4750- self.set_test_pkgfmt("snap", "16.04")
4751- self.set_test_pkg_yaml("name", "foo")
4752- c = ClickReviewLint(self.test_name)
4753- c.check_snappy_unknown_entries()
4754- r = c.click_report
4755- expected_counts = {'info': 1, 'warn': 0, 'error': 0}
4756- self.check_results(r, expected_counts)
4757-
4758 def test_check_snappy_unknown_entries2(self):
4759 '''Test check_snappy_unknown_entries - one'''
4760+ self.set_test_pkgfmt("snap", "15.04")
4761 self.set_test_pkg_yaml("nonexistent", "bar")
4762 c = ClickReviewLint(self.test_name)
4763 c.check_snappy_unknown_entries()
4764@@ -1731,6 +1477,7 @@
4765
4766 def test_check_snappy_unknown_obsoleted(self):
4767 '''Test check_snappy_unknown_entries - obsoleted'''
4768+ self.set_test_pkgfmt("snap", "15.04")
4769 self.set_test_pkg_yaml("maintainer", "bar")
4770 c = ClickReviewLint(self.test_name)
4771 c.check_snappy_unknown_entries()
4772@@ -1745,6 +1492,7 @@
4773
4774 def test_check_snappy_readme_md(self):
4775 '''Test check_snappy_readme_md()'''
4776+ self.set_test_pkgfmt("snap", "15.04")
4777 self.set_test_pkg_yaml("name", self.test_name.split('_')[0])
4778 self.set_test_readme_md("%s - some description" %
4779 self.test_name.split('_')[0])
4780@@ -1754,23 +1502,9 @@
4781 expected_counts = {'info': 2, 'warn': 0, 'error': 0}
4782 self.check_results(r, expected_counts)
4783
4784- def test_check_snappy_readme_md_squashfs(self):
4785- '''Test check_snappy_readme_md() - squashfs file'''
4786- with patch("clickreviews.cr_lint.is_squashfs") as mock_is_squashfs:
4787- mock_is_squashfs.return_value = True
4788- with patch("clickreviews.cr_lint.ClickReviewLint."
4789- "_extract_readme_md") as mock_readme_md:
4790- mock_readme_md.return_value = "Something suitably long"
4791- c = ClickReviewLint(self.test_name)
4792- c.unpack_dir = "/nonexistent.nonexec"
4793- c.check_snappy_readme_md()
4794- r = c.click_report
4795- expected_counts = {'info': None, 'warn': 0, 'error': 0}
4796- self.check_results(r, expected_counts)
4797- self.assertFalse(mock_readme_md.called)
4798-
4799 def test_check_snappy_readme_md_bad(self):
4800 '''Test check_snappy_readme_md() - short'''
4801+ self.set_test_pkgfmt("snap", "15.04")
4802 self.set_test_pkg_yaml("name", "prettylong.name")
4803 self.set_test_readme_md("abc")
4804 c = ClickReviewLint(self.test_name)
4805@@ -1781,6 +1515,7 @@
4806
4807 def test_check_snappy_readme_md_bad2(self):
4808 '''Test check_snappy_readme_md() - missing'''
4809+ self.set_test_pkgfmt("snap", "15.04")
4810 self.set_test_pkg_yaml("name", self.test_name.split('_')[0])
4811 self.set_test_readme_md(None)
4812 c = ClickReviewLint(self.test_name)
4813@@ -1791,6 +1526,7 @@
4814
4815 def test_check_snappy_services_and_binaries1(self):
4816 '''Test check_snappy_services_and_binaries() - different'''
4817+ self.set_test_pkgfmt("snap", "15.04")
4818 self.set_test_pkg_yaml("name", self.test_name.split('_')[0])
4819 self.set_test_pkg_yaml("services", [{"name": "foo",
4820 "start": "bin/foo"}])
4821@@ -1803,6 +1539,7 @@
4822
4823 def test_check_snappy_services_and_binaries2(self):
4824 '''Test check_snappy_services_and_binaries() - different (exec)'''
4825+ self.set_test_pkgfmt("snap", "15.04")
4826 self.set_test_pkg_yaml("name", self.test_name.split('_')[0])
4827 self.set_test_pkg_yaml("services", [{"name": "foo",
4828 "start": "bin/foo"}])
4829@@ -1816,6 +1553,7 @@
4830
4831 def test_check_snappy_services_and_binaries3(self):
4832 '''Test check_snappy_services_and_binaries() - same'''
4833+ self.set_test_pkgfmt("snap", "15.04")
4834 self.set_test_pkg_yaml("name", self.test_name.split('_')[0])
4835 self.set_test_pkg_yaml("services", [{"name": "foo",
4836 "start": "bin/foo"}])
4837@@ -1835,6 +1573,7 @@
4838
4839 def test_check_snappy_services_and_binaries4(self):
4840 '''Test check_snappy_services_and_binaries() - same (subdir)'''
4841+ self.set_test_pkgfmt("snap", "15.04")
4842 self.set_test_pkg_yaml("name", self.test_name.split('_')[0])
4843 self.set_test_pkg_yaml("services", [{"name": "foo",
4844 "start": "bin/foo"}])
4845@@ -1854,6 +1593,7 @@
4846
4847 def test_check_snappy_services_and_binaries5(self):
4848 '''Test check_snappy_services_and_binaries() - same (exec, subdir)'''
4849+ self.set_test_pkgfmt("snap", "15.04")
4850 self.set_test_pkg_yaml("name", self.test_name.split('_')[0])
4851 self.set_test_pkg_yaml("services", [{"name": "foo",
4852 "start": "bin/foo"}])
4853@@ -1874,8 +1614,9 @@
4854
4855 def test_check_snappy_hashes_click(self):
4856 '''Test check_snappy_hashes() - click'''
4857+ self.set_test_pkgfmt("click", "0.4")
4858 c = ClickReviewLint(self.test_name)
4859- c.is_snap = False
4860+ c.is_snap1 = False
4861 c.check_snappy_hashes()
4862 r = c.click_report
4863 # clicks don't have hashes.yaml, so should have no output
4864@@ -1884,8 +1625,8 @@
4865
4866 def test_check_snappy_hashes_archive_sha512_missing(self):
4867 '''Test check_snappy_hashes() - archive-sha512 missing'''
4868+ self.set_test_pkgfmt("snap", "15.04")
4869 c = ClickReviewLint(self.test_name)
4870- c.is_snap = True
4871 c.check_snappy_hashes()
4872 r = c.click_report
4873 expected_counts = {'info': 0, 'warn': 0, 'error': 1}
4874@@ -1893,8 +1634,8 @@
4875
4876 def test_check_snappy_hashes_archive_sha512_invalid(self):
4877 '''Test check_snappy_hashes() - archive-sha512 invalid'''
4878+ self.set_test_pkgfmt("snap", "15.04")
4879 c = ClickReviewLint(self.test_name)
4880- c.is_snap = True
4881 yaml = self._create_hashes_yaml()
4882 yaml['archive-sha512'] = 'deadbeef'
4883 self.set_test_hashes_yaml(yaml)
4884@@ -1908,8 +1649,8 @@
4885
4886 def test_check_snappy_hashes_archive_files_missing(self):
4887 '''Test check_snappy_hashes() - files missing'''
4888+ self.set_test_pkgfmt("snap", "15.04")
4889 c = ClickReviewLint(self.test_name)
4890- c.is_snap = True
4891 yaml = self._create_hashes_yaml()
4892 del yaml['files']
4893 self.set_test_hashes_yaml(yaml)
4894@@ -1923,8 +1664,8 @@
4895
4896 def test_check_snappy_hashes_archive_files_ok(self):
4897 '''Test check_snappy_hashes() - ok'''
4898+ self.set_test_pkgfmt("snap", "15.04")
4899 c = ClickReviewLint(self.test_name)
4900- c.is_snap = True
4901 yaml = self._create_hashes_yaml()
4902 c.pkg_files = self._test_pkg_files
4903 self.set_test_hashes_yaml(yaml)
4904@@ -1937,7 +1678,6 @@
4905 '''Test check_snappy_hashes() - 15.04'''
4906 self.set_test_pkgfmt("snap", "15.04")
4907 c = ClickReviewLint(self.test_name)
4908- c.is_snap = True
4909 yaml = self._create_hashes_yaml()
4910 c.pkg_files = self._test_pkg_files
4911 self.set_test_hashes_yaml(yaml)
4912@@ -1946,24 +1686,10 @@
4913 expected_counts = {'info': 4, 'warn': 0, 'error': 0}
4914 self.check_results(r, expected_counts)
4915
4916- def test_check_snappy_hashes_1604(self):
4917- '''Test check_snappy_hashes() - 16.04'''
4918- self.set_test_pkgfmt("snap", "16.04")
4919- c = ClickReviewLint(self.test_name)
4920- c.is_snap = True
4921- yaml = self._create_hashes_yaml()
4922- c.pkg_files = self._test_pkg_files
4923- self.set_test_hashes_yaml(yaml)
4924- c.check_snappy_hashes()
4925- r = c.click_report
4926- # this should be empty with this package format
4927- expected_counts = {'info': 0, 'warn': 0, 'error': 0}
4928- self.check_results(r, expected_counts)
4929-
4930 def test_check_snappy_hashes_archive_files_missing_name(self):
4931 '''Test check_snappy_hashes() - missing name'''
4932+ self.set_test_pkgfmt("snap", "15.04")
4933 c = ClickReviewLint(self.test_name)
4934- c.is_snap = True
4935 yaml = self._create_hashes_yaml()
4936 del yaml['files'][0]['name']
4937 self.set_test_hashes_yaml(yaml)
4938@@ -1974,8 +1700,8 @@
4939
4940 def test_check_snappy_hashes_archive_files_missing_mode(self):
4941 '''Test check_snappy_hashes() - missing mode'''
4942+ self.set_test_pkgfmt("snap", "15.04")
4943 c = ClickReviewLint(self.test_name)
4944- c.is_snap = True
4945 yaml = self._create_hashes_yaml()
4946 del yaml['files'][0]['mode']
4947 self.set_test_hashes_yaml(yaml)
4948@@ -1986,8 +1712,8 @@
4949
4950 def test_check_snappy_hashes_archive_files_malformed_mode(self):
4951 '''Test check_snappy_hashes() - malformed mode'''
4952+ self.set_test_pkgfmt("snap", "15.04")
4953 c = ClickReviewLint(self.test_name)
4954- c.is_snap = True
4955 yaml = self._create_hashes_yaml()
4956 yaml['files'][0]['mode'] += 'extra'
4957 self.set_test_hashes_yaml(yaml)
4958@@ -1998,8 +1724,8 @@
4959
4960 def test_check_snappy_hashes_archive_files_bad_mode_entry(self):
4961 '''Test check_snappy_hashes() - bad mode entry'''
4962+ self.set_test_pkgfmt("snap", "15.04")
4963 c = ClickReviewLint(self.test_name)
4964- c.is_snap = True
4965 yaml = self._create_hashes_yaml()
4966 count = 0
4967 orig_mode = None
4968@@ -2023,8 +1749,8 @@
4969
4970 def test_check_snappy_hashes_archive_files_mode_world_write(self):
4971 '''Test check_snappy_hashes() - mode world write'''
4972+ self.set_test_pkgfmt("snap", "15.04")
4973 c = ClickReviewLint(self.test_name)
4974- c.is_snap = True
4975 yaml = self._create_hashes_yaml()
4976 count = 0
4977 for e in yaml['files']:
4978@@ -2045,8 +1771,8 @@
4979
4980 def test_check_snappy_hashes_archive_files_mode_mismatch(self):
4981 '''Test check_snappy_hashes() - mode mismatch'''
4982+ self.set_test_pkgfmt("snap", "15.04")
4983 c = ClickReviewLint(self.test_name)
4984- c.is_snap = True
4985 yaml = self._create_hashes_yaml()
4986 count = 0
4987 orig_mode = None
4988@@ -2068,8 +1794,8 @@
4989
4990 def test_check_snappy_hashes_archive_files_mode_bad_symlink(self):
4991 '''Test check_snappy_hashes() - mode bad symlink'''
4992+ self.set_test_pkgfmt("snap", "15.04")
4993 c = ClickReviewLint(self.test_name)
4994- c.is_snap = True
4995 yaml = self._create_hashes_yaml()
4996 yaml['files'].append({'name': 'badlink', 'mode': 'lrwxrwxr-x'})
4997 self.set_test_hashes_yaml(yaml)
4998@@ -2083,8 +1809,8 @@
4999
5000 def test_check_snappy_hashes_archive_files_mode_devices(self):
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches