Skip to content

Commit

Permalink
Fix build-tests/x86/tumbleweed
Browse files Browse the repository at this point in the history
Fix build-tests/x86/tumbleweed to build outside of OBS.
In addition I added a simple build-tests.sh script which
makes use of boxbuild in container mode to build the tests
from a given build-tests directory.
  • Loading branch information
schaefi committed Mar 4, 2025
1 parent 03b0560 commit 61a23d4
Show file tree
Hide file tree
Showing 24 changed files with 231 additions and 11 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ check: setup
# shell code checks
bash -c 'shellcheck -e ${sc_disable} dracut/modules.d/*/*.sh -s bash'
bash -c 'shellcheck -e ${sc_disable} kiwi/config/functions.sh -s bash'
bash -c 'shellcheck build-tests.sh'
# python flake tests
poetry run flake8 --statistics -j auto --count kiwi
poetry run flake8 --statistics -j auto --count test/unit
Expand Down
153 changes: 153 additions & 0 deletions build-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
#!/bin/bash
# git clone https://github.com/OSInside/kiwi.git
# Simple build test script to build the integration test
# images from a given test directory. The host to run this
# command requires the following packages:
#
# - tree
# - git
# - libxml2-tools
# - podman
# - python311-pip
#
# And requires the installation of the kiwi box plugin
#
# $ pip3.11 install --upgrade kiwi-boxed-plugin
#
set -e

ARGUMENT_LIST=(
"test-dir:"
"test-name:"
"box-name:"
)

function usage() {
echo "usage: build-tests --test-dir <dir>"
echo " --test-dir <dir>"
echo " Some test dir name, e.g. build-tests/x86/tumbleweed/"
echo " --test-name <name>"
echo " some test name, e.g. test-image-disk"
echo " --box-name <name>"
echo " name of the box to use for the build, default: universal"
}

if ! opts=$(getopt \
--longoptions "$(printf "%s," "${ARGUMENT_LIST[@]}")" \
--name "$(basename "$0")" \
--options "" \
-- "$@"
); then
usage
exit 0
fi

eval set --"${opts}"

while [[ $# -gt 0 ]]; do
case "$1" in
--test-dir)
argTestDir=$2
shift 2
;;

--test-name)
argTestName=$2
shift 2
;;

--box-name)
argBoxName=$2
shift 2
;;

*)
break
;;
esac
done

if [ ! "${argTestDir}" ];then
usage
exit 1
fi

if [ ! -e "${argTestDir}"/.repos ];then
echo "No .repos information for specified test dir"
exit 1
fi

boxname=universal
if [ "${argBoxName}" ];then
boxname="${argBoxName}"
fi

function create_repo_list() {
local build_dir=$1
local repo_options="--ignore-repos"
while read -r repo;do
repo_options="${repo_options} --add-repo ${repo}"
done < "${build_dir}"/.repos
echo "${repo_options}"
}

function create_build_commands() {
local build_dir=$1
local test_name=$2
build_commands=()
for image in "${build_dir}"/*;do
test -e "${image}/.skip_boxbuild_container" && continue
base_image=$(basename "${image}")
if [ -n "${test_name}" ] && [ ! "${test_name}" = "${base_image}" ];then
continue
fi
build_command="kiwi-ng --debug"
has_profiles=false
repo_options=$(create_repo_list "${build_dir}")
for profile in $(
xmllint --xpath "//image/profiles/profile/@name" \
"${image}/appliance.kiwi" 2>/dev/null | cut -f2 -d\"
);do
has_profiles=true
target_dir="build_results/${base_image}/${profile}"
build_command="${build_command} --profile ${profile}"
build_command="${build_command} system boxbuild"
build_command="${build_command} --box ${boxname} --container --"
build_command="${build_command} --description $image"
build_command="${build_command} ${repo_options}"
build_command="${build_command} --target-dir ${target_dir}"
echo "${build_command}" \
> "build_results/${base_image}-${profile}.build"
build_commands+=( "${build_command}" )
build_command="kiwi-ng --debug"
done
if [ "${has_profiles}" = "false" ];then
target_dir="build_results/${base_image}"
build_command="${build_command} system boxbuild"
build_command="${build_command} --box ${boxname} --container --"
build_command="${build_command} --description $image"
build_command="${build_command} ${repo_options}"
build_command="${build_command} --target-dir ${target_dir}"
echo "${build_command}" \
> "build_results/${base_image}.build"
build_commands+=( "${build_command}" )
fi
done
}

# create results directory
mkdir -p build_results

# build x86/tumbleweed command list
create_build_commands "${argTestDir}" "${argTestName}"

# build them in a row
# export PATH=$PATH:/home/ec2-user/.local/bin/kiwi-ng
for build in "${build_commands[@]}";do
${build}
sudo rm -rf build_results/*/*/build/
sudo rm -rf build_results/*/build/
done

# show result tree
test -d build_results && tree -L 3 build_results
1 change: 1 addition & 0 deletions build-tests/x86/tumbleweed/.repos
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://download.opensuse.org/tumbleweed/repo/oss
15 changes: 10 additions & 5 deletions build-tests/x86/tumbleweed/test-image-MicroOS/appliance.kiwi
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,21 @@
<package name="NetworkManager"/>
</packages>
<packages type="bootstrap">
<package name="coreutils"/>
<package name="shadow"/>
<package name="gzip"/>
<package name="gawk"/>
<package name="openssl"/>
<package name="diffutils"/>
<package name="coreutils"/>
<package name="grep"/>
<package name="gzip"/>
<package name="udev"/>
<package name="xz"/>
<package name="shadow"/>
<package name="filesystem"/>
<package name="glibc-locale-base"/>
<package name="glibc-locale"/>
<package name="cracklib-dict-full"/>
<package name="ca-certificates"/>
<package name="ca-certificates-mozilla"/>
<package name="MicroOS-release-dvd"/>
<package name="diffutils"/>
</packages>
<packages type="image" profiles="Encrypted">
<package name="cryptsetup"/>
Expand Down
1 change: 0 additions & 1 deletion build-tests/x86/tumbleweed/test-image-agama/appliance.kiwi
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
<source path="obsrepositories:/"/>
</repository>
<packages type="image">
<namedCollection name="x11"/>
<package name="avahi"/>
<package name="bind-utils"/>
<package name="patterns-openSUSE-base"/>
Expand Down
11 changes: 10 additions & 1 deletion build-tests/x86/tumbleweed/test-image-azure/appliance.kiwi
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,17 @@
<package name="timezone"/>
</packages>
<packages type="bootstrap">
<package name="openSUSE-release"/>
<package name="gawk"/>
<package name="grep"/>
<package name="gzip"/>
<package name="udev"/>
<package name="xz"/>
<package name="shadow"/>
<package name="filesystem"/>
<package name="glibc-locale"/>
<package name="cracklib-dict-full"/>
<package name="ca-certificates"/>
<package name="ca-certificates-mozilla"/>
<package name="openSUSE-release"/>
</packages>
</image>
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<oem-multipath-scan>false</oem-multipath-scan>
</oemconfig>
<systemdisk>
<volume name="home" quota="5G"/>
<volume name="home"/>
</systemdisk>
</type>
</preferences>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
requires legacy oemboot package which does not exist in the box
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
requires legacy oemboot package which does not exist in the box
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@
<package name="timezone"/>
</packages>
<packages type="bootstrap">
<package name="gawk"/>
<package name="grep"/>
<package name="gzip"/>
<package name="udev"/>
<package name="xz"/>
<package name="shadow"/>
<package name="filesystem"/>
<package name="glibc-locale"/>
<package name="cracklib-dict-full"/>
Expand Down
2 changes: 1 addition & 1 deletion build-tests/x86/tumbleweed/test-image-disk/appliance.kiwi
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<oem-multipath-scan>false</oem-multipath-scan>
</oemconfig>
<systemdisk>
<volume name="home" quota="5G"/>
<volume name="home"/>
</systemdisk>
</type>
</preferences>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
building a container in a container causes issues for buildah
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
building a container in a container causes issues for buildah
11 changes: 10 additions & 1 deletion build-tests/x86/tumbleweed/test-image-ec2/appliance.kiwi
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,17 @@
<package name="timezone"/>
</packages>
<packages type="bootstrap">
<package name="openSUSE-release"/>
<package name="gawk"/>
<package name="grep"/>
<package name="gzip"/>
<package name="udev"/>
<package name="xz"/>
<package name="shadow"/>
<package name="filesystem"/>
<package name="glibc-locale"/>
<package name="cracklib-dict-full"/>
<package name="ca-certificates"/>
<package name="ca-certificates-mozilla"/>
<package name="openSUSE-release"/>
</packages>
</image>
11 changes: 10 additions & 1 deletion build-tests/x86/tumbleweed/test-image-gce/appliance.kiwi
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,17 @@
<package name="timezone"/>
</packages>
<packages type="bootstrap">
<package name="openSUSE-release"/>
<package name="gawk"/>
<package name="grep"/>
<package name="gzip"/>
<package name="udev"/>
<package name="xz"/>
<package name="shadow"/>
<package name="filesystem"/>
<package name="glibc-locale"/>
<package name="cracklib-dict-full"/>
<package name="ca-certificates"/>
<package name="ca-certificates-mozilla"/>
<package name="openSUSE-release"/>
</packages>
</image>
1 change: 1 addition & 0 deletions build-tests/x86/tumbleweed/test-image-live/appliance.kiwi
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
<package name="gzip"/>
<package name="udev"/>
<package name="xz"/>
<package name="shadow"/>
<package name="filesystem"/>
<package name="glibc-locale"/>
<package name="cracklib-dict-full"/>
Expand Down
1 change: 1 addition & 0 deletions build-tests/x86/tumbleweed/test-image-lvm/appliance.kiwi
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
<package name="gzip"/>
<package name="udev"/>
<package name="xz"/>
<package name="shadow"/>
<package name="filesystem"/>
<package name="glibc-locale"/>
<package name="cracklib-dict-full"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
<package name="gzip"/>
<package name="udev"/>
<package name="xz"/>
<package name="shadow"/>
<package name="filesystem"/>
<package name="glibc-locale"/>
<package name="cracklib-dict-full"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
<package name="gzip"/>
<package name="udev"/>
<package name="xz"/>
<package name="shadow"/>
<package name="filesystem"/>
<package name="glibc-locale"/>
<package name="cracklib-dict-full"/>
Expand Down
5 changes: 5 additions & 0 deletions build-tests/x86/tumbleweed/test-image-pxe/appliance.kiwi
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@
<package name="timezone"/>
</packages>
<packages type="bootstrap">
<package name="gawk"/>
<package name="grep"/>
<package name="gzip"/>
<package name="udev"/>
<package name="xz"/>
<package name="shadow"/>
<package name="filesystem"/>
<package name="glibc-locale"/>
<package name="cracklib-dict-full"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,12 @@
<package name="cloud-init-config-suse"/>
</packages>
<packages type="bootstrap">
<package name="gawk"/>
<package name="grep"/>
<package name="gzip"/>
<package name="udev"/>
<package name="xz"/>
<package name="shadow"/>
<package name="filesystem"/>
<package name="glibc-locale"/>
<package name="cracklib-dict-full"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@
<package name="timezone"/>
</packages>
<packages type="bootstrap">
<package name="gawk"/>
<package name="grep"/>
<package name="gzip"/>
<package name="udev"/>
<package name="xz"/>
<package name="shadow"/>
<package name="filesystem"/>
<package name="glibc-locale"/>
<package name="cracklib-dict-full"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
<package name="gzip"/>
<package name="udev"/>
<package name="xz"/>
<package name="shadow"/>
<package name="filesystem"/>
<package name="glibc-locale"/>
<package name="cracklib-dict-full"/>
Expand Down
5 changes: 5 additions & 0 deletions build-tests/x86/tumbleweed/test-image-wsl/appliance.kiwi
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@
<package name="fipscheck"/>
</packages>
<packages type="bootstrap">
<package name="gawk"/>
<package name="grep"/>
<package name="gzip"/>
<package name="udev"/>
<package name="xz"/>
<package name="shadow"/>
<package name="filesystem"/>
<package name="glibc-locale"/>
<package name="cracklib-dict-full"/>
Expand Down

0 comments on commit 61a23d4

Please sign in to comment.