Skip to content

Commit

Permalink
Merge pull request #1398 from ErikJiang/update_other_os_pkgs_1
Browse files Browse the repository at this point in the history
optimize tool scripts for other os packages
  • Loading branch information
ErikJiang authored Nov 6, 2024
2 parents 685cc27 + 6429e76 commit 1d73317
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 71 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/call-offline-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ jobs:
./artifacts/gen_airgap_crs.py Manifest
./artifacts/gen_airgap_crs.py LocalArtifactSet
cp artifacts/import_iso.sh ${KUBEAN_TAG}/
cp build/os-packages/others/other_os_pkgs.sh ${KUBEAN_TAG}/
pushd ${KUBEAN_TAG}
sha256sum localartifactset.cr.yaml >> ../${{ env.SHA256SUM_TXT }}
sha256sum import_iso.sh >> ../${{ env.SHA256SUM_TXT }}
sha256sum other_os_pkgs.sh >> ../${{ env.SHA256SUM_TXT }}
popd
echo "localartifactset cr output:"
Expand Down
3 changes: 0 additions & 3 deletions build/os-packages/others/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Please make sure these tools are installed in your OS environment:

``` bash
$ cd /home
$ curl -Lo ./pkgs.yml https://raw.githubusercontent.com/kubean-io/kubean/main/build/os-packages/others/pkgs.yml
$ curl -Lo ./other_os_pkgs.sh https://raw.githubusercontent.com/kubean-io/kubean/main/build/os-packages/others/other_os_pkgs.sh && chmod +x other_os_pkgs.sh
```

Expand All @@ -19,7 +18,6 @@ Since the build process will download packages, you need to make sure that the n

``` bash
$ cd /home
$ export PKGS_YML_PATH=/home/pkgs.yml
$ ./other_os_pkgs.sh build
```

Expand All @@ -28,7 +26,6 @@ $ ./other_os_pkgs.sh build
Prepare the OS package tarball file in advance.

``` bash
$ export PKGS_YML_PATH=/home/pkgs.yml
$ export PKGS_TAR_PATH=/home/os-pkgs.tar.gz
$ export HOST_IPS='192.168.10.11 192.168.10.12'

Expand Down
85 changes: 64 additions & 21 deletions build/os-packages/others/other_os_pkgs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ DISTRO=${DISTRO:-''}
VERSION=${VERSION:-''}
ARCH=${ARCH:-''}

PKGS_YML_PATH=${PKGS_YML_PATH:-"pkgs.yml"}
PKGS_TAR_PATH=${PKGS_TAR_PATH:-"os-pkgs-${DISTRO}-${VERSION}.tar.gz"}

SSH_MODE=${SSH_MODE:-'PWD'} # PWD or KEY
Expand All @@ -18,6 +17,60 @@ HOST_IPS=${HOST_IPS:-''}

REMOTE_REPO_PATH='/home/other_repo'

#===========================#
###### Packages config ######
#===========================#

PKGS_YML_CONF='
yum:
build_tools:
- createrepo
- yum-utils
required_pkgs:
- libselinux-python
- python3-libselinux
- device-mapper-libs
- nss-tools
- conntrack
- container-selinux
- libseccomp
- chrony
- iputils
required_mods:
- container-tools
apt:
build_tools:
- dpkg-dev
required_pkgs:
- python-apt
- python3-apt
- aufs-tools
- apt-transport-https
- software-properties-common
- conntrack
- apparmor
- libseccomp2
- ntp
- iputils-ping
commons:
- openssl
- curl
- rsync
- socat
- unzip
- e2fsprogs
- xfsprogs
- ebtables
- bash-completion
- tar
- ipvsadm
- ipset
- sshpass
'


#============================#
###### Common Functions ######
#============================#
Expand Down Expand Up @@ -118,8 +171,8 @@ function get_local_os_release() {

function yum_build() {
local build_path="/${DISTRO}/${VERSION}/os"
local build_tools=$(cat ${PKGS_YML_PATH} | yq eval '.yum.build_tools[]' | tr '\n' ' ')
local packages=$(cat ${PKGS_YML_PATH} | yq eval '.yum.required_pkgs[],.commons[]' | tr '\n' ' ')
local build_tools=$(echo "${PKGS_YML_CONF}" | yq eval '.yum.build_tools[]' | tr '\n' ' ')
local packages=$(echo "${PKGS_YML_CONF}" | yq eval '.yum.required_pkgs[],.commons[]' | tr '\n' ' ')

mkdir -p ${build_path}
pushd ${build_path}
Expand All @@ -146,9 +199,9 @@ function yum_build() {

function dnf_build() {
local build_path="/${DISTRO}/${VERSION}/os"
local build_tools=$(cat ${PKGS_YML_PATH} | yq eval '.yum.build_tools[]' | tr '\n' ' ')
local packages=$(cat ${PKGS_YML_PATH} | yq eval '.yum.required_pkgs[],.commons[]' | tr '\n' ' ')
local modules=$(cat ${PKGS_YML_PATH} | yq eval '.yum.required_mods[]' | tr '\n' ' ')
local build_tools=$(echo "${PKGS_YML_CONF}" | yq eval '.yum.build_tools[]' | tr '\n' ' ')
local packages=$(echo "${PKGS_YML_CONF}" | yq eval '.yum.required_pkgs[],.commons[]' | tr '\n' ' ')
local modules=$(echo "${PKGS_YML_CONF}" | yq eval '.yum.required_mods[]' | tr '\n' ' ')

mkdir -p ${build_path}
pushd ${build_path}
Expand Down Expand Up @@ -183,8 +236,8 @@ function dnf_build() {

function apt_build() {
local build_path="/${DISTRO}/$(require_arch)/${VERSION}"
local build_tools=$(cat ${PKGS_YML_PATH} | yq eval '.apt.build_tools[]' | tr '\n' ' ')
local packages=$(cat ${PKGS_YML_PATH} | yq eval '.apt.required_pkgs[],.commons[]' | tr '\n' ' ')
local build_tools=$(echo "${PKGS_YML_CONF}" | yq eval '.apt.build_tools[]' | tr '\n' ' ')
local packages=$(echo "${PKGS_YML_CONF}" | yq eval '.apt.required_pkgs[],.commons[]' | tr '\n' ' ')

mkdir -p ${build_path}
pushd ${build_path}
Expand Down Expand Up @@ -229,10 +282,6 @@ function Build() {
log_erro "Please install the tar command line tool."
fi

if [ -z "${PKGS_YML_PATH}" ] || [ ! -f ${PKGS_YML_PATH} ]; then
log_erro "package config: \${PKGS_YML_PATH} should exist."
fi

if [ -z "${DISTRO}" ]; then
DISTRO=$(get_local_os_release 'ID')
fi
Expand Down Expand Up @@ -318,7 +367,7 @@ function dnf_install() {
local ip=$1
local yum_repos_path='/etc/yum.repos.d'
local yum_repo_config='other-extra.repo'
local packages=$(cat ${PKGS_YML_PATH} | yq eval '.yum.required_pkgs[],.commons[]' | tr '\n' ' ')
local packages=$(echo "${PKGS_YML_CONF}" | yq eval '.yum.required_pkgs[],.commons[]' | tr '\n' ' ')

remote_exec "${ip}" "mv /etc/yum.repos.d/ /etc/yum.repos.d.bak/ && mkdir -p /etc/yum.repos.d/"
# Distribute yum repo configuration
Expand Down Expand Up @@ -356,7 +405,7 @@ function yum_install() {
local ip=$1
local yum_repos_path='/etc/yum.repos.d'
local yum_repo_config='other-extra.repo'
local packages=$(cat ${PKGS_YML_PATH} | yq eval '.yum.required_pkgs[],.commons[]' | tr '\n' ' ')
local packages=$(echo "${PKGS_YML_CONF}" | yq eval '.yum.required_pkgs[],.commons[]' | tr '\n' ' ')

remote_exec "${ip}" "mv /etc/yum.repos.d/ /etc/yum.repos.d.bak/ && mkdir -p /etc/yum.repos.d/"
# Distribute yum repo configuration
Expand Down Expand Up @@ -385,7 +434,7 @@ EOF
function apt_install() {
local ip=$1
local apt_repo_path='/etc/apt/sources.list'
local packages=$(cat ${PKGS_YML_PATH} | yq eval '.apt.required_pkgs[],.commons[]' | tr '\n' ' ')
local packages=$(echo "${PKGS_YML_CONF}" | yq eval '.apt.required_pkgs[],.commons[]' | tr '\n' ' ')
local extra_repo="deb [trusted=yes] file://${REMOTE_REPO_PATH}/os-pkgs/resources/${DISTRO}/$(require_arch)/${VERSION} ./"
local install_failed_list=()

Expand Down Expand Up @@ -441,10 +490,6 @@ function Install() {
if [ -z "${PKGS_TAR_PATH}" ] || [ ! -f ${PKGS_TAR_PATH} ]; then
log_erro "Package tar path: \${PKGS_TAR_PATH} should exist."
fi
# Check if PKGS_YML_PATH exists
if [ -z "${PKGS_YML_PATH}" ] || [ ! -f ${PKGS_YML_PATH} ]; then
log_erro "Package yml path: \${PKGS_YML_PATH} should exist."
fi
# Check if HOST_IPS is empty
if [ -z "${HOST_IPS}" ]; then
log_erro "Host IPs: \${HOST_IPS} should not be empty."
Expand Down Expand Up @@ -520,11 +565,9 @@ Commands
Examples
# Build OS Package
export PKGS_YML_PATH=/home/pkgs.yml
./$cmd build
# Install OS Package
export PKGS_YML_PATH=/home/pkgs.yml
export PKGS_TAR_PATH=/home/os-pkgs.tar.gz
export SSH_USER=root
export SSH_CRED=dangerous
Expand Down
46 changes: 0 additions & 46 deletions build/os-packages/others/pkgs.yml

This file was deleted.

2 changes: 1 addition & 1 deletion version.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
kubespray_version: 5988ba0890b06fb937070fbeb5059861d301e641
kubernetes_version: v1.30.4
kubernetes_version: v1.30.5

0 comments on commit 1d73317

Please sign in to comment.