Skip to content

Commit a8bdd92

Browse files
authored
remove build-fix.sh (#5)
* remove build-fix.sh simplify sudoif * fix justfile * Update create-release.yml * consolidate desktop/server changelogs * control set -x in builds * quiet local builds * set -x if id == 0 * fix justfile * explicitly specify incus dependencies * add back distrobuilder * control set_x * absolute path justfile * Revert "absolute path justfile" This reverts commit b64cca8. * improve merge-changelog * fetch everything for tags * remove UCORE_MATRIX * fix variable name.
1 parent 9253c33 commit a8bdd92

19 files changed

+121
-297
lines changed

.github/workflows/build-image.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ concurrency:
1616
env:
1717
IMAGE_REGISTRY: ghcr.io/m2giles
1818
IMAGE_NAME: m2os
19+
SET_X: 1
1920

2021
jobs:
2122
build-image:

.github/workflows/build.yml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,11 @@ jobs:
4242
images: '["ucore", "ucore-nvidia"]'
4343
image_flavor: Server
4444

45-
changelogs-server-stable:
46-
name: Server Changelogs
47-
uses: ./.github/workflows/changelogs.yml
48-
secrets: inherit
49-
needs: build-image-server
50-
with:
51-
target: ucore
52-
5345
build-iso-desktop:
5446
name: Desktop ISOs
5547
uses: ./.github/workflows/build-iso.yml
5648
secrets: inherit
57-
needs: build-image-desktop
49+
needs: [build-image-desktop, build-image-server]
5850
with:
5951
images: '["aurora", "aurora-nvidia", "bluefin", "bluefin-nvidia", "cosmic", "cosmic-nvidia"]'
6052
image_flavor: Desktop
@@ -70,5 +62,5 @@ jobs:
7062

7163
create-release:
7264
name: Create Release
73-
needs: [build-iso-desktop, build-iso-bazzite, changelogs-server-stable]
65+
needs: [build-iso-desktop, build-iso-bazzite]
7466
uses: ./.github/workflows/create-release.yml

.github/workflows/create-release.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
permissions:
1111
contents: write
1212

13+
env:
14+
SET_X: 1
15+
1316
jobs:
1417
create-release:
1518
name: Create Release
@@ -18,6 +21,7 @@ jobs:
1821
- name: Checkout
1922
uses: actions/checkout@v4
2023
with:
24+
fetch-depth: 0
2125
fetch-tags: true
2226

2327
- name: Download Artifacts
@@ -48,11 +52,12 @@ jobs:
4852
shell: bash
4953
run: |
5054
set -eoux pipefail
51-
output=$(just merge-changelog)
55+
output="$(just merge-changelog)"
5256
cat changelog.md
53-
jq -r <<< $output
54-
echo "title=$(jq -r '."title"' <<< $output)" >> $GITHUB_OUTPUT
55-
echo "tag=$(jq -r '."tag"' <<< $output)" >> $GITHUB_OUTPUT
57+
jq -r <<< "$output"
58+
for k in $(jq 'keys[]' <<< "$output" | tr -d \"); do
59+
echo "$k=$(jq -r ".$k" <<< "$output")" >> $GITHUB_OUTPUT
60+
done
5661
5762
- name: Upload Changelogs as Artifact
5863
uses: actions/upload-artifact@v4

Containerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ FROM ghcr.io/ublue-os/${BASE_IMAGE}:${TAG_VERSION}
99

1010
ARG BASE_IMAGE="bluefin"
1111
ARG IMAGE="bluefin"
12+
ARG SET_X=""
1213

1314
RUN --mount=type=bind,from=ctx,src=/,dst=/ctx \
1415
/ctx/build.sh

Justfile

Lines changed: 45 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ images := '(
1313
[ucore]="stable-zfs"
1414
[ucore-nvidia]="stable-nvidia-zfs"
1515
)'
16+
export SUDOIF := if `id -u` == "0" { "" } else { "sudo" }
17+
export SET_X := if `id -u` == "0" { "1" } else { env('SET_X', '') }
1618

1719
[private]
1820
default:
@@ -45,28 +47,17 @@ fix:
4547
clean:
4648
#!/usr/bin/bash
4749
set -euox pipefail
48-
function sudoif(){
49-
if [[ "${UID}" -eq 0 ]]; then
50-
"$@"
51-
elif [[ "$(command -v sudo)" && -n "${SSH_ASKPASS:-}" ]] && [[ -n "${DISPLAY:-}" || -n "${WAYLAND_DISPLAY:-}" ]]; then
52-
/usr/bin/sudo --askpass "$@" || exit 1
53-
elif [[ "$(command -v sudo)" ]]; then
54-
/usr/bin/sudo "$@" || exit 1
55-
else
56-
exit 1
57-
fi
58-
}
5950
touch {{ repo_image_name }}_
60-
sudoif find {{ repo_image_name }}_* -type d -exec chmod 0755 {} \;
61-
sudoif find {{ repo_image_name }}_* -type f -exec chmod 0644 {} \;
51+
${SUDOIF} find {{ repo_image_name }}_* -type d -exec chmod 0755 {} \;
52+
${SUDOIF} find {{ repo_image_name }}_* -type f -exec chmod 0644 {} \;
6253
find {{ repo_image_name }}_* -maxdepth 0 -exec rm -rf {} \;
6354
rm -f output*.env changelog*.md version.txt previous.manifest.json
6455

6556
# Build Image
6657
[group('Image')]
6758
build image="bluefin":
6859
#!/usr/bin/bash
69-
set -eoux pipefail
60+
set ${SET_X:+-x} -eou pipefail
7061
declare -A images={{ images }}
7162
check=${images[{{ image }}]-}
7263
if [[ -z "$check" ]]; then
@@ -112,6 +103,7 @@ build image="bluefin":
112103
BUILD_ARGS+=("--build-arg" "IMAGE={{ image }}")
113104
BUILD_ARGS+=("--build-arg" "BASE_IMAGE=$BASE_IMAGE")
114105
BUILD_ARGS+=("--build-arg" "TAG_VERSION=$TAG_VERSION")
106+
BUILD_ARGS+=("--build-arg" "SET_X=${SET_X:-}")
115107
BUILD_ARGS+=("--tag" "localhost/{{ repo_image_name }}:{{ image }}")
116108
podman pull ghcr.io/ublue-os/"${BASE_IMAGE}":"${TAG_VERSION}"
117109
buildah build --format docker --label "org.opencontainers.image.description={{ repo_image_name }} is my OCI image built from ublue projects. It mainly extends them for my uses." ${BUILD_ARGS[@]} .
@@ -126,46 +118,35 @@ build image="bluefin":
126118
[private]
127119
rechunk image="bluefin":
128120
#!/usr/bin/bash
129-
set -eoux pipefail
130-
function sudoif(){
131-
if [[ "${UID}" -eq 0 ]]; then
132-
"$@"
133-
elif [[ "$(command -v sudo)" && -n "${SSH_ASKPASS:-}" ]] && [[ -n "${DISPLAY:-}" || -n "${WAYLAND_DISPLAY:-}" ]]; then
134-
/usr/bin/sudo --askpass "$@" || exit 1
135-
elif [[ "$(command -v sudo)" ]]; then
136-
/usr/bin/sudo "$@" || exit 1
137-
else
138-
exit 1
139-
fi
140-
}
121+
set ${SET_X:+-x} -eou pipefail
141122
ID=$(podman images --filter reference=localhost/{{ repo_image_name }}:{{ image }} --format "'{{ '{{.ID}}' }}'")
142123

143124
if [[ -z "$ID" ]]; then
144125
just build {{ image }}
145126
fi
146127

147128
if [[ "${UID}" -gt "0" ]]; then
148-
sudoif podman image scp ${UID}@localhost::localhost/{{ repo_image_name }}:{{ image }} root@localhost::localhost/{{ repo_image_name }}:{{ image }}
129+
${SUDOIF} podman image scp ${UID}@localhost::localhost/{{ repo_image_name }}:{{ image }} root@localhost::localhost/{{ repo_image_name }}:{{ image }}
149130
fi
150131

151-
CREF=$(sudoif podman create localhost/{{ repo_image_name }}:{{ image }} bash)
152-
MOUNT=$(sudoif podman mount $CREF)
153-
FEDORA_VERSION="$(sudoif podman inspect $CREF | jq -r '.[]["Config"]["Labels"]["ostree.linux"]' | grep -oP 'fc\K[0-9]+')"
132+
CREF=$(${SUDOIF} podman create localhost/{{ repo_image_name }}:{{ image }} bash)
133+
MOUNT=$(${SUDOIF} podman mount $CREF)
134+
FEDORA_VERSION="$(${SUDOIF} podman inspect $CREF | jq -r '.[]["Config"]["Labels"]["ostree.linux"]' | grep -oP 'fc\K[0-9]+')"
154135
OUT_NAME="{{ repo_image_name }}_{{ image }}"
155136
VERSION="{{ image }}-${FEDORA_VERSION}.$(date +%Y%m%d)"
156137
LABELS="
157138
org.opencontainers.image.title={{ repo_image_name }}:{{ image }}
158139
org.opencontainers.image.revision=$(git rev-parse HEAD)
159140
ostree.linux=$(podman inspect localhost/{{ repo_image_name }}:{{ image }} | jq -r '.[].["Config"]["Labels"]["ostree.linux"]')
160141
org.opencontainers.image.description={{ repo_image_name }} is my OCI image built from ublue projects. It mainly extends them for my uses."
161-
sudoif podman run --rm \
142+
${SUDOIF} podman run --rm \
162143
--security-opt label=disable \
163144
--volume "$MOUNT":/var/tree \
164145
--env TREE=/var/tree \
165146
--user 0:0 \
166147
ghcr.io/hhd-dev/rechunk:latest \
167148
/sources/rechunk/1_prune.sh
168-
sudoif podman run --rm \
149+
${SUDOIF} podman run --rm \
169150
--security-opt label=disable \
170151
--volume "$MOUNT":/var/tree \
171152
--volume "cache_ostree:/var/ostree" \
@@ -175,13 +156,13 @@ rechunk image="bluefin":
175156
--user 0:0 \
176157
ghcr.io/hhd-dev/rechunk:latest \
177158
/sources/rechunk/2_create.sh
178-
sudoif podman unmount "$CREF"
179-
sudoif podman rm "$CREF"
159+
${SUDOIF} podman unmount "$CREF"
160+
${SUDOIF} podman rm "$CREF"
180161
if [[ "${UID}" -gt "0" ]]; then
181-
sudoif podman rmi localhost/{{ repo_image_name }}:{{ image }}
162+
${SUDOIF} podman rmi localhost/{{ repo_image_name }}:{{ image }}
182163
fi
183164
podman rmi localhost/{{ repo_image_name }}:{{ image }}
184-
sudoif podman run --rm \
165+
${SUDOIF} podman run --rm \
185166
--pull=newer \
186167
--security-opt label=disable \
187168
--volume "$PWD:/workspace" \
@@ -199,21 +180,21 @@ rechunk image="bluefin":
199180
ghcr.io/hhd-dev/rechunk:latest \
200181
/sources/rechunk/3_chunk.sh
201182

202-
sudoif find {{ repo_image_name }}_{{ image }} -type d -exec chmod 0755 {} \; || true
203-
sudoif find {{ repo_image_name }}_{{ image }}* -type f -exec chmod 0644 {} \; || true
183+
${SUDOIF} find {{ repo_image_name }}_{{ image }} -type d -exec chmod 0755 {} \; || true
184+
${SUDOIF} find {{ repo_image_name }}_{{ image }}* -type f -exec chmod 0644 {} \; || true
204185
if [[ "${UID}" -gt "0" ]]; then
205-
sudoif chown -R ${UID}:${GROUPS} "${PWD}"
186+
${SUDOIF} chown -R ${UID}:${GROUPS} "${PWD}"
206187
elif [[ "${UID}" == "0" && -n "${SUDO_USER:-}" ]]; then
207-
sudoif chown -R ${SUDO_UID}:${SUDO_GID} "${PWD}"
188+
${SUDOIF} chown -R ${SUDO_UID}:${SUDO_GID} "${PWD}"
208189
fi
209190

210-
sudoif podman volume rm cache_ostree
191+
${SUDOIF} podman volume rm cache_ostree
211192

212193
# Load Image into Podman and Tag
213194
[private]
214195
load-image image="bluefin":
215196
#!/usr/bin/bash
216-
set -eou pipefail
197+
set ${SET_X:+-x} -eou pipefail
217198
IMAGE=$(podman pull oci:${PWD}/{{ repo_image_name }}_{{ image }})
218199
podman tag ${IMAGE} localhost/{{ repo_image_name }}:{{ image }}
219200
VERSION=$(podman inspect $IMAGE | jq -r '.[]["Config"]["Labels"]["org.opencontainers.image.version"]')
@@ -224,27 +205,15 @@ load-image image="bluefin":
224205
# Get Tags
225206
get-tags image="bluefin":
226207
#!/usr/bin/bash
227-
set -eou pipefail
208+
set ${SET_X:+-x} -eou pipefail
228209
VERSION=$(podman inspect {{ repo_image_name }}:{{ image }} | jq -r '.[]["Config"]["Labels"]["org.opencontainers.image.version"]')
229210
echo "{{ image }} $VERSION"
230211

231212
# Build ISO
232213
[group('ISO')]
233214
build-iso image="bluefin" ghcr="0" clean="0":
234215
#!/usr/bin/bash
235-
set -eou pipefail
236-
function sudoif(){
237-
if [[ "${UID}" -eq 0 ]]; then
238-
"$@"
239-
elif [[ "$(command -v sudo)" && -n "${SSH_ASKPASS:-}" ]] && [[ -n "${DISPLAY:-}" || -n "${WAYLAND_DISPLAY:-}" ]]; then
240-
/usr/bin/sudo --askpass "$@" || exit 1
241-
elif [[ "$(command -v sudo)" ]]; then
242-
/usr/bin/sudo "$@" || exit 1
243-
else
244-
exit 1
245-
fi
246-
}
247-
216+
set ${SET_X:+-x} -eou pipefail
248217
# Validate
249218
declare -A images={{ images }}
250219
check=${images[{{ image }}]-}
@@ -288,7 +257,7 @@ build-iso image="bluefin" ghcr="0" clean="0":
288257

289258
# Load image into rootful podman
290259
if [[ "${UID}" -gt "0" ]]; then
291-
sudoif podman image scp "${UID}"@localhost::"${IMAGE_FULL}" root@localhost::"${IMAGE_FULL}"
260+
${SUDOIF} podman image scp "${UID}"@localhost::"${IMAGE_FULL}" root@localhost::"${IMAGE_FULL}"
292261
fi
293262

294263
# Generate Flatpak List
@@ -360,17 +329,17 @@ build-iso image="bluefin" ghcr="0" clean="0":
360329
ostree refs --repo=\${FLATPAK_SYSTEM_DIR}/repo | grep '^deploy/' | grep -v 'org\.freedesktop\.Platform\.openh264' | sed 's/^deploy\///g' > /output/flatpaks-with-deps
361330
EOF
362331
# Create Flatpak List
363-
sudoif podman run --rm --privileged \
332+
${SUDOIF} podman run --rm --privileged \
364333
--entrypoint /bin/bash \
365334
-e FLATPAK_SYSTEM_DIR=/flatpak/flatpak \
366335
-e FLATPAK_TRIGGERS_DIR=/flatpak/triggers \
367336
-v ${FLATPAK_REFS_DIR_ABS}:/output \
368337
-v ${TEMP_FLATPAK_INSTALL_DIR}:/temp_flatpak_install_dir \
369338
${IMAGE_FULL} /temp_flatpak_install_dir/install-flatpaks.sh
370339

371-
VERSION="$(sudoif podman inspect ${IMAGE_FULL} | jq -r '.[]["Config"]["Labels"]["ostree.linux"]' | grep -oP 'fc\K[0-9]+')"
340+
VERSION="$(${SUDOIF} podman inspect ${IMAGE_FULL} | jq -r '.[]["Config"]["Labels"]["ostree.linux"]' | grep -oP 'fc\K[0-9]+')"
372341
if [[ "{{ ghcr }}" == "1" && "{{ clean }}" == "1" ]]; then
373-
sudoif podman rmi ${IMAGE_FULL}
342+
${SUDOIF} podman rmi ${IMAGE_FULL}
374343
fi
375344
# list Flatpaks
376345
cat ${FLATPAK_REFS_DIR}/flatpaks-with-deps
@@ -398,19 +367,19 @@ build-iso image="bluefin" ghcr="0" clean="0":
398367
iso_build_args+=(VERSION="$VERSION")
399368
iso_build_args+=(WEB_UI="false")
400369
# Build ISO
401-
sudoif podman run --rm --privileged --pull=newer --security-opt label=disable "${iso_build_args[@]}"
370+
${SUDOIF} podman run --rm --privileged --pull=newer --security-opt label=disable "${iso_build_args[@]}"
402371
if [[ "${UID}" -gt "0" ]]; then
403-
sudoif chown -R ${UID}:${GROUPS} "${PWD}"
404-
sudoif podman rmi "${IMAGE_FULL}"
372+
${SUDOIF} chown -R ${UID}:${GROUPS} "${PWD}"
373+
${SUDOIF} podman rmi "${IMAGE_FULL}"
405374
elif [[ "${UID}" == "0" && -n "${SUDO_USER:-}" ]]; then
406-
sudoif chown -R ${SUDO_UID}:${SUDO_GID} "${PWD}"
375+
${SUDOIF} chown -R ${SUDO_UID}:${SUDO_GID} "${PWD}"
407376
fi
408377

409378
# Run ISO
410379
[group('ISO')]
411380
run-iso image="bluefin":
412381
#!/usr/bin/bash
413-
set -eou pipefail
382+
set ${SET_X:+-x} -eou pipefail
414383
if [[ ! -f "{{ repo_image_name }}_build/output/{{ image }}.iso" ]]; then
415384
just build-iso {{ image }}
416385
fi
@@ -440,32 +409,20 @@ run-iso image="bluefin":
440409
[group('Changelogs')]
441410
changelogs branch="stable" urlmd="" handwritten="":
442411
#!/usr/bin/bash
443-
set -eoux pipefail
412+
set ${SET_X:+-x} -eou pipefail
444413
python3 changelogs.py {{ branch }} ./output-{{ branch }}.env ./changelog-{{ branch }}.md --workdir . --handwritten "{{ handwritten }}" --urlmd "{{ urlmd }}"
445414

446415
# Verify Container with Cosign
447416
[group('Utility')]
448417
verify-container container="" registry="ghcr.io/ublue-os" key="":
449418
#!/usr/bin/bash
450-
set -eoux pipefail
451-
452-
function sudoif(){
453-
if [[ "${UID}" -eq 0 ]]; then
454-
"$@"
455-
elif [[ "$(command -v sudo)" && -n "${SSH_ASKPASS:-}" ]] && [[ -n "${DISPLAY:-}" || -n "${WAYLAND_DISPLAY:-}" ]]; then
456-
/usr/bin/sudo --askpass "$@" || exit 1
457-
elif [[ "$(command -v sudo)" ]]; then
458-
/usr/bin/sudo "$@" || exit 1
459-
else
460-
exit 1
461-
fi
462-
}
419+
set ${SET_X:+-x} -eou pipefail
463420

464421
# Get Cosign if Needed
465422
if [[ ! $(command -v cosign) ]]; then
466-
COSIGN_CONTAINER_ID=$(sudoif podman create cgr.dev/chainguard/cosign:latest bash)
467-
sudoif podman cp "${COSIGN_CONTAINER_ID}":/usr/bin/cosign /usr/local/bin/cosign
468-
sudoif podman rm -f "${COSIGN_CONTAINER_ID}"
423+
COSIGN_CONTAINER_ID=$(${SUDOIF} podman create cgr.dev/chainguard/cosign:latest bash)
424+
${SUDOIF} podman cp "${COSIGN_CONTAINER_ID}":/usr/bin/cosign /usr/local/bin/cosign
425+
${SUDOIF} podman rm -f "${COSIGN_CONTAINER_ID}"
469426
fi
470427

471428
# Verify Cosign Image Signatures if needed
@@ -492,7 +449,7 @@ verify-container container="" registry="ghcr.io/ublue-os" key="":
492449
[group('Utility')]
493450
secureboot image="bluefin":
494451
#!/usr/bin/bash
495-
set -eoux pipefail
452+
set ${SET_X:+-x} -eou pipefail
496453

497454
# Get the vmlinuz to check
498455
kernel_release=$(podman inspect "{{ repo_image_name }}":"{{ image }}" | jq -r '.[].Config.Labels["ostree.linux"]')
@@ -536,16 +493,16 @@ secureboot image="bluefin":
536493
# Merge Changelogs
537494
merge-changelog:
538495
#!/usr/bin/bash
539-
set -eou pipefail
496+
set ${SET_X:+-x} -eou pipefail
540497
rm -f changelog.md
541498
cat changelog*.md > changelog.md
542-
last_tag=$(git tag --list {{ repo_image_name }}-* | sort -r | head -1)
543-
date_extract="$(echo ${last_tag:-} | cut -d "-" -f 2 | cut -d "." -f 1)"
544-
date_version="$(echo ${last_tag:-} | cut -d "." -f 2)"
499+
last_tag=$(git tag --list {{ repo_image_name }}-* | sort -V | tail -1)
500+
date_extract="$(echo ${last_tag:-} | grep -oP '{{ repo_image_name }}-\K[0-9]+')"
501+
date_version="$(echo ${last_tag:-} | grep -oP '\.\K[0-9]+$' || true)"
545502
if [[ "${date_extract:-}" == "$(date +%Y%m%d)" ]]; then
546503
tag="{{ repo_image_name }}-${date_extract:-}.$(( ${date_version:-} + 1 ))"
547504
else
548-
tag="{{ repo_image_name }}-$(date +%Y%m%d).0"
505+
tag="{{ repo_image_name }}-$(date +%Y%m%d)"
549506
fi
550507
cat << EOF
551508
{

branding.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/bash
22

3-
set -eoux pipefail
3+
set ${SET_X:+-x} -eou pipefail
44

55
if [[ "${IMAGE}" =~ cosmic|ucore ]]; then
66
tee /usr/share/ublue-os/image-info.json <<'EOF'

0 commit comments

Comments
 (0)