Merge pull request #277708 from Ma27/min-supported-kernel

linux: avoid re-adding unsupported kernel branches (4.14) in this case in updater scripts

authored by K900 and committed by GitHub 7632cf76 da93dfdc

+33 -7
+9 -2
pkgs/os-specific/linux/kernel/hardened/update.py
··· 1 1 #! /usr/bin/env nix-shell 2 - #! nix-shell -i python -p "python3.withPackages (ps: [ps.pygithub])" git gnupg 2 + #! nix-shell -i python -p "python3.withPackages (ps: [ps.pygithub ps.packaging])" git gnupg 3 3 4 4 # This is automatically called by ../update.sh. 5 5 ··· 27 27 from github import Github 28 28 from github.GitRelease import GitRelease 29 29 30 + from packaging.version import parse as parse_version, Version 31 + 30 32 VersionComponent = Union[int, str] 31 33 Version = List[VersionComponent] 32 34 ··· 39 41 }) 40 42 41 43 44 + def read_min_kernel_branch() -> List[str]: 45 + with open(NIXPKGS_KERNEL_PATH / "kernels-org.json") as f: 46 + return list(parse_version(sorted(json.load(f).keys())[0]).release) 47 + 48 + 42 49 @dataclass 43 50 class ReleaseInfo: 44 51 version: Version ··· 51 58 HARDENED_GITHUB_REPO = "anthraxx/linux-hardened" 52 59 HARDENED_TRUSTED_KEY = HERE / "anthraxx.asc" 53 60 HARDENED_PATCHES_PATH = HERE / "patches.json" 54 - MIN_KERNEL_VERSION: Version = [4, 14] 61 + MIN_KERNEL_VERSION: Version = read_min_kernel_branch() 55 62 56 63 57 64 def run(*args: Union[str, Path]) -> subprocess.CompletedProcess[bytes]:
-4
pkgs/os-specific/linux/kernel/kernels-org.json
··· 27 27 "version": "4.19.303", 28 28 "hash": "sha256:0dlbl47xs7z4yf9cxbxqzd7zs1f9070jr6ck231wgppa6lwwwb82" 29 29 }, 30 - "4.14": { 31 - "version": "4.14.334", 32 - "hash": "sha256:0iaaqdkszmfarvjfszc9rf7y9zsv3w82934xmvmzmsbiz86547ca" 33 - }, 34 30 "6.6": { 35 31 "version": "6.6.8", 36 32 "hash": "sha256:05i4ayj9wyjkd1s8ixx7bxwcyagqyx8rhj1zvbc3cjqyw4sc8djh"
+24 -1
pkgs/os-specific/linux/kernel/update-mainline.py
··· 1 1 #!/usr/bin/env nix-shell 2 - #!nix-shell -i python3 -p "python3.withPackages (ps: [ ps.beautifulsoup4 ps.lxml ])" 2 + #!nix-shell -i python3 -p "python3.withPackages (ps: [ ps.beautifulsoup4 ps.lxml ps.packaging ])" 3 3 import json 4 4 import os 5 5 import pathlib ··· 10 10 from enum import Enum 11 11 12 12 from bs4 import BeautifulSoup, NavigableString, Tag 13 + from packaging.version import parse as parse_version, Version 14 + from typing import List 13 15 14 16 HERE = pathlib.Path(__file__).parent 15 17 ROOT = HERE.parent.parent.parent.parent ··· 80 82 return f"sha256:{hash}" 81 83 82 84 85 + def get_oldest_branch() -> Version: 86 + with open(VERSIONS_FILE) as f: 87 + return parse_version(sorted(json.load(f).keys())[0]) 88 + 89 + 90 + def predates_oldest_branch(oldest: Version, to_compare: str) -> bool: 91 + if to_compare == "testing": 92 + return False 93 + 94 + return parse_version(to_compare) < oldest 95 + 96 + 83 97 def commit(message): 84 98 return subprocess.check_call(["git", "commit", "-m", message, VERSIONS_FILE]) 85 99 ··· 97 111 parsed_releases = filter(None, [parse_release(release) for release in releases]) 98 112 all_kernels = json.load(VERSIONS_FILE.open()) 99 113 114 + oldest_branch = get_oldest_branch() 115 + 100 116 for kernel in parsed_releases: 101 117 branch = get_branch(kernel.version) 102 118 nixpkgs_branch = branch.replace(".", "_") ··· 104 120 old_version = all_kernels.get(branch, {}).get("version") 105 121 if old_version == kernel.version: 106 122 print(f"linux_{nixpkgs_branch}: {kernel.version} is latest, skipping...") 123 + continue 124 + 125 + if predates_oldest_branch(oldest_branch, kernel.branch): 126 + print( 127 + f"{kernel.branch} is too old and not supported anymore, skipping...", 128 + file=sys.stderr 129 + ) 107 130 continue 108 131 109 132 if old_version is None: