From 2f0632547afb6fb48442820ed755b7a1f64e5d40 Mon Sep 17 00:00:00 2001 From: R0flcopt3r <12752060+R0flcopt3r@users.noreply.github.com> Date: Mon, 17 Mar 2025 01:15:55 +0100 Subject: feat: build in tempdir and move files on success (#82) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: build in tempdir and move files on success Before it would delete your outputs before starting the build. That means miss-typing the command for example could lead to losing data. This also creates separate folders for each type to avoid collision. * fix: tempdir naming this follows the convention set in the `_rootful_load_image` target. * fix: delete output folder in clean target * fix: move contents of temp build directory This ensures a flatter folder structure, bib allready seem to ensure there aren't any file name collisions. output folder would look like this after building a raw and qcow2. output ├── image │   └── disk.raw ├── manifest-qcow2.json ├── manifest-raw.json └── qcow2 └── disk.qcow2 * fix: overwrite previous output directory From conversations in https://github.com/ublue-os/image-template/pull/82 this is the wanted behaviour for this project. * revert: overwrite previous output directory This reverts commit 75448d72fa624cea01524d5651c926ae772460bf. * chore(gitignore): ensure build directories are not showing up on diffs --------- Co-authored-by: Tulip Blossom --- Justfile | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'Justfile') diff --git a/Justfile b/Justfile index f12166c..000a0c6 100644 --- a/Justfile +++ b/Justfile @@ -45,6 +45,7 @@ clean: rm -f previous.manifest.json rm -f changelog.md rm -f output.env + rm -f output/ # Sudo Clean Repo [group('Utility')] @@ -186,15 +187,6 @@ _build-bib $target_image $tag $type $config: (_rootful_load_image target_image t #!/usr/bin/env bash set -euo pipefail - mkdir -p "output" - - echo "Cleaning up previous build" - if [[ $type == iso ]]; then - sudo rm -rf "output/bootiso" || true - else - sudo rm -rf "output/${type}" || true - fi - args="--type ${type} " args+="--use-librepo=True" @@ -202,6 +194,8 @@ _build-bib $target_image $tag $type $config: (_rootful_load_image target_image t args+=" --local" fi + BUILDTMP=$(mktemp -p "${PWD}" -d -t _build-bib.XXXXXXXXXX) + sudo podman run \ --rm \ -it \ @@ -210,13 +204,16 @@ _build-bib $target_image $tag $type $config: (_rootful_load_image target_image t --net=host \ --security-opt label=type:unconfined_t \ -v $(pwd)/${config}:/config.toml:ro \ - -v $(pwd)/output:/output \ + -v $BUILDTMP:/output \ -v /var/lib/containers/storage:/var/lib/containers/storage \ "${bib_image}" \ ${args} \ "${target_image}:${tag}" - sudo chown -R $USER:$USER output + mkdir -p output + sudo mv -f $BUILDTMP/* output/ + sudo rmdir $BUILDTMP + sudo chown -R $USER:$USER output/ # Podman builds the image from the Containerfile and creates a bootable image # Parameters: -- cgit v1.2.3