diff --git a/bundles/k8s-ubuntu2404/Dockerfile b/bundles/k8s-ubuntu2404/Dockerfile index 6bee4cba17..647d1bfe81 100644 --- a/bundles/k8s-ubuntu2404/Dockerfile +++ b/bundles/k8s-ubuntu2404/Dockerfile @@ -23,6 +23,9 @@ RUN apt-get --print-uris --yes install \ RUN apt-get --print-uris --yes install \ kubelet=$(apt-cache madison kubeadm | grep ${KUBERNETES_VERSION}- | awk '{ print $3 }' | head -n 1) | \ grep ^\' | cut -d\' -f2 >> ~/raw_urls.txt +RUN apt-get --print-uris --yes install \ + kubectl=$(apt-cache madison kubeadm | grep ${KUBERNETES_VERSION}- | awk '{ print $3 }' | head -n 1) | \ + grep ^\' | cut -d\' -f2 >> ~/raw_urls.txt RUN cat ~/raw_urls.txt | grep 'pkgs.k8s.io' > ~/urls.txt RUN cd /archives && cat ~/urls.txt | xargs -I {} -n 1 curl -L -O {} @@ -32,13 +35,19 @@ RUN apt-cache depends kubeadm=$(apt-cache madison kubeadm | grep ${KUBERNETES_VE grep Depends | \ grep -v kubeadm | \ grep -v '<' | \ - grep -v 'cri-tools' | \ - grep -v 'kubernetes-cni' | \ - awk '{ print $2 }' > /archives/Deps + awk '{ print $2 }' > ~/AllDeps 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 kubelet | \ grep -v '<' | \ - grep -v 'cri-tools' | \ - grep -v 'kubernetes-cni' | \ - awk '{ print $2 }' >> /archives/Deps \ + awk '{ print $2 }' >> ~/AllDeps +RUN apt-cache depends kubectl=$(apt-cache madison kubeadm | grep ${KUBERNETES_VERSION}- | awk '{ print $3 }' | head -n 1) | \ + grep Depends | \ + grep -v kubectl | \ + grep -v '<' | \ + awk '{ print $2 }' >> ~/AllDeps + +# list the dependency names in /archives like cri-tools_131.0.0-0_amd64.deb and then remove the version number +RUN ls /archives | awk -F_ '{ print $1 }' > ~/K8sDepsNames +# remove things from 'Deps' that are in 'K8sDepsNames' +RUN grep -v -f ~/K8sDepsNames ~/AllDeps > /archives/Deps diff --git a/scripts/common/host-packages.sh b/scripts/common/host-packages.sh index 706c4fc76d..c22b0524ee 100644 --- a/scripts/common/host-packages.sh +++ b/scripts/common/host-packages.sh @@ -516,7 +516,7 @@ function apt_is_host_package_installed() { local package="$1" log "Checking if $package is installed" - apt list --installed "$package" >/dev/null 2>&1 + dpkg-query -W -f='${Status}' "$dep" 2>/dev/null | grep -q "ok installed" >/dev/null } # yum_is_host_package_installed returns 0 if the package is installed on the host