Skip to content

Commit

Permalink
Revert "build-driver: copy sources.tar in release mode"
Browse files Browse the repository at this point in the history
  • Loading branch information
zeha authored Dec 18, 2024
1 parent 67206d6 commit 41631e7
Showing 1 changed file with 14 additions and 46 deletions.
60 changes: 14 additions & 46 deletions build-driver/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ class JobProperties:
version: str
release_name: str
grml_name: str
iso_name: str # name of the resulting .ISO files
sources_name: str # name of the resulting sources tarball
isoname: str


def usage(program_name):
Expand Down Expand Up @@ -96,7 +95,7 @@ def run_grml_live(
version: str,
release_name: str,
grml_name: str,
iso_name: str,
isoname: str,
old_iso_path: Path | None,
):
env = dict(os.environ)
Expand Down Expand Up @@ -135,7 +134,7 @@ def run_grml_live(
"-g",
grml_name,
"-i",
iso_name,
isoname,
"-o",
output_dir,
]
Expand Down Expand Up @@ -224,7 +223,7 @@ def download_file(url: str, local_path: Path):
run_x(["curl", "-#fSL", "--output", local_path, url])


def skip_sources_requested(build_config: dict, env: dict) -> bool:
def should_skip_sources(build_config: dict, env: dict) -> bool:
if env.get("SKIP_SOURCES", "") == "1":
return True
if build_config.get("skip_sources", False) is True:
Expand Down Expand Up @@ -266,7 +265,7 @@ def build(
job_properties.version,
job_properties.release_name,
job_properties.grml_name,
job_properties.iso_name,
job_properties.isoname,
old_iso_path,
)

Expand Down Expand Up @@ -350,7 +349,10 @@ def download_old_dpkg_list_last_release(tmp_dir: Path, last_release_version: str
return None


def download_old_iso(tmp_dir: Path, old_iso_url: str) -> Path | None:
def download_old_iso(tmp_dir: Path, old_iso_url: str | None) -> Path | None:
if old_iso_url is None:
return None

path = tmp_dir / "old.iso"

with ci_section(f"Downloading old ISO {old_iso_url} to {path!s}"):
Expand All @@ -359,22 +361,6 @@ def download_old_iso(tmp_dir: Path, old_iso_url: str) -> Path | None:
return path


def download_old_sources(tmp_dir: Path, old_iso_url: str) -> Path | None:
path = tmp_dir / "old-sources.tar"

# https://.../2024-12-18_10_03_44/grml_isos/grml...iso
# => https://.../2024-12-18_10_03_44/ , _, grml...iso
old_base_url, _, old_iso_name = old_iso_url.rsplit("/", 2)
# grml-something.iso => grml-something-sources.tar
old_sources_name = old_iso_name.rsplit(".", 1)[0] + "-sources.tar"
old_sources_url = f"{old_base_url}/{old_sources_name}"

with ci_section(f"Downloading old Sources {old_sources_url} to {path!s}"):
download_file(old_sources_url, path)

return path


def main(program_name: str, argv: list[str]) -> int:
print(f"I: {program_name} started with {argv=}")
try:
Expand Down Expand Up @@ -412,12 +398,8 @@ def main(program_name: str, argv: list[str]) -> int:

build_config = load_config(build_config_file)

skip_sources = skip_sources_requested(build_config, dict(os.environ))
# skip SOURCES in release mode as grml-live would re-download all sources,
# possibly mismatching the versions. Also we do not prepare a working DNS,
# so it would just fail. In the future, grml-live should support reusing
# the sources tarball and fetching just the necessary differences.
classes = get_grml_live_classes(arch, flavor, classes_for_mode, skip_sources or build_mode == "release")
skip_sources = should_skip_sources(build_config, dict(os.environ))
classes = get_grml_live_classes(arch, flavor, classes_for_mode, skip_sources)

build_grml_name = f"grml-{flavor}-{arch}"
last_release_version = build_config["last_release"]
Expand All @@ -432,7 +414,6 @@ def main(program_name: str, argv: list[str]) -> int:
if build_mode == "release":
old_iso_url = build_config["base_iso"][flavor][arch]
build_version = build_config["release_version"]
artifact_basename = f"grml-{flavor}-{build_version}-{arch}"

job_properties = JobProperties(
job_timestamp=datetime.datetime.now(),
Expand All @@ -446,8 +427,7 @@ def main(program_name: str, argv: list[str]) -> int:
# f.e. "Glumpad Grumbirn"
release_name=build_config["release_name"],
grml_name=build_grml_name,
iso_name=f"{artifact_basename}.iso",
sources_name=f"{artifact_basename}-sources.tar",
isoname=f"grml-{flavor}-{build_version}-{arch}.iso",
)

elif build_mode == "daily":
Expand All @@ -456,7 +436,6 @@ def main(program_name: str, argv: list[str]) -> int:
CI_PIPELINE_IID = os.getenv("CI_PIPELINE_IID", "0")
build_version = f"d{date_stamp}b{CI_PIPELINE_IID}"
build_release_name = f"daily{date_stamp}build{CI_PIPELINE_IID}{debian_suite}"
artifact_basename = f"grml-{flavor}-{build_release_name}-{arch}"

job_properties = JobProperties(
job_timestamp=datetime.datetime.now(),
Expand All @@ -467,8 +446,7 @@ def main(program_name: str, argv: list[str]) -> int:
version=build_version,
release_name=build_release_name,
grml_name=build_grml_name,
iso_name=f"{artifact_basename}.iso",
sources_name=f"{artifact_basename}-sources.tar",
isoname=f"grml-{flavor}-{build_release_name}-{arch}.iso",
)

else:
Expand Down Expand Up @@ -496,14 +474,7 @@ def main(program_name: str, argv: list[str]) -> int:

old_dpkg_list_previous_build = cache_dir / "dpkg.list"
old_dpkg_list_last_release = download_old_dpkg_list_last_release(tmp_dir, last_release_version, flavor)
if old_iso_url is None:
old_iso_path = None
else:
old_iso_path = download_old_iso(tmp_dir, old_iso_url)
if skip_sources or old_iso_url is None:
old_sources_path = None
else:
old_sources_path = download_old_sources(tmp_dir, old_iso_url)
old_iso_path = download_old_iso(tmp_dir, old_iso_url)

with results_mover(build_dir, output_dir):
build(
Expand All @@ -521,9 +492,6 @@ def main(program_name: str, argv: list[str]) -> int:
old_dpkg_list_previous_build.parent.mkdir(exist_ok=True)
shutil.copyfile(new_dpkg_list, old_dpkg_list_previous_build)

if old_sources_path:
old_sources_path.rename(build_dir / job_properties.sources_name)

print("I: Success.")

return 0
Expand Down

0 comments on commit 41631e7

Please sign in to comment.