From 8fee88e9cc76e4e73c8b9f6cea40dc1e14dc3321 Mon Sep 17 00:00:00 2001 From: RJ Trujillo Date: Sat, 21 Oct 2023 08:51:27 -0600 Subject: [PATCH] feat: Reduce image size and complexity (#40) - Reduce number of copies - Remove redundant container commit - Make scripts executable --- Containerfile | 11 +- build.sh | 36 +----- packages.json | 107 +----------------- system_files/tmp/build.sh | 35 ++++++ system_files/tmp/packages.json | 106 +++++++++++++++++ .../usr/etc}/profile.d/cinnamon-firstboot.sh | 0 .../usr/etc}/ublue-lightdm-workaround.sh | 0 .../system/ublue-lightdm-workaround.service | 0 .../usr/share/touchegg}/touchegg.conf | 0 9 files changed, 144 insertions(+), 151 deletions(-) mode change 100755 => 120000 build.sh mode change 100644 => 120000 packages.json create mode 100755 system_files/tmp/build.sh create mode 100644 system_files/tmp/packages.json rename {etc => system_files/usr/etc}/profile.d/cinnamon-firstboot.sh (100%) rename {etc => system_files/usr/etc}/ublue-lightdm-workaround.sh (100%) mode change 100644 => 100755 rename {etc => system_files/usr/lib}/systemd/system/ublue-lightdm-workaround.service (100%) rename {config => system_files/usr/share/touchegg}/touchegg.conf (100%) diff --git a/Containerfile b/Containerfile index a3225ad..3d3895c 100644 --- a/Containerfile +++ b/Containerfile @@ -6,15 +6,10 @@ ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION:-39}" FROM ${BASE_IMAGE}:${FEDORA_MAJOR_VERSION} AS builder -COPY etc /etc -COPY usr /usr -RUN chmod +x /etc/ublue-lightdm-workaround.sh - ARG IMAGE_NAME="${IMAGE_NAME}" ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION}" -ADD packages.json /tmp/packages.json -ADD build.sh /tmp/build.sh +COPY system_files / RUN /tmp/build.sh && \ pip install --prefix=/usr yafti && \ @@ -25,7 +20,3 @@ RUN /tmp/build.sh && \ ostree container commit && \ mkdir -p /var/tmp && \ chmod -R 1777 /var/tmp - -COPY config/touchegg.conf /usr/share/touchegg - -RUN ostree container commit diff --git a/build.sh b/build.sh deleted file mode 100755 index 3821144..0000000 --- a/build.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh - -set -ouex pipefail - -RELEASE="$(rpm -E %fedora)" - -INCLUDED_PACKAGES=($(jq -r "[(.all.include | (.all, select(.\"$IMAGE_NAME\" != null).\"$IMAGE_NAME\")[]), \ - (select(.\"$FEDORA_MAJOR_VERSION\" != null).\"$FEDORA_MAJOR_VERSION\".include | (.all, select(.\"$IMAGE_NAME\" != null).\"$IMAGE_NAME\")[])] \ - | sort | unique[]" /tmp/packages.json)) -EXCLUDED_PACKAGES=($(jq -r "[(.all.exclude | (.all, select(.\"$IMAGE_NAME\" != null).\"$IMAGE_NAME\")[]), \ - (select(.\"$FEDORA_MAJOR_VERSION\" != null).\"$FEDORA_MAJOR_VERSION\".exclude | (.all, select(.\"$IMAGE_NAME\" != null).\"$IMAGE_NAME\")[])] \ - | sort | unique[]" /tmp/packages.json)) - - -if [[ "${#EXCLUDED_PACKAGES[@]}" -gt 0 ]]; then - EXCLUDED_PACKAGES=($(rpm -qa --queryformat='%{NAME} ' ${EXCLUDED_PACKAGES[@]})) -fi - -if [[ "${#INCLUDED_PACKAGES[@]}" -gt 0 && "${#EXCLUDED_PACKAGES[@]}" -eq 0 ]]; then - rpm-ostree install \ - ${INCLUDED_PACKAGES[@]} - -elif [[ "${#INCLUDED_PACKAGES[@]}" -eq 0 && "${#EXCLUDED_PACKAGES[@]}" -gt 0 ]]; then - rpm-ostree override remove \ - ${EXCLUDED_PACKAGES[@]} - -elif [[ "${#INCLUDED_PACKAGES[@]}" -gt 0 && "${#EXCLUDED_PACKAGES[@]}" -gt 0 ]]; then - rpm-ostree override remove \ - ${EXCLUDED_PACKAGES[@]} \ - $(printf -- "--install=%s " ${INCLUDED_PACKAGES[@]}) - -else - echo "No packages to install." - -fi diff --git a/build.sh b/build.sh new file mode 120000 index 0000000..dc012ee --- /dev/null +++ b/build.sh @@ -0,0 +1 @@ +system_files/tmp/build.sh \ No newline at end of file diff --git a/packages.json b/packages.json deleted file mode 100644 index 712000e..0000000 --- a/packages.json +++ /dev/null @@ -1,106 +0,0 @@ -{ - "all": { - "include": { - "all": [ - "gnome-boxes", - "gnome-software", - "python3-pip", - "timeshift", - "touchegg", - "NetworkManager-adsl", - "NetworkManager-bluetooth", - "NetworkManager-iodine-gnome", - "NetworkManager-l2tp-gnome", - "NetworkManager-libreswan-gnome", - "NetworkManager-openconnect-gnome", - "NetworkManager-openvpn-gnome", - "NetworkManager-ppp", - "NetworkManager-pptp-gnome", - "NetworkManager-vpnc-gnome", - "NetworkManager-wifi", - "NetworkManager-wwan", - "abrt-desktop", - "abrt-java-connector", - "blueman", - "cinnamon", - "cinnamon-control-center", - "cinnamon-screensaver", - "eom", - "ffmpegthumbnailer", - "firewall-config", - "gnome-disk-utility", - "gnome-screenshot", - "gnome-system-monitor", - "gnome-terminal", - "gstreamer1-plugins-ugly-free", - "gvfs-archive", - "gvfs-gphoto2", - "gvfs-mtp", - "gvfs-smb", - "imsettings-gsettings", - "initial-setup-gui", - "metacity", - "nemo-fileroller", - "nemo-image-converter", - "nemo-preview", - "nemo-python", - "nm-connection-editor", - "paper-icon-theme", - "pipewire-alsa", - "pipewire-pulseaudio", - "powerline", - "qgnomeplatform-qt5", - "redshift-gtk", - "sane-backends-drivers-scanners", - "setroubleshoot", - "simple-scan", - "slick-greeter", - "slick-greeter-cinnamon", - "system-config-printer", - "tmux", - "tmux-powerline", - "vim-powerline", - "xawtv", - "xdg-user-dirs-gtk", - "xed", - "xfburn", - "xreader" - ] - }, - "exclude": { - "all": [ - "firefox", - "firefox-langpacks" - ] - } - }, - "37": { - "include": { - "all": [ - "raw-thumbnailer" - ] - }, - "exclude": { - "all": [] - } - }, - "38": { - "include": { - "all": [ - "raw-thumbnailer" - ] - }, - "exclude": { - "all": [ - ] - } - }, - "39": { - "include": { - "all": [] - }, - "exclude": { - "all": [] - } - } -} diff --git a/packages.json b/packages.json new file mode 120000 index 0000000..47e2857 --- /dev/null +++ b/packages.json @@ -0,0 +1 @@ +system_files/tmp/packages.json \ No newline at end of file diff --git a/system_files/tmp/build.sh b/system_files/tmp/build.sh new file mode 100755 index 0000000..3821144 --- /dev/null +++ b/system_files/tmp/build.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +set -ouex pipefail + +RELEASE="$(rpm -E %fedora)" + +INCLUDED_PACKAGES=($(jq -r "[(.all.include | (.all, select(.\"$IMAGE_NAME\" != null).\"$IMAGE_NAME\")[]), \ + (select(.\"$FEDORA_MAJOR_VERSION\" != null).\"$FEDORA_MAJOR_VERSION\".include | (.all, select(.\"$IMAGE_NAME\" != null).\"$IMAGE_NAME\")[])] \ + | sort | unique[]" /tmp/packages.json)) +EXCLUDED_PACKAGES=($(jq -r "[(.all.exclude | (.all, select(.\"$IMAGE_NAME\" != null).\"$IMAGE_NAME\")[]), \ + (select(.\"$FEDORA_MAJOR_VERSION\" != null).\"$FEDORA_MAJOR_VERSION\".exclude | (.all, select(.\"$IMAGE_NAME\" != null).\"$IMAGE_NAME\")[])] \ + | sort | unique[]" /tmp/packages.json)) + + +if [[ "${#EXCLUDED_PACKAGES[@]}" -gt 0 ]]; then + EXCLUDED_PACKAGES=($(rpm -qa --queryformat='%{NAME} ' ${EXCLUDED_PACKAGES[@]})) +fi + +if [[ "${#INCLUDED_PACKAGES[@]}" -gt 0 && "${#EXCLUDED_PACKAGES[@]}" -eq 0 ]]; then + rpm-ostree install \ + ${INCLUDED_PACKAGES[@]} + +elif [[ "${#INCLUDED_PACKAGES[@]}" -eq 0 && "${#EXCLUDED_PACKAGES[@]}" -gt 0 ]]; then + rpm-ostree override remove \ + ${EXCLUDED_PACKAGES[@]} + +elif [[ "${#INCLUDED_PACKAGES[@]}" -gt 0 && "${#EXCLUDED_PACKAGES[@]}" -gt 0 ]]; then + rpm-ostree override remove \ + ${EXCLUDED_PACKAGES[@]} \ + $(printf -- "--install=%s " ${INCLUDED_PACKAGES[@]}) + +else + echo "No packages to install." + +fi diff --git a/system_files/tmp/packages.json b/system_files/tmp/packages.json new file mode 100644 index 0000000..712000e --- /dev/null +++ b/system_files/tmp/packages.json @@ -0,0 +1,106 @@ +{ + "all": { + "include": { + "all": [ + "gnome-boxes", + "gnome-software", + "python3-pip", + "timeshift", + "touchegg", + "NetworkManager-adsl", + "NetworkManager-bluetooth", + "NetworkManager-iodine-gnome", + "NetworkManager-l2tp-gnome", + "NetworkManager-libreswan-gnome", + "NetworkManager-openconnect-gnome", + "NetworkManager-openvpn-gnome", + "NetworkManager-ppp", + "NetworkManager-pptp-gnome", + "NetworkManager-vpnc-gnome", + "NetworkManager-wifi", + "NetworkManager-wwan", + "abrt-desktop", + "abrt-java-connector", + "blueman", + "cinnamon", + "cinnamon-control-center", + "cinnamon-screensaver", + "eom", + "ffmpegthumbnailer", + "firewall-config", + "gnome-disk-utility", + "gnome-screenshot", + "gnome-system-monitor", + "gnome-terminal", + "gstreamer1-plugins-ugly-free", + "gvfs-archive", + "gvfs-gphoto2", + "gvfs-mtp", + "gvfs-smb", + "imsettings-gsettings", + "initial-setup-gui", + "metacity", + "nemo-fileroller", + "nemo-image-converter", + "nemo-preview", + "nemo-python", + "nm-connection-editor", + "paper-icon-theme", + "pipewire-alsa", + "pipewire-pulseaudio", + "powerline", + "qgnomeplatform-qt5", + "redshift-gtk", + "sane-backends-drivers-scanners", + "setroubleshoot", + "simple-scan", + "slick-greeter", + "slick-greeter-cinnamon", + "system-config-printer", + "tmux", + "tmux-powerline", + "vim-powerline", + "xawtv", + "xdg-user-dirs-gtk", + "xed", + "xfburn", + "xreader" + ] + }, + "exclude": { + "all": [ + "firefox", + "firefox-langpacks" + ] + } + }, + "37": { + "include": { + "all": [ + "raw-thumbnailer" + ] + }, + "exclude": { + "all": [] + } + }, + "38": { + "include": { + "all": [ + "raw-thumbnailer" + ] + }, + "exclude": { + "all": [ + ] + } + }, + "39": { + "include": { + "all": [] + }, + "exclude": { + "all": [] + } + } +} diff --git a/etc/profile.d/cinnamon-firstboot.sh b/system_files/usr/etc/profile.d/cinnamon-firstboot.sh similarity index 100% rename from etc/profile.d/cinnamon-firstboot.sh rename to system_files/usr/etc/profile.d/cinnamon-firstboot.sh diff --git a/etc/ublue-lightdm-workaround.sh b/system_files/usr/etc/ublue-lightdm-workaround.sh old mode 100644 new mode 100755 similarity index 100% rename from etc/ublue-lightdm-workaround.sh rename to system_files/usr/etc/ublue-lightdm-workaround.sh diff --git a/etc/systemd/system/ublue-lightdm-workaround.service b/system_files/usr/lib/systemd/system/ublue-lightdm-workaround.service similarity index 100% rename from etc/systemd/system/ublue-lightdm-workaround.service rename to system_files/usr/lib/systemd/system/ublue-lightdm-workaround.service diff --git a/config/touchegg.conf b/system_files/usr/share/touchegg/touchegg.conf similarity index 100% rename from config/touchegg.conf rename to system_files/usr/share/touchegg/touchegg.conf