[rhel6-branch 1/3] Switch translation support to fedora.zanata.org

bcl installerbot-noreply at redhat.com
Tue Mar 24 15:29:34 UTC 2015


From: "Brian C. Lane" <bcl at redhat.com>

This commit adjusts the Makefile targets to use zanata, and makebumpver
to check the zanata.xml for the correct branch.

(cherry picked from commit 16dacf401c7b083963cc8434a9c6107df5524e9d)
---
 .tx/config          |   7 ----
 Makefile.am         |   9 +++--
 scripts/makebumpver |  62 ++++++++++++++++++++++++++----
 zanata.xml          | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 165 insertions(+), 19 deletions(-)
 delete mode 100644 .tx/config
 create mode 100644 zanata.xml

diff --git a/.tx/config b/.tx/config
deleted file mode 100644
index 53d6030..0000000
--- a/.tx/config
+++ /dev/null
@@ -1,7 +0,0 @@
-[main]
-host = https://www.transifex.com
-
-[anaconda.rhel6-branch]
-file_filter = po/<lang>.po
-source_file = po/anaconda.pot
-source_lang = en
diff --git a/Makefile.am b/Makefile.am
index acbb678..a69a2b2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -67,8 +67,8 @@ sed_verbose = $(sed_verbose_$(V))
 sed_verbose_ = $(sed_verbose_$(AM_DEFAULT_VERBOSITY))
 sed_verbose_0 = @echo "  SED    "$@;
 
-TX_PULL_ARGS = -a --disable-overwrite
-TX_PUSH_ARGS = -s
+ZANATA_PULL_ARGS = --transdir $(srcdir)/po/
+ZANATA_PUSH_ARGS = --srcdir $(srcdir)/po/ --push-type source --force
 
 $(PACKAGE_NAME).spec: $(PACKAGE_NAME).spec.in
 	$(sed_verbose)sed -e 's/#VERSION#/$(PACKAGE_VERSION)/' < $< > $@
@@ -89,7 +89,8 @@ tag:
 po-pull:
 	rm -f po/en at boldquot.gmo po/en at boldquot.po
 	rm -f po/en at quot.gmo po/en at quot.po
-	tx pull $(TX_PULL_ARGS)
+	rpm -q zanata-python-client &>/dev/null || ( echo "need to run: yum install zanata-python-client"; exit 1 )
+	zanata pull $(ZANATA_PULL_ARGS)
 
 scratch:
 	$(MAKE) ARCHIVE_TAG=HEAD dist
@@ -126,7 +127,7 @@ bumpver: po-pull
 	fi ; \
 	scripts/makebumpver $${opts} || exit 1 ; \
 	$(MAKE) -C po $(PACKAGE_NAME).pot-update ; \
-	tx push $(TX_PUSH_ARGS)
+	zanata push $(ZANATA_PUSH_ARGS)
 
 install-buildrequires:
 	yum install $$(grep BuildRequires: anaconda.spec.in | cut -d ' ' -f 2)
diff --git a/scripts/makebumpver b/scripts/makebumpver
index 12ded38..a22062a 100755
--- a/scripts/makebumpver
+++ b/scripts/makebumpver
@@ -76,6 +76,13 @@ class MakeBumpVer:
 
         self.configure = kwargs.get('configure')
         self.spec = kwargs.get('spec')
+        self.zanata_config = kwargs.get('zanata_config')
+        self.skip_zanata = kwargs.get("skip_zanata", False)
+
+        self.git_branch = None
+
+        # RHEL release number or None (also fills in self.git_branch)
+        self.rhel = self._isRHEL()
 
     def _gitConfig(self, field):
         proc = subprocess.Popen(['git', 'config', field],
@@ -101,10 +108,15 @@ class MakeBumpVer:
 
         fields = lines[0].split(' ')
 
+        if len(fields) == 2:
+            self.git_branch = fields[1]
+
         if len(fields) == 2 and fields[1].startswith('rhel'):
-            return True
-        else:
-            return False
+            branch_pattern=r"^rhel(\d+)-(.*)"
+            m = re.match(branch_pattern, fields[1])
+            if m:
+                return m.group(1)
+        return False
 
     def _getCommitDetail(self, commit, field):
         proc = subprocess.Popen(['git', 'log', '-1',
@@ -217,7 +229,6 @@ class MakeBumpVer:
 
         rpm_log = []
         bad = False
-        rhel = self._isRHEL()
 
         for line in lines:
             fields = line.split(' ')
@@ -229,7 +240,7 @@ class MakeBumpVer:
                 body = [body]
             author = self._getCommitDetail(commit, "%aE")
 
-            if rhel:
+            if self.rhel:
                 rhbz = set()
 
                 # look for a bug in the summary line, validate if found
@@ -368,7 +379,37 @@ class MakeBumpVer:
         f.writelines(bottom)
         f.close()
 
+    def check_zanata(self):
+        """
+        Make sure that the zanata project-version matches the current git branch
+
+        This is to prevent accidentally pushing translations to the wrong branch,
+        eg. when branching for a new release and zanata.xml hasn't been updated
+        """
+        if not self.git_branch:
+            log.error("No git branch, cannot check zanata config")
+            return False
+
+        version_re = re.compile("<project-version>(.*)</project-version>")
+        ret = False
+        with open(self.zanata_config, "r") as f:
+            for line in f:
+                m = version_re.match(line.strip())
+                if m and m.group(1) == self.git_branch:
+                    ret = True
+                    break
+                elif m:
+                    log.error("zanata.xml branch (%s) does not match current branch: %s", m.group(1), self.git_branch)
+                    break
+            else:
+                log.error("zanata.xml does not have a project-version")
+
+        return ret
+
     def run(self):
+        if not self.skip_zanata and not self.check_zanata():
+            sys.exit(1)
+
         newVersion = self._incrementVersion()
         fixedIn = "%s-%s-%s" % (self.name, newVersion, self.release)
         rpmlog = self._rpmLog(fixedIn)
@@ -386,6 +427,7 @@ def usage(cmd):
     sys.stdout.write("    -i, --ignore     Comma separated list of git commits to ignore.\n")
     sys.stdout.write("    -m, --map        Comma separated list of FEDORA_BZ=RHEL_BZ mappings.\n")
     sys.stdout.write("    -d, --debug      Turn on debug logging to stdout\n")
+    sys.stdout.write("    --skip-zanata    Skip checking Zanata config for branch name\n")
     sys.stdout.write("\nThe -i switch is intended for use with utility commits that we do not need to\n")
     sys.stdout.write("reference in the spec file changelog.  The -m switch is used to map a Fedora\n")
     sys.stdout.write("BZ number to a RHEL BZ number for the spec file changelog.  Use -m if you have\n")
@@ -397,16 +439,17 @@ def main(argv):
     cwd = os.getcwd()
     configure = os.path.realpath(cwd + '/configure.ac')
     spec = os.path.realpath(cwd + '/anaconda.spec.in')
+    zanata_config = os.path.realpath(cwd + '/zanata.xml')
     name, version, release, bugreport = None, None, None, None
     ignore, bugmap = None, None
-    show_help, unknown = False, False
+    show_help, unknown, skip_zanata = False, False, False
     opts, args = [], []
 
     try:
         opts, args = getopt.getopt(sys.argv[1:], 'n:v:r:b:i:m:d?',
                                    ['name=', 'version=', 'release=',
                                     'bugreport=', 'ignore=', 'map=',
-                                    'debug', 'help'])
+                                    'debug', 'help', 'skip-zanata'])
     except getopt.GetoptError:
         show_help = True
 
@@ -425,6 +468,8 @@ def main(argv):
             bugmap = a
         elif o in ('-d', '--debug'):
             log.setLevel(logging.DEBUG)
+        elif o in ('--skip-zanata'):
+            skip_zanata = True
         elif o in ('-?', '--help'):
             show_help = True
         else:
@@ -460,7 +505,8 @@ def main(argv):
 
     mbv = MakeBumpVer(name=name, version=version, release=release,
                       bugreport=bugreport, ignore=ignore, bugmap=bugmap,
-                      configure=configure, spec=spec)
+                      configure=configure, spec=spec, skip_zanata=skip_zanata,
+                      zanata_config=zanata_config)
     mbv.run()
 
 if __name__ == "__main__":
diff --git a/zanata.xml b/zanata.xml
new file mode 100644
index 0000000..7fc986c
--- /dev/null
+++ b/zanata.xml
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<config xmlns="http://zanata.org/namespace/config/">
+  <url>https://fedora.zanata.org/</url>
+  <project>anaconda</project>
+  <project-version>rhel6-branch</project-version>
+  <project-type>gettext</project-type>
+
+  <locales>
+    <locale>sq</locale>
+    <locale>ar</locale>
+    <locale>as</locale>
+    <locale>ast</locale>
+    <locale>bal</locale>
+    <locale>eu</locale>
+    <locale>bn</locale>
+    <locale>bn-IN</locale>
+    <locale>brx</locale>
+    <locale>bs</locale>
+    <locale>br</locale>
+    <locale>bg</locale>
+    <locale>ca</locale>
+    <locale>zh-CN</locale>
+    <locale>zh-HK</locale>
+    <locale>zh-TW</locale>
+    <locale>kw</locale>
+    <locale>kw-GB</locale>
+    <locale>cs</locale>
+    <locale>da</locale>
+    <locale>nl</locale>
+    <locale>en-GB</locale>
+    <locale>eo</locale>
+    <locale>et</locale>
+    <locale>fi</locale>
+    <locale>fr</locale>
+    <locale>gl</locale>
+    <locale>ka</locale>
+    <locale>de</locale>
+    <locale>el</locale>
+    <locale>gu</locale>
+    <locale>he</locale>
+    <locale>hi</locale>
+    <locale>hu</locale>
+    <locale>is</locale>
+    <locale>id</locale>
+    <locale>ia</locale>
+    <locale>it</locale>
+    <locale>ja</locale>
+    <locale>kn</locale>
+    <locale>kk</locale>
+    <locale>km</locale>
+    <locale>ky</locale>
+    <locale>ko</locale>
+    <locale>lt</locale>
+    <locale>nds</locale>
+    <locale>mk</locale>
+    <locale>mai</locale>
+    <locale>ms</locale>
+    <locale>ml</locale>
+    <locale>mr</locale>
+    <locale>mn</locale>
+    <locale>ne</locale>
+    <locale>nb</locale>
+    <locale>nn</locale>
+    <locale>or</locale>
+    <locale>pa</locale>
+    <locale>fa</locale>
+    <locale>pl</locale>
+    <locale>pt</locale>
+    <locale>pt-BR</locale>
+    <locale>ro</locale>
+    <locale>ru</locale>
+    <locale>sr</locale>
+    <locale>sr at latin</locale>
+    <locale>si</locale>
+    <locale>sk</locale>
+    <locale>sl</locale>
+    <locale>es</locale>
+    <locale>sv</locale>
+    <locale>tg</locale>
+    <locale>ta</locale>
+    <locale>te</locale>
+    <locale>bo</locale>
+    <locale>tr</locale>
+    <locale>uk</locale>
+    <locale>ur</locale>
+    <locale>wba</locale>
+    <locale>cy</locale>
+    <locale>lv</locale>
+    <locale>kw at uccor</locale>
+    <locale>kw at kkcor</locale>
+    <locale>af</locale>
+    <locale>am</locale>
+    <locale>be</locale>
+    <locale>hr</locale>
+    <locale>de-CH</locale>
+    <locale>th</locale>
+    <locale>vi</locale>
+    <locale>zu</locale>
+    <locale>ilo</locale>
+    <locale>nso</locale>
+    <locale>tw</locale>
+    <locale>yo</locale>
+    <locale>anp</locale>
+  </locales>
+
+</config>


-- 
To view this commit on github, visit https://github.com/rhinstaller/anaconda/commit/7d6de686dd2b2fcaf5998fa734d4658ec8153f47


More information about the anaconda-patches mailing list