Merge lp:~seb128/pkgbinarymangler/keywords into lp:pkgbinarymangler

Proposed by Sebastien Bacher on 2012-03-08
Status: Superseded
Proposed branch: lp:~seb128/pkgbinarymangler/keywords
Merge into: lp:pkgbinarymangler
Diff against target: 3803 lines (+3719/-0) (has conflicts)
16 files modified
common.OTHER (+62/-0)
debian/changelog.OTHER (+1127/-0)
debian/control.OTHER (+51/-0)
debian/pkgbinarymangler.install.OTHER (+13/-0)
debian/pkgbinarymangler.postrm.OTHER (+15/-0)
debian/pkgbinarymangler.preinst.OTHER (+22/-0)
dh_builddeb (+9/-0)
dh_translations.OTHER (+292/-0)
pkgmaintainermangler.OTHER (+69/-0)
pkgsanitychecks.OTHER (+52/-0)
pkgstripfiles.OTHER (+208/-0)
pkgstriptranslations.OTHER (+382/-0)
striptranslations.blacklist.OTHER (+12/-0)
test/icecream/data/translated.desktop.OTHER (+16/-0)
test/icecream/debian/rules.OTHER (+10/-0)
test/run.OTHER (+1379/-0)
Contents conflict in common
Conflict adding files to debian.  Created directory.
Conflict because debian is not versioned, but has versioned children.  Versioned directory.
Contents conflict in debian/changelog
Contents conflict in debian/control
Contents conflict in debian/pkgbinarymangler.install
Contents conflict in debian/pkgbinarymangler.postrm
Contents conflict in debian/pkgbinarymangler.preinst
Contents conflict in dh_translations
Contents conflict in pkgmaintainermangler
Contents conflict in pkgsanitychecks
Contents conflict in pkgstripfiles
Contents conflict in pkgstriptranslations
Contents conflict in striptranslations.blacklist
Conflict adding files to test.  Created directory.
Conflict because test is not versioned, but has versioned children.  Versioned directory.
Conflict adding files to test/icecream.  Created directory.
Conflict because test/icecream is not versioned, but has versioned children.  Versioned directory.
Conflict adding files to test/icecream/data.  Created directory.
Conflict because test/icecream/data is not versioned, but has versioned children.  Versioned directory.
Contents conflict in test/icecream/data/translated.desktop
Conflict adding files to test/icecream/debian.  Created directory.
Conflict because test/icecream/debian is not versioned, but has versioned children.  Versioned directory.
Contents conflict in test/icecream/debian/rules
Contents conflict in test/run
To merge this branch: bzr merge lp:~seb128/pkgbinarymangler/keywords
Reviewer Review Type Date Requested Status
Martin Pitt 2012-03-08 Disapprove on 2012-03-08
Ubuntu Core Development Team 2012-03-08 Pending
Review via email: mp+96550@code.launchpad.net

This proposal has been superseded by a proposal from 2012-03-08.

Description of the change

  * pkgstriptranslations: change X-GNOME-Keywords to official Keywords
    (lp: #949849)

I've opted to drop the X-GNOME-Keywords use, it has almost no rdepends and I don't want to support both in glib, easier to fix the few rdepends

To post a comment you must log in.
Loïc Minier (lool) wrote :

I don't know why this has conflicts all over the place, but http://bazaar.launchpad.net/~seb128/pkgbinarymangler/keywords/revision/243 looks ok, except I would strip both the old and the new keyword header from .desktop files and extend the test to have both headers -- mainly in case there are still .desktop files with the old header in the archive or out of archive (unlikely to use pkgbinarymangler though), or for backports (unlikely too).

Martin Pitt (pitti) wrote :

lp:pkgbinarymangler does not exist any more. It only has a README explaining why it's obsolete. Please use lp:ubuntu/pkgbinarymangler.

review: Disapprove

Unmerged revisions

243. By Sebastien Bacher on 2012-03-08

pkgstriptranslations: change X-GNOME-Keywords to official Keywords
(lp: #949849)

242. By Martin Pitt on 2012-02-15

releasing version 115

241. By Martin Pitt on 2012-02-12

pkgstriptranslations: Fix updating of md5sums in gnome2_help() and
mallard_help(). (LP: #930757)

240. By Martin Pitt on 2012-02-03

releasing version 114

239. By Martin Pitt on 2012-01-31

pkgstripfiles: Do not truncate changelogs when they are in a different
directory pointed to a symlink. Add corresponding test case which mimics
the perl hack that it applies to its doc files. (LP: #923430)

238. By Martin Pitt on 2012-01-30

pkgstripfiles: Always update md5sum even if advpng fails. Also call advpng
if optipng fails, to at least get some optimization. Thanks Felix Geyer!
(LP: #923407)

237. By Martin Pitt on 2012-01-30

* pkgstripfiles, symlink_doc(): Don't create symlinks that would point to
  the same package. (LP: #923343)
* test/run: Add test_doc_symlink_dependency_cycle() to make sure that
  pkgstripfiles works correctly when there is a dependency cycle inside
  a source package.

236. By Sebastien Bacher on 2012-01-13

releasing version 113

235. By Sebastien Bacher on 2012-01-13

dh_translations: fixes previous issues harder (lp: #913085)

234. By Sebastien Bacher on 2012-01-13

releasing version 112

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'common.OTHER'
2--- common.OTHER 1970-01-01 00:00:00 +0000
3+++ common.OTHER 2012-03-08 11:48:20 +0000
4@@ -0,0 +1,62 @@
5+# read value for attribute $2 in dpkg control style file $1
6+# return value in $RET
7+readctrl() {
8+ _line=$(grep "^$2: " $1) || true
9+ RET=${_line#"$2: "}
10+}
11+
12+#
13+# Execution starts here
14+#
15+
16+# Check configuration: enabled?
17+[ -f "$CONFFILE" ] || exit 0
18+readctrl "$CONFFILE" "enable"
19+[ "$RET" = "true" ] || exit 0
20+
21+if [ ! -f debian/control ]; then
22+ echo "$0: Error: not in source package directory" >&2
23+ exit 0
24+fi
25+
26+srcname=$(dpkg-parsechangelog | grep ^Source: | cut -f 2 -d\ )
27+version=$(dpkg-parsechangelog | grep ^Version: | cut -f 2 -d\ )
28+version=${version#*:}
29+
30+BUILDINFO=${CURRENTLY_BUILDING_PATH:-"/CurrentlyBuilding"}
31+
32+# check whether build info is present and if it's consistent
33+if [ "$PKG_IGNORE_CURRENTLY_BUILDING" != 1 ] && [ -f "$BUILDINFO" ]; then
34+ unset ignore_invalid_cb
35+ readctrl "$CONFFILE" "invalid_currentlybuilding"
36+ [ "$RET" != "ignore" ] || ignore_invalid_cb=1
37+
38+ readctrl "$BUILDINFO" "Package"
39+
40+ if [ "$RET" != $srcname ]; then
41+ echo "$0: inconsistent $BUILDINFO file, Package: value is $RET (should be $srcname)" >&2
42+ [ "$ignore_invalid_cb" ] || exit 1
43+ fi
44+
45+ readctrl "$BUILDINFO" "Component"
46+ if [ -z "$RET" ]; then
47+ echo "$0: inconsistent $BUILDINFO file, Component: value is empty" >&2
48+ [ "$ignore_invalid_cb" ] || exit 1
49+ fi
50+fi
51+
52+# find binary package control file and name
53+while [ $# -gt 0 ]; do
54+ if [ -f "$1"/DEBIAN/control ]; then
55+ PKGCTL="$1"/DEBIAN/control
56+ break
57+ else
58+ shift
59+ fi
60+done
61+
62+if [ -z "$PKGCTL" ]; then
63+ echo "$0: did not find a package name argument or control file, skipping"
64+ exit 0
65+fi
66+
67
68=== added directory 'debian'
69=== added file 'debian/changelog.OTHER'
70--- debian/changelog.OTHER 1970-01-01 00:00:00 +0000
71+++ debian/changelog.OTHER 2012-03-08 11:48:20 +0000
72@@ -0,0 +1,1127 @@
73+pkgbinarymangler (116) UNRELEASED; urgency=low
74+
75+ * pkgstriptranslations: change X-GNOME-Keywords to official Keywords
76+ (lp: #949849)
77+
78+ -- Sebastien Bacher <seb128@ubuntu.com> Thu, 08 Mar 2012 12:41:06 +0100
79+
80+pkgbinarymangler (115) precise; urgency=low
81+
82+ [ Felix Geyer ]
83+ * pkgstriptranslations: Fix updating of md5sums in gnome2_help() and
84+ mallard_help(). (LP: #930757)
85+
86+ -- Martin Pitt <martin.pitt@ubuntu.com> Wed, 15 Feb 2012 07:42:22 +0100
87+
88+pkgbinarymangler (114) precise; urgency=low
89+
90+ [ Felix Geyer ]
91+ * pkgstripfiles, symlink_doc(): Don't create symlinks that would point to
92+ the same package. (LP: #923343)
93+ * test/run: Add test_doc_symlink_dependency_cycle() to make sure that
94+ pkgstripfiles works correctly when there is a dependency cycle inside
95+ a source package.
96+
97+ [ Martin Pitt ]
98+ * pkgstripfiles: Always update md5sum even if advpng fails. Also call advpng
99+ if optipng fails, to at least get some optimization. Thanks Felix Geyer!
100+ (LP: #923407)
101+ * pkgstripfiles: Do not truncate changelogs when they are in a different
102+ directory pointed to a symlink. Add corresponding test case which mimics
103+ the perl hack that it applies to its doc files. (LP: #923430)
104+
105+ -- Martin Pitt <martin.pitt@ubuntu.com> Fri, 03 Feb 2012 06:36:35 +0100
106+
107+pkgbinarymangler (113) precise; urgency=low
108+
109+ * dh_translations: fixes previous issues harder (lp: #913085)
110+
111+ -- Sebastien Bacher <seb128@ubuntu.com> Fri, 13 Jan 2012 17:06:18 +0100
112+
113+pkgbinarymangler (112) precise; urgency=low
114+
115+ * dh_translations:
116+ - strip out quotes from the gettext domain (lp: #913085)
117+
118+ -- Sebastien Bacher <seb128@ubuntu.com> Fri, 13 Jan 2012 10:23:28 +0100
119+
120+pkgbinarymangler (111) precise; urgency=low
121+
122+ * small improvements to dh_translations:
123+ - close the correct file in the configure.ac case
124+ - try using configure.in after configure.ac, those are still common
125+ - get the gettext domain from config.h if possible, the configure.ac can
126+ use variables and reading from it would give the wrong value
127+
128+ -- Sebastien Bacher <seb128@ubuntu.com> Thu, 05 Jan 2012 15:20:36 +0100
129+
130+pkgbinarymangler (110) precise; urgency=low
131+
132+ [ Martin Pitt ]
133+ * pkgstripfiles: Log how many seconds the PNG optimization took.
134+ * pkgstripfiles: Skip PNG optimization for -doc packages. They sometimes
135+ take an inordinate amount of build time and are much less important as we
136+ do not ship them on CD images.
137+
138+ [ Evan Broder ]
139+ * pkgstriptranslations: Use a copy of the code from dh_link to make sure
140+ pkgstriptranslations creates symlinks compliant with Debian
141+ Policy. (LP: #899520)
142+ * test/run: Adjust tests to expect relative symlinks.
143+
144+ -- Martin Pitt <martin.pitt@ubuntu.com> Mon, 12 Dec 2011 12:19:21 +0100
145+
146+pkgbinarymangler (109) precise; urgency=low
147+
148+ * striptranslations.blacklist: Fix libapt entries, these are regexps, not
149+ globs.
150+ * striptranslations.blacklist: Add update-notifier. (LP: #562900)
151+
152+ -- Martin Pitt <martin.pitt@ubuntu.com> Wed, 30 Nov 2011 07:58:02 +0100
153+
154+pkgbinarymangler (108) precise; urgency=low
155+
156+ * test/run: Fix creation of local diversion "fake" symlink to also work when
157+ pkgbinarymangler <= 106 is installed (as on our buildds when we try to
158+ build >= 107 the first time).
159+ * debian/pkgbinarymangler.preinst: Remove obsolete conffile and diversion
160+ migration code. This was last relevant in edgy.
161+
162+ -- Martin Pitt <martin.pitt@ubuntu.com> Tue, 29 Nov 2011 10:21:32 +0100
163+
164+pkgbinarymangler (107) precise; urgency=low
165+
166+ * test/run, test_doc_symlink(): Simplify installation of "Makefile".
167+ * test/run, test_doc_symlink(): Introduce some test library binary packages
168+ to check handling of transitive dependencies.
169+ * pkgstripfiles, symlink_doc(): If the link destination target is itself a
170+ link, resolve it to directly link to the final target instead of not
171+ symlinking the file at all.
172+ * test/run: Add new test cases test_doc_symlink_parallel_{fixed,unlimited}()
173+ which run the symlink test with DEB_BUILD_OPTIONS "parallel=4" and
174+ "parallel" respectively. Run through them three times as this is a race
175+ condition and does not trigger every time. This reproduces LP #893826.
176+ * Add dh_builddeb: Wrapper around the debhelper command which filters out
177+ the "parallel" option from $DEB_BUILD_OPTIONS. We must not run dpkg-deb in
178+ parallel as this breaks a predictable doc symlink structure which we
179+ require for multi-arch. (LP: #893826)
180+ * debian/pkgbinarymangler.install: Install dh_builddeb wrapper.
181+ * debian/pkgbinarymangler.{preinst,postrm}: Set up diversion for
182+ dh_builddeb.
183+
184+ -- Martin Pitt <martin.pitt@ubuntu.com> Tue, 29 Nov 2011 10:00:54 +0100
185+
186+pkgbinarymangler (106) precise; urgency=low
187+
188+ * Move code for determining the location of the binary package control file,
189+ and its existence check into common, and simplify pkgmaintainermangler,
190+ pkgsanitychecks, and pkgstripfiles.
191+ * pkgstriptranslations: Stop iterating over all binary packages, just
192+ process the current one. Update an existing translation tarball if it
193+ already exists from a previous run. This greatly speeds up package builds
194+ with lots of binary packages. (LP: #890595) Also reorganize the code to
195+ put the different tasks into separate functions, so that it becomes
196+ easier to read. Drop the now obsolete stripping of XPI files.
197+ * With this version, haskell-dummy builds in finite time and succeeds.
198+ (LP: #890596)
199+
200+ -- Martin Pitt <martin.pitt@ubuntu.com> Tue, 15 Nov 2011 16:00:12 +0100
201+
202+pkgbinarymangler (105) precise; urgency=low
203+
204+ * pkgstriptranslations: Also strip X-GNOME-Keywords. Add corresponding test
205+ case.
206+ * dh_translations: Also check configure.ac for GETTEXT_DOMAIN. (LP: #786632)
207+ * pkgstripfiles: First symlink identical doc files, then truncate Debian
208+ changelogs. Otherwise truncated changelogs will never be identical due to
209+ the added "please see apt-get changelog <pkgname>" line. In oneiric and
210+ before this got hidden because of a wrong exit code of zcmp, which has
211+ been fixed in gzip 1.4 in precise.
212+ * pkgstripfiles: As we truncate long Debian changelogs, and a packages'
213+ dependencies may not have been processed by pkgstripfiles yet, Debian
214+ changelogs are sometimes different at the tail. Debian changelogs are
215+ generally identical between binary packages anyway, but as there is the
216+ theoretical possibility of having a binary package specific one, do a
217+ comparison still, but only the topmost 20 lines.
218+
219+ -- Martin Pitt <martin.pitt@ubuntu.com> Thu, 27 Oct 2011 14:54:41 +0200
220+
221+pkgbinarymangler (104) oneiric; urgency=low
222+
223+ * Add libapt-pkg* and libapt-inst* to the blacklist. LP: #855085
224+
225+ -- Gabor Kelemen <kelemeng@ubuntu.com> Thu, 22 Sep 2011 09:02:30 +0200
226+
227+pkgbinarymangler (103) oneiric; urgency=low
228+
229+ * debian/control: Drop Vcs-Bzr:, using ubuntu:pkgbinarymangler branch now
230+ (existing history was pushed there).
231+ * test/run: Add test_mallard_help() test case for the new-style
232+ /usr/share/help layout. Reproduces LP#841340.
233+ * pkgstriptranslations: Strip/symlink/save Mallard-style
234+ /usr/share/help/<locale>/<project>/ files. (LP: #841340)
235+
236+ -- Martin Pitt <martin.pitt@ubuntu.com> Mon, 05 Sep 2011 11:44:58 +0200
237+
238+pkgbinarymangler (102) oneiric; urgency=low
239+
240+ * test/icecream/debian/rules, test/icecream/Makefile: Install PNGs with some
241+ defined permissions.
242+ * test/run, check_deb_integrity(): Verify that PNG permissions in the final
243+ debs are as they are expected to be.
244+ * pkgstripfiles: Restore permissions of optimized PNG files to their
245+ original value; advpng does not preserve them. (LP: #817792)
246+
247+ -- Martin Pitt <martin.pitt@ubuntu.com> Sun, 21 Aug 2011 21:13:59 +0200
248+
249+pkgbinarymangler (101) oneiric; urgency=low
250+
251+ * pkgstriptranslations: Run apt-cache under env -u LD_PRELOAD to avoid
252+ running it under fakeroot. This now fails since fakeroot 1.16.1 (see
253+ Debian #629956 and Debian #630591).
254+
255+ -- Martin Pitt <martin.pitt@ubuntu.com> Wed, 15 Jun 2011 14:48:23 +0200
256+
257+pkgbinarymangler (100) oneiric; urgency=low
258+
259+ * test/run: Add forgotten check_deb_integrity() to documentation symlink
260+ tests. This catches the wrong md5sums of symlinked doc files.
261+ * pkgstripfiles: Remove doc files from md5sums which get replaced with a
262+ symlink. (LP: #795845)
263+ * test/run: Call check_deb_integrity() in build(), and remove the explicit
264+ call from all the individual tests. There is no situation where we expect
265+ broken debs to be created, so this saves us from accidentally forgetting
266+ to call it in newly created tests.
267+ * test/run: Drop separate check_translation_tarball() test, and integrate it
268+ into check_deb_mo(). We now want to move to only building translation
269+ tarballs for packages which we actually strip, so it does not make sense
270+ any more to check those two individually.
271+ * pkgstriptranslations: Do not build a translation tarball if we did not
272+ strip the packages. With that, Launchpad does not need to check the
273+ component of the package any more, but can just import everything we throw
274+ at it. This also allows us to put some selected universe packages under
275+ langpack support. (LP: #788685, part 1)
276+ * pkgstriptranslations: Force stripping and translation tarball build if
277+ debian/control has "X..-Ubuntu-Use-Langpack: yes" header. Add
278+ corresponding test case. (LP: #788685, part 2)
279+ * test/run: Fix ResourceWarnings for unclosed files. Python 3, you are
280+ overly picky!
281+
282+ -- Martin Pitt <martin.pitt@ubuntu.com> Wed, 15 Jun 2011 09:08:54 +0200
283+
284+pkgbinarymangler (99) oneiric; urgency=low
285+
286+ * dh-translations:
287+ - support CMake projects having a make .pot target with GETTEXT_PACKAGE
288+
289+ -- Didier Roche <didrocks@ubuntu.com> Wed, 25 May 2011 20:30:04 +0200
290+
291+pkgbinarymangler (98) oneiric; urgency=low
292+
293+ * pkgstriptranslations: Don't break the build on empty po/pot files.
294+ Instead, just print a warning and exclude them from the translation
295+ tarball. Add corresponding test case.
296+
297+ -- Martin Pitt <martin.pitt@ubuntu.com> Mon, 16 May 2011 16:42:50 +0200
298+
299+pkgbinarymangler (97) oneiric; urgency=low
300+
301+ * test/run, test_dh_translations_no_domain(): Explicitly specify UTF-8
302+ encoding for the opened files, so that the test case also succeeds with
303+ Python 3 under a C locale (such as on the buildds).
304+ * pkgstripfiles: Update dependency parsing code to adapt to the changed
305+ behavior of "split" in Perl 5.12.
306+ * debian/control: Bump Standards-Version to 3.9.2. No changes needed.
307+
308+ -- Martin Pitt <martin.pitt@ubuntu.com> Fri, 06 May 2011 10:57:53 +0200
309+
310+pkgbinarymangler (96) oneiric; urgency=low
311+
312+ * pkgstripfiles: Symlink identical documentation to depending packages. This
313+ was ported from cdbs' debhelper.mk, but makes more sense here because more
314+ packages use dh7 these days, we want to reduce the cdbs delta to Debian,
315+ and we want to centralize all our Ubuntu specific package mangling to one
316+ place to reduce confusion. This can be suppressed by setting
317+ $NO_DOC_PKG_MANGLE, or $CDBS_NO_DOC_SYMLINKING for backwards
318+ compatibility. (First part of LP #595008)
319+ * pkgstriptranslations: Symlink identical GNOME help files (which often
320+ happens for images which are just copied verbatim from C, but are not
321+ actually translated). In the new test case for this also check that the
322+ static translation tarball is correct. This provides another Ubuntu
323+ specific general packaging change which previously was done in cdbs'
324+ debhelper.mk. (LP: #595008)
325+ * pkgstripfiles: Break down into separate functions, to make the code easier
326+ to read and maintain.
327+ * test/run: Simplify code with recently introduced sed_control() helper
328+ method.
329+ * test/run: Replace obsolete assert_() and failIf() calls with assertTrue()
330+ and assertFalse().
331+ * test/run, test/pickle_argv: Port to Python 3. Change build dependency from
332+ python to python3.
333+
334+ -- Martin Pitt <martin.pitt@ubuntu.com> Fri, 06 May 2011 09:59:01 +0200
335+
336+pkgbinarymangler (95) natty; urgency=low
337+
338+ * Build-dep on intltool as needed for the testsuite
339+ (dh-translations binary package already depends on it)
340+
341+ -- Didier Roche <didrocks@ubuntu.com> Fri, 01 Apr 2011 00:03:47 +0200
342+
343+pkgbinarymangler (94) natty; urgency=low
344+
345+ * dh_translations:
346+ - support cmake package as there is no makefile in the po dir neither
347+ setup.cfg. Try to grep the domain from CMakeLists.txt and force it in the
348+ intltool call.
349+ - add the cmake testcase in test/run
350+
351+ -- Didier Roche <didrocks@ubuntu.com> Wed, 30 Mar 2011 20:44:15 +0200
352+
353+pkgbinarymangler (93) natty; urgency=low
354+
355+ * When mangling changelogs, make sure to recompress with gzip -n;
356+ otherwise the resulting file is different for each build, so not
357+ compatible with multiarch.
358+
359+ -- Steve Langasek <steve.langasek@ubuntu.com> Fri, 18 Mar 2011 01:41:43 -0700
360+
361+pkgbinarymangler (92) natty; urgency=low
362+
363+ * Add debhelper script for handling translation operations. This makes it
364+ possible to have properly i18n'ed packages that don't use cdbs without
365+ introducing complicated build system changes. (LP: #735934)
366+ - test/icecream: Add po/ dir with an example po/*.po, *.desktop, *.server,
367+ *.policy, *.schemas files, and a Makefile which generates the pot.
368+ - Add dh_translations: debhelper script. Port the logic from
369+ /usr/share/cdbs/1/rules/langpack.mk.
370+ - test/run: Add test_dh_translations() test case.
371+ - debian/control, debian/dh-translations.install: Install dh_translations.
372+ - debian/rules: Build and install manpage from dh_translations POD.
373+ * test/icecream/debian/rules: Simplify using an override.
374+ * Add translations.pm: debhelper sequencer. Switch
375+ test/icecream/debian/rules to use --with translations instead of calling
376+ dh_translations directly. Point to local translations.pm in test/run
377+ setup.
378+ * dh_translations: Try getting domain from Python setup.cfg if po/Makefile
379+ does not exist.
380+
381+ -- Martin Pitt <martin.pitt@ubuntu.com> Thu, 17 Mar 2011 12:25:09 +0100
382+
383+pkgbinarymangler (91) natty; urgency=low
384+
385+ * dpkg-deb: also skip parsing /CurrentlyBuilding and debian/control if
386+ NO_PKG_MANGLE is non-empty as e.g. grep-ing control might trigger warnings
387+ in some testsuites.
388+
389+ -- Loïc Minier <loic.minier@linaro.org> Wed, 19 Jan 2011 18:07:33 +0100
390+
391+pkgbinarymangler (90) natty; urgency=low
392+
393+ * test/icecream/debian/rules: Install a "changes" directory below
394+ /usr/share/doc/. This reproduces the build failure of texlive-extra.
395+ * pkgstripfiles: Only consider files which have a changelog-like name.
396+
397+ -- Martin Pitt <martin.pitt@ubuntu.com> Wed, 22 Dec 2010 17:08:55 +0100
398+
399+pkgbinarymangler (89) natty; urgency=low
400+
401+ * pkgstripfiles: Games are prone to rely on a particular PNG image format,
402+ so skip PNG optimization for "Section: games". Add test case.
403+ (LP: #685421)
404+ * pkgstripfiles: Also skip PNG squashing if $NO_PNG_PKG_MANGLE is set; this
405+ allows packages to selectively disable PNG optimization without disabling
406+ the other parts of pkgbinarymangler. Add test case.
407+ * debian/control: Bump Standards-Version to 3.9.1 (no changes necessary).
408+
409+ -- Martin Pitt <martin.pitt@ubuntu.com> Fri, 10 Dec 2010 10:50:46 +0100
410+
411+pkgbinarymangler (88) natty; urgency=low
412+
413+ * test/run: Use "foo%.png" instead of foo.png, to check that file names with
414+ percent signs are handled correctly. This reproduces LP #684569.
415+ * pkgstripfiles: Escape percent characters in file names, to avoid breaking
416+ the sed expression. (LP: #684569)
417+
418+ -- Martin Pitt <martin.pitt@ubuntu.com> Thu, 09 Dec 2010 12:38:37 +0100
419+
420+pkgbinarymangler (87) natty; urgency=low
421+
422+ * Tweak shell syntax in dpkg-deb and also pass "$@" to pkgstriptranslations
423+ to simplify tests a bit.
424+
425+ -- Loïc Minier <loic.minier@ubuntu.com> Thu, 25 Nov 2010 15:37:40 +0100
426+
427+pkgbinarymangler (86) natty; urgency=low
428+
429+ [ Soren Hansen ]
430+ * Ensure arguments get passed through dpkg-deb wrapper unmangled.
431+
432+ -- Martin Pitt <martin.pitt@ubuntu.com> Thu, 25 Nov 2010 15:28:14 +0100
433+
434+pkgbinarymangler (85) natty; urgency=low
435+
436+ * pkgstriptranslations: In truncated changelogs, point to "apt-get
437+ changelog" instead of the obsolete "apt-changelog". Update test cases
438+ accordingly.
439+
440+ -- Martin Pitt <martin.pitt@ubuntu.com> Thu, 18 Nov 2010 16:15:29 +0100
441+
442+pkgbinarymangler (84) natty; urgency=low
443+
444+ * pkgstripfiles: Don't remove Debian changelogs if they are broken symlinks
445+ (as they are with multi-binary packages during build, since they point to
446+ the location in an installed system). Thanks Colin Watson!
447+
448+ -- Martin Pitt <martin.pitt@ubuntu.com> Tue, 16 Nov 2010 13:01:03 +0100
449+
450+pkgbinarymangler (83) natty; urgency=low
451+
452+ * test/icecream: Install an additional symbolic link "foolink.png" to
453+ "foo.png".
454+ * test/run, check_deb_integrity(): Verify that foolink.png remains a
455+ symbolic link.
456+ * pkgstripfiles: Ignore symbolic links for PNG compression. They mess up the
457+ careful "symlink identical help files" work from pkgstriptranslations and
458+ actually lead to bigger packages.
459+
460+ -- Martin Pitt <martin.pitt@ubuntu.com> Fri, 12 Nov 2010 13:18:49 +0100
461+
462+pkgbinarymangler (82) natty; urgency=low
463+
464+ * test/run: Fix "check for stripped files" test for PPA builds, we expect
465+ those to not get modified.
466+ * test/run: Check that changelogs in PPAs do not get truncated.
467+ * pkgstripfiles: Do not run for non-OEM PPA builds.
468+ * test/run: Add the same short/long checks for changelogs of native
469+ packages.
470+ * pkgstripfiles: For native packages, keep changelog.gz and truncate it like
471+ the Debian changelog.
472+
473+ -- Martin Pitt <martin.pitt@ubuntu.com> Thu, 11 Nov 2010 13:14:09 +0100
474+
475+pkgbinarymangler (81) natty; urgency=low
476+
477+ * pkgstripfiles: Remove more changelog naming variants.
478+ * test/icecream/debian/changelog: Add a lot more older changelog entries,
479+ for testing the truncation.
480+ * test/run: Check that short Debian changelogs remain unaltered, and that
481+ long Debian changelogs are truncated to the topmost 10 records. In both
482+ cases changelog.Debian.gz must be present in the deb.
483+ * pkgstripfiles: Implement Debian changelog truncation as above. If we
484+ truncate, add a note at the end to run apt-changelog for the older
485+ entries.
486+
487+ -- Martin Pitt <martin.pitt@ubuntu.com> Tue, 09 Nov 2010 18:43:49 +0100
488+
489+pkgbinarymangler (80) natty; urgency=low
490+
491+ * pkgstripfiles: Remove "ChangeLog.gz", too.
492+ * pkgstripfiles: Call advpng on PNG files after optipng, to further reduce
493+ their size. Add "advancecomp" build and binary dependencies.
494+ * test/run: Refine orig/new image comparison to ignore comments in the
495+ PNM files.
496+
497+ -- Martin Pitt <martin.pitt@ubuntu.com> Fri, 05 Nov 2010 16:16:35 -0400
498+
499+pkgbinarymangler (79) natty; urgency=low
500+
501+ * test/icecream: Add and install a PNG file, and a JPEG file with a wrong
502+ .png suffix ("notapng.png").
503+ * debian/control: Add optipng dependency, and optipng/imagemagick build
504+ dependencies. (We'll need imagemagick for the test suite.)
505+ * test/run: Add test_optipng() for verifying that shipped PNGs are smaller
506+ than original and visually identical, and that non-PNGs are shipped
507+ unmodified.
508+ * pkgstripfiles: Call optipng on all PNG files, update md5sum if successful.
509+ * test/run: Move md5sums test from test_optipng() to check_deb_integrity(),
510+ so that it's run for all test cases.
511+
512+ -- Martin Pitt <martin.pitt@ubuntu.com> Mon, 01 Nov 2010 13:11:43 -0400
513+
514+pkgbinarymangler (78) natty; urgency=low
515+
516+ * test/icecream/debian/rules: Enable dh_installchangelogs.
517+ * test/run: Verify that changelog.gz gets stripped from packages when
518+ mangling.
519+ * pkgstripfiles: Remove upstream and Debian changelogs from binary packages.
520+ This will save 28 MB on the CDs once all packages get rebuilt against this
521+ mangler. (performance-desktop-n-install-footprint blueprint)
522+
523+ -- Martin Pitt <martin.pitt@ubuntu.com> Mon, 01 Nov 2010 09:02:52 -0400
524+
525+pkgbinarymangler (77) natty; urgency=low
526+
527+ * test/run: If dpkg-buildpackage fails, show the complete output, to ease
528+ diagnostics.
529+ * Add missing dh-buildinfo build dependency, required for selftests.
530+
531+ -- Martin Pitt <martin.pitt@ubuntu.com> Tue, 12 Oct 2010 15:37:42 +0200
532+
533+pkgbinarymangler (76) natty; urgency=low
534+
535+ * striptranslations.blacklist: Add language-selector-common. (LP: #654548)
536+ * pkgstriptranslations: Fix OEM mode for changed apt-cache madison output in
537+ maverick.
538+ * test/icecream/debian/rules: Call dh_buildinfo and dh_md5sums, which are
539+ both very common in Debian/Ubuntu packages.
540+ * Add a new script "pkgstripfiles" for removing files which we don't want in
541+ Ubuntu packages:
542+ - Add pkgstripfiles: Remove buildinfo.gz from packages. These are now
543+ installed by default for cdbs, and for a lot of other packages. However,
544+ these just bloat the packages and installed system, and all the
545+ information they carry is in Launchpad's build logs.
546+ - dpkg-deb: Call pkgstripfiles.
547+ - stripfiles.conf: Configuration file for enabling/disabling.
548+ - test/run: Add new check_deb_stripfiles() check and integrate it into all
549+ existing test cases.
550+ - debian/pkgbinarymangler.install: Install script and conf file.
551+
552+ -- Martin Pitt <martin.pitt@ubuntu.com> Tue, 12 Oct 2010 14:03:36 +0200
553+
554+pkgbinarymangler (75) maverick; urgency=low
555+
556+ * test/run: Add new method check_deb_integrity() which confirms that
557+ dpkg-deb can extract the generated debs without messages or errors. This
558+ catches the regression introduced in version 71 that broke apt. Call this
559+ from various test cases.
560+ * pkgstriptranslations: Filter out PPA entries from apt-cache madison
561+ entries. If the package is also in this or a depending PPA, that will
562+ cause a "main" entry.
563+
564+ -- Martin Pitt <martin.pitt@ubuntu.com> Fri, 16 Jul 2010 09:04:19 +0200
565+
566+pkgbinarymangler (74) maverick; urgency=low
567+
568+ * pkgstriptranslations: Fix another typo. Bah.
569+
570+ -- Martin Pitt <martin.pitt@ubuntu.com> Thu, 15 Jul 2010 12:10:22 +0200
571+
572+pkgbinarymangler (73) maverick; urgency=low
573+
574+ * test/run: Check precise format of generated Installed-Size:.
575+ * pkgstriptranslations: du splits with a tab, not a space, fix extraction of
576+ new size to not contain tabs.
577+
578+ -- Martin Pitt <martin.pitt@ubuntu.com> Thu, 15 Jul 2010 12:01:16 +0200
579+
580+pkgbinarymangler (72) maverick; urgency=low
581+
582+ * Move identification/version string from dpkg-deb to pkgstriptranslations,
583+ having it in dpkg-deb also causes changed apt output (which is confusing).
584+
585+ -- Martin Pitt <martin.pitt@ubuntu.com> Thu, 15 Jul 2010 11:53:13 +0200
586+
587+pkgbinarymangler (71) maverick; urgency=low
588+
589+ * dpkg-deb: Print identification and version number, to ease debugging of
590+ failed builds.
591+ * debian/rules: Insert current version number into dpkg-deb script.
592+ * test/run: Add test case for building a language pack, which must not be
593+ touched by pkgstriptranslations.
594+ * test/run: Ignore system apt sources, otherwise we'll break some tests if
595+ we run them in an OEM buildd environment.
596+
597+ -- Martin Pitt <martin.pitt@ubuntu.com> Thu, 15 Jul 2010 09:59:00 +0200
598+
599+pkgbinarymangler (70) maverick; urgency=low
600+
601+ * Move "PPA" check from dpkg-deb to pkgmaintainermangler and
602+ pkgstriptranslations. We want to call pkgsanitychecks for PPA builds as
603+ well, and also control behaviour for PPAs individually for each mangler.
604+ * pkgstriptranslations: Run if we are building in an OEM PPA. If the built
605+ package is in Ubuntu main, strip translations from it. However, introduce
606+ a blacklist of OEM projects (oem_blacklist in striptranslations.conf)
607+ which are close or past release, to not inflict this rather intrusive
608+ change on them.
609+ * debian/control: Update Maintainer field from myself to Ubuntu Developers.
610+ * Add debian/source/format: 3.0 (native).
611+ * debian/control: Bump Standards-Version to 3.9.0.
612+ * Apply a consistent indentation to all source files (4 spaces, expand
613+ tabs).
614+ * dpkg-deb: Replace hardcoded paths with "which", to allow local testing.
615+ * Replace hardcoded "/CurrentlyBuilding" path with a $BUILDINFO variable set
616+ in "common", to allow local testing.
617+ * Add test/icecream: Test source package building two binary packages
618+ "vanilla" and "chocolate" with two po/mo files each.
619+ * Allow changing the path of "common" with $PKGBINARYMANGLER_COMMON_PATH.
620+ * Allow changing the configuration file directory path with
621+ $PKGBINARYMANGLER_CONF_DIR.
622+ * pkgmaintainermangler: Allow changing the path to the override file with
623+ $PKMAINTAINERGMANGLER_OVERRIDES.
624+ * Add test/run: Test suite for checking the scripts/config files in the
625+ local build tree in a sandbox on the "icecream" test package. Cover all
626+ current scenarios: main/universe/PPA/OEM/NO_PKG_MANGLE/partner/local/no
627+ mangler.
628+ * debian/rules: Run tests during build, and have a failed test suite fail
629+ the build. Add python and fakeroot build dependencies for this.
630+ * Add debian/pkgbinarymangler.lintian-overrides: We divert "dpkg-deb", no
631+ need to ship a manpage for it.
632+ * striptranslations.blacklist: Drop language-selector. (LP: #570240)
633+ * test/run: Add test case for updating of Installed-Size. This reproduces
634+ LP #451764.
635+ * pkgstriptranslations: Adapt Installed-Size: header in control file if we
636+ stripped any files. (LP: #451764)
637+
638+ -- Martin Pitt <martin.pitt@ubuntu.com> Fri, 09 Jul 2010 09:19:44 +0200
639+
640+pkgbinarymangler (69) lucid; urgency=low
641+
642+ * pkgstriptranslations: Work on all binary packages, not just the first one.
643+ If a static tarball already exists, unpack it into our work directory, so
644+ that we merge the GNOME help files of all binary packages. (LP: #457027)
645+ * debian/control: Bump Standards-Version to 3.8.4 (no changes necessary).
646+
647+ -- Martin Pitt <martin.pitt@ubuntu.com> Fri, 09 Apr 2010 08:32:14 +0200
648+
649+pkgbinarymangler (68) lucid; urgency=low
650+
651+ * Looks like a .bzrignore in the bzr branch made a few useful files disappear
652+ in the last upload. Re-upload the change manually basing on version 66.
653+
654+ -- Stéphane Graber <stgraber@ubuntu.com> Mon, 18 Jan 2010 20:53:18 -0500
655+
656+pkgbinarymangler (67) lucid; urgency=low
657+
658+ * Add ldm to the striptranslations blacklist.
659+ (Only installed in a chroot with no langpack but translation wanted)
660+
661+ -- Stéphane Graber <stgraber@ubuntu.com> Mon, 18 Jan 2010 17:28:38 -0500
662+
663+pkgbinarymangler (66) lucid; urgency=low
664+
665+ * Add Vcs-Bzr header; this is now in Bzr at
666+ lp:~ubuntu-core-dev/pkgbinarymangler/ubuntu.
667+ * Install conffiles, binaries, and data file with dh_install.
668+ * List man pages in debian/pkgbinarymangler.manpages instead of the
669+ dh_installman command-line.
670+ * Switch to dh in rules; bump debhelper build-dep to >= 7.
671+ * Make maintainer scripts slightly more robust.
672+ * common: skip tests on /CurrentlyBuilding if PKG_IGNORE_CURRENTLY_BUILDING
673+ is set to 1; this is particularly useful when a package builds launches an
674+ embedded package build, such as the testsuite of pkg-create-dbgsym.
675+ Ideally, we'd have a nicer way to sanity check the same information.
676+ * Bump up Standards-Version to 3.8.3.
677+ * Add ${misc:Depends}.
678+
679+ -- Loïc Minier <loic.minier@ubuntu.com> Sat, 16 Jan 2010 13:25:18 +0100
680+
681+pkgbinarymangler (65) lucid; urgency=low
682+
683+ * Add xkb-data-i18n to the striptranslations blacklist.
684+
685+ -- Evan Dandrea <evand@ubuntu.com> Mon, 11 Jan 2010 11:35:06 +0000
686+
687+pkgbinarymangler (64) lucid; urgency=low
688+
689+ * pkgstriptranslations: Do not copy .pc/* into the translation tarball.
690+ (LP: #410658)
691+
692+ -- Martin Pitt <martin.pitt@ubuntu.com> Sun, 15 Nov 2009 05:52:17 -0600
693+
694+pkgbinarymangler (63) karmic; urgency=low
695+
696+ * pkgstriptranslations:
697+ - Use # instead of @ for the sed delimiter as @ can appear in locale
698+ names (lp: #434544)
699+
700+ -- Michael Bienia <geser@ubuntu.com> Tue, 22 Sep 2009 11:06:59 +0200
701+
702+pkgbinarymangler (62) karmic; urgency=low
703+
704+ * pkgstriptranslations:
705+ - Also store /usr/share/omf/ files in static translation tarball.
706+ - Remove GNOME help translation files now, and replace them with symlinks
707+ to /usr/share/omf-langpack/* and usr/share/gnome/help-langpack/*.
708+
709+ -- Martin Pitt <martin.pitt@ubuntu.com> Sun, 30 Aug 2009 12:39:06 +0200
710+
711+pkgbinarymangler (61) karmic; urgency=low
712+
713+ * pkgstriptranslations: Extract GNOME help translations into a new tarball
714+ and add them to the upload as raw-translations-static component. Do not
715+ strip the files from the .debs just yet, since the upload/download
716+ infrastructure in Soyuz still needs to be tested, and the language pack
717+ integration bits need to be written. See LP #123020
718+ * debian/compat, debian/control: Bump to debhelper compat 5, 4 is
719+ deprecated.
720+ * debian/control: Bump Standards-Version to 3.8.2.
721+ * debian/control: Drop long-obsolete Replaces.
722+
723+ -- Martin Pitt <martin.pitt@ubuntu.com> Mon, 03 Aug 2009 12:59:52 +0100
724+
725+pkgbinarymangler (60) karmic; urgency=low
726+
727+ * pkgbinarymangler: Update package's md5sums list for modified .desktop
728+ files. (LP: #392149)
729+
730+ -- Martin Pitt <martin.pitt@ubuntu.com> Thu, 25 Jun 2009 17:55:59 +0200
731+
732+pkgbinarymangler (59) karmic; urgency=low
733+
734+ * Modify Maintainer field overriding to comply with Technical Board
735+ resolution of 2009-05-05, with a single override for all components
736+ (https://lists.ubuntu.com/archives/ubuntu-devel/2009-May/028213.html).
737+
738+ -- Colin Watson <cjwatson@ubuntu.com> Tue, 09 Jun 2009 11:15:13 +0100
739+
740+pkgbinarymangler (58) karmic; urgency=low
741+
742+ * pkgsanitychecks: Skip udebs, since our checks aren't very interesting
743+ for them (sysadmin with local changes to the installer environment that
744+ they want preserved ...?) and there's one udeb (rootskel-gtk) that
745+ currently ships a /usr/local/etc symlink.
746+
747+ -- Colin Watson <cjwatson@ubuntu.com> Wed, 06 May 2009 10:07:30 +0100
748+
749+pkgbinarymangler (57) jaunty; urgency=low
750+
751+ * pkgstriptranslations: When grabbing XPIs from Mozilla-ish packages, ensure
752+ that the /source/ directory exists in the temporary directory. Fixes
753+ xulrunner FTBFS.
754+
755+ -- Martin Pitt <martin.pitt@ubuntu.com> Fri, 27 Mar 2009 16:17:34 +0100
756+
757+pkgbinarymangler (56) jaunty; urgency=low
758+
759+ * pkgstriptranslations: Remove translations from .desktop files if they have
760+ a gettext domain. Not every package with .desktop files uses cdbs with
761+ langpack.mk (where this stripping has happened so far), and we are now
762+ preferring the language pack translations over the static upstream
763+ translations in .desktop files. (LP: #348225)
764+ * debian/copyright: Update GPL stanza (previously had old FSF address),
765+ thanks lintian.
766+ * debian/control: Bump Standards-Version (no changes required).
767+
768+ -- Martin Pitt <martin.pitt@ubuntu.com> Wed, 25 Mar 2009 10:28:45 +0100
769+
770+pkgbinarymangler (55) jaunty; urgency=low
771+
772+ * pkgsanitychecks: Reject packages which place files in /usr/local.
773+
774+ -- Matthias Klose <doko@ubuntu.com> Mon, 02 Mar 2009 11:59:35 +0100
775+
776+pkgbinarymangler (54) jaunty; urgency=low
777+
778+ * pkgsanitychecks: Reject packages which place public python modules for 2.6
779+ or newer in /usr/local/lib/python{2.[67],3.?} instead of /usr/lib.
780+
781+ -- Matthias Klose <doko@ubuntu.com> Sun, 22 Feb 2009 13:25:13 +0100
782+
783+pkgbinarymangler (53) jaunty; urgency=low
784+
785+ * common: Do not FTBFS if debian/control does not exist. This is *very*
786+ uncommon, but it happens while building with pbuilder (LP: #315101).
787+
788+ -- Luca Falavigna <dktrkranz@ubuntu.com> Tue, 17 Feb 2009 23:01:40 +0100
789+
790+pkgbinarymangler (52) jaunty; urgency=low
791+
792+ * pkgstriptranslations: Use a lockfile to ensure that only one
793+ instance runs at a time. Some packages, such as glib2.0, define
794+ MAKEFLAGS=-j if "$DEB_BUILD_OPTIONS=parallel" is set (apparently
795+ at the Ubuntu buildds); this makes debian/rules, and in turn
796+ pkgstriptranslations run in parallel as well, which produced
797+ corrupted translations.tar.gz tarballs.
798+ * Add lockfile-progs dependency.
799+ * Drop long-obsolete pkgstriptranslations transitional package.
800+
801+ -- Martin Pitt <martin.pitt@ubuntu.com> Mon, 09 Feb 2009 09:49:17 +0100
802+
803+pkgbinarymangler (51) jaunty; urgency=low
804+
805+ * New binary pkgsanitychecks.
806+ - Reject packages which place public python modules for 2.6 or newer in
807+ /usr/lib/python{2.[67],3.?}/site-packages instead of dist-packages.
808+
809+ -- Matthias Klose <doko@ubuntu.com> Mon, 05 Jan 2009 11:18:27 +0100
810+
811+pkgbinarymangler (50) hardy; urgency=low
812+
813+ * pkgstriptranslations: Copy debian/lp-export-xpis/, for finally getting LP
814+ translations love for Mozilla-ish packages.
815+
816+ -- Martin Pitt <martin.pitt@ubuntu.com> Thu, 27 Mar 2008 12:18:04 +0100
817+
818+pkgbinarymangler (49) hardy; urgency=low
819+
820+ * pkgmaintainermangler: Do not fail the build if DEBIAN/control does not
821+ exist. This apparently happens under some conditions, like for
822+ openoffice.org on powerpc. (LP: #205923)
823+
824+ -- Martin Pitt <martin.pitt@ubuntu.com> Wed, 26 Mar 2008 16:46:13 +0100
825+
826+pkgbinarymangler (48) hardy; urgency=low
827+
828+ * striptranslations.conf: Do not strip packages in restricted. Putting the
829+ translations into language packs could possibly create a licensing
830+ conflict. We do not have any in restricted right now, but we want to be
831+ safe.
832+ * Bump Standards-Version to 3.7.3 (no changes necessary).
833+
834+ -- Martin Pitt <martin.pitt@ubuntu.com> Thu, 28 Feb 2008 17:27:14 +0100
835+
836+pkgbinarymangler (47) hardy; urgency=low
837+
838+ * dpkg-deb: Also disable pkgbinarymangler if archive Purpose is PPA.
839+
840+ -- Adam Conrad <adconrad@ubuntu.com> Tue, 18 Dec 2007 15:58:29 -0700
841+
842+pkgbinarymangler (46) hardy; urgency=low
843+
844+ * dpkg-deb: Don't act when doing archive rebuild tests. This change
845+ requires a modified sbuild that writes Suite to /CurrentlyBuilding
846+
847+ -- Adam Conrad <adconrad@ubuntu.com> Fri, 14 Dec 2007 15:04:29 -0700
848+
849+pkgbinarymangler (45) gutsy; urgency=low
850+
851+ * maintainermangler.overrides: Do not mangle Maintainer: for Patrick
852+ Matthäi. (LP: #134694)
853+
854+ -- Martin Pitt <martin.pitt@ubuntu.com> Thu, 13 Sep 2007 22:39:30 +0200
855+
856+pkgbinarymangler (44) gutsy; urgency=low
857+
858+ * dpkg-deb: s/commercial/partner/g.
859+
860+ -- Fabio M. Di Nitto <fabbione@ubuntu.com> Mon, 03 Sep 2007 09:54:25 +0200
861+
862+pkgbinarymangler (43) gutsy; urgency=low
863+
864+ * dpkg-deb: Do not do anything for commercial packages.
865+
866+ -- Martin Pitt <martin.pitt@ubuntu.com> Mon, 20 Aug 2007 11:37:30 +0200
867+
868+pkgbinarymangler (42) gutsy; urgency=low
869+
870+ * debian/rules: Build with NO_PKG_MANGLE to pull ourselves out of the FTBFS
871+ swamp version 40 has created.
872+
873+ -- Martin Pitt <martin.pitt@ubuntu.com> Wed, 08 Aug 2007 19:46:59 +0200
874+
875+pkgbinarymangler (41) gutsy; urgency=low
876+
877+ * dpkg-deb: Use the original arguments for calling pkgmaintainermangler,
878+ too.
879+
880+ -- Martin Pitt <martin.pitt@ubuntu.com> Wed, 08 Aug 2007 19:18:20 +0200
881+
882+pkgbinarymangler (40) gutsy; urgency=low
883+
884+ * Fix the dpkg-deb wrapper to deal with being fed other arguments
885+ like, for instance, -Zbzip2 before "--build" or "-b" is supplied.
886+
887+ -- Adam Conrad <adconrad@ubuntu.com> Wed, 8 Aug 2007 20:41:40 +1000
888+
889+pkgbinarymangler (39) feisty; urgency=low
890+
891+ * pkgstriptranslations: Collect .ts files (KDE XML translation source
892+ format). (LP: #68959)
893+
894+ -- Martin Pitt <martin.pitt@ubuntu.com> Tue, 27 Mar 2007 20:24:16 +0200
895+
896+pkgbinarymangler (38) feisty; urgency=low
897+
898+ * pkgmaintainermangler: Never abort if Original-Maintainer is already
899+ present, even if Maintainer: does not have an Ubuntuish address.
900+ (LP: #91086)
901+
902+ -- Martin Pitt <martin.pitt@ubuntu.com> Mon, 12 Mar 2007 12:06:54 +0100
903+
904+pkgbinarymangler (37) feisty; urgency=low
905+
906+ * maintainermangler.overrides: Don't mangle @kubuntu.org domain.
907+
908+ -- Martin Pitt <martin.pitt@ubuntu.com> Fri, 9 Mar 2007 14:52:34 +0100
909+
910+pkgbinarymangler (36) feisty; urgency=low
911+
912+ * maintainermangler.overrides: Use u-devel-discuss@ as default contact for
913+ main/restricted.
914+
915+ -- Martin Pitt <martin.pitt@ubuntu.com> Mon, 19 Feb 2007 13:16:36 +0100
916+
917+pkgbinarymangler (35) feisty; urgency=low
918+
919+ * pkgstriptranslations: Do not complain about empty .po/.pot files in hidden
920+ directories (such as quilt's ./.pc). Fixes the shadow FTBFS.
921+
922+ -- Martin Pitt <mpitt@debian.org> Tue, 19 Dec 2006 19:32:58 +0100
923+
924+pkgbinarymangler (34) feisty; urgency=low
925+
926+ The "Make doko love me again" release.
927+
928+ * pkgstriptranslations:
929+ - Since we can now afford losing *.mo files, only create the translation
930+ tarball once, and don't update it if it already exists. This massively
931+ speeds up the process especially for large packages like openoffice.org.
932+ - Various small optimizations.
933+
934+ -- Martin Pitt <martin.pitt@ubuntu.com> Tue, 12 Dec 2006 15:57:05 +0100
935+
936+pkgbinarymangler (33) feisty; urgency=low
937+
938+ * Add cjwatson@debian.org to ignore_emails, per request of Colin Watson.
939+
940+ -- Adam Conrad <adconrad@ubuntu.com> Fri, 8 Dec 2006 23:43:30 +1100
941+
942+pkgbinarymangler (32) feisty; urgency=low
943+
944+ * Add ubuntu.com.au to the ignore_domains list, per William Grant.
945+
946+ -- Adam Conrad <adconrad@ubuntu.com> Fri, 8 Dec 2006 23:32:24 +1100
947+
948+pkgbinarymangler (31) edgy; urgency=low
949+
950+ * Add q-funk@iki.fi to ignore_emails, per request of Martin-Éric Racine
951+
952+ -- Adam Conrad <adconrad@ubuntu.com> Wed, 4 Oct 2006 21:09:20 +1000
953+
954+pkgbinarymangler (30) edgy; urgency=low
955+
956+ * Use Original-Maintainer instead of X-Original-Maintainer as if we
957+ had specified XB-Original-Maintainer in a policy-compliant fashion.
958+
959+ -- Adam Conrad <adconrad@ubuntu.com> Wed, 20 Sep 2006 00:05:42 +1000
960+
961+pkgbinarymangler (29) edgy; urgency=low
962+
963+ * pkg{maintainermangler,striptranslations}.1: Document NO_PKG_MANGLE
964+ environment variable. (one part of LP#40735)
965+ * pkgmaintainermangler.1: Fix program name in AUTHOR section.
966+ * pkgstriptranslations: Do not strip backports. Closes: LP#58221
967+
968+ -- Martin Pitt <martin.pitt@ubuntu.com> Tue, 12 Sep 2006 14:22:33 +0200
969+
970+pkgbinarymangler (28) edgy; urgency=low
971+
972+ * Rename source package to pkgbinarymangler, providing a transitional
973+ upgrade path from pkgstriptranslations to the new pkgbinarymangler.
974+ * New binary package pkgbinarymangler now provides two distinct scripts,
975+ pkgstriptranslations, which does the same thing it always did, and
976+ pkgmaintainermangler, which is used to mangle maintainer fields.
977+ * Migrate /etc/pkgstriptranslations conffiles to /etc/pkgbinarymangler.
978+ * Migrate dpkg diversion from pkgstriptranslations to pkgbinarymangler.
979+ * Update debian/copyright to add myself to the list of authors, and
980+ update debian/control to add myself to the list of Uploaders.
981+ * Re-factor some common code into /usr/share/pkgbinarymangler/common.
982+
983+ -- Adam Conrad <adconrad@ubuntu.com> Wed, 6 Sep 2006 22:27:59 +1000
984+
985+pkgstriptranslations (27) dapper; urgency=low
986+
987+ * If NO_PKG_MANGLE is set and non-empty, don't run pkgstriptranslations
988+ for the current dpkg-deb invocation, but print a warning so we know.
989+ * Clean up error handling for when /usr/bin/pkgstriptranslations doesn't
990+ exist, so we actually get a meaningful error and failure, not silence.
991+
992+ -- Adam Conrad <adconrad@ubuntu.com> Fri, 7 Apr 2006 19:05:21 +1000
993+
994+pkgstriptranslations (26) dapper; urgency=low
995+
996+ * Check for empty PO or POT files and fail the build if any are detected
997+ (the translation importer doesn't like them, and in general this is likely
998+ to be a bug). Closes: LP#33674
999+ * dpkg-deb:
1000+ - 'exec -a' is a bashism, so fix the hashbang line.
1001+ - Activate set -e to actually fail the package build if
1002+ pkgstriptranslations fails.
1003+
1004+ -- Martin Pitt <martin.pitt@ubuntu.com> Thu, 6 Apr 2006 13:28:31 +0200
1005+
1006+pkgstriptranslations (25) dapper; urgency=low
1007+
1008+ * Blacklist language-selector, so people can select their language
1009+ in their own language (I suppose this does make some sense...)
1010+
1011+ -- Adam Conrad <adconrad@ubuntu.com> Fri, 31 Mar 2006 21:13:06 +1100
1012+
1013+pkgstriptranslations (24) dapper; urgency=low
1014+
1015+ * Fix package name for *.sdf stripping: openoffice.org2 -> openoffice.org
1016+
1017+ -- Martin Pitt <martin.pitt@ubuntu.com> Tue, 14 Mar 2006 18:32:52 +0100
1018+
1019+pkgstriptranslations (23) dapper; urgency=low
1020+
1021+ * Pull the trigger for Soyuz-Rosetta integration: Call dpkg-distaddfile to
1022+ include the translation tarball into the .changes file.
1023+
1024+ -- Martin Pitt <martin.pitt@ubuntu.com> Fri, 24 Feb 2006 22:56:56 +0100
1025+
1026+pkgstriptranslations (22) dapper; urgency=low
1027+
1028+ * Strip the epoch from the version number, so that it doesn't appear in the
1029+ translation tarball file name.
1030+
1031+ -- Martin Pitt <martin.pitt@ubuntu.com> Wed, 22 Feb 2006 15:55:10 +0100
1032+
1033+pkgstriptranslations (21) dapper; urgency=low
1034+
1035+ * pkgstriptranslations.blacklist: Remove passwd and base-config, with the
1036+ new single-stage installer they can be stripped again.
1037+
1038+ -- Martin Pitt <martin.pitt@ubuntu.com> Mon, 23 Jan 2006 11:25:49 +0100
1039+
1040+pkgstriptranslations (20) dapper; urgency=low
1041+
1042+ * Install a dpkg-deb wrapper which calls pkgstriptranslations before
1043+ calling dpkg-deb, so we can remove our hideous hack from debhelper.
1044+ * Fix manpage to note the correct arch-in-name tarball naming scheme.
1045+
1046+ -- Adam Conrad <adconrad@ubuntu.com> Wed, 26 Oct 2005 04:13:45 +1000
1047+
1048+pkgstriptranslations (19) dapper; urgency=low
1049+
1050+ * Previous upload was too quick; deactivate dpkg-distaddfile until we switch
1051+ to launchpad.
1052+
1053+ -- Martin Pitt <martin.pitt@ubuntu.com> Tue, 25 Oct 2005 07:19:21 +0200
1054+
1055+pkgstriptranslations (18) dapper; urgency=low
1056+
1057+ * Call dpkg-distaddfile to include the translation tarball into the .changes
1058+ file.
1059+
1060+ -- Martin Pitt <martin.pitt@ubuntu.com> Wed, 19 Oct 2005 13:40:27 +0200
1061+
1062+pkgstriptranslations (17) breezy; urgency=low
1063+
1064+ * Blacklist apt.
1065+
1066+ -- Martin Pitt <martin.pitt@ubuntu.com> Wed, 5 Oct 2005 14:36:06 +0200
1067+
1068+pkgstriptranslations (16) breezy; urgency=low
1069+
1070+ * Blacklist debconf-i18n.
1071+
1072+ -- Martin Pitt <martin.pitt@ubuntu.com> Wed, 7 Sep 2005 23:05:43 +0200
1073+
1074+pkgstriptranslations (15) breezy; urgency=low
1075+
1076+ * Append the architecture to the tarball so that we can export tarballs from
1077+ all architectures and later sort out the invalid ones. Until now, the
1078+ latest tarball always won, which overwrote good tarballs with broken ones
1079+ sometimes.
1080+
1081+ -- Martin Pitt <martin.pitt@ubuntu.com> Fri, 26 Aug 2005 16:01:06 +0200
1082+
1083+pkgstriptranslations (14) breezy; urgency=low
1084+
1085+ * If we are stripping the openoffice.org2 source package, save debian/*.sdf
1086+ for later merging of updated translations.
1087+
1088+ -- Martin Pitt <martin.pitt@ubuntu.com> Thu, 11 Aug 2005 18:01:48 +0200
1089+
1090+pkgstriptranslations (13) breezy; urgency=low
1091+
1092+ * pkgstriptranslations.blacklist: Remove kde-i18n-*, KDE translations will
1093+ move into language-pack-kde-<lang> (LanguagePackRoadmap).
1094+
1095+ -- Martin Pitt <mpitt@debian.org> Thu, 16 Jun 2005 12:08:29 +0200
1096+
1097+pkgstriptranslations (12) breezy; urgency=low
1098+
1099+ * Improved debugging messages to ease future bug fixing.
1100+ * Fixed preservation of old tarball contents.
1101+
1102+ -- Martin Pitt <martin.pitt@ubuntu.com> Mon, 13 Jun 2005 12:43:03 +0200
1103+
1104+pkgstriptranslations (11) breezy; urgency=low
1105+
1106+ * Appended an "|| true" to the empty directory cleaning command to work
1107+ around an annoying find bug (or new feature?) introduced in Breezy.
1108+
1109+ -- Martin Pitt <martin.pitt@ubuntu.com> Sat, 11 Jun 2005 20:02:44 +0200
1110+
1111+pkgstriptranslations (10) breezy; urgency=low
1112+
1113+ * Separated blacklist from main configuration file to
1114+ pkgstriptranslations.blacklist. This allows us to update it with uploads
1115+ rather than manual tweakings.
1116+ * Blacklist dpkg.
1117+ * pkgstriptranslations:
1118+ - Ignore "nostrip" option in pkgstriptranslations.conf and only process
1119+ the list in pkgstriptranslations.blacklist.
1120+ - Support regular expressions in the blacklist. This greatly cuts down the
1121+ size of the list and makes it much more robust with e. g. new kde-i18n-*
1122+ packages.
1123+
1124+ -- Martin Pitt <martin.pitt@ubuntu.com> Thu, 9 Jun 2005 15:41:13 +0200
1125+
1126+pkgstriptranslations (9) hoary; urgency=low
1127+
1128+ * Do not overwrite tarballs from previous invocations, add their contents
1129+ instead. This fixes mo file extraction for multi-binary packages.
1130+
1131+ -- Martin Pitt <martin.pitt@ubuntu.com> Sun, 6 Mar 2005 18:07:21 +0100
1132+
1133+pkgstriptranslations (8) hoary; urgency=low
1134+
1135+ * Implemented new specification:
1136+ - Do not produce domains.txt.
1137+ - Copy po/pot files into tarball subdirectory source/.
1138+ - Copy per-deb mo files into tarball subdirectory <debname>/.
1139+ * Cleaned up debug messages.
1140+ * Removed function debug(), it was hardly used any more.
1141+ * Updated manpage.
1142+
1143+ -- Martin Pitt <martin.pitt@ubuntu.com> Thu, 3 Mar 2005 15:29:17 +0100
1144+
1145+pkgstriptranslations (7) hoary; urgency=low
1146+
1147+ * Support new configuration option "nostrip" with a blacklist of binary
1148+ packages (preconfigured for "base-config" and "passwd" which are used at
1149+ installation time when no langpack is already present).
1150+ * Bug fix: Only remove the mo files from md5sum files if we actually
1151+ stripped them.
1152+ * Also strip packages if there is no /CurrentlyBuilding.
1153+
1154+ -- Martin Pitt <martin.pitt@ubuntu.com> Wed, 23 Feb 2005 10:38:33 +0100
1155+
1156+pkgstriptranslations (6) hoary; urgency=low
1157+
1158+ * Generate a list of all translation domains and put them as 'domains.txt'
1159+ into the translation tarball.
1160+
1161+ -- Martin Pitt <martin.pitt@ubuntu.com> Thu, 27 Jan 2005 17:11:08 +0100
1162+
1163+pkgstriptranslations (5) hoary; urgency=low
1164+
1165+ * Added new option "invalid_currentlybuilding" which configures whether an
1166+ existing, but invalid /CurrentlyBuilding file is ignored (default) or
1167+ causes the build to fail (should happen on the buildds).
1168+
1169+ -- Martin Pitt <martin.pitt@ubuntu.com> Tue, 25 Jan 2005 12:54:33 +0100
1170+
1171+pkgstriptranslations (4) hoary; urgency=low
1172+
1173+ * Do not strip/extract language packs.
1174+
1175+ -- Martin Pitt <martin.pitt@ubuntu.com> Wed, 19 Jan 2005 19:07:38 +0100
1176+
1177+pkgstriptranslations (3) hoary; urgency=low
1178+
1179+ * Added support for creating a tarball of all pot/po files (with
1180+ configuration option "posuffix").
1181+ * Added configuration option "components" which restricts the mo file
1182+ deletion to some components only (default: main and restricted) if
1183+ a file /CurrentlyBuilding is present (as on the buildds).
1184+ * Remove mo file entries from md5sums files.
1185+
1186+ -- Martin Pitt <martin.pitt@canonical.com> Fri, 14 Jan 2005 20:15:50 +0100
1187+
1188+pkgstriptranslations (2) hoary; urgency=low
1189+
1190+ * Don't strip packages in section 'debian-installer' which cannot be
1191+ translated using language packs.
1192+
1193+ -- Martin Pitt <martin.pitt@canonical.com> Wed, 5 Jan 2005 11:39:37 +0100
1194+
1195+pkgstriptranslations (1) hoary; urgency=low
1196+
1197+ * Initial Release.
1198+
1199+ -- Martin Pitt <martin.pitt@canonical.com> Tue, 21 Dec 2004 18:46:54 +0100
1200
1201=== added file 'debian/control.OTHER'
1202--- debian/control.OTHER 1970-01-01 00:00:00 +0000
1203+++ debian/control.OTHER 2012-03-08 11:48:20 +0000
1204@@ -0,0 +1,51 @@
1205+Source: pkgbinarymangler
1206+Section: devel
1207+Priority: extra
1208+Build-Depends: debhelper (>= 7.0.50~),
1209+ perl,
1210+ dh-buildinfo,
1211+ python3,
1212+ fakeroot,
1213+ optipng,
1214+ advancecomp,
1215+ imagemagick,
1216+ intltool
1217+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
1218+Standards-Version: 3.9.2
1219+
1220+Package: pkgbinarymangler
1221+Architecture: all
1222+Depends: ${misc:Depends},
1223+ lockfile-progs,
1224+ advancecomp,
1225+ optipng
1226+Description: strips translations and alters maintainers during build
1227+ pkgbinarymangler consists of a dpkg-deb wrapper that calls the following
1228+ helper applications while building a debian binary package:
1229+ .
1230+ pkgstriptranslations removes all *.mo files in /usr/share/locale from
1231+ all package build directories. It is used to strip off gettext translations
1232+ from generated binary packages, because translations are already shipped
1233+ in the language packs. Its behaviour (which is disabled by default) is
1234+ configured in /etc/pkgbinarymangler/striptranslations.conf.
1235+ .
1236+ pkgmaintainermangler adjusts the maintainer field in binary packages to
1237+ match a set of rules (including whitelists, mass renames by component,
1238+ maintainer name, etc) defined in the pkgmaintainermangler configuration
1239+ file at /etc/pkgbinarymangler/maintainermangler.conf.
1240+
1241+Package: dh-translations
1242+Architecture: all
1243+Depends: ${misc:Depends},
1244+ debhelper,
1245+ intltool
1246+Description: debhelper extension for translation support
1247+ This package provides a debhelper extension to perform common translation
1248+ related operations during package build:
1249+ .
1250+ * Try to build a current PO template.
1251+ .
1252+ * Remove inline translations from *.desktop, *.server, *.schemas, and
1253+ *.policy files and replace them with a link to the gettext domain, so that
1254+ strings in them will get translated at runtime from *.mo files. This allows
1255+ language packs to ship updated translations.
1256
1257=== added file 'debian/pkgbinarymangler.install.OTHER'
1258--- debian/pkgbinarymangler.install.OTHER 1970-01-01 00:00:00 +0000
1259+++ debian/pkgbinarymangler.install.OTHER 2012-03-08 11:48:20 +0000
1260@@ -0,0 +1,13 @@
1261+dpkg-deb usr/bin
1262+dh_builddeb usr/bin
1263+pkgstriptranslations usr/bin
1264+pkgmaintainermangler usr/bin
1265+pkgsanitychecks usr/bin
1266+pkgstripfiles usr/bin
1267+common usr/share/pkgbinarymangler
1268+striptranslations.conf etc/pkgbinarymangler
1269+striptranslations.blacklist etc/pkgbinarymangler
1270+maintainermangler.conf etc/pkgbinarymangler
1271+maintainermangler.overrides etc/pkgbinarymangler
1272+sanitychecks.conf etc/pkgbinarymangler
1273+stripfiles.conf etc/pkgbinarymangler
1274
1275=== added file 'debian/pkgbinarymangler.postrm.OTHER'
1276--- debian/pkgbinarymangler.postrm.OTHER 1970-01-01 00:00:00 +0000
1277+++ debian/pkgbinarymangler.postrm.OTHER 2012-03-08 11:48:20 +0000
1278@@ -0,0 +1,15 @@
1279+#!/bin/sh
1280+
1281+set -e
1282+
1283+case "$1" in
1284+ remove|purge)
1285+ # Remove our diversions
1286+ dpkg-divert --remove --rename --package pkgbinarymangler --divert /usr/bin/dpkg-deb.pkgbinarymangler /usr/bin/dpkg-deb > /dev/null
1287+ dpkg-divert --remove --rename --package pkgbinarymangler --divert /usr/bin/dh_builddeb.pkgbinarymangler /usr/bin/dh_builddeb > /dev/null
1288+ ;;
1289+esac
1290+
1291+#DEBHELPER#
1292+
1293+exit 0
1294
1295=== added file 'debian/pkgbinarymangler.preinst.OTHER'
1296--- debian/pkgbinarymangler.preinst.OTHER 1970-01-01 00:00:00 +0000
1297+++ debian/pkgbinarymangler.preinst.OTHER 2012-03-08 11:48:20 +0000
1298@@ -0,0 +1,22 @@
1299+#! /bin/sh
1300+
1301+set -e
1302+
1303+case "$1" in
1304+ install|upgrade)
1305+ # make diversions
1306+ dpkg-divert --add --rename --package pkgbinarymangler --divert /usr/bin/dpkg-deb.pkgbinarymangler /usr/bin/dpkg-deb > /dev/null
1307+ if [ ! -x /usr/bin/dpkg-deb ]; then
1308+ # on initial install, we have no dpkg-deb, cause we just
1309+ # diverted it; this would cause our own package to fail to
1310+ # unpack
1311+ cp /usr/bin/dpkg-deb.pkgbinarymangler /usr/bin/dpkg-deb
1312+ fi
1313+
1314+ dpkg-divert --add --rename --package pkgbinarymangler --divert /usr/bin/dh_builddeb.pkgbinarymangler /usr/bin/dh_builddeb > /dev/null
1315+ ;;
1316+esac
1317+
1318+#DEBHELPER#
1319+
1320+exit 0
1321
1322=== added file 'dh_builddeb'
1323--- dh_builddeb 1970-01-01 00:00:00 +0000
1324+++ dh_builddeb 2012-03-08 11:48:20 +0000
1325@@ -0,0 +1,9 @@
1326+#!/bin/bash
1327+# Wrapper around dh_builddeb to disable parallel invocations of dpkg-deb. This
1328+# would break predictable documentation symlinking in pkgstripfiles.
1329+
1330+set -e
1331+
1332+DEB_BUILD_OPTIONS=$(echo "$DEB_BUILD_OPTIONS" | sed -r 's/parallel(=[0-9]+)?//')
1333+
1334+exec -a "$0" dh_builddeb.pkgbinarymangler "$@"
1335
1336=== added file 'dh_translations.OTHER'
1337--- dh_translations.OTHER 1970-01-01 00:00:00 +0000
1338+++ dh_translations.OTHER 2012-03-08 11:48:20 +0000
1339@@ -0,0 +1,292 @@
1340+#!/usr/bin/perl -w
1341+
1342+=head1 NAME
1343+
1344+dh_translations - perform common translation related operations
1345+
1346+=cut
1347+
1348+use strict;
1349+
1350+use File::Find;
1351+use Debian::Debhelper::Dh_Lib;
1352+
1353+=head1 SYNOPSIS
1354+
1355+B<dh_translations> [S<B<debhelper options>>]
1356+
1357+=head1 DESCRIPTION
1358+
1359+dh_translations is a debhelper program to perform common translation
1360+related operations during package build:
1361+
1362+=over 4
1363+
1364+=item
1365+
1366+Try to build a current PO template.
1367+
1368+=item
1369+
1370+Remove inline translations from *.desktop, *.server, *.schemas, and
1371+*.policy files and replace them with a link to the gettext domain, so that
1372+strings in them will get translated at runtime from *.mo files. This allows
1373+language packs to ship updated translations.
1374+
1375+=back
1376+
1377+=cut
1378+
1379+my ($domain, $use_intltool);
1380+
1381+# figure out intltool usage and domain
1382+sub check_buildsystem {
1383+ $use_intltool = 0;
1384+ if (open MAKEFILE, 'po/Makefile') {
1385+ while (<MAKEFILE>) {
1386+ $use_intltool = 1 if /intltool/;
1387+
1388+ $domain = $1 if /^GETTEXT_PACKAGE\s*=\s*(\S*)/;
1389+ }
1390+ close (MAKEFILE);
1391+ }
1392+ if (!$domain && open CFGFILE, 'configure.ac') {
1393+ while (<CFGFILE>) {
1394+ $use_intltool = 1 if /INTLTOOL/;
1395+
1396+ $domain = $1 if /^GETTEXT_PACKAGE\s*=\s*(\S*)/;
1397+ }
1398+ close (CFGFILE);
1399+ }
1400+ if (!$domain && open CFGFILE, 'configure.in') {
1401+ while (<CFGFILE>) {
1402+ $use_intltool = 1 if /INTLTOOL/;
1403+
1404+ $domain = $1 if /^GETTEXT_PACKAGE\s*=\s*(\S*)/;
1405+ }
1406+ close (CFGFILE);
1407+ }
1408+ if (open CFGFILE, 'config.h') {
1409+ while (<CFGFILE>) {
1410+ $domain = $1 if /^#define GETTEXT_PACKAGE\s*"(\S*)"/;
1411+ }
1412+ close (CFGFILE);
1413+ }
1414+ if (!$domain && open CFGFILE, 'setup.cfg') {
1415+ while (<CFGFILE>) {
1416+ $domain = $1 if /^\s*domain\s*=\s*(\S*)/;
1417+ }
1418+ close (CFGFILE);
1419+ }
1420+ if (!$domain && open CMAKELISTSFILE, 'CMakeLists.txt') {
1421+ while (<CMAKELISTSFILE>) {
1422+ if ( -e 'po/POTFILES.in' ) {
1423+ $use_intltool = 1;
1424+ }
1425+ $domain = $1 if /^set \(GETTEXT_PACKAGE\s*"(\S*)"\)/;
1426+ }
1427+ close (CMAKELISTSFILE)
1428+ }
1429+
1430+ verbose_print "check_buildsystem: got domain '$domain', using intltool: $use_intltool";
1431+}
1432+
1433+# Try to build a POT
1434+sub build_pot {
1435+
1436+ my @cmd;
1437+ if ($use_intltool) {
1438+ # use intltool-update
1439+ if ($domain) {
1440+ @cmd=('/usr/bin/intltool-update', '-p', '--verbose', '-g', $domain);
1441+ } else {
1442+ @cmd=('/usr/bin/intltool-update', '-p', '--verbose');
1443+ }
1444+ } else {
1445+ return unless -e 'po/Makefile';
1446+ if ($domain) {
1447+ # let the Makefile itself handle it
1448+ @cmd=('make', $domain . '.pot');
1449+ } else {
1450+ warn 'Does not use intltool and po/Makefile does not define GETTEXT_PACKAGE, cannot build POT automatically';
1451+ return;
1452+ }
1453+ }
1454+ verbose_print (escape_shell (@cmd));
1455+ chdir 'po';
1456+ system @cmd;
1457+ chdir '..';
1458+
1459+ # try to build help POT
1460+ if (-e 'help/Makefile') {
1461+ chdir 'help';
1462+ system ('make', 'pot');
1463+ chdir '..';
1464+ }
1465+}
1466+
1467+# strip translations and add domain to *.desktop/*.directory
1468+sub process_desktop {
1469+ my @lines = @{$_[0]};
1470+ my @result;
1471+ my $in_desktop_entry = 0;
1472+ my $added_domain = 0;
1473+ foreach (@lines) {
1474+ # filter out translated fields
1475+ next if (/^(Name|GenericName|Comment|X-GNOME-FullName)\[/);
1476+
1477+ if (/^[A-Za-z-0-9-]*Gettext-Domain\s*=/) {
1478+ $added_domain = 1;
1479+ }
1480+
1481+ # catch section headers
1482+ if (/^\[\s*(.+)\s*\]/) {
1483+ $in_desktop_entry = ($1 eq 'Desktop Entry');
1484+ }
1485+
1486+ # if we are ending the desktop section, append the domain
1487+ if (/^\s*$/ && $in_desktop_entry && !$added_domain) {
1488+ push @result, "X-Ubuntu-Gettext-Domain=$domain\n";
1489+ $added_domain = 1;
1490+ }
1491+
1492+ push @result, $_;
1493+ }
1494+
1495+ # single-section .desktop files without ending empty lines
1496+ if ($in_desktop_entry && !$added_domain) {
1497+ push @result, "X-Ubuntu-Gettext-Domain=$domain\n";
1498+ }
1499+ return @result;
1500+}
1501+
1502+# add domain to Bonobo *.server files
1503+sub process_server {
1504+ my @lines = @{$_[0]};
1505+ my @result;
1506+ foreach (@lines) {
1507+ if (/^<oaf_server\b/ && !/ubuntu-gettext-domain/) {
1508+ s/^<oaf_server/<oaf_server ubuntu-gettext-domain="icecream"/;
1509+ }
1510+ push @result, $_;
1511+ }
1512+ return @result;
1513+}
1514+
1515+# strip translations and add domain to gconf *.schemas files
1516+sub process_gconf {
1517+ my @lines = @{$_[0]};
1518+ my @result;
1519+ my $in_locale = 0;
1520+ my $wrote_locale_tag = 0;
1521+ my $locale_tag;
1522+
1523+ foreach (@lines) {
1524+ #case: within a non-C <locale> tag
1525+ if ($in_locale) {
1526+ if (/^\s*<default>/) {
1527+ if (!$wrote_locale_tag) {
1528+ push @result, $locale_tag;
1529+ $wrote_locale_tag = 1;
1530+ }
1531+ push @result, $_;
1532+ } elsif (/^\s*<\/locale>/) {
1533+ push @result, $_ if $wrote_locale_tag;
1534+ $in_locale = 0;
1535+ }
1536+ }
1537+ # case: locale name="C": add <gettext_domain> and leave alone
1538+ elsif (/^(\s*)<locale name=\"C\">/) {
1539+ push @result, "$1<gettext_domain>$domain</gettext_domain>\n";
1540+ push @result, $_;
1541+ }
1542+ # case: locale name="something": start $in_locale and purge <short> and <long>
1543+ elsif (/<locale name=\"[^C]/) {
1544+ $in_locale = 1;
1545+ $wrote_locale_tag = 0;
1546+ $locale_tag = $_;
1547+ }
1548+ else {
1549+ push @result, $_ unless /^$/;
1550+ push @result, "\n" if /^\s*<\/schema>/; # to not kill all whitespace
1551+ }
1552+ }
1553+ return @result;
1554+}
1555+
1556+# strip translations and add domain to *.policy files
1557+sub process_polkit {
1558+ my @lines = @{$_[0]};
1559+ my @result;
1560+ foreach (@lines) {
1561+ # filter out translated fields
1562+ next if (/<(message|description)\s+xml:lang=.*\/\1>/);
1563+
1564+ # add domain
1565+ s/<(message|description)\b/<$1 gettext-domain="$domain"/;
1566+
1567+ push @result, $_;
1568+ }
1569+ return @result;
1570+}
1571+
1572+sub strip_file {
1573+ my $f = $_;
1574+ return unless $f =~ /\.(desktop|directory|server|policy|schemas)$/;
1575+ my $ext = $1;
1576+ return if -l $f or -d $f; # Skip directories and symlinks
1577+
1578+ # See if we were asked to exclude this file.
1579+ foreach my $x (@{$dh{EXCLUDE}}) {
1580+ return if ($File::Find::name =~ m/\Q$x\E/);
1581+ }
1582+
1583+ print " $f\n";
1584+ my @lines;
1585+ open F, $f or die "open $f: $!";
1586+ @lines = <F>;
1587+ close F;
1588+
1589+ if ($ext eq 'desktop' || $ext eq 'directory') {
1590+ @lines = process_desktop \@lines;
1591+ }
1592+ elsif ($ext eq 'server' && index($File::Find::name, '/bonobo/servers/') > 0) {
1593+ @lines = process_server \@lines;
1594+ } elsif ($ext eq 'policy' && index($File::Find::name, '/polkit-1/actions/') > 0) {
1595+ @lines = process_polkit \@lines;
1596+ } elsif ($ext eq 'schemas' && index($File::Find::name, '/gconf/') > 0) {
1597+ @lines = process_gconf \@lines;
1598+ }
1599+
1600+ # write back modified result
1601+ open F, ">$f" or die "open $f: $!";
1602+ foreach (@lines) {
1603+ print F $_;
1604+ }
1605+}
1606+
1607+init();
1608+
1609+check_buildsystem();
1610+build_pot();
1611+
1612+if ($domain) {
1613+ print "dh_langpack: processing files to add translation domain '$domain'..\n";
1614+ foreach my $package (@{$dh{DOPACKAGES}}) {
1615+ next if is_udeb($package);
1616+
1617+ find(\&strip_file, tmpdir($package))
1618+ }
1619+}
1620+
1621+=head1 SEE ALSO
1622+
1623+L<debhelper(1)>
1624+
1625+=head1 AUTHOR
1626+
1627+Martin Pitt <martin.pitt@ubuntu.com>
1628+
1629+Copyright (C) 2011 Canonical Ltd., licensed under the GNU GPL v2 or later.
1630+
1631+=cut
1632
1633=== added file 'pkgmaintainermangler.OTHER'
1634--- pkgmaintainermangler.OTHER 1970-01-01 00:00:00 +0000
1635+++ pkgmaintainermangler.OTHER 2012-03-08 11:48:20 +0000
1636@@ -0,0 +1,69 @@
1637+#!/bin/bash -e
1638+
1639+CONFFILE=/etc/pkgbinarymangler/maintainermangler.conf
1640+CONFFILE=${PKGBINARYMANGLER_CONF_DIR:-/etc/pkgbinarymangler}/maintainermangler.conf
1641+OVERRIDEFILE=${PKMAINTAINERGMANGLER_OVERRIDES:-/etc/pkgbinarymangler/maintainermangler.overrides}
1642+
1643+. ${PKGBINARYMANGLER_COMMON_PATH:-/usr/share/pkgbinarymangler}/common
1644+
1645+readctrl "$OVERRIDEFILE" "default"
1646+OVERRIDE="$RET"
1647+
1648+if [ -f "$BUILDINFO" ]; then
1649+ readctrl "$BUILDINFO" "Component"
1650+ COMPONENT="$RET"
1651+ readctrl "$OVERRIDEFILE" "%$RET"
1652+ if [ -n "$RET" ]; then
1653+ OVERRIDE="$RET"
1654+ fi
1655+ if grep -qs '^Purpose: PPA' "$BUILDINFO"; then
1656+ echo "INFO: Disabling pkgmaintainermangler for PPA build"
1657+ exit 0
1658+ fi
1659+fi
1660+
1661+readctrl "$PKGCTL" "Maintainer"
1662+OLDMAINT="$RET"
1663+OLDMAINTEMAIL=$(echo "$OLDMAINT" | sed -e 's/.*<\(.*\)>.*/\1/')
1664+OLDMAINTDOMAIN=$(echo "$OLDMAINTEMAIL" | sed -e 's/.*@//')
1665+
1666+readctrl "$OVERRIDEFILE" "ignore_domains"
1667+IGNORE_DOMAINS="$RET"
1668+if [ -n "$IGNORE_DOMAINS" ]; then
1669+ for i in $IGNORE_DOMAINS; do
1670+ if [ "$i" = "$OLDMAINTDOMAIN" ]; then
1671+ echo "pkgmaintainermangler: Not overriding Maintainer for domain $OLDMAINTDOMAIN"
1672+ exit 0
1673+ fi
1674+ done
1675+fi
1676+
1677+readctrl "$OVERRIDEFILE" "ignore_emails"
1678+IGNORE_EMAILS="$RET"
1679+if [ -n "$IGNORE_EMAILS" ]; then
1680+ for i in $IGNORE_EMAILS; do
1681+ if [ "$i" = "$OLDMAINTEMAIL" ]; then
1682+ echo "pkgmaintainermangler: Not overriding Maintainer for address $OLDMAINTEMAIL"
1683+ exit 0
1684+ fi
1685+ done
1686+fi
1687+
1688+readctrl "$OVERRIDEFILE" "@$OLDMAINTEMAIL"
1689+if [ -n "$RET" ]; then
1690+ OVERRIDE="$RET"
1691+fi
1692+
1693+readctrl "$PKGCTL" "Original-Maintainer"
1694+if [ -n "$RET" ]; then
1695+ echo "pkgmaintainermangler: $PKGCTL already contains an Original-Maintainer field; doing nothing" >&2
1696+ exit 0
1697+fi
1698+
1699+if [ "$OLDMAINT" = "$OVERRIDE" ]; then
1700+ echo "pkgmaintainermangler: Override matches original Maintainer; doing nothing"
1701+ exit 0
1702+fi
1703+
1704+echo "pkgmaintainermangler: Maintainer field overridden to \"$OVERRIDE\""
1705+sed -i -e "s/^Maintainer: \(.*\)$/Maintainer: $OVERRIDE\nOriginal-Maintainer: \1/" $PKGCTL
1706
1707=== added file 'pkgsanitychecks.OTHER'
1708--- pkgsanitychecks.OTHER 1970-01-01 00:00:00 +0000
1709+++ pkgsanitychecks.OTHER 2012-03-08 11:48:20 +0000
1710@@ -0,0 +1,52 @@
1711+#!/bin/bash -e
1712+
1713+CONFFILE=${PKGBINARYMANGLER_CONF_DIR:-/etc/pkgbinarymangler}/sanitychecks.conf
1714+
1715+. ${PKGBINARYMANGLER_COMMON_PATH:-/usr/share/pkgbinarymangler}/common
1716+
1717+if grep -q '^Section: debian-installer$' "$PKGCTL"; then
1718+ echo "INFO: Disabling pkgsanitychecks for udeb" >&2
1719+ exit 0
1720+fi
1721+
1722+readctrl $PKGCTL Package
1723+PKGNAME=$RET
1724+DIR=$(dirname $(dirname "$PKGCTL"))
1725+
1726+# locations of python modules for 2.6 and newer python versions
1727+case $PKGNAME in
1728+ python2.6|python2.7|python3.0|python3.1)
1729+ :
1730+ ;;
1731+ *)
1732+ for pv in 2.6 2.7 3.0 3.1; do
1733+ if [ -d $DIR/usr/lib/python$pv/site-packages ]; then
1734+ echo "Found files in /usr/lib/python$pv/site-packages (must be in dist-packages for python$pv)." >&2
1735+ find $DIR/usr/lib/python$pv/site-packages >&2
1736+ pysite_found=y
1737+ fi
1738+ if [ -d $DIR/usr/local/lib/python$pv ]; then
1739+ echo "Found files in /usr/local/lib/python$pv (must be in /usr/lib for python$pv)." >&2
1740+ find $DIR/usr/local/lib/python$pv >&2
1741+ pysite_found=y
1742+ fi
1743+ done
1744+ if [ -n "$pysite_found" ]; then
1745+ break_build=y
1746+ fi
1747+esac
1748+
1749+# check for files in /usr/local
1750+if [ -d $DIR/usr/local ]; then
1751+ echo "Found files in /usr/local (must be in /usr)." >&2
1752+ find $DIR/usr/local >&2
1753+ break_build=y
1754+fi
1755+# more sanity checks ...
1756+
1757+# break the build if necessary
1758+if [ -n "$break_build" ]; then
1759+ exit 1
1760+fi
1761+
1762+exit 0
1763
1764=== added file 'pkgstripfiles.OTHER'
1765--- pkgstripfiles.OTHER 1970-01-01 00:00:00 +0000
1766+++ pkgstripfiles.OTHER 2012-03-08 11:48:20 +0000
1767@@ -0,0 +1,208 @@
1768+#!/bin/bash -e
1769+
1770+CONFFILE=${PKGBINARYMANGLER_CONF_DIR:-/etc/pkgbinarymangler}/stripfiles.conf
1771+
1772+. ${PKGBINARYMANGLER_COMMON_PATH:-/usr/share/pkgbinarymangler}/common
1773+
1774+#
1775+# Remove buildinfo files and upstream changelogs; take care to keep native changelogs
1776+#
1777+clean_upstream_changelogs()
1778+{
1779+ # skip if we have symlinked dirs (e. g. Perl, see LP#923430)
1780+ if [ -L usr/share/doc -o -L usr/share/doc/$PKGNAME ]; then
1781+ return
1782+ fi
1783+
1784+ dch=usr/share/doc/$PKGNAME/changelog.Debian.gz
1785+ if [ ! -e "$dch" ] && [ ! -h "$dch" ]; then
1786+ dch=usr/share/doc/$PKGNAME/changelog.gz
1787+ fi
1788+
1789+ if [ -d usr/share/doc ]; then
1790+ (find usr/share/doc -type f \( -name buildinfo.gz -o -iname 'changelog.*' -o -iname changes -o -iname changes.gz -o -iname '*.changes.gz' \) -a ! -name `basename $dch` ) | while read f; do
1791+ echo ".. removing $f"
1792+ rm "$f"
1793+ [ ! -f DEBIAN/md5sums ] || sed -i "\& $f$&d" DEBIAN/md5sums
1794+ done
1795+ fi
1796+}
1797+
1798+#
1799+# Only keep the topmost ten entries in Debian changelogs. If we truncate, add a
1800+# pointer to apt-get changelog.
1801+#
1802+strip_debian_changelogs()
1803+{
1804+ record_sep="^[^ ]+ (.*) .*; urgency"
1805+ if [ -e "$dch" -a ! -L "$dch" ]; then
1806+ record_count=0
1807+ changelog=""
1808+ gzip -cd $dch | (while read; do
1809+ if [[ "$REPLY" =~ $record_sep ]]; then
1810+ ((++record_count))
1811+ if [ "$record_count" -eq 11 ]; then
1812+ echo "pkgstripfiles: Truncating $dch to topmost ten records"
1813+ echo -e "${changelog}# For older changelog entries, run 'apt-get changelog $PKGNAME'" | gzip -9n > $dch
1814+ if [ -f DEBIAN/md5sums ]; then
1815+ MD5=`md5sum "$dch"`
1816+ sed -i "s%^.* $dch\$%$MD5%" DEBIAN/md5sums
1817+ fi
1818+ break
1819+ fi
1820+ fi
1821+ changelog="$changelog$REPLY\n"
1822+ done)
1823+ fi
1824+}
1825+
1826+#
1827+# Optimize PNGs
1828+#
1829+optimize_pngs()
1830+{
1831+ # skip PNG modification for games; they often rely on their particular image
1832+ # format
1833+ if [ "${SECTION%games}" != "$SECTION" ]; then
1834+ echo "pkgstripfiles: Skipping PNG optimization for package in games section."
1835+ return
1836+ fi
1837+
1838+ # skip -doc packages; optimizing them takes a long build time and is not so
1839+ # important as these are not on the CDs
1840+ if [ "${PKGNAME%-doc}" != "$PKGNAME" ]; then
1841+ echo "pkgstripfiles: Disabled PNG optimization for -doc package $PKGNAME (to save build time)"
1842+ return
1843+ fi
1844+
1845+ # also skip when disabling explicitly
1846+ if [ -n "$NO_PNG_PKG_MANGLE" ]; then
1847+ echo "pkgstripfiles: Disabled PNG optimization for package."
1848+ return
1849+ fi
1850+
1851+ time_start=`date +%s`
1852+
1853+ # optipng/advancecomp
1854+ find -type f -name '*.png' | while read f; do
1855+ orig_perms=`stat -c %a "$f"`
1856+ if ! optipng -o4 -preserve "$f"; then
1857+ echo "WARNING: optipng failed on $f, ignoring" >&2
1858+ fi
1859+ if ! advpng -z4 "$f"; then
1860+ echo "WARNING: advpng failed on $f, ignoring" >&2
1861+ fi
1862+
1863+ # advpng does not keep permissions
1864+ chmod "$orig_perms" "$f"
1865+
1866+ # update md5sum
1867+ if [ -f DEBIAN/md5sums ]; then
1868+ f=${f#./}
1869+ MD5=`md5sum "$f"`
1870+ sed -i "s%^.* ${f//%/\%}\$%${MD5//%/\%}%" DEBIAN/md5sums
1871+ fi
1872+ done
1873+
1874+ time_end=`date +%s`
1875+ duration=$(($time_end-$time_start))
1876+ echo "pkgstripfiles: PNG optimization for package $PKGNAME took $duration s" >&2
1877+}
1878+
1879+#
1880+# Symlink identical documentation to depending packages
1881+#
1882+symlink_doc()
1883+{
1884+ if [ -n "$CDBS_NO_DOC_SYMLINKING" -o -n "$NO_DOC_PKG_MANGLE" ]; then
1885+ echo "pkgstripfiles: documentation symlinking disabled"
1886+ return
1887+ fi
1888+
1889+ # skip if doc dirs are already symlinks
1890+ if [ ! -d usr/share/doc -o -h usr/share/doc -o -h usr/share/doc/$PKGNAME ];
1891+ then
1892+ return
1893+ fi
1894+
1895+ # iterate over all dependencies
1896+ for dep in `perl -ne 'if (/^(Pre-)?Depends:/) {s/^\w+://; foreach (split /,/) { @f=split; print($f[0], "\n"); } }' DEBIAN/control`; do
1897+ [ -d ../$dep/usr/share/doc ] || continue
1898+ # don't replace docs with symlinks to matching files in dependent
1899+ # packages when the dependent package is arch: all and the depending
1900+ # package isn't; ensures consistency between packages built with -b vs.
1901+ # -B, required by multiarch.
1902+ readctrl ../$dep/DEBIAN/control Architecture
1903+ DEPARCH=$RET
1904+ if [ "$ARCHITECTURE" != "$DEPARCH" ] && [ "$DEPARCH" = "all" ];
1905+ then
1906+ echo "Skipping arch: any to arch: all dependency to $dep"
1907+ continue
1908+ fi
1909+ echo "Searching for duplicated docs in dependency $dep..."
1910+ (
1911+ r=`pwd`
1912+ cd usr/share/doc/$PKGNAME
1913+ find -type f ! -name copyright | while read f; do
1914+ f=${f#./}
1915+ thisfile="$r/usr/share/doc/$PKGNAME/$f"
1916+ depfile="$r/../$dep/usr/share/doc/$dep/$f"
1917+ if [ -L $depfile ]; then
1918+ dep=$(basename $(dirname $(readlink "$depfile")))
1919+ depfile="$r/../$dep/usr/share/doc/$dep/$f"
1920+ fi
1921+
1922+ [ "$dep" != "$PKGNAME" ] || continue
1923+ [ -f "$depfile" ] || continue
1924+
1925+ # special-case Debian changelog: as we truncate them they may
1926+ # differ, so only compare the topmost lines
1927+ if [ "$f" = "`basename $dch`" ]; then
1928+ if ! cmp <(zcat $thisfile | head -n 20) <(zcat $depfile | head -n 20); then
1929+ continue
1930+ fi
1931+ elif ! zcmp "$thisfile" "$depfile" >/dev/null; then
1932+ continue
1933+ fi
1934+
1935+ # files are identical, symlink
1936+ echo " symlinking $f in $PKGNAME to file in $dep"
1937+ rm "$thisfile"
1938+ ln -s "../$dep/$f" "$thisfile";
1939+ [ ! -f $r/DEBIAN/md5sums ] || sed -i "\& usr/share/doc/$PKGNAME/$f$&d" $r/DEBIAN/md5sums
1940+ done
1941+ )
1942+ done
1943+}
1944+
1945+#
1946+# main
1947+#
1948+
1949+# don't do anything for PPA builds
1950+if [ -f "$BUILDINFO" ]; then
1951+ if grep -qs '^Purpose: PPA' "$BUILDINFO"; then
1952+ if grep -q '/oem-archive' ${PKGBINARYMANGLER_APT_CONF_DIR:-/etc/apt}/sources.list; then
1953+ echo "INFO: Running pkgstripfiles for OEM PPA build"
1954+ else
1955+ echo "INFO: Disabling pkgstripfiles for PPA build"
1956+ exit 0
1957+ fi
1958+ fi
1959+fi
1960+
1961+readctrl $PKGCTL Package
1962+PKGNAME=$RET
1963+readctrl $PKGCTL Section
1964+SECTION=$RET
1965+readctrl $PKGCTL Architecture
1966+ARCHITECTURE=$RET
1967+PKGDIR=$(dirname $(dirname $PKGCTL))
1968+echo "pkgstripfiles: processing control file: $PKGCTL, package $PKGNAME, directory $PKGDIR"
1969+
1970+cd "$PKGDIR"
1971+
1972+clean_upstream_changelogs
1973+symlink_doc
1974+strip_debian_changelogs
1975+optimize_pngs
1976
1977=== added file 'pkgstriptranslations.OTHER'
1978--- pkgstriptranslations.OTHER 1970-01-01 00:00:00 +0000
1979+++ pkgstriptranslations.OTHER 2012-03-08 11:48:20 +0000
1980@@ -0,0 +1,382 @@
1981+#!/bin/bash -e
1982+
1983+CONFFILE=${PKGBINARYMANGLER_CONF_DIR:-/etc/pkgbinarymangler}/striptranslations.conf
1984+
1985+. ${PKGBINARYMANGLER_COMMON_PATH:-/usr/share/pkgbinarymangler}/common
1986+
1987+compliant_symlink() {
1988+ # Shell port of lines 184-222 of dh_link from debhelper
1989+ # 8.9.0ubuntu1
1990+ #
1991+ # This function must be called from the top-level of the package
1992+ local tmp src dest src_dirs dest_dirs x i
1993+
1994+ src="$(echo "$1" | sed -e 's,/+,/,g; s,^/,,')"
1995+ dest="$(echo "$2" | sed -e 's,/+,/,g; s,^/,,')"
1996+
1997+ # Make sure the directory the link will be in exists
1998+ mkdir -p "$(dirname "$dest")"
1999+
2000+ # Policy says that if the link is all within one toplevel
2001+ # directory, it should be relative. If it's between top level
2002+ # directories, leave it absolute.
2003+ IFS="/" read -ra src_dirs <<< "$src"
2004+ IFS="/" read -ra dest_dirs <<< "$dest"
2005+
2006+ if [ ${#src_dirs[@]} -gt 0 ] && [ "${src_dirs[0]}" = "${dest_dirs[0]}" ]; then
2007+ # Figure out how much of a path $src and $dest share in common
2008+ for (( x = 0; x < ${#src_dirs[@]}; x++ )); do
2009+ [ "${src_dirs[$x]}" = "${dest_dirs[$x]}" ] || break
2010+ done
2011+
2012+ # Build up the new src
2013+ src=""
2014+ # Note: use of < and not <= is deliberate here - the Perl
2015+ # version used $#dest_dirs, which is "the index of dest_dirs'
2016+ # last element" - i.e. length minus 1
2017+ for (( i = 1; i < (${#dest_dirs[@]} - x); i++ )); do
2018+ src="${src}../"
2019+ done
2020+ for (( i = x; i < ${#src_dirs[@]}; i++ )); do
2021+ src="${src}${src_dirs[$i]}/"
2022+ done
2023+ if [ $x -gt ${#src_dirs[@]} ] && [ "$src" = "" ]; then
2024+ src="." # special case
2025+ fi
2026+ src="${src%/}"
2027+ else
2028+ # Make sure it's properly absolute
2029+ src="/$src"
2030+ fi
2031+
2032+ if [ -d "$dest" ] && ! [ -L "$dest" ]; then
2033+ echo "pkgstriptranslations: link destination $dest is a directory"
2034+ fi
2035+ rm -f "$dest"
2036+ ln -sf "$src" "$dest"
2037+}
2038+
2039+# strip translations from .desktop files if they have a gettext domain (since
2040+# inline translations are preferred)
2041+desktop_files()
2042+{
2043+ for desktop in `find "$PKGDIR" -type f -name "*.desktop"`; do
2044+ if grep -q '^X-.*-Gettext-Domain=' "$desktop"; then
2045+ echo "$desktop: stripping translations"
2046+ sed -ri '/^(Name|GenericName|Comment|Keywords)\[/d' "$desktop";
2047+ # adapt md5sums file
2048+ if [ -f $PKGDIR/DEBIAN/md5sums ]; then
2049+ P=${desktop#$PKGDIR}
2050+ P=${P#/}
2051+ (cd "$PKGDIR"; sed -i "s#^[[:alnum:]]\+ $P\$#`md5sum $P`#" DEBIAN/md5sums)
2052+ fi
2053+ else
2054+ echo "$desktop: does not have gettext domain, not stripping"
2055+ fi
2056+ done
2057+}
2058+
2059+# save/strip GNOME help files; put translations into $tmp/_static/
2060+gnome2_help()
2061+{
2062+ [ -d "$PKGDIR/usr/share/gnome/help" ] || return 0
2063+
2064+ r=`pwd`
2065+ pushd "$PKGDIR/usr/share/gnome/help" >/dev/null
2066+ # replace help files which are copies of the C version with a symlink
2067+ # to the C version
2068+ find -type f ! -wholename '*/C/*' | while read f; do
2069+ f=${f#./}
2070+
2071+ # construct relative path to C file
2072+ numslash=`echo "$f" | tr -cd / | wc -c`
2073+ dirqueue=./${f#*\/*\/*} # strip off initial pkgname/locale prefix
2074+ back=""
2075+ dir=""
2076+ while [ $numslash -gt 1 ]; do
2077+ back="../$back"
2078+ dir=$dir${dirqueue%%/*}/
2079+ dirqueue=${dirqueue#*/}
2080+ numslash=$((numslash-1))
2081+ done
2082+ dir=${dir#./} # beautify
2083+ c_file="${back}C/$dir$(basename "$f")"
2084+
2085+ # if C file exists and is identical, symlink it
2086+ fdir=`dirname "$f"`
2087+ if [ -e "$fdir/$c_file" ] && zcmp "$f" "$fdir/$c_file" >/dev/null; then
2088+ echo "symlinking duplicate GNOME help file $f to $c_file"
2089+ rm "$f"
2090+ ln -s "$c_file" "$f"
2091+ [ ! -f $r/$PKGDIR/DEBIAN/md5sums ] || sed -i "\& usr/share/gnome/help/$f$&d" $r/$PKGDIR/DEBIAN/md5sums
2092+ fi
2093+ done
2094+ popd >/dev/null
2095+
2096+ # extract the files which are actually translated and replace with
2097+ # links to the langpack
2098+ pushd "$PKGDIR" >/dev/null
2099+ (find usr/share/gnome/help -type f ! -wholename '*/C/*'; [ ! -d usr/share/omf ] || find usr/share/omf -type f -name '*.omf' ! -name '*-C.omf') | while read f; do
2100+ install -D -m 644 "$f" "$tmp/_static/$PKGNAME/$f"
2101+ dest=${f/gnome\/help/gnome\/help-langpack}
2102+ dest=${dest/share\/omf/share\/omf-langpack}
2103+ compliant_symlink "$dest" "$f"
2104+ [ ! -f DEBIAN/md5sums ] || sed -i "\& $f$&d" DEBIAN/md5sums
2105+ done
2106+ popd >/dev/null
2107+}
2108+
2109+# save/strip Mallard help files; put translations into $tmp/_static/
2110+mallard_help()
2111+{
2112+ [ -d "$PKGDIR/usr/share/help" ] || return 0
2113+
2114+ r=`pwd`
2115+ pushd "$PKGDIR/usr/share/help" >/dev/null
2116+ # replace help files which are copies of the C version with a symlink
2117+ # to the C version
2118+ find -type f ! -wholename './C/*' | while read f; do
2119+ f=${f#./}
2120+
2121+ loc=${f%%/*}
2122+ sub=${f#*/}
2123+ project=${sub%%/*}
2124+ sub=${sub#*/}
2125+
2126+ # construct relative path to C file
2127+ numslash=`echo "$sub" | tr -cd / | wc -c`
2128+ c_file="../../C/$project/$sub"
2129+ while [ $numslash -gt 0 ]; do
2130+ c_file="../$c_file"
2131+ numslash=$((numslash-1))
2132+ done
2133+
2134+ # if C file exists and is identical, symlink it
2135+ fdir=`dirname "$f"`
2136+ if [ -e "$fdir/$c_file" ] && zcmp "$f" "$fdir/$c_file" >/dev/null; then
2137+ echo "symlinking duplicate Mallard help file $f to $c_file"
2138+ rm "$f"
2139+ ln -s "$c_file" "$f"
2140+ [ ! -f $r/$PKGDIR/DEBIAN/md5sums ] || sed -i "\& usr/share/help/$f$&d" $r/$PKGDIR/DEBIAN/md5sums
2141+ fi
2142+ done
2143+ popd >/dev/null
2144+
2145+ # extract the files which are actually translated and replace with
2146+ # links to the langpack
2147+ pushd "$PKGDIR" >/dev/null
2148+ find usr/share/help -type f ! -wholename '*/C/*' | while read f; do
2149+ install -D -m 644 "$f" "$tmp/_static/$PKGNAME/$f"
2150+ dest=${f/share\/help/share\/help-langpack}
2151+ compliant_symlink "$dest" "$f"
2152+ [ ! -f DEBIAN/md5sums ] || sed -i "\& $f$&d" DEBIAN/md5sums
2153+ done
2154+ popd >/dev/null
2155+}
2156+
2157+# Remove gettext *.mo files from binary, and save translations
2158+gettext()
2159+{
2160+ # copy po/pot files; no need to do it again if tarball already exists
2161+ # these might be used for help translations etc., so we need to do this
2162+ # even if none of the packages ships *.mo files
2163+ if [ ! -f "$tarball" ]; then
2164+ find \( -name "*.po" -o -name "*.pot" -o -name "*.ts" \) ! -wholename '*/.pc/*' ! -empty -exec install -D -m 644 '{}' "$tmp/source/{}" \;
2165+ fi
2166+
2167+ if [ ! -d "$PKGDIR/usr/share/locale" ]; then
2168+ echo "pkgstriptranslations: $PKGNAME does not contain translations, skipping"
2169+ return 0
2170+ fi
2171+
2172+ # save *.mo files
2173+ pushd "$PKGDIR" >/dev/null
2174+ find -type f -name "*.mo" -exec install -D -m 644 '{}' "$tmp/$PKGNAME/{}" \;
2175+
2176+ find usr/share/locale -type f -name "*.mo" -exec rm '{}' \;
2177+ find usr/share/locale -depth -type d -empty -exec rmdir '{}' \; || true
2178+
2179+ # adapt md5sums file
2180+ if [ -f DEBIAN/md5sums ]; then
2181+ sed -i '/usr\/share\/locale\/.*\.mo$/d' DEBIAN/md5sums
2182+ fi
2183+
2184+ # adapt Installed-Size
2185+ is=`du -k -s .|cut -f1`
2186+ sed -i "s/^Installed-Size:.*$/Installed-Size: $is/" DEBIAN/control
2187+
2188+ popd >/dev/null
2189+}
2190+
2191+# grab sdf files from LibO
2192+libreoffice()
2193+{
2194+ if [ "$srcname" = "openoffice.org" ]; then
2195+ find debian/ -name "*.sdf" -exec install -D -m 644 '{}' "$tmp/source/{}" \;
2196+ fi
2197+}
2198+
2199+# if we saved any files, create/update $tarball and $tarball_static
2200+save_files()
2201+{
2202+ if [ -n "$(ls -I _static $tmp)" ]; then
2203+ if [ -f "$tarball" ]; then
2204+ echo -n "pkgstriptranslations: updating translation tarball $tarball_name..."
2205+ tar -C $tmp -xzf "$tarball"
2206+ else
2207+ echo -n "pkgstriptranslations: preparing translation tarball $tarball_name..."
2208+ dpkg-distaddfile "$tarball_name" raw-translations -
2209+ fi
2210+
2211+ tar -C $tmp -c --exclude=_static . | gzip -9 > "$tarball"
2212+ echo "done"
2213+ else
2214+ echo "pkgstriptranslations: no translation files, not creating tarball"
2215+ fi
2216+
2217+ if [ -d "$tmp/_static" ]; then
2218+ if [ -f "$tarball_static" ]; then
2219+ echo -n "pkgstriptranslations: updating static translation tarball $tarball_static_name..."
2220+ tar -C "$tmp/_static" -xzf "$tarball_static"
2221+ else
2222+ echo -n "pkgstriptranslations: preparing static translation tarball $tarball_static_name..."
2223+ dpkg-distaddfile "$tarball_static_name" raw-translations-static -
2224+ fi
2225+
2226+ tar -C $tmp/_static -c . | gzip -9 > "$tarball_static"
2227+ echo "done "
2228+ fi
2229+}
2230+
2231+#
2232+# main
2233+#
2234+
2235+echo "INFO: pkgstriptranslations version #VERSION#"
2236+
2237+# ignore language packs
2238+if echo "$srcname" | grep -q ^language-pack; then
2239+ echo "pkgstriptranslations: building language pack, doing nothing"
2240+ exit 0
2241+fi
2242+
2243+# ignore backports
2244+if dpkg-parsechangelog | grep -q 'Distribution:.*backport'; then
2245+ echo "pkgstriptranslations: building backport, doing nothing"
2246+ exit 0
2247+fi
2248+
2249+# first, check if the package explicitly requests stripping
2250+if grep -q 'X[[:alpha:]]*-Ubuntu-Use-Langpack: yes' debian/control; then
2251+ dostrip=1
2252+# check whether build info is present; so we can check the component
2253+elif [ -f "$BUILDINFO" ]; then
2254+ unset dostrip
2255+
2256+ if grep -qs '^Purpose: PPA' "$BUILDINFO"; then
2257+ if grep -q '/oem-archive' ${PKGBINARYMANGLER_APT_CONF_DIR:-/etc/apt}/sources.list; then
2258+ echo "INFO: Running pkgstriptranslations for OEM build"
2259+ oemstrip=1
2260+
2261+ # check blacklist
2262+ readctrl "$CONFFILE" oem_blacklist
2263+ for project in $RET; do
2264+ if grep -q "oem-archive/$project" ${PKGBINARYMANGLER_APT_CONF_DIR:-/etc/apt}/sources.list; then
2265+ echo "INFO: Disabling pkgstriptranslations for blacklisted OEM project"
2266+ exit 0
2267+ fi
2268+ done
2269+ else
2270+ echo "INFO: Disabling pkgstriptranslations for PPA build"
2271+ exit 0
2272+ fi
2273+ else
2274+ # we have a PRIMARY build, check component
2275+ readctrl "$CONFFILE" "components"
2276+ stripcomponents="$RET"
2277+ readctrl "$BUILDINFO" "Component"
2278+ for c in $stripcomponents; do
2279+ if [ $c = "$RET" ]; then dostrip=1; fi
2280+ done
2281+ fi
2282+else
2283+ dostrip=1
2284+fi
2285+
2286+# determine tarball name
2287+readctrl "$CONFFILE" "posuffix"
2288+posuffix=$RET
2289+arch=$(dpkg --print-architecture)
2290+[ "$posuffix" ] || posuffix=translations
2291+tarball_name=${srcname}_${version}_${arch}_$posuffix.tar.gz
2292+tarball=`pwd`/../$tarball_name
2293+tarball_static_name=${srcname}_${version}_static_${posuffix}.tar.gz
2294+tarball_static=`pwd`/../$tarball_static_name
2295+readctrl $PKGCTL Package
2296+PKGNAME=$RET
2297+PKGDIR=$(dirname $(dirname $PKGCTL))
2298+
2299+# skip installer udebs
2300+readctrl $PKGCTL Section
2301+if [ "$RET" = debian-installer ]; then
2302+ exit 0
2303+fi
2304+
2305+# special-case OEM builds here: strip packages if we are building a package
2306+# for an OEM archive which would be stripped in Ubuntu
2307+if [ -n "$oemstrip" ]; then
2308+ if env -u LD_PRELOAD apt-cache madison "$PKGNAME" | egrep -v '://[^ ]*ppa' | grep -q '/ubuntu.*/main .*Packages'; then
2309+ echo "INFO (OEM mode): Package is in Ubuntu main, enabling stripping of *.mo"
2310+ dostrip=1
2311+ else
2312+ echo "INFO (OEM mode): Package is not in Ubuntu main, not stripping"
2313+ unset dostrip
2314+ fi
2315+fi
2316+
2317+
2318+echo "pkgstriptranslations: processing $PKGNAME (in $PKGDIR); do_strip: $dostrip, oemstrip: $oemstrip"
2319+
2320+# read blacklist file and test all regexps
2321+if [ -f /etc/pkgbinarymangler/striptranslations.blacklist ]; then
2322+ while read regex; do
2323+ if echo "$PKGNAME" | egrep -xq "$regex"; then
2324+ echo "pkgstriptranslations: $PKGNAME is blacklisted, not stripping"
2325+ exit 0
2326+ fi
2327+ done < /etc/pkgbinarymangler/striptranslations.blacklist
2328+fi
2329+
2330+# check for empty files, as they indicate a package bug
2331+EMPTYFILES="`find -mindepth 1 -name '.*' -prune -o \( -name "*.po" -o -name "*.pot" \) -empty -print`"
2332+if [ -n "$EMPTYFILES" ]; then
2333+ cat <<EOF
2334+pkgstriptranslations: The following PO/POT files are empty. This is known to
2335+cause trouble in the translation importer and generally indicates a package
2336+bug:
2337+
2338+$EMPTYFILES
2339+EOF
2340+fi
2341+
2342+#
2343+# Now start the actual work
2344+#
2345+
2346+# make sure that only one pkgstriptranslations runs at a time, so that we don't
2347+# corrupt the tarball
2348+lockfile-create --retry 20 "$tarball"
2349+tmp=$(mktemp -t -d pkgstriptranslations.XXXXXX)
2350+trap "lockfile-remove '$tarball'; rm -rf $tmp" 0 1 2 3 7 10 13 15
2351+
2352+desktop_files
2353+
2354+if [ "$dostrip" ]; then
2355+ gnome2_help
2356+ mallard_help
2357+ gettext
2358+ #libreoffice # currently unused
2359+
2360+ save_files
2361+fi
2362+
2363
2364=== added file 'striptranslations.blacklist.OTHER'
2365--- striptranslations.blacklist.OTHER 1970-01-01 00:00:00 +0000
2366+++ striptranslations.blacklist.OTHER 2012-03-08 11:48:20 +0000
2367@@ -0,0 +1,12 @@
2368+iso-codes
2369+dpkg
2370+language-pack.*
2371+debconf-i18n
2372+apt
2373+libapt-pkg.*
2374+libapt-inst.*
2375+xkb-data-i18n
2376+ldm
2377+language-selector-common
2378+update-notifier
2379+update-notifier-common
2380
2381=== added directory 'test'
2382=== added directory 'test/icecream'
2383=== added directory 'test/icecream/data'
2384=== added file 'test/icecream/data/translated.desktop.OTHER'
2385--- test/icecream/data/translated.desktop.OTHER 1970-01-01 00:00:00 +0000
2386+++ test/icecream/data/translated.desktop.OTHER 2012-03-08 11:48:20 +0000
2387@@ -0,0 +1,16 @@
2388+[Desktop Entry]
2389+Name=icecream
2390+Name[de]=Eiscreme
2391+Name[en_GB]=icecream
2392+GenericName=desert
2393+GenericName[de]=Dessert
2394+GenericName[en_GB]=desert
2395+X-GNOME-FullName=Vanilla or Chocolate
2396+X-GNOME-FullName[de]=Vanille oder Schokolade
2397+X-GNOME-FullName[en_GB]=Vanilla or Chocolate
2398+Comment=Yummy!
2399+Comment[de]=Lecker!
2400+Comment[en_GB]=Wonderful!
2401+Keywords=Dessert;Sweets;
2402+Keywords[de]=Nachtisch;Süßigkeiten;
2403+Exec=/usr/bin/vanilla
2404
2405=== added directory 'test/icecream/debian'
2406=== added file 'test/icecream/debian/rules.OTHER'
2407--- test/icecream/debian/rules.OTHER 1970-01-01 00:00:00 +0000
2408+++ test/icecream/debian/rules.OTHER 2012-03-08 11:48:20 +0000
2409@@ -0,0 +1,10 @@
2410+#!/usr/bin/make -f
2411+%:
2412+ dh $@ --with translations --parallel
2413+
2414+override_dh_fixperms:
2415+ dh_fixperms -X*.png
2416+
2417+override_dh_install:
2418+ dh_install
2419+ dh_buildinfo
2420
2421=== added file 'test/run.OTHER'
2422--- test/run.OTHER 1970-01-01 00:00:00 +0000
2423+++ test/run.OTHER 2012-03-08 11:48:20 +0000
2424@@ -0,0 +1,1379 @@
2425+#!/usr/bin/python3
2426+# pkgbinarymangler automatic tests
2427+# (C) 2010 - 2011 Canonical Ltd.
2428+# Author: Martin Pitt <martin.pitt@ubuntu.com>
2429+# License: GPL 2 or later
2430+
2431+import pickle
2432+import unittest
2433+import subprocess
2434+import tempfile
2435+import shutil
2436+import os.path
2437+import sys
2438+import tarfile
2439+import re
2440+from glob import glob
2441+
2442+class T(unittest.TestCase):
2443+ def setUp(self):
2444+ self.srcdir = os.path.dirname(os.path.dirname(os.path.abspath(sys.argv[0])))
2445+
2446+ self.workdir = tempfile.mkdtemp()
2447+ self.pkgdir = os.path.join(self.workdir, 'icecream')
2448+ shutil.copytree(os.path.join(self.srcdir, 'test', 'icecream'),
2449+ self.pkgdir)
2450+
2451+ self.buildinfo = None
2452+ # do not depend on host induced build options
2453+ os.environ['DEB_BUILD_OPTIONS'] = ''
2454+
2455+ os.environ['PKGBINARYMANGLER_COMMON_PATH'] = self.srcdir
2456+ # locally fake the diversions
2457+ if os.path.exists('/usr/bin/dpkg-deb.pkgbinarymangler'):
2458+ os.symlink('/usr/bin/dpkg-deb.pkgbinarymangler', os.path.join(self.srcdir, 'dpkg-deb.pkgbinarymangler'))
2459+ else:
2460+ os.symlink('/usr/bin/dpkg-deb', os.path.join(self.srcdir, 'dpkg-deb.pkgbinarymangler'))
2461+ if os.path.exists('/usr/bin/dh_builddeb.pkgbinarymangler'):
2462+ os.symlink('/usr/bin/dh_builddeb.pkgbinarymangler', os.path.join(self.srcdir, 'dh_builddeb.pkgbinarymangler'))
2463+ else:
2464+ os.symlink('/usr/bin/dh_builddeb', os.path.join(self.srcdir, 'dh_builddeb.pkgbinarymangler'))
2465+
2466+ # copy our default configuration files, and enable them
2467+ for conf in glob(os.path.join(self.srcdir, '*.conf')):
2468+ with open(conf) as old:
2469+ with open(os.path.join(self.workdir, os.path.basename(conf)), 'w') as new:
2470+ new.write(old.read().replace('enable: false', 'enable: true'))
2471+ os.environ['PKGBINARYMANGLER_CONF_DIR'] = self.workdir
2472+
2473+ os.environ['PKMAINTAINERGMANGLER_OVERRIDES'] = os.path.join(
2474+ self.srcdir, 'maintainermangler.overrides')
2475+
2476+ # point to local debhelper sequencer
2477+ d = os.path.join(self.workdir, 'Debian', 'Debhelper', 'Sequence')
2478+ os.makedirs(d)
2479+ shutil.copy('translations.pm', d)
2480+ os.environ['PERLLIB'] = '%s:%s' % (self.workdir, os.environ.get('PERLLIB', ''))
2481+
2482+ def tearDown(self):
2483+ shutil.rmtree(self.workdir)
2484+ os.unlink(os.path.join(self.srcdir, 'dpkg-deb.pkgbinarymangler'))
2485+ os.unlink(os.path.join(self.srcdir, 'dh_builddeb.pkgbinarymangler'))
2486+
2487+ def build(self, use_local_mangler=True, extra_env=None, srcname='icecream'):
2488+ env = os.environ.copy()
2489+ if use_local_mangler:
2490+ env['PATH'] = self.srcdir + ':' + env.get('PATH', '')
2491+
2492+ bi = os.path.join(self.workdir, 'CurrentlyBuilding')
2493+ env['CURRENTLY_BUILDING_PATH'] = bi
2494+ # ignore system apt sources, otherwise we'll break some tests if we
2495+ # run them in an OEM buildd environment
2496+ env['PKGBINARYMANGLER_APT_CONF_DIR'] = self.workdir
2497+ if self.buildinfo:
2498+ f = open(bi, 'w')
2499+ f.write(self.buildinfo)
2500+ f.close()
2501+ else:
2502+ # disable a system-installed pkgbinarymangler
2503+ if os.path.exists('/usr/bin/dpkg-deb.pkgbinarymangler'):
2504+ os.symlink('/usr/bin/dpkg-deb.pkgbinarymangler',
2505+ os.path.join(self.workdir, 'dpkg-deb'))
2506+ # make dh_translations available in $PATH
2507+ os.symlink(os.path.join(self.srcdir, 'dh_translations'),
2508+ os.path.join(self.workdir, 'dh_translations'))
2509+ env['PATH'] = self.workdir + ':' + env.get('PATH', '')
2510+
2511+ if extra_env:
2512+ env.update(extra_env)
2513+
2514+ build = subprocess.Popen(['dpkg-buildpackage', '-us', '-uc', '-b'],
2515+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
2516+ cwd=self.pkgdir, env=env)
2517+ out = build.communicate()[0].decode()
2518+ self.assertEqual(build.returncode, 0,
2519+ '--- dpkg failed with error %i:\n%s\n-----' % (build.returncode, out))
2520+
2521+ with open(glob(os.path.join(self.workdir, '%s_12*_*.changes' % srcname))[0]) as f:
2522+ self.changes = f.read()
2523+
2524+ tars = glob(os.path.join(self.workdir, '%s_12*_*_translations.tar.gz' % srcname))
2525+ if len(tars) == 0:
2526+ self.translations_tar = None
2527+ self.static_translations_tar = None
2528+ elif len(tars) == 2:
2529+ # gettext and static tarballs
2530+ if '_static_' in tars[0]:
2531+ self.static_translations_tar = tars[0]
2532+ self.translations_tar = tars[1]
2533+ else:
2534+ self.static_translations_tar = tars[1]
2535+ self.translations_tar = tars[0]
2536+ else:
2537+ assert len(tars) == 1
2538+ self.translations_tar = tars[0]
2539+ self.static_translations_tar = None
2540+
2541+ self.check_deb_integrity()
2542+
2543+ def sed_control(self, cmd, files=['control']):
2544+ '''Apply sed commands to icecream debian/control
2545+
2546+ You can specify different/more files with the "files" list argument.
2547+ '''
2548+ f = [os.path.join(self.pkgdir, 'debian', name) for name in files]
2549+ subprocess.check_call(['sed', '-i', cmd] + f)
2550+
2551+ def deb_contents(self):
2552+ '''Return contents for all built binary packages.
2553+
2554+ Returns dictionary: package name -> file -> info, where info is a map
2555+ with 'size', 'owner', 'mode', 'linkto' (None for non-symlinks).
2556+ '''
2557+ contents_map = {}
2558+ contents_line_re = re.compile('^([\w-]+)\s+([\w/]+)\s+(\d+)\s+([\d-]+)\s+([\d:]+)\s+(\S+)(?: -> (\S+))?$')
2559+
2560+ for deb in glob(os.path.join(self.workdir, '*_*_*.deb')):
2561+ deb_map = contents_map.setdefault(os.path.basename(deb).split('_')[0], {})
2562+
2563+ dpkg = subprocess.Popen(['dpkg', '-c', deb], stdout=subprocess.PIPE)
2564+ for line in dpkg.stdout:
2565+ m = contents_line_re.match(line.decode())
2566+ info = deb_map.setdefault(m.group(6), {})
2567+ info['mode'] = m.group(1)
2568+ info['owner'] = m.group(2)
2569+ info['size'] = int(m.group(3))
2570+ info['linkto'] = m.group(7)
2571+
2572+ dpkg.communicate()
2573+ assert dpkg.returncode == 0
2574+
2575+ return contents_map
2576+
2577+ def check_deb_mo(self, expect_mo):
2578+ '''Verify the built .deb contents for translations
2579+
2580+ This also checks the validity of the corresponding translation tarball.
2581+ '''
2582+ for pkg in ('vanilla', 'chocolate'):
2583+ deb = glob(os.path.join(self.workdir, '%s_12_*.deb' % pkg))[0]
2584+ dpkg = subprocess.Popen(['dpkg', '-c', deb],
2585+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
2586+ out = dpkg.communicate()[0].decode()
2587+ if expect_mo:
2588+ self.assertTrue('./usr/share/locale/fr/LC_MESSAGES/%s.mo' % pkg in out)
2589+ self.assertTrue('./usr/share/locale/de/LC_MESSAGES/%s.mo' % pkg in out)
2590+ else:
2591+ self.assertFalse('/usr/share/locale/' in out)
2592+ self.assertTrue('./usr/share/doc/%s/copyright' % pkg in out)
2593+
2594+ if expect_mo:
2595+ self.assertEqual(self.translations_tar, None,
2596+ 'does not build a translation tarball for unstripped packages')
2597+ else:
2598+ self.assertTrue('raw-translations - ' + os.path.basename(self.translations_tar) in self.changes)
2599+
2600+ tar = tarfile.open(self.translations_tar)
2601+ self.assertTrue('./vanilla/usr/share/locale/fr/LC_MESSAGES/vanilla.mo'
2602+ in tar.getnames())
2603+ self.assertTrue('./chocolate/usr/share/locale/de/LC_MESSAGES/chocolate.mo'
2604+ in tar.getnames())
2605+ self.assertTrue('./source/po-vanilla/vanilla.pot'
2606+ in tar.getnames())
2607+ self.assertFalse('./source/po-vanilla/empty.pot'
2608+ in tar.getnames())
2609+ self.assertTrue('./source/po-chocolate/de.po'
2610+ in tar.getnames())
2611+
2612+ def check_deb_stripfiles(self, expect_files):
2613+ '''Verify the built .deb contents for files we want to strip'''
2614+
2615+ for pkg in ('vanilla', 'chocolate'):
2616+ deb = glob(os.path.join(self.workdir, '%s_12*_*.deb' % pkg))[0]
2617+ dpkg = subprocess.Popen(['dpkg', '-c', deb],
2618+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
2619+ out = dpkg.communicate()[0].decode()
2620+ if expect_files:
2621+ self.assertTrue('./usr/share/doc/%s/buildinfo.gz' % pkg in out)
2622+ self.assertTrue('./usr/share/doc/%s/changelog.gz' % pkg in out or
2623+ './usr/share/doc/%s/changelog.Debian.gz' % pkg in out)
2624+ else:
2625+ self.assertFalse('./usr/share/doc/%s/buildinfo.gz' % pkg in out)
2626+ if 'changelog.Debian.gz' in out:
2627+ self.assertFalse('changelog.gz' in out)
2628+
2629+ dpkg = subprocess.Popen('ar p %s control.tar.gz | tar xOz ./md5sums' % deb, shell=True,
2630+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
2631+ (out, err) = dpkg.communicate()
2632+ out = out.decode()
2633+ self.assertEqual(err, b'')
2634+ if expect_files:
2635+ self.assertTrue('usr/share/doc/%s/buildinfo.gz' % pkg in out)
2636+ self.assertTrue('usr/share/doc/%s/changelog.gz' % pkg in out or
2637+ 'usr/share/doc/%s/changelog.Debian.gz' % pkg in out)
2638+ else:
2639+ self.assertFalse('buildinfo.gz' in out)
2640+ if 'changelog.Debian.gz' in out:
2641+ self.assertFalse('changelog.gz' in out)
2642+
2643+ def check_maintainer(self, expect_mangle):
2644+ '''Verify the built .deb for mangled maintainer'''
2645+
2646+ for deb in glob(os.path.join(self.workdir, '*_12_*.deb')):
2647+ dpkg = subprocess.Popen(['dpkg', '-I', deb],
2648+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
2649+ (out, err) = dpkg.communicate()
2650+ out = out.decode()
2651+ self.assertEqual(err, b'')
2652+ if expect_mangle:
2653+ self.assertTrue('Maintainer: Ubuntu' in out)
2654+ self.assertTrue('Original-Maintainer: Joe User <joe@example.com>' in out)
2655+ else:
2656+ self.assertTrue('Maintainer: Joe User <joe@example.com>' in out)
2657+ self.assertFalse('Original-Maintainer:' in out)
2658+
2659+ def check_deb_integrity(self):
2660+ '''Check that we can properly unpack the generated .debs
2661+
2662+ This also verifies md5sums.
2663+ '''
2664+ debs = glob(os.path.join(self.workdir, '*.deb'))
2665+ if not debs:
2666+ self.fail('No .debs produced')
2667+
2668+ for deb in debs:
2669+ extractdir = os.path.join(self.workdir, 'deb-' +
2670+ os.path.splitext(os.path.basename(deb))[0])
2671+
2672+ env = os.environ.copy()
2673+ env['PATH'] = self.srcdir + ':' + env.get('PATH', '')
2674+ dpkg = subprocess.Popen(['dpkg-deb', '-x', deb, extractdir],
2675+ stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env)
2676+ (out, err) = dpkg.communicate()
2677+
2678+ # dpkg-deb must not print anything, otherwise apt falls over
2679+ self.assertEqual(out, b'')
2680+ self.assertEqual(err, b'')
2681+ self.assertEqual(dpkg.returncode, 0)
2682+
2683+ # verify md5sums
2684+ md5sum = subprocess.Popen('ar p %s control.tar.gz | tar xOz ./md5sums | md5sum -c' % deb,
2685+ shell=True, cwd=extractdir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
2686+ out, err = md5sum.communicate()
2687+ self.assertEqual(err, b'', out + err)
2688+ self.assertEqual(md5sum.returncode, 0)
2689+
2690+ # our link to .png file must remain a link
2691+ foolink = os.path.join(extractdir, 'usr', 'share', 'icecream',
2692+ 'foolink.png')
2693+ if os.path.exists(foolink):
2694+ self.assertTrue(os.path.islink(foolink))
2695+ self.assertEqual(os.readlink(foolink), 'foo%.png')
2696+
2697+ # verify permissions are kept
2698+ d = os.path.join(extractdir, 'usr', 'share', 'icecream')
2699+ foo_png = os.path.join(d, 'foo%.png')
2700+ if os.path.exists(foo_png):
2701+ self.assertEqual(os.stat(foo_png).st_mode & 0o777, 0o600)
2702+ notapng = os.path.join(d, 'nota.png')
2703+ if os.path.exists(notapng):
2704+ self.assertEqual(os.stat(notapng).st_mode & 0o777, 0o644)
2705+
2706+ def test_no_mangler(self):
2707+ '''No pkgbinarymangler'''
2708+
2709+ self.build(False)
2710+ self.check_deb_mo(True)
2711+ self.check_maintainer(False)
2712+ self.check_deb_stripfiles(True)
2713+
2714+ def test_no_pkg_mangle(self):
2715+ '''$NO_PKG_MANGLE disables pkgbinarymangler'''
2716+
2717+ self.build(True, {'NO_PKG_MANGLE': '1'})
2718+ self.check_deb_mo(True)
2719+ self.check_maintainer(False)
2720+ self.check_deb_stripfiles(True)
2721+
2722+ def test_no_buildinfo(self):
2723+ '''No build info'''
2724+
2725+ # this should always strip
2726+ self.build()
2727+ self.check_deb_mo(False)
2728+ self.check_maintainer(True)
2729+ self.check_deb_stripfiles(False)
2730+
2731+ def test_main(self):
2732+ '''Component: main'''
2733+
2734+ self.buildinfo = '''Package: icecream
2735+Component: main
2736+Suite: lucid
2737+Purpose: PRIMARY
2738+'''
2739+
2740+ self.build()
2741+ # main packages get stripped and produce a tarball
2742+ self.check_deb_mo(False)
2743+ self.check_deb_stripfiles(False)
2744+ self.check_maintainer(True)
2745+
2746+ def test_universe(self):
2747+ '''Component: universe'''
2748+
2749+ self.buildinfo = '''Package: icecream
2750+Component: universe
2751+Suite: lucid
2752+Purpose: PRIMARY
2753+'''
2754+
2755+ self.build()
2756+ # universe packages don't get stripped, and don't produce a tarball
2757+ self.check_deb_mo(True)
2758+ self.check_maintainer(True)
2759+ self.check_deb_stripfiles(False)
2760+
2761+ def test_force_stripping(self):
2762+ '''Component: universe, but with X-Ubuntu-Use-Langpack: yes'''
2763+
2764+ self.buildinfo = '''Package: icecream
2765+Component: universe
2766+Suite: lucid
2767+Purpose: PRIMARY
2768+'''
2769+
2770+ self.sed_control('s/^Section:/X-Ubuntu-Use-Langpack: yes\\n&/')
2771+
2772+ self.build()
2773+ self.check_deb_mo(False)
2774+ self.check_deb_stripfiles(False)
2775+ self.check_maintainer(True)
2776+
2777+ def test_ppa(self):
2778+ '''Purpose: PPA'''
2779+
2780+ self.buildinfo = '''Package: icecream
2781+Component: main
2782+Suite: lucid
2783+Purpose: PPA
2784+'''
2785+
2786+ # PPA builds are never touched by default
2787+ self.build()
2788+ self.check_deb_mo(True)
2789+ self.check_maintainer(False)
2790+ self.check_deb_stripfiles(True)
2791+
2792+ def test_partner(self):
2793+ '''Section: partner'''
2794+
2795+ self.sed_control('s/^Section:.*$/Section: partner/')
2796+
2797+ # partner builds are not touched
2798+ self.build()
2799+ self.check_deb_mo(True)
2800+ self.check_maintainer(False)
2801+ self.check_deb_stripfiles(True)
2802+
2803+ def test_langpack(self):
2804+ '''language packs are not stripped'''
2805+
2806+ self.buildinfo = '''Package: language-pack-de
2807+Component: main
2808+Suite: lucid
2809+Purpose: PRIMARY
2810+'''
2811+
2812+ # rename source to langpack
2813+ self.sed_control('s/icecream/language-pack-de/g', ['control', 'changelog'])
2814+ self.build(True, srcname='language-pack-de')
2815+
2816+ # should not strip translations, since partner is blacklisted
2817+ self.check_deb_mo(True)
2818+ self.check_deb_stripfiles(False)
2819+
2820+ def test_ppa_oem_non_main(self):
2821+ '''OEM PPA for non-main package'''
2822+
2823+ # these currently look like normal PPAs, we can't yet determine the PPA
2824+ # name from buildinfo; hack around with checking apt sources
2825+ self.buildinfo = '''Package: icecream
2826+Component: main
2827+Suite: lucid
2828+Purpose: PPA
2829+'''
2830+ apt_sources = open(os.path.join(self.workdir, 'sources.list'), 'w')
2831+ apt_sources.write('''deb http://private-ppa.buildd/oem-archive/myoem/ubuntu lucid main
2832+deb https://cesg.canonical.com/canonical myoem public private
2833+deb https://cesg.canonical.com/canonical myoem-devel public private
2834+deb http://ftpmaster.internal/ubuntu lucid main restricted universe multiverse
2835+''')
2836+ apt_sources.close()
2837+
2838+ # those should not strip translations, since it's not in main
2839+ self.build(True, {'PKGBINARYMANGLER_APT_CONF_DIR': self.workdir})
2840+ self.check_deb_mo(True)
2841+ self.check_deb_stripfiles(False)
2842+
2843+ # no maintainer mangling in PPAs, as usual
2844+ self.check_maintainer(False)
2845+
2846+ def test_ppa_oem_main(self):
2847+ '''OEM PPA for main package'''
2848+
2849+ # these currently look like normal PPAs, we can't yet determine the PPA
2850+ # name from buildinfo; hack around with checking apt sources
2851+ self.buildinfo = '''Package: icecream
2852+Component: main
2853+Suite: lucid
2854+Purpose: PPA
2855+'''
2856+ apt_sources = open(os.path.join(self.workdir, 'sources.list'), 'w')
2857+ apt_sources.write('''deb http://private-ppa.buildd/oem-archive/myoem/ubuntu lucid main
2858+deb https://cesg.canonical.com/canonical myoem public private
2859+deb https://cesg.canonical.com/canonical myoem-devel public private
2860+deb http://ftpmaster.internal/ubuntu lucid main restricted universe multiverse
2861+''')
2862+ apt_sources.close()
2863+
2864+ # rename binaries to two in main
2865+ self.sed_control('s/vanilla/coreutils/g; s/chocolate/bash/g')
2866+ os.rename(os.path.join(self.pkgdir, 'debian', 'vanilla.install'),
2867+ os.path.join(self.pkgdir, 'debian', 'coreutils.install'))
2868+ os.rename(os.path.join(self.pkgdir, 'debian', 'chocolate.install'),
2869+ os.path.join(self.pkgdir, 'debian', 'bash.install'))
2870+
2871+ self.build(True, {'PKGBINARYMANGLER_APT_CONF_DIR': self.workdir})
2872+
2873+ # should strip translations, since the are in Ubuntu main
2874+ for pkg in ('coreutils', 'bash'):
2875+ deb = glob(os.path.join(self.workdir, '%s_12_*.deb' % pkg))[0]
2876+ dpkg = subprocess.Popen(['dpkg', '-c', deb],
2877+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
2878+ out = dpkg.communicate()[0].decode()
2879+ self.assertFalse('/usr/share/locale/' in out)
2880+ self.assertTrue('./usr/share/doc/%s/copyright' % pkg in out)
2881+
2882+ tar = tarfile.open(self.translations_tar)
2883+ self.assertTrue('./coreutils/usr/share/locale/fr/LC_MESSAGES/vanilla.mo'
2884+ in tar.getnames())
2885+ self.assertTrue('./bash/usr/share/locale/de/LC_MESSAGES/chocolate.mo'
2886+ in tar.getnames())
2887+ self.assertTrue('./source/po-vanilla/vanilla.pot'
2888+ in tar.getnames())
2889+ self.assertTrue('./source/po-chocolate/de.po'
2890+ in tar.getnames())
2891+
2892+ # no maintainer mangling in PPAs, as usual
2893+ self.check_maintainer(False)
2894+
2895+ def test_ppa_oem_main_blacklisted(self):
2896+ '''OEM PPA for main package for blacklisted project'''
2897+
2898+ # these currently look like normal PPAs, we can't yet determine the PPA
2899+ # name from buildinfo; hack around with checking apt sources
2900+ self.buildinfo = '''Package: icecream
2901+Component: main
2902+Suite: lucid
2903+Purpose: PPA
2904+'''
2905+ apt_sources = open(os.path.join(self.workdir, 'sources.list'), 'w')
2906+ apt_sources.write('''deb http://private-ppa.buildd/oem-archive/partner/ubuntu lucid main
2907+deb https://cesg.canonical.com/canonical partner public private
2908+deb https://cesg.canonical.com/canonical partner-devel public private
2909+deb http://ftpmaster.internal/ubuntu lucid main restricted universe multiverse
2910+''')
2911+ apt_sources.close()
2912+
2913+ # rename binaries to two in main
2914+ self.sed_control('s/vanilla/coreutils/g; s/chocolate/bash/g')
2915+ os.rename(os.path.join(self.pkgdir, 'debian', 'vanilla.install'),
2916+ os.path.join(self.pkgdir, 'debian', 'coreutils.install'))
2917+ os.rename(os.path.join(self.pkgdir, 'debian', 'chocolate.install'),
2918+ os.path.join(self.pkgdir, 'debian', 'bash.install'))
2919+
2920+ self.build(True, {'PKGBINARYMANGLER_APT_CONF_DIR': self.workdir})
2921+
2922+ # should not strip translations, since partner is blacklisted
2923+ for pkg in ('coreutils', 'bash'):
2924+ deb = glob(os.path.join(self.workdir, '%s_12_*.deb' % pkg))[0]
2925+ dpkg = subprocess.Popen(['dpkg', '-c', deb],
2926+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
2927+ out = dpkg.communicate()[0].decode()
2928+ if pkg == 'coreutils':
2929+ self.assertTrue('./usr/share/locale/fr/LC_MESSAGES/vanilla.mo' in out)
2930+ else:
2931+ self.assertTrue('./usr/share/locale/de/LC_MESSAGES/chocolate.mo' in out)
2932+ self.assertTrue('./usr/share/doc/%s/copyright' % pkg in out)
2933+
2934+ self.assertEqual(self.translations_tar, None)
2935+
2936+ # no maintainer mangling in PPAs, as usual
2937+ self.check_maintainer(False)
2938+
2939+ def test_installed_size(self):
2940+ '''Installed-Size gets updated'''
2941+
2942+ # add some bloat to the vanilla po to get a recognizable size increase
2943+ f = open(os.path.join(self.pkgdir, 'po-vanilla', 'de.po'), 'a')
2944+ for i in range(10000):
2945+ f.write('\nmsgid "%i"\nmsgstr"%i"\n' % (i, i))
2946+ f.close()
2947+
2948+ self.build()
2949+
2950+ dpkg = subprocess.Popen(['dpkg', '-I', os.path.join(self.workdir, 'vanilla_12_all.deb')],
2951+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
2952+ try:
2953+ for l in dpkg.stdout:
2954+ l = l.decode().strip()
2955+ if l.startswith('Installed-Size:'):
2956+ self.assertTrue(re.match('^Installed-Size: \d+$', l))
2957+ self.assertTrue(int(l.split()[1]) < 200)
2958+ break
2959+ else:
2960+ self.fail('No Installed-Size: header')
2961+ finally:
2962+ dpkg.communicate()
2963+ self.assertEqual(dpkg.returncode, 0)
2964+
2965+ def test_empty_pot(self):
2966+ '''Handling of empty POT'''
2967+
2968+ self.buildinfo = '''Package: icecream
2969+Component: main
2970+Suite: lucid
2971+Purpose: PRIMARY
2972+'''
2973+
2974+ open(os.path.join(self.pkgdir, 'po-vanilla', 'empty.pot'), 'w').close()
2975+ self.build()
2976+ self.check_deb_mo(False)
2977+ self.check_deb_stripfiles(False)
2978+ self.check_maintainer(True)
2979+
2980+ def test_debian_changelog_truncation(self):
2981+ '''Long Debian changelog gets truncated'''
2982+
2983+ # change into non-native package
2984+ cpath = os.path.join(self.pkgdir, 'debian', 'changelog')
2985+ with open(cpath) as f:
2986+ contents = f.readlines()
2987+ contents[0] = contents[0].replace('(12)', '(12-1)')
2988+ f = open(cpath, 'w')
2989+ f.write(''.join(contents))
2990+ f.close()
2991+
2992+ self.build()
2993+ self.check_deb_stripfiles(False)
2994+
2995+ deb = glob(os.path.join(self.workdir, 'vanilla_12*_*.deb'))[0]
2996+ dpkg = subprocess.Popen('ar p %s data.tar.gz | tar xOz ./usr/share/doc/vanilla/changelog.Debian.gz | gzip -cd' % deb,
2997+ shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
2998+ (out, err) = dpkg.communicate()
2999+ out = out.decode()
3000+ self.assertEqual(err, b'')
3001+ self.assertTrue('icecream (12-1)' in out)
3002+ self.assertTrue('\n * release 12' in out)
3003+ self.assertTrue('icecream (3)' in out)
3004+ self.assertFalse('icecream (2)' in out)
3005+ self.assertFalse('icecream (1)' in out)
3006+ self.assertTrue('apt-get changelog' in out)
3007+
3008+ def test_native_changelog_truncation(self):
3009+ '''Long Debian changelog for native packages gets truncated'''
3010+
3011+ self.build()
3012+ self.check_deb_stripfiles(False)
3013+
3014+ deb = glob(os.path.join(self.workdir, 'vanilla_12*_*.deb'))[0]
3015+ dpkg = subprocess.Popen('ar p %s data.tar.gz | tar xOz ./usr/share/doc/vanilla/changelog.gz | gzip -cd' % deb,
3016+ shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
3017+ (out, err) = dpkg.communicate()
3018+ out = out.decode()
3019+ self.assertEqual(err, b'')
3020+ self.assertTrue('icecream (12)' in out)
3021+ self.assertTrue('\n * release 12' in out)
3022+ self.assertTrue('icecream (3)' in out)
3023+ self.assertFalse('icecream (2)' in out)
3024+ self.assertFalse('icecream (1)' in out)
3025+ self.assertTrue('apt-get changelog' in out)
3026+
3027+ def test_native_changelog_truncation_symlink(self):
3028+ '''Long Debian changelog for native packages with symlinked doc dir'''
3029+
3030+ # perl does a hackery like this
3031+ rpath = os.path.join(self.pkgdir, 'debian', 'rules')
3032+ with open(rpath, 'a') as f:
3033+ f.write('''
3034+override_dh_installdocs:
3035+ dh_installdocs
3036+ cp debian/changelog debian/vanilla/usr/share/doc/vanilla/changelog.Debian
3037+ mv debian/vanilla/usr/share/doc/vanilla debian/vanilla/usr/share/doc/vanilla-base
3038+ ln -s vanilla-base debian/vanilla/usr/share/doc/vanilla
3039+''')
3040+
3041+ self.build()
3042+
3043+ deb = glob(os.path.join(self.workdir, 'vanilla_12*_*.deb'))[0]
3044+ dpkg = subprocess.Popen('ar p %s data.tar.gz | tar xOz ./usr/share/doc/vanilla-base/changelog.gz | gzip -cd' % deb,
3045+ shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
3046+ (out, err) = dpkg.communicate()
3047+ out = out.decode()
3048+ self.assertEqual(err, b'')
3049+ self.assertTrue('icecream (12)' in out)
3050+ self.assertTrue('\n * release 12' in out)
3051+ # make no assumption whether this gets truncated or not
3052+
3053+ def test_short_debian_changelog(self):
3054+ '''Short Debian changelog remains unaltered'''
3055+
3056+ # change into non-native package
3057+ cpath = os.path.join(self.pkgdir, 'debian', 'changelog')
3058+ with open(cpath) as f:
3059+ contents = f.readlines()[:11]
3060+ contents[0] = contents[0].replace('(12)', '(12-1)')
3061+ with open(cpath, 'w') as f:
3062+ f.write(''.join(contents))
3063+
3064+ self.build()
3065+ self.check_deb_stripfiles(False)
3066+
3067+ deb = glob(os.path.join(self.workdir, 'vanilla_12*_*.deb'))[0]
3068+ dpkg = subprocess.Popen('ar p %s data.tar.gz | tar xOz ./usr/share/doc/vanilla/changelog.Debian.gz | gzip -cd' % deb,
3069+ shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
3070+ (out, err) = dpkg.communicate()
3071+ out = out.decode()
3072+ self.assertEqual(err, b'')
3073+ self.assertTrue('icecream (12-1)' in out)
3074+ self.assertTrue('icecream (11)' in out)
3075+ self.assertFalse('icecream (10)' in out)
3076+ self.assertFalse('apt-get changelog' in out)
3077+
3078+ def test_short_native_changelog(self):
3079+ '''Short Debian changelog for native packages remains unaltered'''
3080+
3081+ # truncate changelog
3082+ cpath = os.path.join(self.pkgdir, 'debian', 'changelog')
3083+ with open(cpath) as f:
3084+ contents = f.readlines()[:11]
3085+ with open(cpath, 'w') as f:
3086+ f.write(''.join(contents))
3087+
3088+ self.build()
3089+ self.check_deb_stripfiles(False)
3090+
3091+ deb = glob(os.path.join(self.workdir, 'vanilla_12*_*.deb'))[0]
3092+ dpkg = subprocess.Popen('ar p %s data.tar.gz | tar xOz ./usr/share/doc/vanilla/changelog.gz | gzip -cd' % deb,
3093+ shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
3094+ (out, err) = dpkg.communicate()
3095+ out = out.decode()
3096+ self.assertEqual(err, b'')
3097+ self.assertTrue('icecream (12)' in out)
3098+ self.assertTrue('icecream (11)' in out)
3099+ self.assertFalse('icecream (10)' in out)
3100+ self.assertFalse('apt-get changelog' in out)
3101+
3102+ def test_ppa_debian_changelog(self):
3103+ '''Debian changelog in PPA build remains unaltered'''
3104+
3105+ self.buildinfo = '''Package: icecream
3106+Component: main
3107+Suite: lucid
3108+Purpose: PPA
3109+'''
3110+
3111+ # change into non-native package
3112+ cpath = os.path.join(self.pkgdir, 'debian', 'changelog')
3113+ with open(cpath) as f:
3114+ contents = f.readlines()
3115+ contents[0] = contents[0].replace('(12)', '(12-1)')
3116+ with open(cpath, 'w') as f:
3117+ f.write(''.join(contents))
3118+
3119+ self.build()
3120+ self.check_deb_stripfiles(True)
3121+
3122+ deb = glob(os.path.join(self.workdir, 'vanilla_12*_*.deb'))[0]
3123+ dpkg = subprocess.Popen('ar p %s data.tar.gz | tar xOz ./usr/share/doc/vanilla/changelog.Debian.gz | gzip -cd' % deb,
3124+ shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
3125+ (out, err) = dpkg.communicate()
3126+ out = out.decode()
3127+ self.assertEqual(err, b'')
3128+ self.assertTrue('icecream (12-1)' in out)
3129+ self.assertTrue('icecream (11)' in out)
3130+ self.assertTrue('icecream (1)' in out)
3131+ self.assertFalse('apt-get changelog' in out)
3132+
3133+ def test_png_shrinking(self):
3134+ '''PNGs get optimized, and non-PNGs unmodified'''
3135+
3136+ self.build()
3137+
3138+ deb = glob(os.path.join(self.workdir, 'vanilla_12_*.deb'))[0]
3139+ self.assertEqual(subprocess.call(['dpkg', '-x', deb, self.workdir]), 0)
3140+
3141+ png_orig = os.path.join(self.pkgdir, 'foo%.png')
3142+ png_ship = os.path.join(self.workdir, 'usr', 'share', 'icecream', 'foo%.png')
3143+
3144+ # shipped PNG should be visually identical to original
3145+ subprocess.call(['convert', '-depth', '24', '-compress', 'none', png_orig,
3146+ 'ppm:%s/orig.ppm' % self.workdir])
3147+ subprocess.call(['convert', '-depth', '24', '-compress', 'none', png_ship,
3148+ 'ppm:%s/ship.ppm' % self.workdir])
3149+ # we need to filter out comments
3150+ orig = ''
3151+ with open(os.path.join(self.workdir, 'orig.ppm')) as f:
3152+ for l in f:
3153+ if not l.startswith('#'):
3154+ orig += l
3155+ ship = ''
3156+ with open(os.path.join(self.workdir, 'ship.ppm')) as f:
3157+ for l in f:
3158+ if not l.startswith('#'):
3159+ ship += l
3160+ self.assertEqual(orig, ship)
3161+
3162+ # shipped PNG should be smaller than original
3163+ self.assertTrue(os.path.getsize(png_ship) < os.path.getsize(png_orig))
3164+
3165+ # non-PNG should be unmodified
3166+ nopng_orig = open(os.path.join(self.pkgdir, 'notapng.png'), 'rb')
3167+ nopng_ship = open(os.path.join(self.workdir, 'usr', 'share',
3168+ 'icecream', 'notapng.png'), 'rb')
3169+ self.assertEqual(nopng_orig.read(), nopng_ship.read())
3170+ nopng_orig.close()
3171+ nopng_ship.close()
3172+
3173+ def test_png_games(self):
3174+ '''PNGs in Section: games are left unmodified'''
3175+
3176+ self.sed_control('s/^Section:.*$/Section: games/')
3177+ self.build()
3178+
3179+ deb = glob(os.path.join(self.workdir, 'vanilla_12_*.deb'))[0]
3180+ self.assertEqual(subprocess.call(['dpkg', '-x', deb, self.workdir]), 0)
3181+
3182+ orig = open(os.path.join(self.pkgdir, 'foo%.png'), 'rb')
3183+ ship = open(os.path.join(self.workdir, 'usr', 'share',
3184+ 'icecream', 'foo%.png'), 'rb')
3185+ self.assertTrue(orig.read() == ship.read(), 'PNG is left unmodified')
3186+ orig.close()
3187+ ship.close()
3188+
3189+ orig = open(os.path.join(self.pkgdir, 'notapng.png'), 'rb')
3190+ ship = open(os.path.join(self.workdir, 'usr', 'share',
3191+ 'icecream', 'notapng.png'), 'rb')
3192+ self.assertTrue(orig.read() == ship.read(), 'non-PNG is left unmodified')
3193+ orig.close()
3194+ ship.close()
3195+
3196+ def test_png_disable_optimization(self):
3197+ '''$NO_PNG_PKG_MANGLE disables PNG optimization'''
3198+
3199+ self.build(True, {'NO_PNG_PKG_MANGLE': '1'})
3200+
3201+ deb = glob(os.path.join(self.workdir, 'vanilla_12_*.deb'))[0]
3202+ self.assertEqual(subprocess.call(['dpkg', '-x', deb, self.workdir]), 0)
3203+
3204+ orig = open(os.path.join(self.pkgdir, 'foo%.png'), 'rb')
3205+ ship = open(os.path.join(self.workdir, 'usr', 'share',
3206+ 'icecream', 'foo%.png'), 'rb')
3207+ self.assertTrue(orig.read() == ship.read(), 'PNG is left unmodified')
3208+ orig.close()
3209+ ship.close()
3210+
3211+ orig = open(os.path.join(self.pkgdir, 'notapng.png'), 'rb')
3212+ ship = open(os.path.join(self.workdir, 'usr', 'share',
3213+ 'icecream', 'notapng.png'), 'rb')
3214+ self.assertTrue(orig.read() == ship.read(), 'non-PNG is left unmodified')
3215+ orig.close()
3216+ ship.close()
3217+
3218+ def test_dpkg_deb_argv_handling(self):
3219+ '''dpkg-deb doesn't split up arguments with whitespace in them'''
3220+
3221+ # Wrap all the scripts that dpkg-deb wants to call with arguments
3222+ for wrapped_cmd in ['pkgsanitychecks',
3223+ 'pkgmaintainermangler',
3224+ 'pkgstripfiles',
3225+ 'pkgstriptranslations',
3226+ 'dpkg-deb.pkgbinarymangler']:
3227+ os.symlink(os.path.join(self.srcdir, 'test', 'pickle_argv'),
3228+ os.path.join(self.workdir, wrapped_cmd))
3229+
3230+ # Run dpkg-deb
3231+ env = os.environ.copy()
3232+ env['PATH'] = '%s:%s' % (self.workdir, env['PATH'])
3233+ dpkg_deb = os.path.join(self.srcdir, 'dpkg-deb')
3234+ argv_test = subprocess.Popen(['pickle_argv', '-b', 'foo bar'],
3235+ executable=dpkg_deb, env=env,
3236+ stdout=subprocess.PIPE)
3237+
3238+ # Make the check
3239+ while True:
3240+ try:
3241+ argv = pickle.load(argv_test.stdout)
3242+ except EOFError:
3243+ break
3244+ self.assertEqual(argv[-1], 'foo bar',
3245+ 'argument with space in it did not make it through dpkg-deb alive (%r)' % (argv,))
3246+ argv_test.communicate()
3247+
3248+
3249+ def test_doc_symlink_nodep(self):
3250+ '''doc symlinking: no dependency (no linking)'''
3251+
3252+ with open(os.path.join(self.pkgdir, 'debian', 'vanilla.docs'), 'w') as f:
3253+ f.write('test.c\n')
3254+ with open(os.path.join(self.pkgdir, 'debian', 'chocolate.docs'), 'w') as f:
3255+ f.write('test.c\n')
3256+ orig_size = os.path.getsize(os.path.join(self.pkgdir, 'test.c'))
3257+ self.sed_control('/^Architecture:/ s/all/any/g')
3258+
3259+ self.build()
3260+ c = self.deb_contents()
3261+
3262+ self.assertEqual(c['vanilla']['./usr/share/doc/vanilla/test.c']['size'], orig_size)
3263+ self.assertEqual(c['vanilla']['./usr/share/doc/vanilla/test.c']['linkto'], None)
3264+ self.assertEqual(c['vanilla']['./usr/share/doc/vanilla/changelog.gz']['linkto'], None)
3265+ self.assertEqual(c['chocolate']['./usr/share/doc/chocolate/test.c']['size'], orig_size)
3266+ self.assertEqual(c['chocolate']['./usr/share/doc/chocolate/test.c']['linkto'], None)
3267+ self.assertEqual(c['chocolate']['./usr/share/doc/chocolate/changelog.gz']['linkto'], None)
3268+
3269+ def test_doc_symlink_archmismatch(self):
3270+ '''doc symlinking: different architecture (no linking)'''
3271+
3272+ with open(os.path.join(self.pkgdir, 'debian', 'vanilla.docs'), 'w') as f:
3273+ f.write('test.c\n')
3274+ with open(os.path.join(self.pkgdir, 'debian', 'chocolate.docs'), 'w') as f:
3275+ f.write('test.c\n')
3276+ self.sed_control('s/^Description: chocolate/Depends: vanilla\\n&/')
3277+ orig_size = os.path.getsize(os.path.join(self.pkgdir, 'test.c'))
3278+
3279+ self.build()
3280+ c = self.deb_contents()
3281+
3282+ self.assertEqual(c['vanilla']['./usr/share/doc/vanilla/test.c']['size'], orig_size)
3283+ self.assertEqual(c['vanilla']['./usr/share/doc/vanilla/test.c']['linkto'], None)
3284+ self.assertEqual(c['vanilla']['./usr/share/doc/vanilla/changelog.gz']['linkto'], None)
3285+ self.assertEqual(c['chocolate']['./usr/share/doc/chocolate/test.c']['size'], orig_size)
3286+ self.assertEqual(c['chocolate']['./usr/share/doc/chocolate/test.c']['linkto'], None)
3287+ self.assertEqual(c['chocolate']['./usr/share/doc/chocolate/changelog.gz']['linkto'], None)
3288+
3289+ def test_doc_symlink(self):
3290+ '''doc symlinking: Architecture: any, linking of identical files to dependency'''
3291+
3292+ # install Makefile into all doc dirs, and add some extra binaries, to
3293+ # also test transitive dependencies
3294+ with open(os.path.join(self.pkgdir, 'debian', 'rules'), 'a') as f:
3295+ f.write('\tdh_installdocs --all Makefile\n')
3296+
3297+ with open(os.path.join(self.pkgdir, 'debian', 'control'), 'w') as f:
3298+ f.write('''Source: icecream
3299+Section: utils
3300+Priority: extra
3301+Maintainer: Joe User <joe@example.com>
3302+Build-Depends: debhelper (>= 7.0.50~)
3303+Standards-Version: 3.9.2
3304+
3305+Package: vanilla
3306+Architecture: all
3307+Description: vanilla
3308+ vanilla
3309+
3310+Package: libbase1
3311+Architecture: any
3312+Description: test
3313+
3314+Package: libfoo1
3315+Architecture: any
3316+Depends: libbase1
3317+Description: test
3318+
3319+Package: libbar2
3320+Architecture: any
3321+Depends: libbase1
3322+Description: test
3323+
3324+Package: chocolate
3325+Architecture: any
3326+Depends: libc6 (>= 2.6), libfoo1, libbar2
3327+Description: chocolate
3328+ chocolate
3329+''')
3330+ with open(os.path.join(self.pkgdir, 'debian', 'test.c'), 'w') as f:
3331+ f.write('moo')
3332+ with open(os.path.join(self.pkgdir, 'debian', 'vanilla.docs'), 'w') as f:
3333+ f.write('test.c\nnotapng.png')
3334+ with open(os.path.join(self.pkgdir, 'debian', 'chocolate.docs'), 'w') as f:
3335+ f.write('debian/test.c')
3336+ with open(os.path.join(self.pkgdir, 'debian', 'chocolate.links'), 'w') as f:
3337+ f.write('''usr/share/doc/chocolate/test.c /usr/share/doc/chocolate/test2.c
3338+ /usr/share/doc/vanilla/changelog.gz /usr/share/doc/chocolate/notapng.png
3339+ /bin/nonexisting /usr/share/doc/chocolate/nirvana1
3340+ /usr/share/doc/chocolate/nonexisting /usr/share/doc/chocolate/nirvana2
3341+ ''')
3342+ test_c_size = os.path.getsize(os.path.join(self.pkgdir, 'test.c'))
3343+ makefile_size = os.path.getsize(os.path.join(self.pkgdir, 'Makefile'))
3344+
3345+ self.build()
3346+ c = self.deb_contents()
3347+
3348+ self.assertEqual(c['libbase1']['./usr/share/doc/libbase1/Makefile']['size'], makefile_size)
3349+ self.assertEqual(c['libbase1']['./usr/share/doc/libbase1/Makefile']['linkto'], None)
3350+ self.assertEqual(c['libbase1']['./usr/share/doc/libbase1/changelog.gz']['linkto'], None)
3351+ self.assertEqual(c['libfoo1']['./usr/share/doc/libfoo1/changelog.gz']['linkto'], '../libbase1/changelog.gz')
3352+ self.assertEqual(c['libfoo1']['./usr/share/doc/libfoo1/Makefile']['linkto'], '../libbase1/Makefile')
3353+ self.assertEqual(c['libbar2']['./usr/share/doc/libbar2/changelog.gz']['linkto'], '../libbase1/changelog.gz')
3354+ self.assertEqual(c['libbar2']['./usr/share/doc/libbar2/Makefile']['linkto'], '../libbase1/Makefile')
3355+
3356+ self.assertEqual(c['vanilla']['./usr/share/doc/vanilla/test.c']['size'], test_c_size)
3357+ self.assertEqual(c['vanilla']['./usr/share/doc/vanilla/test.c']['linkto'], None)
3358+ self.assertEqual(c['vanilla']['./usr/share/doc/vanilla/Makefile']['size'], makefile_size)
3359+ self.assertEqual(c['vanilla']['./usr/share/doc/vanilla/Makefile']['linkto'], None)
3360+ self.assertEqual(c['vanilla']['./usr/share/doc/vanilla/changelog.gz']['linkto'], None)
3361+ self.assertEqual(c['vanilla']['./usr/share/doc/vanilla/notapng.png']['linkto'], None)
3362+
3363+ self.assertEqual(c['chocolate']['./usr/share/doc/chocolate/test.c']['size'], 3)
3364+ self.assertEqual(c['chocolate']['./usr/share/doc/chocolate/test.c']['linkto'], None)
3365+ # link to transitive dependency
3366+ self.assertEqual(c['chocolate']['./usr/share/doc/chocolate/Makefile']['linkto'], '../libbase1/Makefile')
3367+ self.assertEqual(c['chocolate']['./usr/share/doc/chocolate/changelog.gz']['linkto'], '../libbase1/changelog.gz')
3368+ self.assertEqual(c['chocolate']['./usr/share/doc/chocolate/test2.c']['linkto'], 'test.c')
3369+ # this one was manually created by chocolate.links above
3370+ self.assertEqual(c['chocolate']['./usr/share/doc/chocolate/notapng.png']['linkto'], '../vanilla/changelog.gz')
3371+ self.assertEqual(c['chocolate']['./usr/share/doc/chocolate/nirvana1']['linkto'], '/bin/nonexisting')
3372+ self.assertEqual(c['chocolate']['./usr/share/doc/chocolate/nirvana2']['linkto'], 'nonexisting')
3373+
3374+ def test_doc_symlink_parallel_fixed(self):
3375+ '''doc symlinking: parallel=4 build'''
3376+
3377+ try:
3378+ os.environ['DEB_BUILD_OPTIONS'] = 'parallel=4'
3379+ # as this is a race condition, run it a couple of times
3380+ for i in range(3):
3381+ self.test_doc_symlink()
3382+
3383+ # also test "unlimited" case
3384+ os.environ['DEB_BUILD_OPTIONS'] = 'parallel,nostrip'
3385+ # as this is a race condition, run it a couple of times
3386+ self.test_doc_symlink()
3387+ finally:
3388+ os.environ['DEB_BUILD_OPTIONS'] = ''
3389+
3390+ def test_doc_symlink_parallel_unlimited(self):
3391+ '''doc symlinking: unlimited parallel build'''
3392+
3393+ try:
3394+ os.environ['DEB_BUILD_OPTIONS'] = 'parallel,nostrip'
3395+ # as this is a race condition, run it a couple of times
3396+ for i in range(3):
3397+ self.test_doc_symlink()
3398+ finally:
3399+ os.environ['DEB_BUILD_OPTIONS'] = ''
3400+
3401+ def test_doc_symlink_archall(self):
3402+ '''doc symlinking: Architecture: all, linking of identical files to dependency'''
3403+
3404+ with open(os.path.join(self.pkgdir, 'debian', 'vanilla.docs'), 'w') as f:
3405+ f.write('test.c')
3406+ with open(os.path.join(self.pkgdir, 'debian', 'chocolate.docs'), 'w') as f:
3407+ f.write('test.c')
3408+ self.sed_control('/^Architecture:/ s/any/all/g; s/^Description: chocolate/Depends: libc6 (>= 2.6), vanilla\\n&/')
3409+ orig_size = os.path.getsize(os.path.join(self.pkgdir, 'test.c'))
3410+
3411+ self.build()
3412+ c = self.deb_contents()
3413+
3414+ self.assertEqual(c['vanilla']['./usr/share/doc/vanilla/test.c']['size'], orig_size)
3415+ self.assertEqual(c['vanilla']['./usr/share/doc/vanilla/test.c']['linkto'], None)
3416+ self.assertEqual(c['vanilla']['./usr/share/doc/vanilla/changelog.gz']['linkto'], None)
3417+ self.assertEqual(c['chocolate']['./usr/share/doc/chocolate/test.c']['linkto'], '../vanilla/test.c')
3418+ self.assertEqual(c['chocolate']['./usr/share/doc/chocolate/changelog.gz']['linkto'], '../vanilla/changelog.gz')
3419+
3420+ def test_doc_symlink_dependency_cycle(self):
3421+ '''doc symlinking: cyclic dependency'''
3422+
3423+ with open(os.path.join(self.pkgdir, 'debian', 'vanilla.docs'), 'w') as f:
3424+ f.write('test.c')
3425+ with open(os.path.join(self.pkgdir, 'debian', 'chocolate.docs'), 'w') as f:
3426+ f.write('test.c')
3427+ self.sed_control('/^Architecture:/ s/any/all/g')
3428+ self.sed_control('s/^Description: vanilla/Depends: chocolate\\n&/')
3429+ self.sed_control('s/^Description: chocolate/Depends: vanilla\\n&/')
3430+ orig_size = os.path.getsize(os.path.join(self.pkgdir, 'test.c'))
3431+
3432+ self.build()
3433+ c = self.deb_contents()
3434+
3435+ vanilla_link = c['vanilla']['./usr/share/doc/vanilla/test.c']['linkto']
3436+ chocolate_link = c['chocolate']['./usr/share/doc/chocolate/test.c']['linkto']
3437+
3438+ # exactly one of them has to be a symlink
3439+ self.assertTrue(vanilla_link is None or chocolate_link is None)
3440+ self.assertTrue(vanilla_link is not None or chocolate_link is not None)
3441+
3442+ if vanilla_link is None:
3443+ file_pkg = "vanilla"
3444+ link_pkg = "chocolate"
3445+ else:
3446+ file_pkg = "chocolate"
3447+ link_pkg = "vanilla"
3448+
3449+ self.assertEqual(c[file_pkg]['./usr/share/doc/%s/test.c' % (file_pkg,)]['linkto'], None)
3450+ self.assertEqual(c[file_pkg]['./usr/share/doc/%s/test.c' % (file_pkg,)]['size'], orig_size)
3451+ self.assertEqual(c[file_pkg]['./usr/share/doc/%s/changelog.gz' % (file_pkg,)]['linkto'], None)
3452+ self.assertEqual(c[link_pkg]['./usr/share/doc/%s/test.c' % (link_pkg,)]['linkto'], '../%s/test.c' % (file_pkg,))
3453+ self.assertEqual(c[link_pkg]['./usr/share/doc/%s/changelog.gz' % (link_pkg,)]['linkto'], '../%s/changelog.gz' % (file_pkg,))
3454+
3455+ def test_doc_symlink_disable(self):
3456+ '''doc symlinking: Disabling with $NO_DOC_PKG_MANGLE'''
3457+
3458+ with open(os.path.join(self.pkgdir, 'debian', 'vanilla.docs'), 'w') as f:
3459+ f.write('test.c')
3460+ with open(os.path.join(self.pkgdir, 'debian', 'chocolate.docs'), 'w') as f:
3461+ f.write('test.c')
3462+ self.sed_control('/^Architecture:/ s/any/all/g; s/^Description: chocolate/Depends: libc6 (>= 2.6), vanilla\\n&/')
3463+ orig_size = os.path.getsize(os.path.join(self.pkgdir, 'test.c'))
3464+
3465+ self.build(extra_env={'NO_DOC_PKG_MANGLE': '1'})
3466+ c = self.deb_contents()
3467+
3468+ self.assertEqual(c['chocolate']['./usr/share/doc/chocolate/test.c']['size'], orig_size)
3469+ self.assertEqual(c['chocolate']['./usr/share/doc/chocolate/test.c']['linkto'], None)
3470+
3471+ def test_gnome_help(self):
3472+ '''GNOME help symlinking and static translation tarball'''
3473+
3474+ os.makedirs(os.path.join(self.pkgdir, 'help', 'C', 'figures'))
3475+ os.makedirs(os.path.join(self.pkgdir, 'help', 'de', 'figures'))
3476+ os.makedirs(os.path.join(self.pkgdir, 'help', 'es', 'figures'))
3477+ with open(os.path.join(self.pkgdir, 'help', 'C', 'figures', 'main.png'), 'w') as f:
3478+ f.write('moo')
3479+ with open(os.path.join(self.pkgdir, 'help', 'C', 'index.html'), 'w') as f:
3480+ f.write('htmlC')
3481+ # "translated"
3482+ with open(os.path.join(self.pkgdir, 'help', 'de', 'figures', 'main.png'), 'w') as f:
3483+ f.write('muh!')
3484+ with open(os.path.join(self.pkgdir, 'help', 'de', 'index.html'), 'w') as f:
3485+ f.write('htmlde')
3486+ # "untranslated"
3487+ with open(os.path.join(self.pkgdir, 'help', 'es', 'figures', 'main.png'), 'w') as f:
3488+ f.write('moo')
3489+ with open(os.path.join(self.pkgdir, 'help', 'es', 'index.html'), 'w') as f:
3490+ f.write('htmlC')
3491+ # manual symlink
3492+ os.symlink('../C/index.html', os.path.join(self.pkgdir, 'help', 'de', 'link.html'))
3493+
3494+ with open(os.path.join(self.pkgdir, 'debian', 'vanilla.install'), 'a') as f:
3495+ f.write('help/* usr/share/gnome/help/vanilla/\n')
3496+
3497+ self.build()
3498+ self.check_deb_mo(False)
3499+
3500+ c = self.deb_contents()
3501+
3502+ # C always keeps the originals
3503+ self.assertEqual(c['vanilla']['./usr/share/gnome/help/vanilla/C/index.html']['size'], 5)
3504+ self.assertEqual(c['vanilla']['./usr/share/gnome/help/vanilla/C/index.html']['linkto'], None)
3505+ self.assertEqual(c['vanilla']['./usr/share/gnome/help/vanilla/C/figures/main.png']['size'], 3)
3506+ self.assertEqual(c['vanilla']['./usr/share/gnome/help/vanilla/C/figures/main.png']['linkto'], None)
3507+
3508+ # manual symlink untouched
3509+ self.assertEqual(c['vanilla']['./usr/share/gnome/help/vanilla/de/link.html']['linkto'],
3510+ '../C/index.html')
3511+
3512+ # translated de will be replaced with symlink to langpack
3513+ self.assertEqual(c['vanilla']['./usr/share/gnome/help/vanilla/de/index.html']['linkto'],
3514+ '../../../help-langpack/vanilla/de/index.html')
3515+ self.assertEqual(c['vanilla']['./usr/share/gnome/help/vanilla/de/figures/main.png']['linkto'],
3516+ '../../../../help-langpack/vanilla/de/figures/main.png')
3517+
3518+ # untranslated es will be replace with a symlink to C file
3519+ self.assertEqual(c['vanilla']['./usr/share/gnome/help/vanilla/es/index.html']['linkto'],
3520+ '../C/index.html')
3521+ self.assertEqual(c['vanilla']['./usr/share/gnome/help/vanilla/es/figures/main.png']['linkto'],
3522+ '../../C/figures/main.png')
3523+
3524+ # translation tarball should not have the C files nor the identical
3525+ # copies, just the actually translated ones
3526+ tar = tarfile.open(self.static_translations_tar)
3527+ names = tar.getnames()
3528+ tar.close()
3529+ self.assertTrue('./vanilla/usr/share/gnome/help/vanilla/de/figures/main.png' in names)
3530+ self.assertTrue('./vanilla/usr/share/gnome/help/vanilla/de/index.html' in names)
3531+ self.assertFalse('./vanilla/usr/share/gnome/help/vanilla/es/figures/main.png' in names)
3532+ self.assertFalse('./vanilla/usr/share/gnome/help/vanilla/es/index.html' in names)
3533+ self.assertFalse('./vanilla/usr/share/gnome/help/vanilla/C/figures/main.png' in names)
3534+ self.assertFalse('./vanilla/usr/share/gnome/help/vanilla/C/index.html' in names)
3535+
3536+ def test_mallard_help(self):
3537+ '''Mallard help symlinking and static translation tarball'''
3538+
3539+ os.makedirs(os.path.join(self.pkgdir, 'help', 'C', 'vanilla', 'figures'))
3540+ os.makedirs(os.path.join(self.pkgdir, 'help', 'de', 'vanilla', 'figures'))
3541+ os.makedirs(os.path.join(self.pkgdir, 'help', 'es', 'vanilla', 'figures'))
3542+ with open(os.path.join(self.pkgdir, 'help', 'C', 'vanilla', 'figures', 'main.png'), 'w') as f:
3543+ f.write('moo')
3544+ with open(os.path.join(self.pkgdir, 'help', 'C', 'vanilla', 'index.page'), 'w') as f:
3545+ f.write('htmlC')
3546+ # "translated"
3547+ with open(os.path.join(self.pkgdir, 'help', 'de', 'vanilla', 'figures', 'main.png'), 'w') as f:
3548+ f.write('muh!')
3549+ with open(os.path.join(self.pkgdir, 'help', 'de', 'vanilla', 'index.page'), 'w') as f:
3550+ f.write('htmlde')
3551+ # "untranslated"
3552+ with open(os.path.join(self.pkgdir, 'help', 'es', 'vanilla', 'figures', 'main.png'), 'w') as f:
3553+ f.write('moo')
3554+ with open(os.path.join(self.pkgdir, 'help', 'es', 'vanilla', 'index.page'), 'w') as f:
3555+ f.write('htmlC')
3556+ # manual symlink
3557+ os.symlink('../../C/vanilla/index.page', os.path.join(self.pkgdir,
3558+ 'help', 'de', 'vanilla', 'link.page'))
3559+
3560+ with open(os.path.join(self.pkgdir, 'debian', 'vanilla.install'), 'a') as f:
3561+ f.write('help usr/share/\n')
3562+
3563+ self.build()
3564+ self.check_deb_mo(False)
3565+
3566+ c = self.deb_contents()
3567+
3568+ # C always keeps the originals
3569+ self.assertEqual(c['vanilla']['./usr/share/help/C/vanilla/index.page']['size'], 5)
3570+ self.assertEqual(c['vanilla']['./usr/share/help/C/vanilla/index.page']['linkto'], None)
3571+ self.assertEqual(c['vanilla']['./usr/share/help/C/vanilla/figures/main.png']['size'], 3)
3572+ self.assertEqual(c['vanilla']['./usr/share/help/C/vanilla/figures/main.png']['linkto'], None)
3573+
3574+ # manual symlink untouched
3575+ self.assertEqual(c['vanilla']['./usr/share/help/de/vanilla/link.page']['linkto'],
3576+ '../../C/vanilla/index.page')
3577+
3578+ # translated de will be replaced with symlink to langpack
3579+ self.assertEqual(c['vanilla']['./usr/share/help/de/vanilla/index.page']['linkto'],
3580+ '../../../help-langpack/de/vanilla/index.page')
3581+ self.assertEqual(c['vanilla']['./usr/share/help/de/vanilla/figures/main.png']['linkto'],
3582+ '../../../../help-langpack/de/vanilla/figures/main.png')
3583+
3584+ # untranslated es will be replace with a symlink to C file
3585+ self.assertEqual(c['vanilla']['./usr/share/help/es/vanilla/index.page']['linkto'],
3586+ '../../C/vanilla/index.page')
3587+ self.assertEqual(c['vanilla']['./usr/share/help/es/vanilla/figures/main.png']['linkto'],
3588+ '../../../C/vanilla/figures/main.png')
3589+
3590+ # translation tarball should not have the C files nor the identical
3591+ # copies, just the actually translated ones
3592+ tar = tarfile.open(self.static_translations_tar)
3593+ names = tar.getnames()
3594+ tar.close()
3595+ self.assertTrue('./vanilla/usr/share/help/de/vanilla/figures/main.png' in names)
3596+ self.assertTrue('./vanilla/usr/share/help/de/vanilla/index.page' in names)
3597+ self.assertFalse('./vanilla/usr/share/help/es/vanilla/figures/main.png' in names)
3598+ self.assertFalse('./vanilla/usr/share/help/es/vanilla/index.page' in names)
3599+ self.assertFalse('./vanilla/usr/share/help/C/vanilla/figures/main.png' in names)
3600+ self.assertFalse('./vanilla/usr/share/help/C/vanilla/index.page' in names)
3601+
3602+ def test_dh_translations(self):
3603+ '''dh_translations'''
3604+
3605+ # this should always strip
3606+ pot = os.path.join(self.pkgdir, 'po', 'icecream.pot')
3607+ self.assertFalse(os.path.exists(pot))
3608+ self.build()
3609+ self.assertTrue(os.path.exists(pot))
3610+ with open(pot) as f:
3611+ lines = f.readlines()
3612+ self.assertTrue('msgid "icecream"\n' in lines)
3613+
3614+ # check *.desktop stripping
3615+ expected_desktop = {'simple': '''[Desktop Entry]
3616+Name=icecream
3617+Comment=Yummy!
3618+Exec=/usr/bin/vanilla
3619+X-Ubuntu-Gettext-Domain=icecream
3620+''',
3621+
3622+ 'translated': '''[Desktop Entry]
3623+Name=icecream
3624+GenericName=desert
3625+X-GNOME-FullName=Vanilla or Chocolate
3626+Comment=Yummy!
3627+Keywords=Dessert;Sweets;
3628+Exec=/usr/bin/vanilla
3629+X-Ubuntu-Gettext-Domain=icecream
3630+''',
3631+
3632+ 'leadingspace': '''
3633+[Desktop Entry]
3634+Name=icecream
3635+Comment=Yummy!
3636+Exec=/usr/bin/vanilla
3637+X-Ubuntu-Gettext-Domain=icecream
3638+''',
3639+
3640+ 'multisection': '''[Desktop Entry]
3641+Name=icecream
3642+GenericName=desert
3643+X-GNOME-FullName=Vanilla or Chocolate
3644+Comment=Yummy!
3645+Exec=/usr/bin/vanilla
3646+X-Ubuntu-Gettext-Domain=icecream
3647+
3648+X-Ayatana-Desktop-Shortcuts=Request
3649+
3650+[Request Shortcut Group]
3651+Name=Request some icecream
3652+Exec=vanilla request:
3653+OnlyShowIn=Messaging Menu
3654+''',
3655+ 'withdomain': '''[Desktop Entry]
3656+Name=icecream
3657+Comment=Yummy!
3658+X-GNOME-Gettext-Domain=icecream
3659+Exec=/usr/bin/vanilla
3660+''',
3661+ 'withdomain2': '''[Desktop Entry]
3662+Name=icecream
3663+Comment=Yummy!
3664+Exec=/usr/bin/vanilla
3665+X-Ubuntu-Gettext-Domain=icecream
3666+''',
3667+ }
3668+
3669+ for name, expected in expected_desktop.items():
3670+ with open(os.path.join(self.pkgdir,
3671+ 'debian/vanilla/usr/share/applications/%s.desktop' % name)) as f:
3672+ actual = f.read()
3673+ self.assertEqual(actual, expected, '%s.desktop mismatch:\n"%s"' % (name, actual))
3674+
3675+ # check *.server domain addition
3676+ with open(os.path.join(self.pkgdir, 'debian/vanilla/usr/lib/bonobo/servers/bonobo.server')) as f:
3677+ self.assertEqual(f.read(), '''<oaf_info>
3678+
3679+<oaf_server ubuntu-gettext-domain="icecream" iid="OAFIID:IcecreamExample" type="exe"
3680+ location="/usr/lib/bonobo-2.0/samples/bonobo-icecream">
3681+ <oaf_attribute name="name" type="string" value="Vanilla example"/>
3682+ <oaf_attribute name="name-de" type="string" value="Vanille-Beispiel"/>
3683+</oaf_server>
3684+
3685+<oaf_server ubuntu-gettext-domain="icecream" iid="OAFIID:AnotherExample" type="factory"
3686+ location="OAFIID:Vanilla_Factory">
3687+ <oaf_attribute name="name" type="string" value="Icecream component"/>
3688+ <oaf_attribute name="name-de" type="string" value="Eiscreme-Komponente"/>
3689+</oaf_server>
3690+
3691+</oaf_info>
3692+''')
3693+
3694+ # check *.policy domain addition and stripping
3695+ with open(os.path.join(self.pkgdir, 'debian/vanilla/usr/share/polkit-1/actions/icecream.policy')) as f:
3696+ self.assertEqual(f.read(), '''<?xml version="1.0" encoding="UTF-8"?>
3697+<policyconfig>
3698+
3699+ <vendor>World Ice, Inc.</vendor>
3700+
3701+ <action id="icecream.info">
3702+ <description gettext-domain="icecream">Get information about ice cream</description>
3703+ <message gettext-domain="icecream">System policy prevents querying icecream info</message>
3704+ <defaults>
3705+ <allow_any>yes</allow_any>
3706+ </defaults>
3707+ </action>
3708+</policyconfig>
3709+''')
3710+
3711+ # check *.schemas domain addition and stripping
3712+ with open(os.path.join(self.pkgdir, 'debian/vanilla/usr/share/gconf/schemas/icecream.schemas')) as f:
3713+ actual = f.read()
3714+ expected = '''<?xml version="1.0"?>
3715+<gconfschemafile>
3716+<schemalist>
3717+ <schema>
3718+ <key>/apps/icecream/simple</key>
3719+ <owner>icecream</owner>
3720+ <type>bool</type>
3721+ <default>FALSE</default>
3722+ <gettext_domain>icecream</gettext_domain>
3723+ <locale name="C">
3724+ <short>Simple bool option</short>
3725+ <long>Bool doc</long>
3726+ </locale>
3727+ </schema>
3728+
3729+ <schema>
3730+ <key>/apps/icecream/localedefault</key>
3731+ <owner>icecream</owner>
3732+ <type>string</type>
3733+ <default>xxx</default>
3734+ <gettext_domain>icecream</gettext_domain>
3735+ <locale name="C">
3736+ <default>CCC</default>
3737+ <short>Locale dependent default option</short>
3738+ <long>Locale doc</long>
3739+ </locale>
3740+ <locale name="de">
3741+ <default>dede</default>
3742+ </locale>
3743+ </schema>
3744+
3745+ </schemalist>
3746+</gconfschemafile>
3747+'''
3748+ self.assertEqual(actual, expected)
3749+
3750+ def test_dh_translations_no_domain(self):
3751+ '''dh_translations on package without po/Makefile'''
3752+
3753+ os.remove(os.path.join(self.pkgdir, 'po', 'Makefile'))
3754+ self.build()
3755+
3756+ # should not touch files
3757+ file_pairs = [
3758+ (os.path.join(self.pkgdir, 'data/translated.desktop'),
3759+ os.path.join(self.pkgdir, 'debian/vanilla/usr/share/applications/translated.desktop')),
3760+ (os.path.join(self.pkgdir, 'data/icecream.schemas'),
3761+ os.path.join(self.pkgdir, 'debian/vanilla/usr/share/gconf/schemas/icecream.schemas')),
3762+ ]
3763+ for (orig, ship) in file_pairs:
3764+ with open(orig, encoding='UTF-8') as forig:
3765+ with open(ship, encoding='UTF-8') as fship:
3766+ self.assertEqual(forig.read(), fship.read())
3767+
3768+ def test_dh_translations_python(self):
3769+ '''dh_translations: Get domain from Python setup.cfg'''
3770+
3771+ os.remove(os.path.join(self.pkgdir, 'po', 'Makefile'))
3772+ with open(os.path.join(self.pkgdir, 'setup.cfg'), 'w') as f:
3773+ f.write('[build_i18n]\ndomain=icecream\n')
3774+
3775+ self.build()
3776+
3777+ with open(os.path.join(self.pkgdir,
3778+ 'debian/vanilla/usr/share/applications/translated.desktop')) as f:
3779+ self.assertTrue('X-Ubuntu-Gettext-Domain=icecream' in f.read())
3780+
3781+ def test_dh_translations_cmake(self):
3782+ '''dh_translations: Get domain from cmake CMakeLists. CMakeLists.txt'''
3783+
3784+ os.remove(os.path.join(self.pkgdir, 'po', 'Makefile'))
3785+ with open(os.path.join(self.pkgdir, 'CMakeLists.txt'), 'w') as f:
3786+ f.write('set (GETTEXT_PACKAGE "icecream")\n')
3787+ with open(os.path.join(self.pkgdir, 'po', 'POTFILES.in'), 'w') as f:
3788+ f.write('test.c\n')
3789+
3790+ pot = os.path.join(self.pkgdir, 'po', 'icecream.pot')
3791+ self.assertFalse(os.path.exists(pot))
3792+ self.build()
3793+
3794+ self.assertTrue(os.path.exists(pot))
3795+ with open(pot) as f:
3796+ lines = f.readlines()
3797+ self.assertTrue('msgid "icecream"\n' in lines)
3798+
3799+#
3800+# main
3801+#
3802+
3803+unittest.main()

Subscribers

People subscribed via source and target branches

to all changes: