initial commit
This commit is contained in:
64
builder.sh
Executable file
64
builder.sh
Executable file
@@ -0,0 +1,64 @@
|
||||
#!/bin/bash
|
||||
set -euxo pipefail
|
||||
|
||||
# Usage: ./builder.sh <image-name> <version>
|
||||
if [[ $# -lt 2 ]]; then
|
||||
echo "Usage: $0 <image-name> <version>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
IMAGE="$1"
|
||||
VERSION="$2"
|
||||
|
||||
IMAGE_DIR="images/${IMAGE}"
|
||||
MANIFEST="${IMAGE_DIR}/manifest.yaml"
|
||||
OUTPUT="${IMAGE_DIR}/manifest.ociarchive"
|
||||
REF="images/${IMAGE}/${VERSION}"
|
||||
|
||||
# --- CHECKS ---
|
||||
if [[ ! -d "$IMAGE_DIR" ]]; then
|
||||
echo "Image directory not found: $IMAGE_DIR"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "$MANIFEST" ]]; then
|
||||
echo "Manifest not found: $MANIFEST"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# --- PREPARE OSTREE REPO ---
|
||||
mkdir -p repo cache
|
||||
if [[ ! -f "repo/config" ]]; then
|
||||
pushd repo >/dev/null
|
||||
ostree init --repo=. --mode=bare-user
|
||||
popd >/dev/null
|
||||
fi
|
||||
|
||||
ostree --repo=repo config set core.fsync false
|
||||
|
||||
# --- VERSIONING ---
|
||||
buildid="$(date '+%Y%m%d.0')"
|
||||
timestamp="$(date --iso-8601=sec)"
|
||||
echo "${buildid}" > .buildid
|
||||
|
||||
echo "Composing ${VERSION}.${buildid} ..."
|
||||
|
||||
# shared repos
|
||||
cp images/shared/*.repo "${IMAGE_DIR}"
|
||||
|
||||
# Ensure manifest has correct ref and releasever
|
||||
sed -i '/^ref:/d' "$MANIFEST"
|
||||
sed -i '/^releasever:/d' "$MANIFEST"
|
||||
sed -i "1i releasever: ${VERSION}" "$MANIFEST"
|
||||
sed -i "1i ref: ${REF}" "$MANIFEST"
|
||||
# --- COMPOSE IMAGE ---
|
||||
ARGS=(
|
||||
"--cachedir=cache"
|
||||
"--initialize"
|
||||
"--max-layers=96"
|
||||
)
|
||||
|
||||
rpm-ostree compose image \
|
||||
"${ARGS[@]}" \
|
||||
"$MANIFEST" \
|
||||
"$OUTPUT"
|
||||
Reference in New Issue
Block a user