@@ -14,31 +14,127 @@ if [ "${OPENSHIFT_CI}" != 0 ]; then
1414 /run/src/ci/get-ocp-repo.sh /etc/yum.repos.d/ocp.repo
1515fi
1616
17- # add all the repos from the src repo into `/etc/yum.repos.d` so dnf sees them
17+ # add all the repos from the src repo (including mounted in secret.repo)
18+ # into `/etc/yum.repos.d` so dnf sees them
1819cat /run/src/* .repo >> /etc/yum.repos.d/git.repo
1920
2021source /etc/os-release
2122
2223# XXX: For SCOS, only allow certain packages to come from ART; everything else
2324# should come from CentOS. We should eventually sever this.
2425if [ $ID = centos ]; then
25- # this says: "if the line starts with [.*], turn off printing. if the line starts with [our-repo], turn it on."
26- awk " /\[.*\]/{p=0} /\[rhel-10.2-server-ose-5.0\]/{p=1} p" /etc/yum.repos.d/* .repo > /etc/yum.repos.d/okd.repo.tmp
27- sed -i -e ' s,\[rhel-10.2-server-ose-5.0\],\[rhel-10.2-server-ose-5.0-okd\],' /etc/yum.repos.d/okd.repo.tmp
28- echo ' includepkgs=openshift-*,ose-aws-ecr-*,ose-azure-acr-*,ose-gcp-gcr-*,ose-crio-* ' >> /etc/yum.repos.d/okd.repo.tmp
29- mv /etc/yum.repos.d/okd.repo{.tmp,}
26+ OPENSHIFT_ART_REPO_NAME=${YUM_REPO_NAMES/* ,/ } # ART repo == the last repo in the list
27+ dnf config-manager --save \
28+ --setopt=" ${OPENSHIFT_ART_REPO_NAME} .includepkgs=openshift-*,ose-aws-ecr-*,ose-azure-acr-*,ose-gcp-gcr-*,ose-crio-*"
3029fi
3130
3231# XXX: patch cri-o spec to use tmpfiles
3332# https://github.com/CentOS/centos-bootc/issues/393
3433mkdir -p /var/opt
3534
36- # this is where all the real work happens
37- rpm-ostree experimental compose treefile-apply \
38- --var " osversion=${ID} -${VERSION_ID} " /run/src/packages-openshift.yaml
35+ # Version lock to the specific packages installed on the system already
36+ dnf --disablerepo=* versionlock add ' *'
3937
40- # cleanup any repo files we injected
41- rm -f /etc/yum.repos.d/{ocp,git,okd}.repo
38+ # Install the OCP packages. Limit to appropriate repos for this stream.
39+ dnf --repo=" ${YUM_REPO_NAMES} " install -y \
40+ cri-o cri-tools conmon-rs \
41+ openshift-clients openshift-kubelet \
42+ openvswitch3.5 \
43+ NetworkManager-ovs \
44+ ose-aws-ecr-image-credential-provider \
45+ ose-azure-acr-image-credential-provider \
46+ ose-gcp-gcr-image-credential-provider \
47+ ose-crio-credential-provider
48+
49+ # clear the versionlock and clean up any dnf caches / yum repo files we created.
50+ # note `redhat.repo` gets created when you run dnf (via subscription-manager plugin),
51+ # so we'll clean that up too.
52+ dnf --disablerepo=* versionlock clear
53+ dnf clean all
54+ rm -vf /etc/yum.repos.d/{ocp,git,redhat}.repo
55+
56+
57+ # --- postprocess steps ---
58+ # These were previously in the `postprocess` section of packages-openshift.yaml.
59+
60+ # Disable any built-in repos. We need to work in disconnected environments by
61+ # default, and default-enabled repos will be attempted to be fetched by
62+ # rpm-ostree when doing node-local kernel overrides today for e.g. kernel-rt.
63+ for x in $( find /etc/yum.repos.d/ -name ' *.repo' ) ; do
64+ sed -i -e ' s/enabled\s*=\s*1/enabled=0/g' " $x "
65+ done
66+
67+ # Enable librhsm which enables host subscriptions to work in containers
68+ # https://github.com/rpm-software-management/librhsm/blob/fcd972cbe7c8a3907ba9f091cd082b1090231492/rhsm/rhsm-context.c#L30
69+ ln -sr /run/secrets/etc-pki-entitlement /etc/pki/entitlement-host
70+ ln -sr /run/secrets/rhsm /etc/rhsm-host
71+
72+ # Manually modify SELinux booleans that are needed for OCP use cases
73+ semanage boolean --modify --on container_use_cephfs # RHBZ#1694045
74+ semanage boolean --modify --on virt_use_samba # RHBZ#1754825
75+
76+ # https://gitlab.cee.redhat.com/coreos/redhat-coreos/merge_requests/812
77+ # https://bugzilla.redhat.com/show_bug.cgi?id=1796537
78+ mkdir -p /usr/share/containers/oci/hooks.d
79+
80+ # crio conmon symlink
81+ mkdir -p /usr/libexec/crio
82+ ln -sr /usr/bin/conmon /usr/libexec/crio/conmon
83+
84+ # Inject OpenShift-specific release fields
85+ cat >> /usr/lib/os-release << EOF
86+ OPENSHIFT_VERSION="${OPENSHIFT_VERSION} "
87+ EOF
88+
89+ # Generate MOTD
90+ # Detect variant based on the Containerfile metadata. In the absence of
91+ # rpm-ostree treefile metadata, we use a heuristic: centos builds are SCOS.
92+ if [ " $ID " = " centos" ]; then
93+ colloquial_name=SCOS
94+ project_name=OKD
95+ else
96+ colloquial_name=RHCOS
97+ project_name=OpenShift
98+ fi
99+ # in the el-only variants, we already have CoreOS in the NAME, so don't
100+ # re-add it when building the node image
101+ if [[ $NAME != * CoreOS* ]]; then
102+ NAME=" $NAME CoreOS"
103+ fi
104+ cat > /etc/motd << EOF
105+ $NAME $OSTREE_VERSION
106+ Part of ${project_name} ${OPENSHIFT_VERSION} , ${colloquial_name} is a Kubernetes-native operating system
107+ managed by the Machine Config Operator (\` clusteroperator/machine-config\` ).
108+
109+ WARNING: Direct SSH access to machines is not recommended; instead,
110+ make configuration changes via \` machineconfig\` objects:
111+ https://docs.openshift.com/container-platform/${OPENSHIFT_VERSION} /architecture/architecture-rhcos.html
112+
113+ ---
114+ EOF
115+
116+ # Delete leftover files in the layering path
117+ if [ -f /run/.containerenv ]; then
118+ # lockfiles and backup files
119+ rm -f /etc/.pwd.lock /etc/group- /etc/gshadow- /etc/shadow- /etc/passwd-
120+ rm -f /etc/selinux/targeted/* .LOCK
121+ # cache, logs, etc...
122+ rm -rf /var && mkdir /var
123+ # All the entries here should instead be part of their respective
124+ # packages. But we carry them here for now to maintain compatibility.
125+ cat > /usr/lib/tmpfiles.d/openshift.conf << EOF
126+ L /opt/cni - - - - ../../usr/lib/opt/cni
127+ d /var/lib/cni 0755 root root - -
128+ d /var/lib/cni/bin 0755 root root - -
129+ d /var/lib/containers 0755 root root - -
130+ d /var/lib/openvswitch 0755 root root - -
131+ d /var/lib/openvswitch/pki 0755 root root - -
132+ d /var/log/openvswitch 0750 openvswitch hugetlbfs - -
133+ d /var/lib/unbound 0755 unbound unbound - -
134+ EOF
135+ fi
136+
137+ # --- end postprocess steps ---
42138
43139find /usr -name ' *.pyc.bak' -exec sh -c ' mv $1 ${1%.bak}' _ {} \;
44140ostree container commit
0 commit comments