Skip to content

Commit

Permalink
feat: add framework-packages.json (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
bobslept authored Sep 9, 2023
1 parent fdc3f5d commit 0ee9d18
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
35 changes: 35 additions & 0 deletions framework-install.sh
Original file line number Diff line number Diff line change
@@ -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
32 changes: 32 additions & 0 deletions framework-packages.json
Original file line number Diff line number Diff line change
@@ -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": []
}
}
}

0 comments on commit 0ee9d18

Please sign in to comment.