Update freeze.py for new scheme. am: 5a600e744e
am: 344cd7b0db
am: 17bfef6467
Original change: https://android-review.googlesource.com/c/kernel/configs/+/2572972 Change-Id: I422d3b9da55fda58aebac2509f52468453317efa Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
79aaa1f1ba
1 changed files with 14 additions and 46 deletions
|
@ -16,84 +16,52 @@
|
|||
#
|
||||
|
||||
"""
|
||||
Freeze kernel configs for a compatibility matrix release.
|
||||
Creates new kernel configs for the next compatibility matrix.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import datetime
|
||||
import os
|
||||
import shutil
|
||||
|
||||
import subprocess
|
||||
|
||||
def check_call(*args, **kwargs):
|
||||
print(args[0])
|
||||
subprocess.check_call(*args, **kwargs)
|
||||
|
||||
def replace_configs_module_name(new_release, file_path):
|
||||
check_call("sed -i'' -E 's/\"kernel_config_current_([0-9.]*)\"/\"kernel_config_{}_\\1\"/g' {}"
|
||||
.format(new_release, file_path), shell=True)
|
||||
def replace_configs_module_name(current_release, new_release, file_path):
|
||||
check_call("sed -i'' -E 's/\"kernel_config_{}_([0-9.]*)\"/\"kernel_config_{}_\\1\"/g' {}"
|
||||
.format(current_release, new_release, file_path), shell=True)
|
||||
|
||||
class Freeze(object):
|
||||
class Bump(object):
|
||||
def __init__(self, cmdline_args):
|
||||
top = os.environ["ANDROID_BUILD_TOP"]
|
||||
self.new_release = cmdline_args.name
|
||||
self.current_release = cmdline_args.current
|
||||
self.new_release = cmdline_args.next
|
||||
self.configs_dir = os.path.join(top, "kernel/configs")
|
||||
self.current_release_dir = os.path.join(self.configs_dir, self.current_release)
|
||||
self.new_release_dir = os.path.join(self.configs_dir, self.new_release)
|
||||
self.interfaces_dir = os.path.join(top, "hardware/interfaces")
|
||||
self.versions = [e for e in os.listdir(self.configs_dir) if e.startswith("android-")]
|
||||
self.bugline = "Bug: {}\n".format(cmdline_args.bug) if cmdline_args.bug else ""
|
||||
self.versions = [e for e in os.listdir(self.current_release_dir) if e.startswith("android-")]
|
||||
|
||||
def run(self):
|
||||
self.move_configs()
|
||||
self.freeze_configs_in_matrices()
|
||||
self.create_current()
|
||||
self.print_summary()
|
||||
|
||||
def move_configs(self):
|
||||
os.makedirs(self.new_release_dir, exist_ok=False)
|
||||
shutil.copytree(self.current_release_dir, self.new_release_dir)
|
||||
for version in self.versions:
|
||||
src = os.path.join(self.configs_dir, version)
|
||||
dst = os.path.join(self.new_release_dir, version)
|
||||
shutil.move(src, dst)
|
||||
for file_name in os.listdir(dst):
|
||||
abs_path = os.path.join(dst, file_name)
|
||||
if not os.path.isfile(abs_path):
|
||||
continue
|
||||
year = datetime.datetime.now().year
|
||||
check_call("sed -i'' -E 's/Copyright \\(C\\) [0-9]{{4,}}/Copyright (C) {}/g' {}".format(year, abs_path), shell=True)
|
||||
replace_configs_module_name(self.new_release, abs_path)
|
||||
|
||||
check_call('git -C {} add android-* {}'.format(self.configs_dir, self.new_release), shell=True)
|
||||
check_call('git -C {} commit -m "Freeze kernel configs for {}.\n\n{}Test: builds"'.format(self.configs_dir, self.new_release, self.bugline), shell=True)
|
||||
|
||||
def freeze_configs_in_matrices(self):
|
||||
matrices_soong = "compatibility_matrices/Android.bp"
|
||||
matrices_soong_abs_path = os.path.join(self.interfaces_dir, matrices_soong)
|
||||
replace_configs_module_name(self.new_release, matrices_soong_abs_path)
|
||||
|
||||
check_call('git -C {} add {}'.format(self.interfaces_dir, matrices_soong), shell=True)
|
||||
check_call('git -C {} commit -m "Freeze kernel configs for {}.\n\n{}Test: builds"'.format(self.interfaces_dir, self.new_release, self.bugline), shell=True)
|
||||
|
||||
def create_current(self):
|
||||
check_call('git -C {} checkout HEAD~ -- android-*'.format(self.configs_dir), shell=True)
|
||||
check_call('git -C {} add android-*'.format(self.configs_dir), shell=True)
|
||||
check_call('git -C {} commit -m "Create kernel configs for current.\n\n{}Test: builds"'.format(self.configs_dir, self.bugline), shell=True)
|
||||
|
||||
def print_summary(self):
|
||||
print("*** Please submit these changes to {} branch: ***".format(self.new_release))
|
||||
check_call('git -C {} show -s --format=%B HEAD~1'.format(self.configs_dir), shell=True)
|
||||
check_call('git -C {} show -s --format=%B HEAD'.format(self.interfaces_dir), shell=True)
|
||||
print("*** Please submit these changes to master branch: ***")
|
||||
check_call('git -C {} show -s --format=%B HEAD'.format(self.configs_dir), shell=True)
|
||||
replace_configs_module_name(self.current_release, self.new_release, abs_path)
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('name', type=str, help='name of the directory (e.g. r)')
|
||||
parser.add_argument('--bug', type=str, nargs='?', help='Bug number')
|
||||
parser.add_argument('current', type=str, help='name of the current version (e.g. v)')
|
||||
parser.add_argument('next', type=str, help='name of the next version (e.g. w)')
|
||||
cmdline_args = parser.parse_args()
|
||||
|
||||
Freeze(cmdline_args).run()
|
||||
Bump(cmdline_args).run()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
Loading…
Reference in a new issue