From 30c8a222959d51c8db0a4cf77fe45af2094ae276 Mon Sep 17 00:00:00 2001 From: Michael Jones Date: Sat, 14 Dec 2024 10:58:57 +0100 Subject: [PATCH] Initial Universal Blue Custom Image --- Containerfile | 41 ++++-- README.md | 138 +++++++----------- build.sh | 40 +++-- cosign.pub | 4 + mkdir | 0 packages/desktop | 7 + packages/develop | 61 ++++++++ packages/flatpaks | 6 + packages/fonts | 4 + packages/multimedia | 18 +++ packages/personal | 31 ++++ packages/security | 6 + packages/temporary | 9 ++ packages/virtual | 24 +++ scripts/kvm.sh | 12 ++ scripts/yubico.sh | 5 + system_files/etc/fail2ban/jail.local | 8 + system_files/etc/yum.repos.d/1password.repo | 7 + ...infracloud.org:gmaglione:podman-bootc.repo | 10 ++ ...fedorainfracloud.org:pennbauman:ports.repo | 10 ++ .../etc/yum.repos.d/_copr_ryanabx-cosmic.repo | 10 ++ .../yum.repos.d/atim-starship-fedora-41.repo | 10 ++ ...org.groups.virt.virtio-win.virtio-win.repo | 23 +++ 23 files changed, 367 insertions(+), 117 deletions(-) create mode 100644 cosign.pub create mode 100644 mkdir create mode 100644 packages/desktop create mode 100644 packages/develop create mode 100644 packages/flatpaks create mode 100644 packages/fonts create mode 100644 packages/multimedia create mode 100644 packages/personal create mode 100644 packages/security create mode 100644 packages/temporary create mode 100644 packages/virtual create mode 100644 scripts/kvm.sh create mode 100644 scripts/yubico.sh create mode 100644 system_files/etc/fail2ban/jail.local create mode 100644 system_files/etc/yum.repos.d/1password.repo create mode 100644 system_files/etc/yum.repos.d/_copr:copr.fedorainfracloud.org:gmaglione:podman-bootc.repo create mode 100644 system_files/etc/yum.repos.d/_copr:copr.fedorainfracloud.org:pennbauman:ports.repo create mode 100644 system_files/etc/yum.repos.d/_copr_ryanabx-cosmic.repo create mode 100644 system_files/etc/yum.repos.d/atim-starship-fedora-41.repo create mode 100644 system_files/etc/yum.repos.d/fedorapeople.org.groups.virt.virtio-win.virtio-win.repo diff --git a/Containerfile b/Containerfile index 5d08ad5..b41a286 100644 --- a/Containerfile +++ b/Containerfile @@ -1,11 +1,12 @@ -## 1. BUILD ARGS -# These allow changing the produced image by passing different build args to adjust -# the source from which your image is built. -# Build args can be provided on the commandline when building locally with: -# podman build -f Containerfile --build-arg FEDORA_VERSION=40 -t local-image - -# SOURCE_IMAGE arg can be anything from ublue upstream which matches your desired version: -# See list here: https://github.com/orgs/ublue-os/packages?repo_name=main + +### 1. BUILD ARGS +## These allow changing the produced image by passing different build args to adjust +## the source from which your image is built. +## Build args can be provided on the commandline when building locally with: +## podman build -f Containerfile --build-arg FEDORA_VERSION=40 -t local-image + +## SOURCE_IMAGE arg can be anything from ublue upstream which matches your desired version: +## See list here: https://github.com/orgs/ublue-os/packages?repo_name=main # - "silverblue" # - "kinoite" # - "sericea" @@ -13,21 +14,21 @@ # - "lazurite" # - "vauxite" # - "base" -# -# "aurora", "bazzite", "bluefin" or "ucore" may also be used but have different suffixes. + +## "aurora", "bazzite", "bluefin" or "ucore" may also be used but have different suffixes. ARG SOURCE_IMAGE="silverblue" ## SOURCE_SUFFIX arg should include a hyphen and the appropriate suffix name -# These examples all work for silverblue/kinoite/sericea/onyx/lazurite/vauxite/base +## These examples all work for silverblue/kinoite/sericea/onyx/lazurite/vauxite/base # - "-main" # - "-nvidia" # - "-asus" # - "-asus-nvidia" # - "-surface" # - "-surface-nvidia" -# -# aurora, bazzite and bluefin each have unique suffixes. Please check the specific image. -# ucore has the following possible suffixes + +## aurora, bazzite and bluefin each have unique suffixes. Please check the specific image. +## ucore has the following possible suffixes # - stable # - stable-nvidia # - stable-zfs @@ -48,12 +49,20 @@ FROM ghcr.io/ublue-os/${SOURCE_IMAGE}${SOURCE_SUFFIX}:${SOURCE_TAG} ## make modifications desired in your image and install packages by modifying the build.sh script ## the following RUN directive does all the things required to run "build.sh" as recommended. +## copy dirs and files to /tmp directory +COPY packages /tmp/packages +COPY scripts /tmp/scripts +COPY system_files /tmp/system_files COPY build.sh /tmp/build.sh -RUN mkdir -p /var/lib/alternatives && \ +## copy repository files, run build.sh script and commit +RUN rsync -rvK /tmp/system_files/ / && \ + mkdir -p /var/lib/alternatives && \ /tmp/build.sh && \ ostree container commit -## NOTES: + + +### NOTES: # - /var/lib/alternatives is required to prevent failure with some RPM installs # - All RUN commands must end with ostree container commit # see: https://coreos.github.io/rpm-ostree/container/#using-ostree-container-commit diff --git a/README.md b/README.md index bfb9e86..e8ba32a 100644 --- a/README.md +++ b/README.md @@ -1,86 +1,52 @@ -# image-template - -# Purpose - -This repository is meant to be a template for building your own custom Universal Blue image. This template is the recommended way to make customizations to any image published by the Universal Blue Project: -- [Aurora](https://getaurora.dev/) -- [Bazzite](https://bazzite.gg/) -- [Bluefin](https://projectbluefin.io/) -- [uCore](https://projectucore.io/) -- [main](https://github.com/ublue-os/main/) -- [hwe](https://github.com/ublue-os/hwe/) - -This template includes a Containerfile and a Github workflow for building the container image. As soon as the workflow is enabled in your repository, it will build the container image and push it to the Github Container Registry. - -# Prerequisites - -Working knowledge in the following topics: - -- Containers - - https://www.youtube.com/watch?v=SnSH8Ht3MIc - - https://www.mankier.com/5/Containerfile -- rpm-ostree - - https://coreos.github.io/rpm-ostree/container/ -- Fedora Silverblue (and other Fedora Atomic variants) - - https://docs.fedoraproject.org/en-US/fedora-silverblue/ -- Github Workflows - - https://docs.github.com/en/actions/using-workflows - -# How to Use - -## Template - -Select `Use this Template` and create a new repository from it. To enable the workflows, you may need to go the `Actions` tab of the new repository and click to enable workflows. - -## Containerfile - -This file defines the operations used to customize the selected image. It contains examples of possible modifications, including how to: -- change the upstream from which the custom image is derived -- add additional RPM packages -- add binaries as a layer from other images - -## Workflows - -### build.yml - -This workflow creates your custom OCI image and publishes it to the Github Container Registry (GHCR). By default, the image name will match the Github repository name. - -#### Container Signing - -Container signing is important for end-user security and is enabled on all Universal Blue images. It is recommended you set this up, and by default the image builds *will fail* if you don't. - -This provides users a method of verifying the image. - -1. Install the [cosign CLI tool](https://edu.chainguard.dev/open-source/sigstore/cosign/how-to-install-cosign/#installing-cosign-with-the-cosign-binary) - -2. Run inside your repo folder: - - ```bash - cosign generate-key-pair - ``` - - - - Do NOT put in a password when it asks you to, just press enter. The signing key will be used in GitHub Actions and will not work if it is encrypted. - -> [!WARNING] -> Be careful to *never* accidentally commit `cosign.key` into your git repo. - -3. Add the private key to GitHub - - - This can also be done manually. Go to your repository settings, under Secrets and Variables -> Actions - ![image](https://user-images.githubusercontent.com/1264109/216735595-0ecf1b66-b9ee-439e-87d7-c8cc43c2110a.png) - Add a new secret and name it `SIGNING_SECRET`, then paste the contents of `cosign.key` into the secret and save it. Make sure it's the .key file and not the .pub file. Once done, it should look like this: - ![image](https://user-images.githubusercontent.com/1264109/216735690-2d19271f-cee2-45ac-a039-23e6a4c16b34.png) - - - (CLI instructions) If you have the `github-cli` installed, run: - - ```bash - gh secret set SIGNING_SECRET < cosign.key - ``` - -4. Commit the `cosign.pub` file into your git repository - -### Examples -- [m2os](https://github.com/m2giles/m2os) -- [bos](https://github.com/bsherman/bos) -- [homer](https://github.com/bketelsen/homer/) +# Universal Blue Custom Image +[universal-blue.org](https://universal-blue.org/) + +## Purpose + +This repository is meant to be a quick setup and restore for my personal use. + +## Install + +To rebase from an atomic distribution: +```bash +sudo bootc switch --enforce-container-sigpolicy ghcr.io/yardquit/atomic_custm:latest +``` + +## Post Installs + +### 1. YubiKey +To access the system using sudo, you will need to use your YubiKey as an additional factor of authentication. +YubiKey Registration: +Follow the below instructions to complete the registration process. +```bash +# Insert your YubiKey into a compatible USB port on your computer. +ykpamcfg -2 +``` +Ensure that YubiKey support is enabled and functional in your system settings. +```bash +sudo echo "Testing sudo with YubiKey" +``` +Once your YubiKey is registered and supported by your system, you can use it to access the sudo command. + + +### 2. fapolicyd +Enabling and Installing fapolicyd for Enhanced Security + +To secure your system, follow these steps to install, enable, and start fapolicyd. + +Use the following command to install fapolicyd, its SELinux module, and a plugin for rpm-ostree. +```bash +rpm-ostree install fapolicyd fapolicyd-selinux rpm-plugin-fapolicyd +``` +Restart your system for the changes take effect: +```bash +reboot +``` +Configure the fapolicyd to allow repository packages, else fapolicy will allow everything. +```bash +sudo sed -i 's/integrity = none/integrity = sha256/g' /etc/fapolicyd/fapolicyd.conf +``` +Configure the fapolicyd service to start automatically on boot and enable it immediately. +```bash +sudo systemctl enable --now fapolicyd.service +``` diff --git a/build.sh b/build.sh index 0ca1678..98c57ae 100755 --- a/build.sh +++ b/build.sh @@ -3,21 +3,31 @@ set -ouex pipefail RELEASE="$(rpm -E %fedora)" - +### install flatpaks +flatpak remote-add --system --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo +# flatpak -y install --system $(cat /tmp/packages/flatpaks) ### Install packages - -# Packages can be installed from any enabled yum repo on the image. -# RPMfusion repos are available by default in ublue main images -# List of rpmfusion packages can be found here: -# https://mirrors.rpmfusion.org/mirrorlist?path=free/fedora/updates/39/x86_64/repoview/index.html&protocol=https&redirect=1 - -# this installs a package from fedora repos -rpm-ostree install screen - -# this would install a package from rpmfusion -# rpm-ostree install vlc - -#### Example for enabling a System Unit File - +rpm-ostree install \ +$(cat /tmp/packages/desktop) \ +$(cat /tmp/packages/develop) \ +$(cat /tmp/packages/fonts) \ +$(cat /tmp/packages/multimedia) \ +$(cat /tmp/packages/personal) \ +$(cat /tmp/packages/security) \ +$(cat /tmp/packages/temporary) \ +$(cat /tmp/packages/virtual) + +### Run configuration scripts +sh /tmp/scripts/kvm.sh +sh /tmp/scripts/yubico.sh + +### Enabling System Unit File(s) +systemctl enable rpm-ostreed-automatic.timer +systemctl enable tuned.service +systemctl enable docker.service systemctl enable podman.socket +systemctl enable fstrim.timer + +### Disabling System Unit File(s) +systemctl disable cosmic-greeter.service diff --git a/cosign.pub b/cosign.pub new file mode 100644 index 0000000..cfad0a3 --- /dev/null +++ b/cosign.pub @@ -0,0 +1,4 @@ +-----BEGIN PUBLIC KEY----- +MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAExKav2IaMoThdWkKBC8B542o36xkH +N5gNpZA+dOf94UxEPyxsobP8ABov+Rj1YcCYwt4HsB8Kfe+Je689B5zHWA== +-----END PUBLIC KEY----- diff --git a/mkdir b/mkdir new file mode 100644 index 0000000..e69de29 diff --git a/packages/desktop b/packages/desktop new file mode 100644 index 0000000..7b00a86 --- /dev/null +++ b/packages/desktop @@ -0,0 +1,7 @@ +cosmic-desktop +cosmic-idle +NetworkManager-tui +NetworkManager-openvpn +gnome-keyring +pinentry-gnome3 +udiskie diff --git a/packages/develop b/packages/develop new file mode 100644 index 0000000..90e3b8e --- /dev/null +++ b/packages/develop @@ -0,0 +1,61 @@ +helix +neovim +osbuild +osbuild-selinux +koji +fedora-packager +fedora-review +packit +fedrq +rpm-spec-language-server +rpmdevtools +rpmlint +policycoreutils +sepolicy_analysis +libselinux-utils +checkpolicy +selinux-policy +selinux-policy-mls +selinux-policy-doc +selinux-policy-mls +selinux-policy-targeted +setools-console +setools-console-analyses +libvirt-devel +xorriso +livecd-tools +pykickstart +rust +rust-analyzer +cargo +rust-gdb +rust2rpm +rust-srpm-macros +cargo-rpm-macros +cargo2rpm +clang +gdb +gdb-doc +valgrind +golang +golang-x-tools-gopls +go-rpm-macros +go-srpm-macros +go-rpm-templates +go2rpm +python-pip +python3-devel +python3-lsp-black +python3-lsp-server+all +python3-mypy +python3-pytest +python3-pytest-lsp +poetry +cairo-devel +cairo-gobject-devel +gobject-introspection-devel +zig +zig-doc +zig-libs +zig-rpm-macros +zig-srpm-macros diff --git a/packages/flatpaks b/packages/flatpaks new file mode 100644 index 0000000..edf1709 --- /dev/null +++ b/packages/flatpaks @@ -0,0 +1,6 @@ +hu.irl.cameractrls +com.github.wwmm.easyeffects +io.freetubeapp.FreeTube +org.fedoraproject.MediaWriter +org.gnome.Connections +org.gnome.World.PikaBackup diff --git a/packages/fonts b/packages/fonts new file mode 100644 index 0000000..02ce36d --- /dev/null +++ b/packages/fonts @@ -0,0 +1,4 @@ +cascadia-fonts-all +fontawesome-fonts-all +jetbrains-mono-fonts-all +liberation-fonts diff --git a/packages/multimedia b/packages/multimedia new file mode 100644 index 0000000..90ea9b0 --- /dev/null +++ b/packages/multimedia @@ -0,0 +1,18 @@ +mediainfo +mpv +PackageKit-gstreamer-plugin +alsa-ucm +alsa-utils +gstreamer1-plugin-libav +gstreamer1-plugin-openh264 +gstreamer1-plugins-bad-free +gstreamer1-plugins-good +gstreamer1-plugins-ugly-free +libva-intel-media-driver +pipewire-alsa +pipewire-gstreamer +pipewire-pulseaudio +pipewire-utils +wireplumber +gstreamer-plugins-espeak +ffmpeg diff --git a/packages/personal b/packages/personal new file mode 100644 index 0000000..5431960 --- /dev/null +++ b/packages/personal @@ -0,0 +1,31 @@ +starship +lf +fd-find +iucode-tool +stow +stow-doc +texinfo +tldr +yum-utils +ptyxis +inxi +fastfetch +fzf +sshfs +dislocker +pinentry-qt +pinentry-tty +pinentry-emacs +translate-shell +lm_sensors +lshw +nvtop +parallel +xxd +sassc +unrar +p7zip +btop +solaar +solaar-doc +solaar-udev diff --git a/packages/security b/packages/security new file mode 100644 index 0000000..da0f320 --- /dev/null +++ b/packages/security @@ -0,0 +1,6 @@ +pass +pam_yubico +ykocli +yubico-piv-tool +borgbackup +syncthing diff --git a/packages/temporary b/packages/temporary new file mode 100644 index 0000000..5b9a25b --- /dev/null +++ b/packages/temporary @@ -0,0 +1,9 @@ +darktable +darktable-tools-noise +obs-studio +gnome-shell-extension-pop-shell +gnome-shell-extension-pop-shell-shortcut-overrides +pop-gnome-shell-theme +gimp +chromium +fedora-chromium-config diff --git a/packages/virtual b/packages/virtual new file mode 100644 index 0000000..d957383 --- /dev/null +++ b/packages/virtual @@ -0,0 +1,24 @@ +docker +libvirt +libvirt-daemon-config-network +libvirt-daemon-kvm +virt-install +virt-manager +virt-viewer +virt-top +virtio-win +qemu +qemu-kvm +tuned +swtpm +swtpm-libs +swtpm-tools +swtpm-selinux +edk2-ovmf +libguestfs +libguestfs-bash-completion +python3-libguestfs +podman +podman-bootc +podman-machine +podman-compose diff --git a/scripts/kvm.sh b/scripts/kvm.sh new file mode 100644 index 0000000..2be009c --- /dev/null +++ b/scripts/kvm.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -oue pipefail + +# enable virtualization services +for drv in qemu interface network nodedev nwfilter secret storage; do + systemctl enable virt${drv}d.service; + systemctl enable virt${drv}d{,-ro,-admin}.socket; +done + +# enable nested virtualization +echo 'options kvm_intel nested=1' > /etc/modprobe.d/kvm_intel.conf + diff --git a/scripts/yubico.sh b/scripts/yubico.sh new file mode 100644 index 0000000..470174a --- /dev/null +++ b/scripts/yubico.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +set -oue pipefail + +# add yubico challange for sudo +sed -i '/PAM-1.0/a\auth required pam_yubico.so mode=challenge-response' /etc/pam.d/sudo diff --git a/system_files/etc/fail2ban/jail.local b/system_files/etc/fail2ban/jail.local new file mode 100644 index 0000000..da665f6 --- /dev/null +++ b/system_files/etc/fail2ban/jail.local @@ -0,0 +1,8 @@ +[DEFAULT] +ignoreip = 127.0.0.1 ::1 +bantime = 3600 +findtime = 600 +maxretry = 5 + +[sshd] +enabled = true diff --git a/system_files/etc/yum.repos.d/1password.repo b/system_files/etc/yum.repos.d/1password.repo new file mode 100644 index 0000000..b71d04b --- /dev/null +++ b/system_files/etc/yum.repos.d/1password.repo @@ -0,0 +1,7 @@ +[1password] +name=1Password Stable Channel +baseurl=https://downloads.1password.com/linux/rpm/stable/$basearch +enabled=1 +gpgcheck=1 +repo_gpgcheck=1 +gpgkey=https://downloads.1password.com/linux/keys/1password.asc diff --git a/system_files/etc/yum.repos.d/_copr:copr.fedorainfracloud.org:gmaglione:podman-bootc.repo b/system_files/etc/yum.repos.d/_copr:copr.fedorainfracloud.org:gmaglione:podman-bootc.repo new file mode 100644 index 0000000..ff70909 --- /dev/null +++ b/system_files/etc/yum.repos.d/_copr:copr.fedorainfracloud.org:gmaglione:podman-bootc.repo @@ -0,0 +1,10 @@ +[copr:copr.fedorainfracloud.org:gmaglione:podman-bootc] +name=Copr repo for podman-bootc owned by gmaglione +baseurl=https://download.copr.fedorainfracloud.org/results/gmaglione/podman-bootc/fedora-$releasever-$basearch/ +type=rpm-md +skip_if_unavailable=True +gpgcheck=1 +gpgkey=https://download.copr.fedorainfracloud.org/results/gmaglione/podman-bootc/pubkey.gpg +repo_gpgcheck=0 +enabled=1 +enabled_metadata=1 diff --git a/system_files/etc/yum.repos.d/_copr:copr.fedorainfracloud.org:pennbauman:ports.repo b/system_files/etc/yum.repos.d/_copr:copr.fedorainfracloud.org:pennbauman:ports.repo new file mode 100644 index 0000000..1f47210 --- /dev/null +++ b/system_files/etc/yum.repos.d/_copr:copr.fedorainfracloud.org:pennbauman:ports.repo @@ -0,0 +1,10 @@ +[copr:copr.fedorainfracloud.org:pennbauman:ports] +name=Copr repo for ports owned by pennbauman +baseurl=https://download.copr.fedorainfracloud.org/results/pennbauman/ports/fedora-$releasever-$basearch/ +type=rpm-md +skip_if_unavailable=True +gpgcheck=1 +gpgkey=https://download.copr.fedorainfracloud.org/results/pennbauman/ports/pubkey.gpg +repo_gpgcheck=0 +enabled=1 +enabled_metadata=1 diff --git a/system_files/etc/yum.repos.d/_copr_ryanabx-cosmic.repo b/system_files/etc/yum.repos.d/_copr_ryanabx-cosmic.repo new file mode 100644 index 0000000..0d654be --- /dev/null +++ b/system_files/etc/yum.repos.d/_copr_ryanabx-cosmic.repo @@ -0,0 +1,10 @@ +[copr:copr.fedorainfracloud.org:ryanabx:cosmic-epoch] +name=Copr repo for cosmic-epoch owned by ryanabx +baseurl=https://download.copr.fedorainfracloud.org/results/ryanabx/cosmic-epoch/fedora-$releasever-$basearch/ +type=rpm-md +skip_if_unavailable=True +gpgcheck=1 +gpgkey=https://download.copr.fedorainfracloud.org/results/ryanabx/cosmic-epoch/pubkey.gpg +repo_gpgcheck=0 +enabled=1 +enabled_metadata=1 diff --git a/system_files/etc/yum.repos.d/atim-starship-fedora-41.repo b/system_files/etc/yum.repos.d/atim-starship-fedora-41.repo new file mode 100644 index 0000000..faf942f --- /dev/null +++ b/system_files/etc/yum.repos.d/atim-starship-fedora-41.repo @@ -0,0 +1,10 @@ +[copr:copr.fedorainfracloud.org:atim:starship] +name=Copr repo for starship owned by atim +baseurl=https://download.copr.fedorainfracloud.org/results/atim/starship/fedora-$releasever-$basearch/ +type=rpm-md +skip_if_unavailable=True +gpgcheck=1 +gpgkey=https://download.copr.fedorainfracloud.org/results/atim/starship/pubkey.gpg +repo_gpgcheck=0 +enabled=1 +enabled_metadata=1 diff --git a/system_files/etc/yum.repos.d/fedorapeople.org.groups.virt.virtio-win.virtio-win.repo b/system_files/etc/yum.repos.d/fedorapeople.org.groups.virt.virtio-win.virtio-win.repo new file mode 100644 index 0000000..bec5ce5 --- /dev/null +++ b/system_files/etc/yum.repos.d/fedorapeople.org.groups.virt.virtio-win.virtio-win.repo @@ -0,0 +1,23 @@ +# virtio-win yum repo +# Details: https://fedoraproject.org/wiki/Windows_Virtio_Drivers + +[virtio-win-stable] +name=virtio-win builds roughly matching what was shipped in latest RHEL +baseurl=https://fedorapeople.org/groups/virt/virtio-win/repo/stable +enabled=1 +skip_if_unavailable=1 +gpgcheck=0 + +[virtio-win-latest] +name=Latest virtio-win builds +baseurl=https://fedorapeople.org/groups/virt/virtio-win/repo/latest +enabled=0 +skip_if_unavailable=1 +gpgcheck=0 + +[virtio-win-source] +name=virtio-win source RPMs +baseurl=https://fedorapeople.org/groups/virt/virtio-win/repo/srpms +enabled=0 +skip_if_unavailable=1 +gpgcheck=0