fix(kernel-update): handle ebuild revisions

Signed-off-by: Martin Matous <m@matous.dev>
This commit is contained in:
Martin Matous 2022-03-29 16:23:56 +02:00
parent 3ad6ce63c4
commit 77bec8cf55
Signed by: mmatous
GPG key ID: 8BED4CD352953224

View file

@ -7,7 +7,6 @@ import shutil
import subprocess import subprocess
import sys import sys
from packaging.version import Version
from pathlib import Path from pathlib import Path
from typing import Any, Dict, List, Tuple from typing import Any, Dict, List, Tuple
@ -100,7 +99,12 @@ def install_kernel(kernel_dir: Path, boot_dir: Path, boot_files: Dict[str, Path]
def linux_folder(src_dir: Path, version: str) -> Path: def linux_folder(src_dir: Path, version: str) -> Path:
return (src_dir / (f'linux-{version}-gentoo')) revision = ''
version = version.split('-')
if len(version) > 1:
revision = '-' + version[1]
version = version[0]
return (src_dir / (f'linux-{version}-gentoo{revision}'))
def module_check(boot_dir: Path, boot_files: Dict[str, Path]) -> Tuple[bool, Path]: def module_check(boot_dir: Path, boot_files: Dict[str, Path]) -> Tuple[bool, Path]:
@ -172,12 +176,8 @@ def main() -> None:
update.add_argument( update.add_argument(
'--install', '-i', action='store_true', '--install', '-i', action='store_true',
help='Install new kernel') help='Install new kernel')
update.add_argument( update.add_argument('old_version', help='Old kernel version')
'old_version', type=Version, update.add_argument('new_version', help='New kernel version')
help='Old kernel version')
update.add_argument(
'new_version', type=Version,
help='New kernel version')
update.set_defaults(func=update_kernel) update.set_defaults(func=update_kernel)
args = parser.parse_args() args = parser.parse_args()