Merge "gentoo: don't uninstall packages that aren't installed"

This commit is contained in:
Zuul 2024-01-30 15:03:34 +00:00 committed by Gerrit Code Review
commit 6fa80234bc
3 changed files with 26 additions and 14 deletions

View File

@ -232,7 +232,7 @@
base_element: gentoo
release: ''
env-vars:
GENTOO_PROFILE: 'default/linux/amd64/17.1/systemd'
GENTOO_PROFILE: 'default/linux/amd64/17.1/systemd/merged-usr'
- job:
name: dib-nodepool-functional-openstack-debian-stretch-src

View File

@ -126,8 +126,20 @@ else
if [[ ! -f ${PORTDIR}/profiles ]]; then
emerge-webrsync -q
fi
install_gentoo_packages -C "${PKGS}"
# remove packages from uninstall list that are not already installed
# this can result in false positives if not presented with full category/package names
CLEANED_PKGS=()
for PKG in ${PKGS}; do
# the '^' and '$' in the search query are important so we don't get matched to
# packages that include our package name as part of their package name
if [ ! emerge --search "^${PKG}$" | grep -q 'Not Installed' ]; then
CLEANED_PKGS+=("${PKG}")
fi
done
if [ ${#CLEANED_PKGS[@]} -ne 0 ]; then
install_gentoo_packages -C "${CLEANED_PKGS[@]}"
fi
else
echo 'something when really wrong, install action is not install or remove'
echo 'something went really wrong, install action is not install or remove'
fi
fi

View File

@ -45,24 +45,24 @@ elif [[ "${GENTOO_PROFILE}" == "default/linux/amd64/17.1/no-multilib/hardened" ]
elif [[ "${GENTOO_PROFILE}" == "default/linux/amd64/17.0/musl/hardened" ]]; then
FILENAME_BASE='amd64_gentoo-stage3-hardened-musl'
SIGNED_SOURCE_SUFFIX='-musl-hardened'
elif [[ "${GENTOO_PROFILE}" == "default/linux/amd64/17.1/systemd" ]]; then
FILENAME_BASE='amd64_gentoo-stage3-systemd'
SIGNED_SOURCE_SUFFIX='-systemd'
elif [[ "${GENTOO_PROFILE}" == "default/linux/arm64/17.1" ]]; then
elif [[ "${GENTOO_PROFILE}" == "default/linux/amd64/17.1/systemd/merged-usr" ]]; then
FILENAME_BASE='amd64_gentoo-stage3-systemd-mergedusr'
SIGNED_SOURCE_SUFFIX='-systemd-mergedusr'
elif [[ "${GENTOO_PROFILE}" == "default/linux/arm64/17.0" ]]; then
FILENAME_BASE='arm64_gentoo-stage3'
SIGNED_SOURCE_SUFFIX=''
elif [[ "${GENTOO_PROFILE}" == "default/linux/arm64/17.1/systemd" ]]; then
FILENAME_BASE='arm64_gentoo-stage3-systemd'
SIGNED_SOURCE_SUFFIX='-systemd'
elif [[ "${GENTOO_PROFILE}" == "default/linux/arm64/17.0/systemd/merged-usr" ]]; then
FILENAME_BASE='arm64_gentoo-stage3-systemd-mergedusr'
SIGNED_SOURCE_SUFFIX='-systemd-mergedusr'
else
echo 'invalid profile, please select from the following profiles'
echo 'default/linux/amd64/17.1'
echo 'default/linux/amd64/17.1/no-multilib'
echo 'default/linux/amd64/17.1/hardened'
echo 'default/linux/amd64/17.1/no-multilib/hardened'
echo 'default/linux/amd64/17.1/systemd'
echo 'default/linux/arm64/17.1'
echo 'default/linux/arm64/17.1/systemd'
echo 'default/linux/amd64/17.1/systemd/merged-usr'
echo 'default/linux/arm64/17.0'
echo 'default/linux/arm64/17.0/systemd/merged-usr'
exit 1
fi
@ -72,7 +72,7 @@ elif [[ "${GENTOO_PROFILE}" == *'arm64'* ]]; then
ARCH_PATH='arm64'
fi
DIB_CLOUD_SOURCE=${DIB_CLOUD_SOURCE:-"http://distfiles.gentoo.org/releases/${ARCH_PATH}/autobuilds/latest-stage3-${ARCH_PATH}${SIGNED_SOURCE_SUFFIX}.txt"}
BASE_IMAGE_FILE=${BASE_IMAGE_FILE:-"http://distfiles.gentoo.org/releases/${ARCH_PATH}/autobuilds/$(curl "${DIB_CLOUD_SOURCE}" -s -f | tail -n 1 | cut -d\ -f 1)"}
BASE_IMAGE_FILE=${BASE_IMAGE_FILE:-"http://distfiles.gentoo.org/releases/${ARCH_PATH}/autobuilds/$(curl "${DIB_CLOUD_SOURCE}" -s -f | grep -B1 'BEGIN PGP SIGNATURE' | head -n 1 | cut -d\ -f 1)"}
BASE_IMAGE_FILE_SUFFIX=${BASE_IMAGE_FILE_SUFFIX:-"$(basename "${BASE_IMAGE_FILE}" | cut -d. -f 2,3)"}
SIGNATURE_FILE="${SIGNATURE_FILE:-${BASE_IMAGE_FILE}.asc}"
CACHED_FILE="${DIB_IMAGE_CACHE}/${FILENAME_BASE}.${BASE_IMAGE_FILE_SUFFIX}"