chore(kernel-update): clarify dir names
Signed-off-by: Martin Matous <m@matous.dev>
This commit is contained in:
parent
77bec8cf55
commit
12bb69a61c
1 changed files with 19 additions and 19 deletions
|
|
@ -37,11 +37,11 @@ def rollback_impl(boot_dir: Path, files: Dict[str, Path]) -> None:
|
||||||
shutil.copy2(src, dst)
|
shutil.copy2(src, dst)
|
||||||
|
|
||||||
|
|
||||||
def update_config(old_path: Path, new_path: Path, make_cmd: List[str]) -> None:
|
def update_config(old_dir: Path, new_dir: Path, make_cmd: List[str]) -> None:
|
||||||
if old_path == new_path:
|
if old_dir == new_dir:
|
||||||
return
|
return
|
||||||
old_config = old_path/'.config'
|
old_config = old_dir/'.config'
|
||||||
new_config = new_path/'.config'
|
new_config = new_dir/'.config'
|
||||||
while new_config.is_file():
|
while new_config.is_file():
|
||||||
response = input('New config present. Overwrite? [y/N]').strip().lower()
|
response = input('New config present. Overwrite? [y/N]').strip().lower()
|
||||||
if response == 'y':
|
if response == 'y':
|
||||||
|
|
@ -53,12 +53,12 @@ def update_config(old_path: Path, new_path: Path, make_cmd: List[str]) -> None:
|
||||||
print(f'Copying config from {old_config} to {new_config}')
|
print(f'Copying config from {old_config} to {new_config}')
|
||||||
shutil.copy2(old_config, new_config)
|
shutil.copy2(old_config, new_config)
|
||||||
|
|
||||||
print(f'Setting symlink to {new_path}')
|
print(f'Setting symlink to {new_dir}')
|
||||||
subprocess.run(['eselect', 'kernel', 'set', new_path.name])
|
subprocess.run(['eselect', 'kernel', 'set', new_dir.name])
|
||||||
print(f'Migrating config options')
|
print(f'Migrating config options')
|
||||||
migrate = make_cmd + ['-C', new_path.as_posix(), 'oldconfig']
|
migrate = make_cmd + ['-C', new_dir.as_posix(), 'oldconfig']
|
||||||
subprocess.run(migrate)
|
subprocess.run(migrate)
|
||||||
menuconfig = make_cmd + ['-C', new_path.as_posix(), 'menuconfig']
|
menuconfig = make_cmd + ['-C', new_dir.as_posix(), 'menuconfig']
|
||||||
while True:
|
while True:
|
||||||
subprocess.run(menuconfig)
|
subprocess.run(menuconfig)
|
||||||
response = input('Stop editing? [Y/n]').strip().lower()
|
response = input('Stop editing? [Y/n]').strip().lower()
|
||||||
|
|
@ -70,8 +70,8 @@ def update_config(old_path: Path, new_path: Path, make_cmd: List[str]) -> None:
|
||||||
print("unrecognized option {}", response)
|
print("unrecognized option {}", response)
|
||||||
|
|
||||||
|
|
||||||
def compile_kernel(new_path: Path, make_cmd: List[str]) -> None:
|
def compile_kernel(new_dir: Path, make_cmd: List[str]) -> None:
|
||||||
cc = make_cmd + ['-C', new_path.as_posix()]
|
cc = make_cmd + ['-C', new_dir.as_posix()]
|
||||||
subprocess.run(cc)
|
subprocess.run(cc)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -125,9 +125,9 @@ def rollback_kernel(boot_dir: Path, boot_files: Dict[str, Path], _args: Any) ->
|
||||||
rollback_impl(boot_dir, boot_files)
|
rollback_impl(boot_dir, boot_files)
|
||||||
|
|
||||||
def update_kernel(boot_dir: Path, boot_files: Dict[str, Path], args: Any) -> None:
|
def update_kernel(boot_dir: Path, boot_files: Dict[str, Path], args: Any) -> None:
|
||||||
old_path = linux_folder(SRC_DIR, args.old_version)
|
old_dir = linux_folder(SRC_DIR, args.old_version)
|
||||||
new_path = linux_folder(SRC_DIR, args.new_version)
|
new_dir = linux_folder(SRC_DIR, args.new_version)
|
||||||
new_version = new_path.name # rename to new_folder
|
new_version = new_dir.name
|
||||||
make_cmd = ['make', f'-j{len(os.sched_getaffinity(0))}']
|
make_cmd = ['make', f'-j{len(os.sched_getaffinity(0))}']
|
||||||
clang_env = ['CC=clang', 'LD=ld.lld', 'LLVM=1', 'LLVM_IAS=1']
|
clang_env = ['CC=clang', 'LD=ld.lld', 'LLVM=1', 'LLVM_IAS=1']
|
||||||
|
|
||||||
|
|
@ -136,17 +136,17 @@ def update_kernel(boot_dir: Path, boot_files: Dict[str, Path], args: Any) -> Non
|
||||||
none_selected = not (args.backup or args.config or args.compile or args.install or args.rollback)
|
none_selected = not (args.backup or args.config or args.compile or args.install or args.rollback)
|
||||||
if none_selected:
|
if none_selected:
|
||||||
backup_kernel(BOOT_DIR, BOOT_FILES)
|
backup_kernel(BOOT_DIR, BOOT_FILES)
|
||||||
update_config(old_path, new_path, make_cmd)
|
update_config(old_dir, new_dir, make_cmd)
|
||||||
compile_kernel(new_path, make_cmd)
|
compile_kernel(new_dir, make_cmd)
|
||||||
install_kernel(new_path, BOOT_DIR, BOOT_FILES, make_cmd)
|
install_kernel(new_dir, BOOT_DIR, BOOT_FILES, make_cmd)
|
||||||
if args.backup:
|
if args.backup:
|
||||||
backup_kernel(BOOT_DIR, BOOT_FILES)
|
backup_kernel(BOOT_DIR, BOOT_FILES)
|
||||||
if args.config:
|
if args.config:
|
||||||
update_config(old_path, new_path, make_cmd)
|
update_config(old_dir, new_dir, make_cmd)
|
||||||
if args.compile:
|
if args.compile:
|
||||||
compile_kernel(new_path, make_cmd)
|
compile_kernel(new_dir, make_cmd)
|
||||||
if args.install:
|
if args.install:
|
||||||
install_kernel(new_path, BOOT_DIR, BOOT_FILES, make_cmd)
|
install_kernel(new_dir, BOOT_DIR, BOOT_FILES, make_cmd)
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
parser = argparse.ArgumentParser(description='Convenience for manual kernel updates')
|
parser = argparse.ArgumentParser(description='Convenience for manual kernel updates')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue