From d734030413c0c6abe39ac2a118b6b18bbcd3faa3 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Mon, 23 Feb 2015 11:13:52 -0800 Subject: [PATCH] Switch translation support to fedora.zanata.org 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) Resolves: rhbz#1205285 --- .tx/config | 9 ---- Makefile.am | 10 ++--- scripts/makebumpver | 50 +++++++++++++++++++-- zanata.xml | 106 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 157 insertions(+), 18 deletions(-) delete mode 100644 .tx/config create mode 100644 zanata.xml diff --git a/.tx/config b/.tx/config deleted file mode 100644 index 99e3dce6c5e..00000000000 --- a/.tx/config +++ /dev/null @@ -1,9 +0,0 @@ -[main] -host = https://www.transifex.com - -[anaconda.rhel7-branch] -file_filter = po/.po -source_file = po/anaconda.pot -source_lang = en -type = PO - diff --git a/Makefile.am b/Makefile.am index 3c647f73e6f..8e9cef347be 100644 --- a/Makefile.am +++ b/Makefile.am @@ -51,8 +51,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)/' < $< > $@ @@ -64,8 +64,8 @@ tag: po-pull: rm -f po/en@boldquot.gmo po/en@boldquot.po rm -f po/en@quot.gmo po/en@quot.po - rpm -q transifex-client &>/dev/null || ( echo "need to run: yum install transifex-client"; exit 1 ) - 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: po-pull $(MAKE) ARCHIVE_TAG=HEAD dist @@ -107,7 +107,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 fa2df04f5dc..aa8d84af645 100755 --- a/scripts/makebumpver +++ b/scripts/makebumpver @@ -79,11 +79,16 @@ class MakeBumpVer: self.spec = kwargs.get('spec') self.skip_acks = kwargs.get('skip_acks', False) self.skip_all = kwargs.get('skip_all', False) + self.zanata_config = kwargs.get('zanata_config') + self.skip_zanata = kwargs.get("skip_zanata", False) if self.skip_all: self.skip_acks = True + self.skip_zanata = True - # RHEL release number or None + self.git_branch = None + + # RHEL release number or None (also fills in self.git_branch) self.rhel = self._isRHEL() def _gitConfig(self, field): @@ -110,6 +115,9 @@ class MakeBumpVer: fields = lines[0].split(' ') + if len(fields) == 2: + self.git_branch = fields[1] + if len(fields) == 2 and fields[1].startswith('rhel'): branch_pattern=r"^rhel(\d+)-(.*)" m = re.match(branch_pattern, fields[1]) @@ -432,7 +440,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("(.*)") + 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) @@ -452,6 +490,7 @@ def usage(cmd): sys.stdout.write(" -s, --skip-acks Skip checking for rhel-X.X.X ack flag\n") sys.stdout.write(" -S, --skip-all Skip all checks\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") @@ -463,16 +502,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, skip_acks, skip_all = False, False, False, False + show_help, unknown, skip_acks, skip_all, skip_zanata = False, False, False, False, False opts, _args = [], [] try: opts, _args = getopt.getopt(sys.argv[1:], 'n:v:r:b:i:m:sSd?', ['name=', 'version=', 'release=', 'bugreport=', 'ignore=', 'map=', - 'debug', 'help']) + 'debug', 'help', 'skip-zanata']) except getopt.GetoptError: show_help = True @@ -495,6 +535,8 @@ def main(argv): skip_all = True 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: @@ -531,7 +573,7 @@ def main(argv): mbv = MakeBumpVer(name=name, version=version, release=release, bugreport=bugreport, ignore=ignore, bugmap=bugmap, configure=configure, spec=spec, skip_acks=skip_acks, - skip_all=skip_all) + skip_all=skip_all, zanata_config=zanata_config, skip_zanata=skip_zanata) mbv.run() if __name__ == "__main__": diff --git a/zanata.xml b/zanata.xml new file mode 100644 index 00000000000..b6da60afe45 --- /dev/null +++ b/zanata.xml @@ -0,0 +1,106 @@ + + + https://fedora.zanata.org/ + anaconda + rhel7-branch + gettext + + + sq + ar + as + ast + bal + eu + bn + bn-IN + brx + bs + br + bg + ca + zh-CN + zh-HK + zh-TW + kw + kw-GB + cs + da + nl + en-GB + eo + et + fi + fr + gl + ka + de + el + gu + he + hi + hu + is + id + ia + it + ja + kn + kk + km + ky + ko + lt + nds + mk + mai + ms + ml + mr + mn + ne + nb + nn + or + pa + fa + pl + pt + pt-BR + ro + ru + sr + sr@latin + si + sk + sl + es + sv + tg + ta + te + bo + tr + uk + ur + wba + cy + lv + kw@uccor + kw@kkcor + af + am + be + hr + de-CH + th + vi + zu + ilo + nso + tw + yo + anp + + +