Skip to content

Commit

Permalink
feat: Builds oracle-9.4 offline package
Browse files Browse the repository at this point in the history
  • Loading branch information
manoj-nutanix committed Sep 30, 2024
1 parent 4f29942 commit e2a307c
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 0 deletions.
54 changes: 54 additions & 0 deletions bundles/oracle9.4/bundle.sh.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash
set -x
set -euo pipefail

# When yum operates on multiple packages, it does not, by default, return an error if a subset
# of packages is not found. This makes yum return an error.
echo skip_missing_names_on_install=False >> /etc/yum.conf

# Check for Oracle Linux repositories
ORACLE_REPOS=${ORACLE_REPOS:-"ol9_baseos_latest,ol9_appstream"}

KUBERNETES_REPOS=${KUBERNETES_REPOS:-""}
if [[ -n "${KUBERNETES_REPOS}" ]]; then
ORACLE_REPOS="${ORACLE_REPOS},kubernetes"
fi

# Install required tools for repository creation
yum -y install dnf-utils createrepo modulemd-tools yum-utils
yum clean all
TMP_DIR="$(mktemp -d repodata-XXXX)"
chmod 777 -R "${TMP_DIR}"
cp packages.txt "${TMP_DIR}"
pushd "${TMP_DIR}"

# Download package dependencies
# shellcheck disable=SC2046,SC2062,SC2063,SC2035
repoquery --archlist=x86_64,noarch --resolve --requires --recursive $(< packages.txt) | grep -v *.i686 >> reqs.txt
sed -i 1d reqs.txt # Remove the first line from the requirements file

# Download packages and dependencies
# shellcheck disable=SC2046
yumdownloader --archlist=x86_64,noarch \
--setopt=skip_missing_names_on_install=False -x \*i686 $(< reqs.txt)

yumdownloader --setopt=skip_missing_names_on_install=False -x \*i686 --archlist=x86_64,noarch \
--resolve --disablerepo=* --enablerepo="${ORACLE_REPOS}" \
$(< packages.txt)

# Clean up package and requirements files
rm packages.txt reqs.txt

# Create repository metadata and module information
createrepo -v .
repo2module . --module-name offline
createrepo_mod .

# Package the repository into a tarball with proper permissions
# shellcheck disable=SC1083,SC2035
tar -czf {{ .OutputDirectory }}/{{ .KubernetesVersion }}_oracle_9.4_x86_64{{ .FipsSuffix }}.tar.gz *
chmod 777 {{ .OutputDirectory }}/{{ .KubernetesVersion }}_oracle_9.4_x86_64{{ .FipsSuffix }}.tar.gz

# Return to the original directory and clean up
popd
rm -rf "${TMP_DIR}"
29 changes: 29 additions & 0 deletions bundles/oracle9.4/packages.txt.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
audit
ca-certificates
conntrack-tools
chrony
open-vm-tools
python3-pip
socat
sysstat
dnf-utils
dnf-plugin-versionlock
NetworkManager
cloud-init
cloud-utils-growpart
container-selinux
{{ if .FetchKubernetesRPMs -}}
kubectl-{{ .KubernetesVersion }}-0
kubelet-{{ .KubernetesVersion }}-0
kubeadm-{{ .KubernetesVersion }}-0
cri-tools
{{- end }}
conntrack
ebtables
ethtool
iproute
iptables
socat
gcc
libseccomp
nfs-utils
5 changes: 5 additions & 0 deletions bundles/oracle9.4/repo-templates/kubernetes.repo.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[kubernetes]
name=Konvoy Kubernetes package repository
baseurl=https://packages.d2iq.com/konvoy/stable/linux/repos/el/kubernetes-v{{ .KubernetesVersion }}-{{ .RepoSuffix }}/x86_64
gpgcheck=1
gpgkey=https://packages.d2iq.com/konvoy/stable/linux/repos/d2iq-sign-authority-gpg-public-key
5 changes: 5 additions & 0 deletions cmd/konvoy-image-wrapper/cmd/create-package-bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ var osToConfig = map[string]OSConfig{
configDir: "bundles/ubuntu20.04",
containerImage: "docker.io/library/ubuntu:20.04",
},
"oracle-9.4": {
configDir: "bundles/oracle9.4",
containerImage: "docker.io/library/oraclelinux:9",
},
}

func getKubernetesVerisonFromAnsible() (string, error) {
Expand Down Expand Up @@ -346,6 +350,7 @@ func startContainer(containerEngine, containerImage,
cmd := exec.Command(
containerEngine, "run",
"--interactive",
// "--platform linux/amd64",
"--tty="+strconv.FormatBool(tty),
"--rm",
"-v", fmt.Sprintf("%s:/%s", outputDir, outputBaseName),
Expand Down

0 comments on commit e2a307c

Please sign in to comment.