← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad-buildd/ttb-substitute-package-from-ac-init into lp:launchpad-buildd

 

Colin Watson has proposed merging lp:~cjwatson/launchpad-buildd/ttb-substitute-package-from-ac-init into lp:launchpad-buildd.

Commit message:
Fall back to the package name from AC_INIT when expanding $(PACKAGE) in
translation configuration files if no other definition can be found.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad-buildd/ttb-substitute-package-from-ac-init/+merge/333568

This can happen reasonably easily in projects that don't have autotools output committed to the repository: my test case was lp:telegnome, where we have configure.ac and po/Makevars but no po/Makefile.in.in, so we need some way to expand the "DOMAIN = $(PACKAGE)" line in po/Makevars.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad-buildd/ttb-substitute-package-from-ac-init into lp:launchpad-buildd.
=== modified file 'debian/changelog'
--- debian/changelog	2017-11-09 14:55:22 +0000
+++ debian/changelog	2017-11-10 20:49:38 +0000
@@ -5,6 +5,8 @@
   * Replace shell_escape function with shlex.quote (Python 3) or pipes.quote
     (Python 2).
   * Fix handling of null/empty-domain case in generate_pots.
+  * Fall back to the package name from AC_INIT when expanding $(PACKAGE) in
+    translation configuration files if no other definition can be found.
 
  -- Colin Watson <cjwatson@xxxxxxxxxx>  Thu, 09 Nov 2017 12:08:42 +0000
 

=== modified file 'lpbuildd/pottery/intltool.py'
--- lpbuildd/pottery/intltool.py	2017-11-10 20:07:26 +0000
+++ lpbuildd/pottery/intltool.py	2017-11-10 20:49:38 +0000
@@ -114,6 +114,8 @@
         config_files = config_files[:-1]
     for config_file in reversed(config_files):
         subst_value = config_file.getVariable(substitution.name)
+        if subst_value is None and substitution.name == "PACKAGE":
+            subst_value = _get_AC_PACKAGE_NAME(config_file)
         if subst_value is not None:
             # Substitution found.
             break

=== modified file 'lpbuildd/pottery/tests/test_intltool.py'
--- lpbuildd/pottery/tests/test_intltool.py	2017-11-09 14:55:22 +0000
+++ lpbuildd/pottery/tests/test_intltool.py	2017-11-10 20:49:38 +0000
@@ -199,17 +199,16 @@
             "packagename-ac",
             get_translation_domain(backend, os.path.join(package_dir, "po")))
 
-    def prepare_ac_init(self, parameters):
+    def prepare_ac_init(self, parameters, extra_files=None):
         # Prepare test for various permutations of AC_INIT parameters
         configure_ac_content = dedent("""
             AC_INIT(%s)
             GETTEXT_PACKAGE=AC_PACKAGE_NAME
             """) % parameters
-        return self.prepare_package(
-            "intltool_domain_base",
-            {
-                "configure.ac": configure_ac_content,
-            })
+        files = {"configure.ac": configure_ac_content}
+        if extra_files is not None:
+            files.update(extra_files)
+        return self.prepare_package("intltool_domain_base", files)
 
     def test_get_translation_domain_configure_ac_init(self):
         # Find a translation domain in configure.ac in AC_INIT.
@@ -266,6 +265,16 @@
             "package-tarname",
             get_translation_domain(backend, os.path.join(package_dir, "po")))
 
+    def test_get_translation_domain_substitute_package_from_ac_init(self):
+        # PACKAGE is substituted from AC_INIT parameters as a fallback.
+        backend = UncontainedBackend("1")
+        package_dir = self.prepare_ac_init(
+            "[packagename-ac-init], 1.0, http://bug.org";,
+            {"po/Makevars": "DOMAIN = $(PACKAGE)\n"})
+        self.assertEqual(
+            "packagename-ac-init",
+            get_translation_domain(backend, os.path.join(package_dir, "po")))
+
     def test_get_translation_domain_configure_in(self):
         # Find a translation domain in configure.in.
         backend = UncontainedBackend("1")