refactor: reorder build scripts (#1771)

* refactor: reorder build scripts

Many RUN statements are very costly in terms of disk IO as every single
one commits layer cache for no benefit. But this retains most benefits
of the split in terms of disabling networking on the scripts that don't
need it.

There were also some leftover scripts that were running one command or
beta.sh which we don't use at all anymore. If there is a need to do
something on the beta only we should probably integrate it in the
other scripts.

Due to moving image-info.sh to the end we can drop the copr.vendor.conf
as we are still fedora when installing packages.

The disablement of openh264 repo and ublue akmods copr in dx.sh we can drop as
this is already handled by cleanup.sh

This is how https://github.com/ublue-os/aurora/pull/1670 should've been
done from the start.

* fix: Plasma 6.6 dropped the panel config

* chore: move strict /opt to clean-stage.sh

avoids one more RUN statement, this is stil visible enough here

* fix: beta oopsie

---------

Co-authored-by: inffy <10782843+inffy@users.noreply.github.com>
This commit is contained in:
renner 2026-02-17 23:37:17 +01:00 committed by GitHub
parent a1bdead3ae
commit 0880b9d4a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 93 additions and 196 deletions

View file

@ -38,113 +38,35 @@ ARG UBLUE_IMAGE_TAG="stable"
ARG VERSION=""
ARG IMAGE_FLAVOR=""
# Prep
RUN --mount=type=tmpfs,dst=/boot \
--mount=type=bind,from=ctx,source=/,target=/ctx \
--mount=type=cache,dst=/var/cache/libdnf5 \
/ctx/build_files/shared/build.sh
# so ghcurl wrapper is available to all later RUNs
ENV PATH="/tmp/scripts/helpers:${PATH}"
# Generate image-info.json, os-release
RUN --network=none \
--mount=type=tmpfs,dst=/boot \
--mount=type=bind,from=ctx,source=/,target=/ctx \
/ctx/build_files/base/00-image-info.sh
# Install Additional Packages
RUN --mount=type=tmpfs,dst=/boot \
--mount=type=bind,from=ctx,source=/,target=/ctx \
--mount=type=cache,dst=/var/cache/libdnf5 \
/ctx/build_files/base/03-packages.sh
# Install Kernel and Akmods
# Copy files from common/from system_files
# Install Packages, miscellaneous things that need a network
RUN --mount=type=tmpfs,dst=/boot \
--mount=type=tmpfs,dst=/var \
--mount=type=bind,from=ctx,source=/,target=/ctx \
--mount=type=cache,dst=/var/cache/libdnf5 \
--mount=type=secret,id=GITHUB_TOKEN \
/ctx/build_files/base/04-install-kernel-akmods.sh
/ctx/build_files/shared/build.sh && \
/ctx/build_files/base/01-packages.sh && \
/ctx/build_files/base/02-install-kernel-akmods.sh && \
/ctx/build_files/base/03-fetch.sh
# Wallpapers/Apperance
# Everything that can be done offline after things are in place should be done here
RUN --network=none \
--mount=type=tmpfs,dst=/boot \
--mount=type=bind,from=ctx,source=/,target=/ctx \
/ctx/build_files/base/05-branding.sh
# Install Overrides and Fetch Install
RUN --mount=type=tmpfs,dst=/boot \
--mount=type=tmpfs,dst=/run \
--mount=type=bind,from=ctx,source=/,target=/ctx \
--mount=type=cache,dst=/var/cache/libdnf5 \
--mount=type=secret,id=GITHUB_TOKEN \
/ctx/build_files/base/06-override-install.sh
# Beta
RUN --mount=type=tmpfs,dst=/boot \
--mount=type=bind,from=ctx,source=/,target=/ctx \
--mount=type=cache,dst=/var/cache/libdnf5 \
if [ "${UBLUE_IMAGE_TAG}" == "beta" ] ; then \
/ctx/build_files/base/10-beta.sh; \
fi
# Enable systemd services and Remove Items
RUN --network=none \
--mount=type=tmpfs,dst=/boot \
--mount=type=bind,from=ctx,source=/,target=/ctx \
--mount=type=cache,dst=/var/cache/libdnf5 \
/ctx/build_files/base/17-cleanup.sh
RUN --mount=type=tmpfs,dst=/boot \
--mount=type=bind,from=ctx,source=/,target=/ctx \
--mount=type=cache,dst=/var/cache/libdnf5 \
/ctx/build_files/base/18-workarounds.sh
# Regenerate initramfs
RUN --network=none \
--mount=type=tmpfs,dst=/boot \
--mount=type=bind,from=ctx,source=/,target=/ctx \
/ctx/build_files/base/19-initramfs.sh
# Aurora-DX
RUN --mount=type=tmpfs,dst=/boot \
--mount=type=bind,from=ctx,source=/,target=/ctx \
--mount=type=cache,dst=/var/cache/libdnf5 \
--mount=type=secret,id=GITHUB_TOKEN \
if [ "${IMAGE_FLAVOR}" == "dx" ] ; then \
/ctx/build_files/shared/build-dx.sh; \
fi
RUN --mount=type=tmpfs,dst=/boot \
--mount=type=bind,from=ctx,source=/,target=/ctx \
--mount=type=cache,dst=/var/cache/libdnf5 \
--mount=type=secret,id=GITHUB_TOKEN \
if [ "${IMAGE_FLAVOR}" == "dx" ] ; then \
/ctx/build_files/dx/00-dx.sh; \
fi
RUN --network=none \
--mount=type=bind,from=ctx,source=/,target=/ctx \
/ctx/build_files/shared/validate-repos.sh
RUN --network=none \
--mount=type=bind,from=ctx,source=/,target=/ctx \
/ctx/build_files/shared/clean-stage.sh
# Sanity checks
RUN --network=none \
--mount=type=bind,from=ctx,source=/,target=/ctx \
/ctx/build_files/base/16-override-install.sh && \
/ctx/build_files/base/17-cleanup.sh && \
/ctx/build_files/base/18-image-info.sh && \
/ctx/build_files/base/19-initramfs.sh && \
/ctx/build_files/shared/validate-repos.sh && \
/ctx/build_files/shared/clean-stage.sh && \
/ctx/build_files/base/20-tests.sh
RUN --network=none \
--mount=type=bind,from=ctx,source=/,target=/ctx \
if [ "${IMAGE_FLAVOR}" == "dx" ] ; then \
/ctx/build_files/dx/10-tests-dx.sh; \
fi
# Needs to be here to make the main image build strict (no /opt there)
# This is for downstream images/stuff like k0s
RUN rm -rf /opt && ln -s /var/opt /opt
CMD ["/sbin/init"]
RUN bootc container lint

View file

@ -295,4 +295,9 @@ else
plasma-firewall-$(rpm -q --qf "%{VERSION}" plasma-desktop)
fi
# Install DX specific packages
if [[ "${IMAGE_FLAVOR}" == "dx" ]]; then
/ctx/build_files/dx/00-dx.sh
fi
echo "::endgroup::"

48
build_files/base/03-fetch.sh Executable file
View file

@ -0,0 +1,48 @@
#!/usr/bin/bash
echo "::group:: ===$(basename "$0")==="
set -eoux pipefail
# Enable Flathub
flatpak remote-add --system --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
# Offline Aurora documentation
ghcurl "https://github.com/ublue-os/aurora-docs/releases/download/0.1/aurora.pdf" --retry 3 -o /tmp/aurora.pdf
install -Dm0644 -t /usr/share/doc/aurora/ /tmp/aurora.pdf
cp /usr/share/applications/dev.getaurora.offline-docs.desktop /usr/share/kglobalaccel/
# Weekly user count for fastfetch
ghcurl https://raw.githubusercontent.com/ublue-os/countme/main/badge-endpoints/aurora.json | jq -r ".message" > /usr/share/ublue-os/fastfetch-user-count
# bazaar weekly downloads used for fastfetch
curl -X 'GET' \
'https://flathub.org/api/v2/stats/io.github.kolunmi.Bazaar?all=false&days=1' \
-H 'accept: application/json' | jq -r ".installs_last_7_days" | numfmt --to=si --round=nearest > /usr/share/ublue-os/bazaar-install-count
# Starship Shell Prompt
ghcurl "https://github.com/starship/starship/releases/latest/download/starship-$(uname -m)-unknown-linux-gnu.tar.gz" --retry 3 -o /tmp/starship.tar.gz
ghcurl "https://github.com/starship/starship/releases/latest/download/starship-$(uname -m)-unknown-linux-gnu.tar.gz.sha256" --retry 3 -o /tmp/starship.tar.gz.sha256
echo "$(cat /tmp/starship.tar.gz.sha256) /tmp/starship.tar.gz" | sha256sum --check
tar -xzf /tmp/starship.tar.gz -C /tmp
install -c -m 0755 /tmp/starship /usr/bin
# Nerdfont symbols
# to fix motd and prompt atleast temporarily
ghcurl "https://github.com/ryanoasis/nerd-fonts/releases/latest/download/NerdFontsSymbolsOnly.zip" --retry 3 -o /tmp/nerdfontsymbols.zip
unzip /tmp/nerdfontsymbols.zip -d /tmp
mkdir -p /usr/share/fonts/nerd-fonts/NerdFontsSymbolsOnly/
mv /tmp/SymbolsNerdFont*.ttf /usr/share/fonts/nerd-fonts/NerdFontsSymbolsOnly/
# Bash Prexec v0.6.0
ghcurl https://raw.githubusercontent.com/rcaloras/bash-preexec/b73ed5f7f953207b958f15b1773721dded697ac3/bash-preexec.sh --retry 3 -Lo /usr/share/bash-prexec
# use CoreOS' generator for emergency/rescue boot
# see detail: https://github.com/ublue-os/main/issues/653
mkdir -p /usr/lib/systemd/system-generators
ghcurl "https://raw.githubusercontent.com/coreos/fedora-coreos-config/refs/heads/stable/overlay.d/05core/usr/lib/systemd/system-generators/coreos-sulogin-force-generator" --retry 3 -Lo /usr/lib/systemd/system-generators/coreos-sulogin-force-generator
chmod +x /usr/lib/systemd/system-generators/coreos-sulogin-force-generator
echo "::endgroup::"

View file

@ -1,11 +0,0 @@
#!/bin/bash
echo "::group:: ===$(basename "$0")==="
# Branding for Images
# sets default/pinned applications on the taskmanager applet on the panel, there is no nice way to do this
# https://bugs.kde.org/show_bug.cgi?id=511560
sed -i '/<entry name="launchers" type="StringList">/,/<\/entry>/ s/<default>[^<]*<\/default>/<default>preferred:\/\/browser,applications:org.gnome.Ptyxis.desktop,applications:io.github.kolunmi.Bazaar.desktop,preferred:\/\/filemanager<\/default>/' /usr/share/plasma/plasmoids/org.kde.plasma.taskmanager/contents/config/main.xml
echo "::endgroup::"

View file

@ -1,7 +0,0 @@
#!/usr/bin/bash
echo "::group:: ===$(basename "$0")==="
set -eoux pipefail
echo "::endgroup::"

View file

@ -4,9 +4,6 @@ echo "::group:: ===$(basename "$0")==="
set -eoux pipefail
# Enable Flathub
flatpak remote-add --system --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
# Footgun, See: https://github.com/ublue-os/main/issues/598
rm -f /usr/bin/chsh /usr/bin/lchsh
@ -20,47 +17,19 @@ ln -s "/usr/share/fonts/google-noto-sans-cjk-fonts" "/usr/share/fonts/noto-cjk"
# KDE Documentation is available online
rm -rf /usr/share/doc/HTML
# Offline Aurora documentation
ghcurl "https://github.com/ublue-os/aurora-docs/releases/download/0.1/aurora.pdf" --retry 3 -o /tmp/aurora.pdf
install -Dm0644 -t /usr/share/doc/aurora/ /tmp/aurora.pdf
cp /usr/share/applications/dev.getaurora.offline-docs.desktop /usr/share/kglobalaccel/
# Weekly user count for fastfetch
ghcurl https://raw.githubusercontent.com/ublue-os/countme/main/badge-endpoints/aurora.json | jq -r ".message" > /usr/share/ublue-os/fastfetch-user-count
# bazaar weekly downloads used for fastfetch
curl -X 'GET' \
'https://flathub.org/api/v2/stats/io.github.kolunmi.Bazaar?all=false&days=1' \
-H 'accept: application/json' | jq -r ".installs_last_7_days" | numfmt --to=si --round=nearest > /usr/share/ublue-os/bazaar-install-count
# Starship Shell Prompt
ghcurl "https://github.com/starship/starship/releases/latest/download/starship-$(uname -m)-unknown-linux-gnu.tar.gz" --retry 3 -o /tmp/starship.tar.gz
ghcurl "https://github.com/starship/starship/releases/latest/download/starship-$(uname -m)-unknown-linux-gnu.tar.gz.sha256" --retry 3 -o /tmp/starship.tar.gz.sha256
echo "$(cat /tmp/starship.tar.gz.sha256) /tmp/starship.tar.gz" | sha256sum --check
tar -xzf /tmp/starship.tar.gz -C /tmp
install -c -m 0755 /tmp/starship /usr/bin
# Nerdfont symbols
# to fix motd and prompt atleast temporarily
ghcurl "https://github.com/ryanoasis/nerd-fonts/releases/latest/download/NerdFontsSymbolsOnly.zip" --retry 3 -o /tmp/nerdfontsymbols.zip
unzip /tmp/nerdfontsymbols.zip -d /tmp
mkdir -p /usr/share/fonts/nerd-fonts/NerdFontsSymbolsOnly/
mv /tmp/SymbolsNerdFont*.ttf /usr/share/fonts/nerd-fonts/NerdFontsSymbolsOnly/
# Bash Prexec v0.6.0
ghcurl https://raw.githubusercontent.com/rcaloras/bash-preexec/b73ed5f7f953207b958f15b1773721dded697ac3/bash-preexec.sh --retry 3 -Lo /usr/share/bash-prexec
# use CoreOS' generator for emergency/rescue boot
# see detail: https://github.com/ublue-os/main/issues/653
mkdir -p /usr/lib/systemd/system-generators
ghcurl "https://raw.githubusercontent.com/coreos/fedora-coreos-config/refs/heads/stable/overlay.d/05core/usr/lib/systemd/system-generators/coreos-sulogin-force-generator" --retry 3 -Lo /usr/lib/systemd/system-generators/coreos-sulogin-force-generator
chmod +x /usr/lib/systemd/system-generators/coreos-sulogin-force-generator
# ######
# BASE IMAGE CHANGES
# ######
# sets default/pinned applications on the taskmanager applet on the panel, there is no nice way to do this
# https://bugs.kde.org/show_bug.cgi?id=511560
# TODO: KDE 6.6 dropped this file, find out some other way to set these
PANEL_CONF="/usr/share/plasma/plasmoids/org.kde.plasma.taskmanager/contents/config/main.xml"
if [[ -f "${PANEL_CONF}" ]]; then
sed -i '/<entry name="launchers" type="StringList">/,/<\/entry>/ s/<default>[^<]*<\/default>/<default>preferred:\/\/browser,applications:org.gnome.Ptyxis.desktop,applications:io.github.kolunmi.Bazaar.desktop,preferred:\/\/filemanager<\/default>/' "${PANEL_CONF}"
fi
# Hide Discover entries by renaming them (allows for easy re-enabling)
discover_apps=(
"org.kde.discover.desktop"
@ -79,6 +48,9 @@ done
rm /etc/xdg/autostart/org.kde.discover.notifier.desktop
# Use Bazaar for Flatpak refs
# Force Ptyxis version opened via dbus (e.g., keyboard shortcut) to use the proper shim
# https://github.com/ublue-os/bazzite/pull/3620
sed -i 's@Exec=/usr/bin/ptyxis@Exec=/usr/bin/kde-ptyxis@g' /usr/share/dbus-1/services/org.gnome.Ptyxis.service
echo "application/vnd.flatpak.ref=io.github.kolunmi.Bazaar.desktop" >> /usr/share/applications/mimeapps.list
# Ptyxis Terminal

View file

@ -1,11 +0,0 @@
#!/usr/bin/bash
echo "::group:: ===$(basename "$0")==="
set -eoux pipefail
# Force Ptyxis version opened via dbus (e.g., keyboard shortcut) to use the proper shim
# https://github.com/ublue-os/bazzite/pull/3620
sed -i 's@Exec=/usr/bin/ptyxis@Exec=/usr/bin/kde-ptyxis@g' /usr/share/dbus-1/services/org.gnome.Ptyxis.service
echo "::endgroup::"

View file

@ -162,4 +162,8 @@ for unit in "${IMPORTANT_UNITS[@]}"; do
fi
done
if [[ "${IMAGE_FLAVOR}" == "dx" ]]; then
/ctx/build_files/dx/10-tests-dx.sh;
fi
echo "::endgroup::"

View file

@ -74,7 +74,6 @@ if [[ ! "${IMAGE_NAME}" =~ nvidia ]]; then
fi
# Docker packages from their repo
echo "Installing Docker from official repo..."
dnf config-manager addrepo --from-repofile=https://download.docker.com/linux/fedora/docker-ce.repo
sed -i "s/enabled=.*/enabled=0/g" /etc/yum.repos.d/docker-ce.repo
dnf -y install --enablerepo=docker-ce-stable \
@ -136,12 +135,6 @@ systemctl enable ublue-os-libvirt-workarounds.service
systemctl enable aurora-dx-groups.service
systemctl enable --global aurora-dx-user-vscode.service
# NOTE: With isolated COPR installation, most repos are never enabled globally.
# We only need to clean up repos that were enabled during the build process.
sed -i 's@enabled=1@enabled=0@g' /etc/yum.repos.d/fedora-cisco-openh264.repo
sed -i 's@enabled=1@enabled=0@g' /etc/yum.repos.d/_copr:copr.fedorainfracloud.org:ublue-os:akmods.repo
# Disable RPM Fusion repos
for i in /etc/yum.repos.d/rpmfusion-*.repo; do
if [[ -f "$i" ]]; then

View file

@ -17,6 +17,10 @@ rpm --erase --nodeps --nodb generic-logos
# Copy Files to Container
rsync -rvKl /ctx/system_files/shared/ /
if [[ "${IMAGE_FLAVOR}" == "dx" ]]; then
/ctx/build_files/shared/build-dx.sh
fi
mkdir -p /tmp/scripts/helpers
install -Dm0755 /ctx/build_files/shared/utils/ghcurl /tmp/scripts/helpers/ghcurl

View file

@ -16,13 +16,10 @@ mv '/usr/share/doc/just/README.中文.md' '/usr/share/doc/just/README.zh-cn.md'
rm -rf /.gitkeep
# https://bootc-dev.github.io/bootc/filesystem.html#filesystem
rm -rf /{var,tmp,boot}
mkdir -p /{var,tmp,boot}
find /run/* -maxdepth 0 -type d \
\! -name .containerenv \
\! -name secrets \
\! -name systemd \
-exec rm -fr {} \;
rm -rf /var/ && mkdir -p /var/tmp
# Needs to be here to make the main image build strict (no /opt there)
# This is for downstream images/stuff like k0s
rm -rf /opt && ln -s /var/opt /opt
echo "::endgroup::"

View file

@ -1,19 +0,0 @@
# This override is to handle the default behavior of dnf5 using ID at /etc/os-release
# to select which chroot gets used to fetch the copr repo.
#
# An example of the behavior displayed without this override in Bazzite:
# sudo dnf5 copr enable ublue-os/bling
# https://copr.fedorainfracloud.org/api_3/rpmrepo/ublue-os/bling/bazzite-41/ 100% | 946.0 B/s | 500.0 B | 00m01s
# Chroot not found in the given Copr project (bazzite-41-x86_64). You can choose one of the available chroots explicitly:
# fedora-38-x86_64
# fedora-39-x86_64
# fedora-40-x86_64
# fedora-41-x86_64
# fedora-rawhide-x86_64
#
# See:
# https://github.com/rpm-software-management/dnf5/blob/01d4df824ff4a94ae1fc288f81923d02ba71173a/dnf5-plugins/copr_plugin/copr_config.cpp#L79-L81
# https://github.com/rpm-software-management/dnf5/blob/01d4df824ff4a94ae1fc288f81923d02ba71173a/dnf5-plugins/copr_plugin/copr_repo.cpp#L146
[main]
distribution = fedora