diff --git a/bin/save-manifest-assets.sh b/bin/save-manifest-assets.sh index 6384ad1c61..ff1ab460e7 100755 --- a/bin/save-manifest-assets.sh +++ b/bin/save-manifest-assets.sh @@ -378,6 +378,7 @@ pkgs_ol7=() pkgs_amazon2023=() deps_rhel9=() deps_amazon2023=() +deps_ubuntu2404=() while read -r line || [ -n "$line" ]; do if [ -z "$line" ]; then @@ -426,6 +427,7 @@ while read -r line || [ -n "$line" ]; do apt) mkdir -p "$OUT_DIR"/ubuntu-22.04 "$OUT_DIR"/ubuntu-20.04 "$OUT_DIR"/ubuntu-18.04 "$OUT_DIR"/ubuntu-16.04 package=$(echo "$line" | awk '{ print $2 }') + deps_ubuntu2404+=("$package") docker rm -f ubuntu-2204-"$package" 2>/dev/null || true docker run \ diff --git a/bundles/k8s-ubuntu2404/Dockerfile b/bundles/k8s-ubuntu2404/Dockerfile index b0590e0545..6bee4cba17 100644 --- a/bundles/k8s-ubuntu2404/Dockerfile +++ b/bundles/k8s-ubuntu2404/Dockerfile @@ -16,6 +16,7 @@ RUN mkdir -p /archives ARG KUBERNETES_VERSION +# get the urls of the actual kubernetes packages RUN apt-get --print-uris --yes install \ kubeadm=$(apt-cache madison kubeadm | grep ${KUBERNETES_VERSION}- | awk '{ print $3 }' | head -n 1) | \ grep ^\' | cut -d\' -f2 > ~/raw_urls.txt @@ -25,3 +26,19 @@ RUN apt-get --print-uris --yes install \ RUN cat ~/raw_urls.txt | grep 'pkgs.k8s.io' > ~/urls.txt RUN cd /archives && cat ~/urls.txt | xargs -I {} -n 1 curl -L -O {} + +# get the names of the packages that those depend on +RUN apt-cache depends kubeadm=$(apt-cache madison kubeadm | grep ${KUBERNETES_VERSION}- | awk '{ print $3 }' | head -n 1) | \ + grep Depends | \ + grep -v kubeadm | \ + grep -v '<' | \ + grep -v 'cri-tools' | \ + grep -v 'kubernetes-cni' | \ + awk '{ print $2 }' > /archives/Deps +RUN apt-cache depends kubelet=$(apt-cache madison kubeadm | grep ${KUBERNETES_VERSION}- | awk '{ print $3 }' | head -n 1) | \ + grep Depends | \ + grep -v kubeadm | \ + grep -v '<' | \ + grep -v 'cri-tools' | \ + grep -v 'kubernetes-cni' | \ + awk '{ print $2 }' >> /archives/Deps \ diff --git a/scripts/common/host-packages.sh b/scripts/common/host-packages.sh index 811216fc64..706c4fc76d 100644 --- a/scripts/common/host-packages.sh +++ b/scripts/common/host-packages.sh @@ -458,17 +458,41 @@ function preflights_require_host_packages() { fi seen+=("$dep") - if ! echo "$deps_file" | grep -q "rhel-9"; then - if ! echo "$deps_file" | grep -q "amazon-2023"; then - if ! echo "$deps_file" | grep -q "ubuntu-24.04"; then + # use rpm to check rhel/centos/ol/rocky/amzn and dpkg-query to check ubuntu + case "$LSB_DIST" in + centos|rhel|ol|rocky) + if ! echo "$deps_file" | grep -q "rhel-9"; then continue fi - fi - fi - if rpm -q "$dep" >/dev/null 2>&1 ; then - continue - fi - fail=1 + if rpm -q "$dep" >/dev/null 2>&1 ; then + continue + fi + fail=1 + ;; + amzn) + if ! echo "$deps_file" | grep -q "amazon-2023"; then + continue + fi + if rpm -q "$dep" >/dev/null 2>&1 ; then + continue + fi + fail=1 + ;; + ubuntu) + if ! echo "$deps_file" | grep -q "ubuntu-24"; then + continue + fi + if dpkg-query -W -f='${Status}' "$dep" 2>/dev/null | grep -q "ok installed"; then + continue + fi + fail=1 + ;; + *) + logFail "Host package checks are not supported on ${LSB_DIST} ${DIST_MAJOR}" + fail=1 + ;; + esac + component=$(echo "$deps_file" | awk -F'/' '{print $3}') if [ "$component" = "host" ]; then logFail "Host package $dep is required"