Add version string in group policy templates (issue 1392383004 by fqj@chromium.org)

0 views
Skip to first unread message

f...@chromium.org

unread,
Oct 12, 2015, 10:11:32 AM10/12/15
to b...@chromium.org, grit-de...@googlegroups.com
Reviewers: Ben Goodger (Google),

Message:
Hello,

Could you please help review this?

Thanks

Description:
Add version string in group policy templates

1. Add the missing version number comment for AndroidPolicyWriter
2. Enable GetConfigurationForBuild to read version number from
chrome/VERSION to determine the version number as grit_defines doesn't
have information for version number at all.

BUG=108941

Please review this at https://codereview.chromium.org/1392383004/

Base URL: https://chromium.googlesource.com/external/grit-i18n.git@master

Affected files (+22, -0 lines):
grit/format/policy_templates/writer_configuration.py
grit/format/policy_templates/writers/android_policy_writer.py


Index: grit/format/policy_templates/writer_configuration.py
diff --git a/grit/format/policy_templates/writer_configuration.py
b/grit/format/policy_templates/writer_configuration.py
index
db9613b2eca0d71a9feaad870526b549f2b7f8be..ca9396addf2184d091ccf7df261cb90d1836fe0f
100644
--- a/grit/format/policy_templates/writer_configuration.py
+++ b/grit/format/policy_templates/writer_configuration.py
@@ -4,6 +4,9 @@
# found in the LICENSE file.


+
+VERSION_FILE="../chrome/VERSION"
+
def GetConfigurationForBuild(defines):
'''Returns a configuration dictionary for the given build that contains
build-specific settings and information.
@@ -54,8 +57,24 @@ def GetConfigurationForBuild(defines):
raise Exception('Unknown build')
if 'version' in defines:
config['version'] = defines['version']
+ else:
+ version = _parseVersionFile(VERSION_FILE)
+ if version:
+ config['version'] = version
config['win_group_policy_class'] = 'Both'
config['win_supported_os'] = 'SUPPORTED_WINXPSP2'
if 'mac_bundle_id' in defines:
config['mac_bundle_id'] = defines['mac_bundle_id']
return config
+
+def _parseVersionFile(path):
+ versions = {}
+ keys = ["MAJOR", "MINOR", "BUILD", "PATCH"]
+ try:
+ version_file_content = open(path).readlines()
+ for line in version_file_content:
+ name, value = line.strip().split('=')
+ versions[name] = value
+ return ".".join([versions[key] for key in keys])
+ except IOError:
+ return None
Index: grit/format/policy_templates/writers/android_policy_writer.py
diff --git a/grit/format/policy_templates/writers/android_policy_writer.py
b/grit/format/policy_templates/writers/android_policy_writer.py
index
5d8cbef38f991b2964d15d36ce6f6e3b45133072..8cc447d01333699978312e965e68a878e269e1ab
100644
--- a/grit/format/policy_templates/writers/android_policy_writer.py
+++ b/grit/format/policy_templates/writers/android_policy_writer.py
@@ -88,6 +88,9 @@ class
AndroidPolicyWriter(xml_formatted_writer.XMLFormattedWriter):
def BeginTemplate(self):
comment_text = 'DO NOT MODIFY THIS FILE DIRECTLY!\n' \
'IT IS GENERATED FROM policy_templates.json.'
+ if self._GetChromiumVersionString():
+ comment_text += "\n" + self.config["build"] + " version: "\
+ + self._GetChromiumVersionString()
comment_node = self._doc.createComment(comment_text)
self._doc.insertBefore(comment_node, self._resources)



Reply all
Reply to author
Forward
0 new messages