diff --git a/Containerfile b/Containerfile index 7ecc342..9239ed6 100644 --- a/Containerfile +++ b/Containerfile @@ -5,11 +5,16 @@ ARG BASE_IMAGE="ghcr.io/ublue-os/${SOURCE_IMAGE}" ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION:-38}" FROM ${BASE_IMAGE}:${FEDORA_MAJOR_VERSION} AS framework +ARG BASE_IMAGE_NAME="${BASE_IMAGE_NAME:-silverblue}" +ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION:-38}" COPY usr /usr +COPY framework-install.sh /tmp/framework-install.sh +COPY framework-packages.json /tmp/framework-packages.json -RUN rpm-ostree install tlp tlp-rdw && \ - rpm-ostree override remove power-profiles-daemon && \ +RUN /tmp/framework-install.sh && \ systemctl enable tlp && \ systemctl enable fprintd && \ - ostree container commit + rm -rf /tmp/* /var/* && \ + ostree container commit && \ + mkdir -p /var/tmp && chmod -R 1777 /tmp /var/tmp diff --git a/framework-install.sh b/framework-install.sh new file mode 100755 index 0000000..fccd842 --- /dev/null +++ b/framework-install.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +set -ouex pipefail + +RELEASE="$(rpm -E %fedora)" + +INCLUDED_PACKAGES=($(jq -r "[(.all.include | (.all, select(.\"$BASE_IMAGE_NAME\" != null).\"$BASE_IMAGE_NAME\")[]), \ + (select(.\"$FEDORA_MAJOR_VERSION\" != null).\"$FEDORA_MAJOR_VERSION\".include | (.all, select(.\"$BASE_IMAGE_NAME\" != null).\"$BASE_IMAGE_NAME\")[])] \ + | sort | unique[]" /tmp/framework-packages.json)) +EXCLUDED_PACKAGES=($(jq -r "[(.all.exclude | (.all, select(.\"$BASE_IMAGE_NAME\" != null).\"$BASE_IMAGE_NAME\")[]), \ + (select(.\"$FEDORA_MAJOR_VERSION\" != null).\"$FEDORA_MAJOR_VERSION\".exclude | (.all, select(.\"$BASE_IMAGE_NAME\" != null).\"$BASE_IMAGE_NAME\")[])] \ + | sort | unique[]" /tmp/framework-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/framework-packages.json b/framework-packages.json new file mode 100644 index 0000000..58018f7 --- /dev/null +++ b/framework-packages.json @@ -0,0 +1,32 @@ +{ + "all": { + "include": { + "all": [ + "fprintd", + "tlp", + "tlp-rdw" + ] + }, + "exclude": { + "all": [ + "power-profiles-daemon" + ] + } + }, + "37": { + "include": { + "all": [] + }, + "exclude": { + "all": [] + } + }, + "38": { + "include": { + "all": [] + }, + "exclude": { + "all": [] + } + } +}