linux: more update-script cleanups/fixes

- special case linux-testing fetching
- use hash instead of sha256 everywhere
- respect COMMIT envvar

This causes rebuilds, so should go in with the next bump probably.

K900 c08efe14 c792f6b8

+54 -23
+10 -10
pkgs/os-specific/linux/kernel/kernels-org.json
··· 1 1 { 2 2 "testing": { 3 - "version": "6.6-rc1", 4 - "hash": "02zh3dnikyhhlas9xccia963d4yqmzq0m4b8s10x8mjng3na45hd" 3 + "version": "6.6-rc2", 4 + "hash": "sha256:1hbva5vsfi48h82ll4kmhzm5hxp7340bj2smwgvjikam26icaj54" 5 5 }, 6 6 "6.5": { 7 7 "version": "6.5.4", 8 - "hash": "0s8nzd8yaq06bq8byk7aakbk95gh0rhlif26h1biw94v48anrxxx" 8 + "hash": "sha256:0s8nzd8yaq06bq8byk7aakbk95gh0rhlif26h1biw94v48anrxxx" 9 9 }, 10 10 "6.4": { 11 11 "version": "6.4.16", 12 - "hash": "0zgj1z97jyx7wf12zrnlcp0mj4cl43ais9qsy6dh1jwylf2fq9ln" 12 + "hash": "sha256:0zgj1z97jyx7wf12zrnlcp0mj4cl43ais9qsy6dh1jwylf2fq9ln" 13 13 }, 14 14 "6.1": { 15 15 "version": "6.1.54", 16 - "hash": "09sfrq2l8f777mx2n9mhb6bgz1064bl04921byqnmk87si31w653" 16 + "hash": "sha256:09sfrq2l8f777mx2n9mhb6bgz1064bl04921byqnmk87si31w653" 17 17 }, 18 18 "5.15": { 19 19 "version": "5.15.132", 20 - "hash": "1b0qjsaqjw2rk86shmmrj2aasblkn27acjmc761vnjg7sv2baxs1" 20 + "hash": "sha256:1b0qjsaqjw2rk86shmmrj2aasblkn27acjmc761vnjg7sv2baxs1" 21 21 }, 22 22 "5.10": { 23 23 "version": "5.10.195", 24 - "hash": "0n4vg2i9sq89wnz85arlyvwysh9s83cgzs5bk2wh98bivi5fwfs1" 24 + "hash": "sha256:0n4vg2i9sq89wnz85arlyvwysh9s83cgzs5bk2wh98bivi5fwfs1" 25 25 }, 26 26 "5.4": { 27 27 "version": "5.4.256", 28 - "hash": "0fim5q9xakwnjfg48bpsic9r2r8dvrjlalqqkm9vh1rml9mhi967" 28 + "hash": "sha256:0fim5q9xakwnjfg48bpsic9r2r8dvrjlalqqkm9vh1rml9mhi967" 29 29 }, 30 30 "4.19": { 31 31 "version": "4.19.294", 32 - "hash": "03x0xsb8a369zdr81hg6xdl5n5v48k6iwnhj6r29725777lvvbfc" 32 + "hash": "sha256:03x0xsb8a369zdr81hg6xdl5n5v48k6iwnhj6r29725777lvvbfc" 33 33 }, 34 34 "4.14": { 35 35 "version": "4.14.325", 36 - "hash": "117p1mdha57f6d3kdwac9jrbmib7g77q4xhir8ghl6fmrs1f2sav" 36 + "hash": "sha256:117p1mdha57f6d3kdwac9jrbmib7g77q4xhir8ghl6fmrs1f2sav" 37 37 } 38 38 }
+17 -8
pkgs/os-specific/linux/kernel/mainline.nix
··· 1 - { branch, lib, fetchurl, buildLinux, ... } @ args: 1 + { branch, lib, fetchurl, fetchzip, buildLinux, ... } @ args: 2 2 3 3 let 4 4 allKernels = builtins.fromJSON (builtins.readFile ./kernels-org.json); 5 5 thisKernel = allKernels.${branch}; 6 + inherit (thisKernel) version; 6 7 7 - args' = (builtins.removeAttrs args ["branch"]) // rec { 8 - inherit (thisKernel) version; 8 + src = 9 + # testing kernels are a special case because they don't have tarballs on the CDN 10 + if branch == "testing" 11 + then fetchzip { 12 + url = "https://git.kernel.org/torvalds/t/linux-${version}.tar.gz"; 13 + inherit (thisKernel) hash; 14 + } 15 + else fetchurl { 16 + url = "mirror://kernel/linux/kernel/v${lib.versions.major version}.x/linux-${version}.tar.xz"; 17 + inherit (thisKernel) hash; 18 + }; 19 + 20 + args' = (builtins.removeAttrs args ["branch"]) // { 21 + inherit src version; 22 + 9 23 modDirVersion = lib.versions.pad 3 version; 10 24 extraMeta.branch = branch; 11 - 12 - src = fetchurl { 13 - url = "mirror://kernel/linux/kernel/v${lib.versions.major version}.x/linux-${version}.tar.xz"; 14 - sha256 = thisKernel.hash; 15 - }; 16 25 } // (args.argsOverride or {}); 17 26 in 18 27 buildLinux args'
+27 -5
pkgs/os-specific/linux/kernel/update-mainline.py
··· 9 9 import subprocess 10 10 import urllib.request 11 11 import sys 12 + import os 12 13 13 14 14 15 HERE = pathlib.Path(__file__).parent ··· 24 25 class KernelRelease: 25 26 nature: KernelNature 26 27 version: str 28 + branch: str 27 29 date: str 28 30 link: str 29 31 eol: bool = False ··· 43 45 assert link is not None, f'link for kernel {version} is non-existent' 44 46 eol = bool(release.find(class_='eolkernel')) 45 47 46 - return KernelRelease(nature=nature, version=version, date=date, link=link, eol=eol) 48 + return KernelRelease( 49 + nature=nature, 50 + branch=get_branch(version), 51 + version=version, 52 + date=date, 53 + link=link, 54 + eol=eol, 55 + ) 47 56 48 57 def get_branch(version: str): 49 58 # This is a testing kernel. ··· 53 62 major, minor, *_ = version.split(".") 54 63 return f"{major}.{minor}" 55 64 65 + def get_hash(kernel: KernelRelease): 66 + if kernel.branch == "testing": 67 + args = ["--unpack"] 68 + else: 69 + args = [] 56 70 57 - def get_hash(url: str): 58 - return subprocess.check_output(["nix-prefetch-url", url]).decode().strip() 71 + hash = ( 72 + subprocess.check_output(["nix-prefetch-url", kernel.link] + args) 73 + .decode() 74 + .strip() 75 + ) 76 + return f"sha256:{hash}" 59 77 60 78 61 79 def commit(message): ··· 91 109 92 110 print(message) 93 111 94 - all_kernels[branch] = {"version": kernel.version, "hash": get_hash(kernel.link)} 112 + all_kernels[branch] = { 113 + "version": kernel.version, 114 + "hash": get_hash(kernel), 115 + } 95 116 96 117 with VERSIONS_FILE.open("w") as fd: 97 118 json.dump(all_kernels, fd, indent=4) 98 119 fd.write("\n") # makes editorconfig happy 99 120 100 - commit(message) 121 + if os.environ.get("COMMIT") == "1": 122 + commit(message) 101 123 102 124 103 125 if __name__ == "__main__":