Bug 1732676 - include the full app version in langpack versions r=aki,robwu

Bug 1455337 started mangling the app version into both the langpack
version and strict_min_version.  It turns out using the mangled version
as langpack version means firefox ignores legitimate updates.

So we keep the mangled `major.0` as the "min version", but the
langpack's version itself should be bumped on every minor release so
firefox knows to update to it.

We also split the buildid part of the version number so that
nsVersionComparator::compare can order them properly, e.g. for beta
builds where the app version doesn't change.

Differential Revision: https://phabricator.services.mozilla.com/D126815
This commit is contained in:
Julien Cristau 2021-10-06 09:16:44 +00:00
parent a030f418ad
commit d6098a8b00
3 changed files with 17 additions and 9 deletions

View File

@ -307,14 +307,16 @@ def parse_chrome_manifest(path, base_path, chrome_entries):
# str - Version to use, may include buildid
#
###
def get_version_maybe_buildid(min_version):
version = str(min_version)
def get_version_maybe_buildid(version):
buildid = os.environ.get("MOZ_BUILD_DATE")
if buildid and len(buildid) != 14:
print("Ignoring invalid MOZ_BUILD_DATE: %s" % buildid, file=sys.stderr)
buildid = None
if buildid:
version = version + "buildid" + buildid
# Split into date/time parts so no part is >= 2^31 (bug 1732676)
# Bug 1733396 may revisit that limit
date, time = buildid[:8], buildid[8:]
version = f"{version}buildid{date}.{time}"
return version
@ -384,6 +386,7 @@ def get_version_maybe_buildid(min_version):
###
def create_webmanifest(
locstr,
version,
min_app_ver,
max_app_ver,
app_name,
@ -414,7 +417,7 @@ def create_webmanifest(
},
"name": "{0} Language Pack".format(defines["MOZ_LANG_TITLE"]),
"description": "Language pack for {0} for {1}".format(app_name, main_locale),
"version": get_version_maybe_buildid(min_app_ver),
"version": get_version_maybe_buildid(version),
"languages": {},
"sources": {"browser": {"base_path": "browser/"}},
"author": author,
@ -449,9 +452,7 @@ def main(args):
parser.add_argument(
"--locales", help="List of language codes provided by the langpack"
)
parser.add_argument(
"--min-app-ver", help="Min version of the application the langpack is for"
)
parser.add_argument("--app-version", help="Version of the application")
parser.add_argument(
"--max-app-ver", help="Max version of the application the langpack is for"
)
@ -481,7 +482,8 @@ def main(args):
defines = parse_defines(args.defines)
min_app_version = args.min_app_ver
# Mangle the app version to set min version (remove patch level)
min_app_version = args.app_version
if "a" not in min_app_version: # Don't mangle alpha versions
v = Version(min_app_version)
if args.app_name == "SeaMonkey":
@ -494,6 +496,7 @@ def main(args):
res = create_webmanifest(
args.locales,
args.app_version,
min_app_version,
args.max_app_ver,
args.app_name,

View File

@ -7,6 +7,7 @@ from __future__ import absolute_import, print_function
import unittest
import json
import os
import mozunit
@ -29,8 +30,10 @@ class TestGenerateManifest(unittest.TestCase):
<em:contributor>Joe Smith</em:contributor>
<em:contributor>Mary White</em:contributor>
"""
os.environ["MOZ_BUILD_DATE"] = "20210928100000"
manifest = langpack_manifest.create_webmanifest(
"fi",
"57.0.1",
"57.0",
"57.0.*",
"Firefox",
@ -45,6 +48,7 @@ class TestGenerateManifest(unittest.TestCase):
self.assertEquals(
data["author"], "Suomennosprojekti (contributors: Joe Smith, Mary White)"
)
self.assertEquals(data["version"], "57.0.1buildid20210928.100000")
def test_manifest_without_contributors(self):
ctx = Context()
@ -52,6 +56,7 @@ class TestGenerateManifest(unittest.TestCase):
ctx["MOZ_LANGPACK_CREATOR"] = "Suomennosprojekti"
manifest = langpack_manifest.create_webmanifest(
"fi",
"57.0.1",
"57.0",
"57.0.*",
"Firefox",

View File

@ -233,7 +233,7 @@ package-langpack-%: XPI_NAME=locale-$*
package-langpack-%: AB_CD=$*
package-langpack-%:
$(NSINSTALL) -D $(DIST)/$(PKG_LANGPACK_PATH)
$(call py_action,langpack_manifest,--locales $(AB_CD) --min-app-ver $(MOZ_APP_VERSION) --max-app-ver $(MOZ_APP_MAXVERSION) --app-name '$(MOZ_APP_DISPLAYNAME)' --l10n-basedir '$(L10NBASEDIR)' --defines $(LANGPACK_DEFINES) --langpack-eid '$(MOZ_LANGPACK_EID)' --input $(DIST)/xpi-stage/locale-$(AB_CD))
$(call py_action,langpack_manifest,--locales $(AB_CD) --app-version $(MOZ_APP_VERSION) --max-app-ver $(MOZ_APP_MAXVERSION) --app-name '$(MOZ_APP_DISPLAYNAME)' --l10n-basedir '$(L10NBASEDIR)' --defines $(LANGPACK_DEFINES) --langpack-eid '$(MOZ_LANGPACK_EID)' --input $(DIST)/xpi-stage/locale-$(AB_CD))
$(call py_action,zip,-C $(DIST)/xpi-stage/locale-$(AB_CD) -x **/*.manifest -x **/*.js -x **/*.ini $(LANGPACK_FILE) $(PKG_ZIP_DIRS) manifest.json)
# This variable is to allow the wget-en-US target to know which ftp server to download from