Skip to content

Commit 8d3b3d7

Browse files
authoredAug 22, 2024··
do intelligent detection of which ubuntu 24.04 deps are provided by k8s packages (#5346)
1 parent b8efefe commit 8d3b3d7

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed
 

‎bundles/k8s-ubuntu2404/Dockerfile

+16-7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ RUN apt-get --print-uris --yes install \
2323
RUN apt-get --print-uris --yes install \
2424
kubelet=$(apt-cache madison kubeadm | grep ${KUBERNETES_VERSION}- | awk '{ print $3 }' | head -n 1) | \
2525
grep ^\' | cut -d\' -f2 >> ~/raw_urls.txt
26+
RUN apt-get --print-uris --yes install \
27+
kubectl=$(apt-cache madison kubeadm | grep ${KUBERNETES_VERSION}- | awk '{ print $3 }' | head -n 1) | \
28+
grep ^\' | cut -d\' -f2 >> ~/raw_urls.txt
2629

2730
RUN cat ~/raw_urls.txt | grep 'pkgs.k8s.io' > ~/urls.txt
2831
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
3235
grep Depends | \
3336
grep -v kubeadm | \
3437
grep -v '<' | \
35-
grep -v 'cri-tools' | \
36-
grep -v 'kubernetes-cni' | \
37-
awk '{ print $2 }' > /archives/Deps
38+
awk '{ print $2 }' > ~/AllDeps
3839
RUN apt-cache depends kubelet=$(apt-cache madison kubeadm | grep ${KUBERNETES_VERSION}- | awk '{ print $3 }' | head -n 1) | \
3940
grep Depends | \
40-
grep -v kubeadm | \
41+
grep -v kubelet | \
4142
grep -v '<' | \
42-
grep -v 'cri-tools' | \
43-
grep -v 'kubernetes-cni' | \
44-
awk '{ print $2 }' >> /archives/Deps \
43+
awk '{ print $2 }' >> ~/AllDeps
44+
RUN apt-cache depends kubectl=$(apt-cache madison kubeadm | grep ${KUBERNETES_VERSION}- | awk '{ print $3 }' | head -n 1) | \
45+
grep Depends | \
46+
grep -v kubectl | \
47+
grep -v '<' | \
48+
awk '{ print $2 }' >> ~/AllDeps
49+
50+
# list the dependency names in /archives like cri-tools_131.0.0-0_amd64.deb and then remove the version number
51+
RUN ls /archives | awk -F_ '{ print $1 }' > ~/K8sDepsNames
52+
# remove things from 'Deps' that are in 'K8sDepsNames'
53+
RUN grep -v -f ~/K8sDepsNames ~/AllDeps > /archives/Deps

‎scripts/common/host-packages.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ function apt_is_host_package_installed() {
516516
local package="$1"
517517

518518
log "Checking if $package is installed"
519-
apt list --installed "$package" >/dev/null 2>&1
519+
dpkg-query -W -f='${Status}' "$dep" 2>/dev/null | grep -q "ok installed" >/dev/null
520520
}
521521

522522
# yum_is_host_package_installed returns 0 if the package is installed on the host

0 commit comments

Comments
 (0)
Please sign in to comment.