diff options
author | Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de> | 2017-02-11 22:38:54 +0100 |
---|---|---|
committer | Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de> | 2017-02-11 22:38:54 +0100 |
commit | 530288f5a725848bb899636665ea3f14f9398fad (patch) | |
tree | 097879192b3926c5c6503b058d3582d680110bfc /tools | |
parent | 34b65b9553c9395846ae1bbe186be2667139db79 (diff) | |
parent | fafb7e2a14706f75bd76aca21c1c7d695f938ed3 (diff) | |
download | build-530288f5a725848bb899636665ea3f14f9398fad.zip build-530288f5a725848bb899636665ea3f14f9398fad.tar.gz build-530288f5a725848bb899636665ea3f14f9398fad.tar.bz2 |
Merge branch 'cm-13.0' of https://github.com/LineageOS/android_build into replicant-6.0
Signed-off-by: Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/releasetools/common.py | 17 | ||||
-rw-r--r-- | tools/releasetools/edify_generator.py | 2 | ||||
-rwxr-xr-x | tools/releasetools/ota_from_target_files.py | 23 | ||||
-rwxr-xr-x | tools/releasetools/sign_zip.py | 69 | ||||
-rwxr-xr-x | tools/repopick.py | 7 | ||||
-rwxr-xr-x | tools/roomservice.py | 46 |
6 files changed, 123 insertions, 41 deletions
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index 32bbc68..ea7312a 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -863,6 +863,7 @@ class PasswordManager(object): def __init__(self): self.editor = os.getenv("EDITOR", None) self.pwfile = os.getenv("ANDROID_PW_FILE", None) + self.secure_storage_cmd = os.getenv("ANDROID_SECURE_STORAGE_CMD", None) def GetPasswords(self, items): """Get passwords corresponding to each string in 'items', @@ -882,9 +883,23 @@ class PasswordManager(object): missing = [] for i in items: if i not in current or not current[i]: - missing.append(i) + #Attempt to load using ANDROID_SECURE_STORAGE_CMD + if self.secure_storage_cmd: + try: + os.environ["TMP__KEY_FILE_NAME"] = str(i) + ps = subprocess.Popen(self.secure_storage_cmd, shell=True, stdout=subprocess.PIPE) + output = ps.communicate()[0] + if ps.returncode == 0: + current[i] = output + except Exception as e: + print(e) + pass + if i not in current or not current[i]: + missing.append(i) # Are all the passwords already in the file? if not missing: + if "ANDROID_SECURE_STORAGE_CMD" in os.environ: + del os.environ["ANDROID_SECURE_STORAGE_CMD"] return current for i in missing: diff --git a/tools/releasetools/edify_generator.py b/tools/releasetools/edify_generator.py index 825a7eb..8025235 100644 --- a/tools/releasetools/edify_generator.py +++ b/tools/releasetools/edify_generator.py @@ -151,7 +151,7 @@ class EdifyGenerator(object): self.script.append(('run_program("/tmp/install/bin/backuptool.sh", "%s");' % command)) def ValidateSignatures(self, command): - self.script.append('package_extract_file("META-INF/org/cyanogenmod/releasekey", "/tmp/releasekey");') + self.script.append('package_extract_file("META-INF/org/lineageos/releasekey", "/tmp/releasekey");') # Exit code 124 == abort. run_program returns raw, so left-shift 8bit self.script.append('run_program("/tmp/install/bin/otasigcheck.sh") != "31744" || abort("Can\'t install this package on top of incompatible data. Please try another package or run a factory reset");') diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py index bc40873..66db227 100755 --- a/tools/releasetools/ota_from_target_files.py +++ b/tools/releasetools/ota_from_target_files.py @@ -96,14 +96,6 @@ Usage: ota_from_target_files [flags] input_target_files output_ota_package --backup <boolean> Enable or disable the execution of backuptool.sh. Disabled by default. - - --override_device <device> - Override device-specific asserts. Can be a comma-separated list. - - --override_prop <boolean> - Override build.prop items with custom vendor init. - Enabled when TARGET_UNIFIED_DEVICE is defined in BoardConfig - """ from __future__ import print_function @@ -753,7 +745,7 @@ endif; common.ZipWriteStr(output_zip, "system/build.prop", ""+input_zip.read("SYSTEM/build.prop")) - common.ZipWriteStr(output_zip, "META-INF/org/cyanogenmod/releasekey", + common.ZipWriteStr(output_zip, "META-INF/org/lineageos/releasekey", ""+input_zip.read("META/releasekey.txt")) def WritePolicyConfig(file_name, output_zip): @@ -1629,10 +1621,6 @@ def main(argv): "a float" % (a, o)) elif o in ("--backup",): OPTIONS.backuptool = bool(a.lower() == 'true') - elif o in ("--override_device",): - OPTIONS.override_device = a - elif o in ("--override_prop",): - OPTIONS.override_prop = bool(a.lower() == 'true') else: return False return True @@ -1658,9 +1646,7 @@ def main(argv): "verify", "no_fallback_to_full", "stash_threshold=", - "backup=", - "override_device=", - "override_prop=" + "backup=" ], extra_option_handler=option_handler) if len(args) != 2: @@ -1676,6 +1662,11 @@ def main(argv): OPTIONS.target_tmp = OPTIONS.input_tmp OPTIONS.info_dict = common.LoadInfoDict(input_zip) + if "ota_override_device" in OPTIONS.info_dict: + OPTIONS.override_device = OPTIONS.info_dict.get("ota_override_device") + if "ota_override_prop" in OPTIONS.info_dict: + OPTIONS.override_prop = OPTIONS.info_dict.get("ota_override_prop") == "true" + # If this image was originally labelled with SELinux contexts, make sure we # also apply the labels in our new image. During building, the "file_contexts" # is in the out/ directory tree, but for repacking from target-files.zip it's diff --git a/tools/releasetools/sign_zip.py b/tools/releasetools/sign_zip.py new file mode 100755 index 0000000..c40b1b4 --- /dev/null +++ b/tools/releasetools/sign_zip.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python +# +# Copyright (C) 2017 The LineageOS Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +Signs the given zip with the given key producing a new zip. + +Usage: sign_release_zip [flags] input_zip output_zip + + -k (--package_key) <key> Key to use to sign the package (default is + "build/target/product/security/testkey"). +""" +import sys + +import common + +OPTIONS = common.OPTIONS + +OPTIONS.package_key = "build/target/product/security/testkey" + +def SignOutput(input_zip_name, output_zip_name): + key_passwords = common.GetKeyPasswords([OPTIONS.package_key]) + pw = key_passwords[OPTIONS.package_key] + + common.SignFile(input_zip_name, output_zip_name, OPTIONS.package_key, pw, + whole_file=True) + + +def main(argv): + + def option_handler(o, a): + if o in ("-k", "--package_key"): + OPTIONS.package_key = a + else: + return False + return True + + args = common.ParseOptions(argv, __doc__, + extra_opts="k:", + extra_long_opts=[ + "package_key=", + ], extra_option_handler=option_handler) + if len(args) != 2: + common.Usage(__doc__) + sys.exit(1) + + SignOutput(args[0], args[1]) + + +if __name__ == '__main__': + try: + main(sys.argv[1:]) + except common.ExternalError as e: + print() + print(" ERROR: %s" % e) + print() + sys.exit(1) diff --git a/tools/repopick.py b/tools/repopick.py index cfbb8a8..9bb39aa 100755 --- a/tools/repopick.py +++ b/tools/repopick.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # # Copyright (C) 2013-15 The CyanogenMod Project +# (C) 2017 The LineageOS Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -121,12 +122,12 @@ def fetch_query(remote_url, query): raise Exception('Gerrit URL should be in the form http[s]://hostname/ or ssh://[user@]host[:port]') if __name__ == '__main__': - # Default to CyanogenMod Gerrit - default_gerrit = 'http://review.cyanogenmod.org' + # Default to LineageOS Gerrit + default_gerrit = 'http://review.lineageos.org' parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter, description=textwrap.dedent('''\ repopick.py is a utility to simplify the process of cherry picking - patches from CyanogenMod's Gerrit instance (or any gerrit instance of your choosing) + patches from LineageOS's Gerrit instance (or any gerrit instance of your choosing) Given a list of change numbers, repopick will cd into the project path and cherry pick the latest patch available. diff --git a/tools/roomservice.py b/tools/roomservice.py index a1b69cd..691456e 100755 --- a/tools/roomservice.py +++ b/tools/roomservice.py @@ -1,5 +1,6 @@ #!/usr/bin/env python # Copyright (C) 2012-2013, The CyanogenMod Project +# (C) 2017, The LineageOS Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -51,7 +52,7 @@ except: device = product if not depsonly: - print("Device %s not found. Attempting to retrieve device repository from CyanogenMod Github (http://github.com/CyanogenMod)." % device) + print("Device %s not found. Attempting to retrieve device repository from LineageOS Github (http://github.com/LineageOS)." % device) repositories = [] @@ -71,7 +72,7 @@ def add_auth(githubreq): githubreq.add_header("Authorization","Basic %s" % githubauth) if not depsonly: - githubreq = urllib.request.Request("https://api.github.com/search/repositories?q=%s+user:CyanogenMod+in:name+fork:true" % device) + githubreq = urllib.request.Request("https://api.github.com/search/repositories?q=%s+user:LineageOS+in:name+fork:true" % device) add_auth(githubreq) try: result = json.loads(urllib.request.urlopen(githubreq).read().decode()) @@ -175,12 +176,12 @@ def add_to_manifest(repositories, fallback_branch = None): repo_target = repository['target_path'] print('Checking if %s is fetched from %s' % (repo_target, repo_name)) if is_in_manifest(repo_target): - print('CyanogenMod/%s already fetched to %s' % (repo_name, repo_target)) + print('LineageOS/%s already fetched to %s' % (repo_name, repo_target)) continue - print('Adding dependency: CyanogenMod/%s -> %s' % (repo_name, repo_target)) + print('Adding dependency: LineageOS/%s -> %s' % (repo_name, repo_target)) project = ElementTree.Element("project", attrib = { "path": repo_target, - "remote": "github", "name": "CyanogenMod/%s" % repo_name }) + "remote": "github", "name": "LineageOS/%s" % repo_name }) if 'branch' in repository: project.set('revision',repository['branch']) @@ -202,25 +203,30 @@ def add_to_manifest(repositories, fallback_branch = None): def fetch_dependencies(repo_path, fallback_branch = None): print('Looking for dependencies') - dependencies_path = repo_path + '/cm.dependencies' + dependencies_paths = [repo_path + '/lineage.dependencies', repo_path + '/cm.dependencies'] + found_dependencies = False syncable_repos = [] - if os.path.exists(dependencies_path): - dependencies_file = open(dependencies_path, 'r') - dependencies = json.loads(dependencies_file.read()) - fetch_list = [] + for dependencies_path in dependencies_paths: + if os.path.exists(dependencies_path): + dependencies_file = open(dependencies_path, 'r') + dependencies = json.loads(dependencies_file.read()) + fetch_list = [] - for dependency in dependencies: - if not is_in_manifest(dependency['target_path']): - fetch_list.append(dependency) - syncable_repos.append(dependency['target_path']) + for dependency in dependencies: + if not is_in_manifest(dependency['target_path']): + fetch_list.append(dependency) + syncable_repos.append(dependency['target_path']) - dependencies_file.close() + dependencies_file.close() + found_dependencies = True - if len(fetch_list) > 0: - print('Adding dependencies to manifest') - add_to_manifest(fetch_list, fallback_branch) - else: + if len(fetch_list) > 0: + print('Adding dependencies to manifest') + add_to_manifest(fetch_list, fallback_branch) + break + + if not found_dependencies: print('Dependencies file not found, bailing out.') if len(syncable_repos) > 0: @@ -294,4 +300,4 @@ else: print("Done") sys.exit() -print("Repository for %s not found in the CyanogenMod Github repository list. If this is in error, you may need to manually add it to your local_manifests/roomservice.xml." % device) +print("Repository for %s not found in the LineageOS Github repository list. If this is in error, you may need to manually add it to your local_manifests/roomservice.xml." % device) |