Merge ~zhsj/+git/pkgbinarymangler:lp2002871 into ~ubuntu-core-dev/+git/pkgbinarymangler:master

Proposed by Shengjing Zhu
Status: Merged
Merged at revision: 24ec5b1659a0f89e0b118e84e10e035aa2f5f937
Proposed branch: ~zhsj/+git/pkgbinarymangler:lp2002871
Merge into: ~ubuntu-core-dev/+git/pkgbinarymangler:master
Diff against target: 239 lines (+95/-21)
4 files modified
debian/changelog (+3/-4)
pkgstripfiles (+33/-0)
test/icecream/debian/rules (+1/-0)
test/run (+58/-17)
Reviewer Review Type Date Requested Status
Gunnar Hjalmarsson Approve
Colin Watson Pending
Dimitri John Ledkov Pending
Review via email: mp+437569@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

Approving this based on the short conversation here:

https://irclogs.ubuntu.com/2023/02/21/%23ubuntu-devel.html#t10:37

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index ac61184..cda2d25 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,9 +1,8 @@
6-pkgbinarymangler (152) UNRELEASED; urgency=medium
7+pkgbinarymangler (152) lunar; urgency=medium
8
9 [ Shengjing Zhu ]
10- * pkgstripfiles: no longer strip debian changelog.
11- It's now enabled by default in debhelper >= 13.10. But debhelper
12- strips debian changelog for PPA as well.
13+ * pkgstripfiles: only strip debian changelog if debhelper hasn't done so.
14+ debhelper >= 13.10 strips debian changelog by default.
15
16 [ Gunnar Hjalmarsson ]
17 * Add VCS fields
18diff --git a/pkgstripfiles b/pkgstripfiles
19index a0ea6dd..ed68b9b 100755
20--- a/pkgstripfiles
21+++ b/pkgstripfiles
22@@ -29,6 +29,38 @@ clean_upstream_changelogs()
23 }
24
25 #
26+# Only keep the topmost ten entries in Debian changelogs. If we truncate, add a
27+# pointer to apt-get changelog.
28+#
29+strip_debian_changelogs()
30+{
31+ record_sep="^[^ ]+ (.*) .*; urgency"
32+ if [ -e "$dch" -a ! -L "$dch" ]; then
33+ if zgrep -q "Older entries have been removed from this changelog." $dch;
34+ # already stripped by debhelper >= 13.10
35+ then return;
36+ fi
37+ record_count=0
38+ changelog=""
39+ gzip -cd $dch | (while read; do
40+ if [[ "$REPLY" =~ $record_sep ]]; then
41+ ((++record_count))
42+ if [ "$record_count" -eq 11 ]; then
43+ echo "pkgstripfiles: Truncating $dch to topmost ten records"
44+ echo -e "${changelog}# For older changelog entries, run 'apt-get changelog $PKGNAME'" | gzip -9n > $dch
45+ if [ -f DEBIAN/md5sums ]; then
46+ MD5=`md5sum "$dch"`
47+ sed -i "s%^.* $dch\$%$MD5%" DEBIAN/md5sums
48+ fi
49+ break
50+ fi
51+ fi
52+ changelog="$changelog$REPLY\n"
53+ done)
54+ fi
55+}
56+
57+#
58 # Optimize PNGs
59 #
60 optimize_pngs()
61@@ -269,6 +301,7 @@ trap clear_lock 1 2 3 7 10 13 15
62 wait_for_lock
63
64 symlink_doc
65+strip_debian_changelogs
66 optimize_pngs
67
68 clear_lock
69diff --git a/test/icecream/debian/rules b/test/icecream/debian/rules
70index bc499e3..3f0cd14 100755
71--- a/test/icecream/debian/rules
72+++ b/test/icecream/debian/rules
73@@ -1,4 +1,5 @@
74 #!/usr/bin/make -f
75+
76 %:
77 dh $@ --with translations --parallel
78
79diff --git a/test/run b/test/run
80index 3a7da50..ca78a06 100755
81--- a/test/run
82+++ b/test/run
83@@ -555,8 +555,6 @@ Purpose: PRIMARY
84 def test_debian_changelog_truncation(self):
85 '''Long Debian changelog gets truncated'''
86
87- # debian changelog truncations is moved to debhelper but the tests have been kept.
88-
89 # change into non-native package
90 cpath = os.path.join(self.pkgdir, 'debian', 'changelog')
91 with open(cpath) as f:
92@@ -566,7 +564,7 @@ Purpose: PRIMARY
93 f.write(''.join(contents))
94 f.close()
95
96- self.build()
97+ self.build(extra_env={'DEB_BUILD_OPTIONS': 'notrimdch'})
98 self.check_deb_stripfiles(False)
99
100 deb = glob(os.path.join(self.workdir, 'vanilla_12*_*.deb'))[0]
101@@ -577,16 +575,15 @@ Purpose: PRIMARY
102 self.assertEqual(err, b'')
103 self.assertIn('icecream (12-1)', out)
104 self.assertIn('\n * release 12', out)
105+ self.assertIn('icecream (3)', out)
106 self.assertNotIn('icecream (2)', out)
107 self.assertNotIn('icecream (1)', out)
108- self.assertIn('apt changelog', out)
109+ self.assertIn('apt-get changelog', out)
110
111 def test_native_changelog_truncation(self):
112 '''Long Debian changelog for native packages gets truncated'''
113
114- # debian changelog truncations is moved to debhelper but the tests have been kept.
115-
116- self.build()
117+ self.build(extra_env={'DEB_BUILD_OPTIONS': 'notrimdch'})
118 self.check_deb_stripfiles(False)
119
120 deb = glob(os.path.join(self.workdir, 'vanilla_12*_*.deb'))[0]
121@@ -597,9 +594,10 @@ Purpose: PRIMARY
122 self.assertEqual(err, b'')
123 self.assertIn('icecream (12)', out)
124 self.assertIn('\n * release 12', out)
125+ self.assertIn('icecream (3)', out)
126 self.assertNotIn('icecream (2)', out)
127 self.assertNotIn('icecream (1)', out)
128- self.assertIn('apt changelog', out)
129+ self.assertIn('apt-get changelog', out)
130
131 def test_native_changelog_truncation_symlink(self):
132 '''Long Debian changelog for native packages with symlinked doc dir'''
133@@ -615,7 +613,7 @@ override_dh_installdocs:
134 ln -s vanilla-base debian/vanilla/usr/share/doc/vanilla
135 ''')
136
137- self.build()
138+ self.build(extra_env={'DEB_BUILD_OPTIONS': 'notrimdch'})
139
140 deb = glob(os.path.join(self.workdir, 'vanilla_12*_*.deb'))[0]
141 dpkg = subprocess.Popen('dpkg-deb --fsys-tarfile %s | tar xO ./usr/share/doc/vanilla-base/changelog.gz | gzip -cd' % deb,
142@@ -630,8 +628,6 @@ override_dh_installdocs:
143 def test_short_debian_changelog(self):
144 '''Short Debian changelog remains unaltered'''
145
146- # debian changelog truncations is moved to debhelper but the tests have been kept.
147-
148 # change into non-native package
149 cpath = os.path.join(self.pkgdir, 'debian', 'changelog')
150 with open(cpath) as f:
151@@ -640,7 +636,7 @@ override_dh_installdocs:
152 with open(cpath, 'w') as f:
153 f.write(''.join(contents))
154
155- self.build()
156+ self.build(extra_env={'DEB_BUILD_OPTIONS': 'notrimdch'})
157 self.check_deb_stripfiles(False)
158
159 deb = glob(os.path.join(self.workdir, 'vanilla_12*_*.deb'))[0]
160@@ -652,13 +648,11 @@ override_dh_installdocs:
161 self.assertIn('icecream (12-1)', out)
162 self.assertIn('icecream (11)', out)
163 self.assertNotIn('icecream (10)', out)
164- self.assertNotIn('apt changelog', out)
165+ self.assertNotIn('apt-get changelog', out)
166
167 def test_short_native_changelog(self):
168 '''Short Debian changelog for native packages remains unaltered'''
169
170- # debian changelog truncations is moved to debhelper but the tests have been kept.
171-
172 # truncate changelog
173 cpath = os.path.join(self.pkgdir, 'debian', 'changelog')
174 with open(cpath) as f:
175@@ -666,7 +660,7 @@ override_dh_installdocs:
176 with open(cpath, 'w') as f:
177 f.write(''.join(contents))
178
179- self.build()
180+ self.build(extra_env={'DEB_BUILD_OPTIONS': 'notrimdch'})
181 self.check_deb_stripfiles(False)
182
183 deb = glob(os.path.join(self.workdir, 'vanilla_12*_*.deb'))[0]
184@@ -678,7 +672,54 @@ override_dh_installdocs:
185 self.assertIn('icecream (12)', out)
186 self.assertIn('icecream (11)', out)
187 self.assertNotIn('icecream (10)', out)
188- self.assertNotIn('apt changelog', out)
189+ self.assertNotIn('apt-get changelog', out)
190+
191+ def test_ppa_debian_changelog(self):
192+ '''Debian changelog in PPA build remains unaltered'''
193+
194+ self.buildinfo = '''Package: icecream
195+Component: main
196+Suite: lucid
197+Purpose: PPA
198+'''
199+
200+ # change into non-native package
201+ cpath = os.path.join(self.pkgdir, 'debian', 'changelog')
202+ with open(cpath) as f:
203+ contents = f.readlines()
204+ contents[0] = contents[0].replace('(12)', '(12-1)')
205+ with open(cpath, 'w') as f:
206+ f.write(''.join(contents))
207+
208+ self.build(extra_env={'DEB_BUILD_OPTIONS': 'notrimdch'})
209+ self.check_deb_stripfiles(True)
210+
211+ deb = glob(os.path.join(self.workdir, 'vanilla_12*_*.deb'))[0]
212+ dpkg = subprocess.Popen('dpkg-deb --fsys-tarfile %s | tar xO ./usr/share/doc/vanilla/changelog.Debian.gz | gzip -cd' % deb,
213+ shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
214+ (out, err) = dpkg.communicate()
215+ out = out.decode()
216+ self.assertEqual(err, b'')
217+ self.assertIn('icecream (12-1)', out)
218+ self.assertIn('icecream (11)', out)
219+ self.assertIn('icecream (1)', out)
220+ self.assertNotIn('apt-get changelog', out)
221+
222+ def test_debian_changelog_truncation_by_debhelper(self):
223+ '''Long Debian changelog gets truncated by debhelper'''
224+
225+ self.build(extra_env={'DEB_BUILD_OPTIONS': 'trimdch'})
226+
227+ deb = glob(os.path.join(self.workdir, 'vanilla_12*_*.deb'))[0]
228+ dpkg = subprocess.Popen('dpkg-deb --fsys-tarfile %s | tar xO ./usr/share/doc/vanilla/changelog.gz | gzip -cd' % deb,
229+ shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
230+ (out, err) = dpkg.communicate()
231+ out = out.decode()
232+ self.assertEqual(err, b'')
233+ self.assertNotIn('icecream (1)', out)
234+ # we use "apt-get changelog"; but debhelper use "apt changelog"
235+ self.assertIn('apt changelog', out)
236+ self.assertNotIn('apt-get changelog', out)
237
238 def test_png_shrinking(self):
239 '''PNGs get optimized, and non-PNGs unmodified'''

Subscribers

People subscribed via source and target branches