|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +set -ouex pipefail |
| 4 | + |
| 5 | +RELEASE="$(rpm -E %fedora)" |
| 6 | + |
| 7 | +curl -Lo /etc/yum.repos.d/negativo17-fedora-multimedia.repo https://negativo17.org/repos/fedora-multimedia.repo |
| 8 | +sed -i '0,/enabled=1/{s/enabled=1/enabled=1\npriority=90/}' /etc/yum.repos.d/negativo17-fedora-multimedia.repo |
| 9 | + |
| 10 | +curl -Lo /etc/yum.repos.d/_copr_ublue-os_staging.repo https://copr.fedorainfracloud.org/coprs/ublue-os/staging/repo/fedora-"${RELEASE}"/ublue-os-staging-fedora-"${RELEASE}".repo |
| 11 | + |
| 12 | +# From https://github.com/ublue-os/main/blob/main/packages.sh |
| 13 | + |
| 14 | +# build list of all packages requested for inclusion |
| 15 | +INCLUDED_PACKAGES=($(jq -r "[(.all.include | (.all, select(.\"$IMAGE_NAME\" != null).\"$IMAGE_NAME\")[]), \ |
| 16 | + (select(.\"$RELEASE\" != null).\"$RELEASE\".include | (.all, select(.\"$IMAGE_NAME\" != null).\"$IMAGE_NAME\")[])] \ |
| 17 | + | sort | unique[]" 03-ublue.json)) |
| 18 | + |
| 19 | +# build list of all packages requested for exclusion |
| 20 | +EXCLUDED_PACKAGES=($(jq -r "[(.all.exclude | (.all, select(.\"$IMAGE_NAME\" != null).\"$IMAGE_NAME\")[]), \ |
| 21 | + (select(.\"$RELEASE\" != null).\"$RELEASE\".exclude | (.all, select(.\"$IMAGE_NAME\" != null).\"$IMAGE_NAME\")[])] \ |
| 22 | + | sort | unique[]" 03-ublue.json)) |
| 23 | + |
| 24 | + |
| 25 | +# ensure exclusion list only contains packages already present on image |
| 26 | +if [[ "${#EXCLUDED_PACKAGES[@]}" -gt 0 ]]; then |
| 27 | + EXCLUDED_PACKAGES=($(rpm -qa --queryformat='%{NAME} ' ${EXCLUDED_PACKAGES[@]})) |
| 28 | +fi |
| 29 | + |
| 30 | +# simple case to install where no packages need excluding |
| 31 | +if [[ "${#INCLUDED_PACKAGES[@]}" -gt 0 && "${#EXCLUDED_PACKAGES[@]}" -eq 0 ]]; then |
| 32 | + rpm-ostree install \ |
| 33 | + ${INCLUDED_PACKAGES[@]} |
| 34 | + |
| 35 | +# install/excluded packages both at same time |
| 36 | +elif [[ "${#INCLUDED_PACKAGES[@]}" -gt 0 && "${#EXCLUDED_PACKAGES[@]}" -gt 0 ]]; then |
| 37 | + rpm-ostree override remove \ |
| 38 | + ${EXCLUDED_PACKAGES[@]} \ |
| 39 | + $(printf -- "--install=%s " ${INCLUDED_PACKAGES[@]}) |
| 40 | + |
| 41 | +else |
| 42 | + echo "No packages to install." |
| 43 | + |
| 44 | +fi |
| 45 | + |
| 46 | +# check if any excluded packages are still present |
| 47 | +# (this can happen if an included package pulls in a dependency) |
| 48 | +EXCLUDED_PACKAGES=($(jq -r "[(.all.exclude | (.all, select(.\"$IMAGE_NAME\" != null).\"$IMAGE_NAME\")[]), \ |
| 49 | + (select(.\"$RELEASE\" != null).\"$RELEASE\".exclude | (.all, select(.\"$IMAGE_NAME\" != null).\"$IMAGE_NAME\")[])] \ |
| 50 | + | sort | unique[]" 03-ublue.json)) |
| 51 | + |
| 52 | +if [[ "${#EXCLUDED_PACKAGES[@]}" -gt 0 ]]; then |
| 53 | + EXCLUDED_PACKAGES=($(rpm -qa --queryformat='%{NAME} ' ${EXCLUDED_PACKAGES[@]})) |
| 54 | +fi |
| 55 | + |
| 56 | +# remove any excluded packages which are still present on image |
| 57 | +if [[ "${#EXCLUDED_PACKAGES[@]}" -gt 0 ]]; then |
| 58 | + rpm-ostree override remove \ |
| 59 | + ${EXCLUDED_PACKAGES[@]} |
| 60 | +fi |
0 commit comments