From e298827400cf7d34bb9d54c78faa6194b89901ab Mon Sep 17 00:00:00 2001
From: Gordon Messmer <gmessmer@redhat.com>
Date: Mar 25 2026 17:46:09 +0000
Subject: Backport justfile changes from main branch


---

diff --git a/justfile b/justfile
index 4b1ce06..0a1a5e3 100644
--- a/justfile
+++ b/justfile
@@ -161,7 +161,7 @@ compose-legacy variant=default_variant:
     mkdir -p repo cache logs
     if [[ ! -f "repo/config" ]]; then
         pushd repo > /dev/null || exit 1
-        ostree init --repo . --mode=bare-user
+        ostree init --repo . --mode=archive-z2
         popd > /dev/null || exit 1
     fi
     # Set option to reduce fsync for transient builds
@@ -180,7 +180,7 @@ compose-legacy variant=default_variant:
         "--unified-core"
     )
     if [[ {{force_nocache}} == "true" ]]; then
-        ARGS+=(" --force-nocache")
+        ARGS+=("--force-nocache")
     fi
     CMD="rpm-ostree"
     if [[ ${EUID} -ne 0 ]]; then
@@ -213,20 +213,13 @@ compose-image variant=default_variant:
 
     just validate > /dev/null || (echo "Failed manifest validation" && exit 1)
 
-    mkdir -p repo cache
-    if [[ ! -f "repo/config" ]]; then
-        pushd repo > /dev/null || exit 1
-        ostree init --repo . --mode=bare-user
-        popd > /dev/null || exit 1
-    fi
-    # Set option to reduce fsync for transient builds
-    ostree --repo=repo config set 'core.fsync' 'false'
+    mkdir -p cache
 
     buildid="$(date '+%Y%m%d.0')"
     timestamp="$(date --iso-8601=sec)"
     echo "${buildid}" > .buildid
 
-    version="$(rpm-ostree compose tree --print-only --repo=repo ${variant}.yaml | jq -r '."mutate-os-release"')"
+    version="$(rpm-ostree compose tree --print-only ${variant}.yaml | jq -r '."mutate-os-release"')"
     echo "Composing ${variant_pretty} ${version}.${buildid} ..."
 
     ARGS=(
@@ -443,6 +436,74 @@ upload-container variant=default_variant arch=default_arch:
     # Cleanup private key
     rm private.key.b64 private.key
 
+# Upload a container to an anonymous registry. Useful for local builds
+upload-container-local variant=default_variant arch=default_arch:
+    #!/bin/bash
+    set -euxo pipefail
+
+    {{retry_function}}
+
+    variant={{variant}}
+    arch={{arch}}
+
+    declare -A pretty_names={{pretty_names}}
+    variant_pretty=${pretty_names[$variant]-}
+    if [[ -z $variant_pretty ]]; then
+        echo "Unknown variant"
+        exit 1
+    fi
+
+    if [[ -z ${REGISTRY+x} ]] || [[ -z ${RELEASE_REPO+x} ]]; then
+        echo "Skipping: No REGISTRY or RELEASE_REPO set"
+        exit 1
+    fi
+
+    buildid=""
+    if [[ -f ".buildid" ]]; then
+        buildid="$(< .buildid)"
+    else
+        echo "Skipping: No '.buildid' file"
+        exit 1
+    fi
+
+    version=""
+    if [[ "$(git rev-parse --abbrev-ref HEAD)" == "main" ]] || [[ -f "fedora-rawhide.repo" ]]; then
+        version="rawhide"
+    else
+        version="$(rpm-ostree compose tree --print-only --repo=repo ${variant}.yaml | jq -r '."mutate-os-release"')"
+    fi
+
+    if [[ -n ${CI_REGISTRY_USER+x} ]] || [[ -n ${CI_REGISTRY_PASSWORD+x} ]]; then
+        # Login to the registry
+        retry 5 60 skopeo login --username "${CI_REGISTRY_USER}" --password "${CI_REGISTRY_PASSWORD}" "${REGISTRY}"
+    fi
+
+    image="${REGISTRY}/${RELEASE_REPO}/${variant}"
+
+    # Only append arch suffix if requested
+    suffix=""
+    if [[ ${arch} != "default" ]]; then
+        suffix="-${arch}"
+    fi
+
+    SKOPEO_ARGS=(
+        "--retry-times" "3"
+        "--dest-tls-verify=false"
+    )
+
+    # Support for the zstd:chunked format is not ready yet
+    SKOPEO_ARGS+=("--dest-compress-format")
+    if [[ ${version} == "rawhide" ]] || [[ ${version} == "43" ]]; then
+        SKOPEO_ARGS+=("zstd")
+    else
+        SKOPEO_ARGS+=("gzip")
+    fi
+
+    # Push fully versioned tag (major version, build date/id, arch)
+    retry 5 60 skopeo copy "${SKOPEO_ARGS[@]}" \
+        "oci-archive:${variant}.ociarchive" \
+        "docker://${image}:${version}.${buildid}${suffix}"
+
 # Create a multi-arch manifest for a given variant, push it to a registry and sign it
 multi-arch-manifest variant=default_variant:
     #!/bin/bash

