diff --git a/Containerfile b/Containerfile index c1ea467b..6298f0b6 100644 --- a/Containerfile +++ b/Containerfile @@ -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 diff --git a/build_files/base/03-packages.sh b/build_files/base/01-packages.sh similarity index 98% rename from build_files/base/03-packages.sh rename to build_files/base/01-packages.sh index aae7fece..3751617c 100755 --- a/build_files/base/03-packages.sh +++ b/build_files/base/01-packages.sh @@ -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::" diff --git a/build_files/base/04-install-kernel-akmods.sh b/build_files/base/02-install-kernel-akmods.sh similarity index 100% rename from build_files/base/04-install-kernel-akmods.sh rename to build_files/base/02-install-kernel-akmods.sh diff --git a/build_files/base/03-fetch.sh b/build_files/base/03-fetch.sh new file mode 100755 index 00000000..f914b949 --- /dev/null +++ b/build_files/base/03-fetch.sh @@ -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::" + diff --git a/build_files/base/05-branding.sh b/build_files/base/05-branding.sh deleted file mode 100755 index 500e79a7..00000000 --- a/build_files/base/05-branding.sh +++ /dev/null @@ -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>/ s/[^<]*<\/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::" diff --git a/build_files/base/10-beta.sh b/build_files/base/10-beta.sh deleted file mode 100755 index df0266fe..00000000 --- a/build_files/base/10-beta.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/bash - -echo "::group:: ===$(basename "$0")===" - -set -eoux pipefail - -echo "::endgroup::" diff --git a/build_files/base/06-override-install.sh b/build_files/base/16-override-install.sh similarity index 56% rename from build_files/base/06-override-install.sh rename to build_files/base/16-override-install.sh index 1359462c..c8efb3d9 100755 --- a/build_files/base/06-override-install.sh +++ b/build_files/base/16-override-install.sh @@ -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>/ s/[^<]*<\/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 diff --git a/build_files/base/00-image-info.sh b/build_files/base/18-image-info.sh similarity index 100% rename from build_files/base/00-image-info.sh rename to build_files/base/18-image-info.sh diff --git a/build_files/base/18-workarounds.sh b/build_files/base/18-workarounds.sh deleted file mode 100755 index 79e18709..00000000 --- a/build_files/base/18-workarounds.sh +++ /dev/null @@ -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::" diff --git a/build_files/base/20-tests.sh b/build_files/base/20-tests.sh index d9b1c95c..0da37923 100755 --- a/build_files/base/20-tests.sh +++ b/build_files/base/20-tests.sh @@ -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::" diff --git a/build_files/dx/00-dx.sh b/build_files/dx/00-dx.sh index 87fcae3a..612c3114 100755 --- a/build_files/dx/00-dx.sh +++ b/build_files/dx/00-dx.sh @@ -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 diff --git a/build_files/shared/build.sh b/build_files/shared/build.sh index d99317e0..1a288b23 100755 --- a/build_files/shared/build.sh +++ b/build_files/shared/build.sh @@ -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 diff --git a/build_files/shared/clean-stage.sh b/build_files/shared/clean-stage.sh index 453a8f32..a7cf8abf 100755 --- a/build_files/shared/clean-stage.sh +++ b/build_files/shared/clean-stage.sh @@ -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::" diff --git a/system_files/shared/usr/share/dnf/plugins/copr.vendor.conf b/system_files/shared/usr/share/dnf/plugins/copr.vendor.conf deleted file mode 100644 index 3ad3bc76..00000000 --- a/system_files/shared/usr/share/dnf/plugins/copr.vendor.conf +++ /dev/null @@ -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