mirror of
https://github.com/outbackdingo/ucore.git
synced 2026-01-27 18:20:42 +00:00
refactor: ensure packages.json override/replace works (#80)
This commit is contained in:
33
hci/build.sh
33
hci/build.sh
@@ -4,25 +4,34 @@ set -ouex pipefail
|
||||
|
||||
RELEASE="$(rpm -E %fedora)"
|
||||
|
||||
## install packages.json stuffs
|
||||
# build list of all packages requested for inclusion
|
||||
INCLUDED_PACKAGES=($(jq -r "[(.all.include | (.all, select(.\"$IMAGE_NAME\" != null).\"$IMAGE_NAME\")[]), \
|
||||
(select(.\"$COREOS_VERSION\" != null).\"$COREOS_VERSION\".include | (.all, select(.\"$IMAGE_NAME\" != null).\"$IMAGE_NAME\")[])] \
|
||||
| sort | unique[]" /tmp/packages.json))
|
||||
|
||||
# build list of all packages requested for exclusion
|
||||
EXCLUDED_PACKAGES=($(jq -r "[(.all.exclude | (.all, select(.\"$IMAGE_NAME\" != null).\"$IMAGE_NAME\")[]), \
|
||||
(select(.\"$COREOS_VERSION\" != null).\"$COREOS_VERSION\".exclude | (.all, select(.\"$IMAGE_NAME\" != null).\"$IMAGE_NAME\")[])] \
|
||||
| sort | unique[]" /tmp/packages.json))
|
||||
|
||||
|
||||
# ensure exclusion list only contains packages already present on image
|
||||
if [[ "${#EXCLUDED_PACKAGES[@]}" -gt 0 ]]; then
|
||||
EXCLUDED_PACKAGES=($(rpm -qa --queryformat='%{NAME} ' ${EXCLUDED_PACKAGES[@]}))
|
||||
fi
|
||||
|
||||
# ensure exclusion list only contains packages already present on image
|
||||
if [[ "${#EXCLUDED_PACKAGES[@]}" -gt 0 ]]; then
|
||||
EXCLUDED_PACKAGES=($(rpm -qa --queryformat='%{NAME} ' ${EXCLUDED_PACKAGES[@]}))
|
||||
fi
|
||||
|
||||
# simple case to install where no packages need excluding
|
||||
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[@]}
|
||||
|
||||
# install/excluded packages both at same time
|
||||
elif [[ "${#INCLUDED_PACKAGES[@]}" -gt 0 && "${#EXCLUDED_PACKAGES[@]}" -gt 0 ]]; then
|
||||
rpm-ostree override remove \
|
||||
${EXCLUDED_PACKAGES[@]} \
|
||||
@@ -33,6 +42,22 @@ else
|
||||
|
||||
fi
|
||||
|
||||
# check if any excluded packages are still present
|
||||
# (this can happen if an included package pulls in a dependency)
|
||||
EXCLUDED_PACKAGES=($(jq -r "[(.all.exclude | (.all, select(.\"$IMAGE_NAME\" != null).\"$IMAGE_NAME\")[]), \
|
||||
(select(.\"$COREOS_VERSION\" != null).\"$COREOS_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
|
||||
|
||||
# remove any excluded packages which are still present on image
|
||||
if [[ "${#EXCLUDED_PACKAGES[@]}" -gt 0 ]]; then
|
||||
rpm-ostree override remove \
|
||||
${EXCLUDED_PACKAGES[@]}
|
||||
fi
|
||||
|
||||
|
||||
## install packages direct from github
|
||||
/tmp/github-release-install.sh trapexit/mergerfs fc.x86_64
|
||||
|
||||
@@ -42,25 +42,33 @@ if [[ "-zfs" == "${ZFS_TAG}" ]]; then
|
||||
fi
|
||||
|
||||
## install packages.json stuffs
|
||||
# build list of all packages requested for inclusion
|
||||
INCLUDED_PACKAGES=($(jq -r "[(.all.include | (.all, select(.\"$IMAGE_NAME\" != null).\"$IMAGE_NAME\")[]), \
|
||||
(select(.\"$COREOS_VERSION\" != null).\"$COREOS_VERSION\".include | (.all, select(.\"$IMAGE_NAME\" != null).\"$IMAGE_NAME\")[])] \
|
||||
| sort | unique[]" /tmp/packages.json))
|
||||
|
||||
# build list of all packages requested for exclusion
|
||||
EXCLUDED_PACKAGES=($(jq -r "[(.all.exclude | (.all, select(.\"$IMAGE_NAME\" != null).\"$IMAGE_NAME\")[]), \
|
||||
(select(.\"$COREOS_VERSION\" != null).\"$COREOS_VERSION\".exclude | (.all, select(.\"$IMAGE_NAME\" != null).\"$IMAGE_NAME\")[])] \
|
||||
| sort | unique[]" /tmp/packages.json))
|
||||
|
||||
|
||||
# ensure exclusion list only contains packages already present on image
|
||||
if [[ "${#EXCLUDED_PACKAGES[@]}" -gt 0 ]]; then
|
||||
EXCLUDED_PACKAGES=($(rpm -qa --queryformat='%{NAME} ' ${EXCLUDED_PACKAGES[@]}))
|
||||
fi
|
||||
|
||||
# ensure exclusion list only contains packages already present on image
|
||||
if [[ "${#EXCLUDED_PACKAGES[@]}" -gt 0 ]]; then
|
||||
EXCLUDED_PACKAGES=($(rpm -qa --queryformat='%{NAME} ' ${EXCLUDED_PACKAGES[@]}))
|
||||
fi
|
||||
|
||||
# simple case to install where no packages need excluding
|
||||
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[@]}
|
||||
|
||||
# install/excluded packages both at same time
|
||||
elif [[ "${#INCLUDED_PACKAGES[@]}" -gt 0 && "${#EXCLUDED_PACKAGES[@]}" -gt 0 ]]; then
|
||||
rpm-ostree override remove \
|
||||
${EXCLUDED_PACKAGES[@]} \
|
||||
@@ -70,3 +78,19 @@ else
|
||||
echo "No packages to install."
|
||||
|
||||
fi
|
||||
|
||||
# check if any excluded packages are still present
|
||||
# (this can happen if an included package pulls in a dependency)
|
||||
EXCLUDED_PACKAGES=($(jq -r "[(.all.exclude | (.all, select(.\"$IMAGE_NAME\" != null).\"$IMAGE_NAME\")[]), \
|
||||
(select(.\"$COREOS_VERSION\" != null).\"$COREOS_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
|
||||
|
||||
# remove any excluded packages which are still present on image
|
||||
if [[ "${#EXCLUDED_PACKAGES[@]}" -gt 0 ]]; then
|
||||
rpm-ostree override remove \
|
||||
${EXCLUDED_PACKAGES[@]}
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user