mirror of
https://github.com/xddxdd/nix-cachyos-kernel.git
synced 2026-07-03 19:18:07 +02:00
fmt: run ruff and isort on kernel-cachyos/update.py
This commit is contained in:
parent
86a4ac1656
commit
8962a0f04a
@ -1,16 +1,19 @@
|
|||||||
import json
|
import json
|
||||||
from pathlib import Path
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
def get_srctag(variant: str = "latest") -> str:
|
def get_srctag(variant: str = "latest") -> str:
|
||||||
with tempfile.TemporaryDirectory(ignore_cleanup_errors=True) as dir:
|
with tempfile.TemporaryDirectory(ignore_cleanup_errors=True) as dir:
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["nix", "build", ".#cachyos-kernel-input-path", "-o", f"{dir}/result"], check=True
|
["nix", "build", ".#cachyos-kernel-input-path", "-o", f"{dir}/result"],
|
||||||
|
check=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
pkgbuild_path = f"linux-cachyos-{variant}" if variant != "latest" else "linux-cachyos"
|
pkgbuild_path = (
|
||||||
|
f"linux-cachyos-{variant}" if variant != "latest" else "linux-cachyos"
|
||||||
|
)
|
||||||
|
|
||||||
with open(f"{dir}/result/{pkgbuild_path}/PKGBUILD") as f:
|
with open(f"{dir}/result/{pkgbuild_path}/PKGBUILD") as f:
|
||||||
pkgbuild = f.read()
|
pkgbuild = f.read()
|
||||||
@ -33,7 +36,9 @@ def nix_sha256_to_sri(hash: str) -> str:
|
|||||||
result = subprocess.run(cmd, capture_output=True, text=True, timeout=300)
|
result = subprocess.run(cmd, capture_output=True, text=True, timeout=300)
|
||||||
|
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
raise RuntimeError(f"nix hash command failed with return code: {result.returncode}")
|
raise RuntimeError(
|
||||||
|
f"nix hash command failed with return code: {result.returncode}"
|
||||||
|
)
|
||||||
|
|
||||||
output = result.stdout.strip()
|
output = result.stdout.strip()
|
||||||
if not output:
|
if not output:
|
||||||
@ -49,7 +54,9 @@ def run_nix_prefetch_url(url: str) -> str:
|
|||||||
result = subprocess.run(cmd, capture_output=True, text=True, timeout=300)
|
result = subprocess.run(cmd, capture_output=True, text=True, timeout=300)
|
||||||
|
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
raise RuntimeError(f"nix-prefetch-url command failed with return code: {result.returncode}")
|
raise RuntimeError(
|
||||||
|
f"nix-prefetch-url command failed with return code: {result.returncode}"
|
||||||
|
)
|
||||||
|
|
||||||
output = result.stdout.strip()
|
output = result.stdout.strip()
|
||||||
if not output:
|
if not output:
|
||||||
@ -80,7 +87,9 @@ if __name__ == "__main__":
|
|||||||
current = Path.cwd()
|
current = Path.cwd()
|
||||||
while not (current / "flake.lock").exists():
|
while not (current / "flake.lock").exists():
|
||||||
if current == current.parent:
|
if current == current.parent:
|
||||||
raise RuntimeError("Could not find flake.lock in any parent directory, exiting")
|
raise RuntimeError(
|
||||||
|
"Could not find flake.lock in any parent directory, exiting"
|
||||||
|
)
|
||||||
current = current.parent
|
current = current.parent
|
||||||
|
|
||||||
output_file = current / "kernel-cachyos" / "version.json"
|
output_file = current / "kernel-cachyos" / "version.json"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user