return run(cmd, check=False).returncode == 0
-def strip_suffixes(path: Path) -> Path:
- while path.suffix in {
- ".xz",
- ".zstd",
- ".raw",
- ".tar",
- ".cpio",
- }:
- path = path.with_suffix("")
-
- return path
-
-
def find_image_version(args: argparse.Namespace) -> None:
if args.image_version is not None:
return
import logging
import os
import shutil
-import urllib.parse
-import urllib.request
from collections.abc import Iterable, Mapping, Sequence
from pathlib import Path
from textwrap import dedent
return int(release) >= int(threshold)
-def url_exists(url: str) -> bool:
- req = urllib.request.Request(url, method="HEAD")
- try:
- if urllib.request.urlopen(req):
- return True
- except Exception:
- pass
- return False
-
-
class Repo(NamedTuple):
id: str
url: str
return f"{Style.red}{text}{Style.reset}"
-def color_warning(text: Any) -> str:
- return f"{Style.yellow}{text}{Style.reset}"
-
-
def log_step(text: str) -> None:
prefix = " " * LEVEL
+++ /dev/null
-# SPDX-License-Identifier: LGPL-2.1+
-
-from pathlib import Path
-
-from mkosi.config import strip_suffixes
-
-
-def test_strip_suffixes() -> None:
- assert strip_suffixes(Path("home/test.zstd")) == Path("home/test")
- assert strip_suffixes(Path("home/test.xz")) == Path("home/test")
- assert strip_suffixes(Path("home/test.raw")) == Path("home/test")
- assert strip_suffixes(Path("home/test.tar")) == Path("home/test")
- assert strip_suffixes(Path("home/test.cpio")) == Path("home/test")
- assert strip_suffixes(Path("home.xz/test.xz")) == Path("home.xz/test")
- assert strip_suffixes(Path("home.xz/test")) == Path("home.xz/test")
- assert strip_suffixes(Path("home.xz/test.txt")) == Path("home.xz/test.txt")