Merge lp:~sil2100/cupstream2distro/whitelist_symbols_refresh into lp:cupstream2distro

Proposed by Łukasz Zemczak on 2015-05-11
Status: Merged
Approved by: Łukasz Zemczak on 2015-05-12
Approved revision: 981
Merged at revision: 980
Proposed branch: lp:~sil2100/cupstream2distro/whitelist_symbols_refresh
Merge into: lp:cupstream2distro
Diff against target: 82 lines (+44/-3)
3 files modified
cupstream2distro/packagemanager.py (+12/-3)
tests/data/results/simple_update_alone_arch.changelog (+12/-0)
tests/unit/test_packagemanager.py (+20/-0)
To merge this branch: bzr merge lp:~sil2100/cupstream2distro/whitelist_symbols_refresh
Reviewer Review Type Date Requested Status
Barry Warsaw (community) 2015-05-11 Approve on 2015-05-11
PS Jenkins bot continuous-integration Approve on 2015-05-11
Review via email: mp+258803@code.launchpad.net

Commit Message

Change the refresh_package_versions() method to only update symbols in selected, whitelisted files. The debian/ directory can generally even ship with binaries in it, so replacing any file that's in the directory can potentially be very risky.

Description of the Change

Change the refresh_package_versions() method to only update symbols in selected, whitelisted files. The debian/ directory can generally even ship with binaries in it, so replacing any file that's in the directory can potentially be very risky.
Barry already encountered a problem where the train barfed out trying to interpret a binary blob from debian/ as UTF-8.

To post a comment you must log in.
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:981
http://jenkins.qa.ubuntu.com/job/cu2d-choo-choo-ci/641/
Executed test runs:

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/cu2d-choo-choo-ci/641/rebuild

review: Approve (continuous-integration)
Barry Warsaw (barry) wrote :

LGTM. The symbols globs might be a bit too wide, but I guess if that's ever a problem you can deal with it then.

review: Approve
Łukasz Zemczak (sil2100) wrote :

Tested on staging, looks fine - merging.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cupstream2distro/packagemanager.py'
2--- cupstream2distro/packagemanager.py 2015-03-16 02:14:52 +0000
3+++ cupstream2distro/packagemanager.py 2015-05-11 17:56:40 +0000
4@@ -171,14 +171,23 @@
5 return 'no-rewrite-version' in line
6
7 def refresh_package_versions(self, version, tag='0replaceme'):
8- """Replace 0replaceme with real versions in any debian/* files.
9+ """Replace 0replaceme with real versions in selected debian/ files.
10
11 :param version: The version to insert.
12 """
13- logging.info('Refreshing versions in debian/* files.')
14+ logging.info('Refreshing versions in selected debian/ files.')
15 replaced = set()
16 upstream = V(version).get_upstream(epoch=True)
17- for path in glob(os_path_join_safe(self.debian, '*')):
18+
19+ whitelist = [
20+ '*.symbols*', 'symbols*', 'rules',
21+ 'control', 'changelog', 'copyright'
22+ ]
23+ files = []
24+ for entry in whitelist:
25+ files.extend(glob(os_path_join_safe(self.debian, entry)))
26+
27+ for path in files:
28 if os.path.isfile(path) and not os.path.islink(path):
29 for line, new in utf8_inplace(path):
30 if tag in line:
31
32=== added file 'tests/data/results/simple_update_alone_arch.changelog'
33--- tests/data/results/simple_update_alone_arch.changelog 1970-01-01 00:00:00 +0000
34+++ tests/data/results/simple_update_alone_arch.changelog 2015-05-11 17:56:40 +0000
35@@ -0,0 +1,12 @@
36+foo (42.0daily83.09.13-0ubuntu2) UNRELEASED; urgency=low
37+
38+ * debian/symbols.amd64: update to released version.
39+
40+ -- CI Train Bot <ci-train-bot@canonical.com> Fri, 08 Mar 2013 16:33:04 +0100
41+
42+foo (42.0daily83.09.13-0ubuntu1) raring; urgency=low
43+
44+ * We snapshotted it for please
45+ * Automatic snapshot from revision 1
46+
47+ -- Automatic Didrocks uploader <did@machine.fr> Fri, 13 Sep 1983 04:02:00 +0000
48
49=== modified file 'tests/unit/test_packagemanager.py'
50--- tests/unit/test_packagemanager.py 2015-03-16 02:14:52 +0000
51+++ tests/unit/test_packagemanager.py 2015-05-11 17:56:40 +0000
52@@ -620,6 +620,18 @@
53 self.assertChangelogFilesAreIdenticals(result_changelog, changelog)
54 self.assertFilesAreIdenticals(symbols, result_symbols)
55
56+ def test_refresh_symbols_files_alone_symbol_with_arch(self):
57+ """Update a symbols.arch file."""
58+ changelog = self.prep_debian_file('changelog', s.BASE_CHANGELOG)
59+ symbols = self.prep_debian_file('symbols.amd64', s.BASIC_SYMBOLS)
60+ self.package.refresh_package_versions('42.0daily83.09.14-0ubuntu1')
61+ result_symbols = os_path_join_safe(
62+ self.result_dir, 'simple_update.symbols')
63+ result_changelog = os_path_join_safe(
64+ self.result_dir, 'simple_update_alone_arch.changelog')
65+ self.assertFilesAreIdenticals(symbols, result_symbols)
66+ self.assertChangelogFilesAreIdenticals(result_changelog, changelog)
67+
68 def test_dont_refresh_symbols_files_for_directory(self):
69 """We don't fail for directories under debian/."""
70 self.prep_debian_file('changelog', s.DUMMY_CHANGELOG)
71@@ -639,3 +651,11 @@
72 self.package.refresh_package_versions('42.0daily83.09.14-0ubuntu1')
73 self.assertTrue(os.path.islink(symlink_path))
74 self.assertEqual('foo.symbols', os.readlink(symlink_path))
75+
76+ def test_dont_refresh_symbols_files_for_others(self):
77+ """We don't update unrelated files under debian/."""
78+ self.prep_debian_file('changelog', s.BASE_CHANGELOG)
79+ other = self.prep_debian_file('almostbinary', s.BASIC_SYMBOLS)
80+ self.package.refresh_package_versions('42.0daily83.09.14-0ubuntu1')
81+ with utf8_open(other) as fd:
82+ self.assertEqual(fd.read(), s.BASIC_SYMBOLS)

Subscribers

People subscribed via source and target branches