Files
sos_testing/do_sos_deb.sh
2025-04-15 11:50:23 +01:00

118 lines
2.5 KiB
Bash
Executable File

#!/bin/bash
#set -ax
script_cmd=${0##*/}
declare -A all_series
all_series=(
['sid']="debian/sid/cloud"
)
project_name="deb-testing"
project="--project ${project_name}"
lxc="lxc ${project}"
lxc_exec="${lxc} exec"
fresh="false"
show_help() {
echo "
-p <product> The product need testing
-f Create a fresh instance
"
}
if [ $# -eq 0 ]; then
printf "%s needs options to function correctly. Valid options are:" "$0"
show_help
exit 0
fi
while getopts ":p:f" opt; do
case $opt in
p)
prod="$OPTARG"
;;
f)
fresh="true"
;;
:)
printf "Option -%s needs an argument.\n" "$OPTARG" >&2
show_help
echo ""
exit 1
;;
esac
done
prod_location="$HOME/packaging/${prod}"
lxc project create ${project_name}
${lxc} profile edit default < lxd_profile_deb.yaml
for distro in "${!all_series[@]}"
do
inst_name=${prod}-${distro}
inst_name=autopkgtest
if [[ ${fresh} == "true" ]] ; then
image="images:${all_series[${distro}]}"
${lxc} delete ${inst_name} --force
${lxc} launch ${image} ${inst_name} --vm -c limits.cpu=4 -c limits.memory=4GiB -s virtual
else
${lxc} start ${inst_name}
fi
cd ${prod_location}
find . -type f -name "*.pyc" -exec sudo rm -f {} \;
rm -rf .tox *.snap *.deb
tar cfz /tmp/${prod}.tgz .
cd -
echo -n "Checking VM status of ${inst_name} "
while true ; do
num_of_procs=$(${lxc} info ${inst_name} | yq .Resources.Processes)
[[ ${num_of_procs} -gt 0 ]] && break
sleep 3
echo -n "."
done
echo " done"
${lxc} exec ${inst_name} -- rm -rf /root/build
${lxc} exec ${inst_name} -- mkdir -p /root/build
${lxc} file push /tmp/${prod}.tgz ${inst_name}/root/build/${prod}.tgz
echo -n "Checking cloud-init status of ${inst_name} "
while true ; do
status=$(${lxc_exec} ${inst_name} -- cloud-init status | grep status | awk '{print $2}')
[[ "${status}" == "done" ]] && break
[[ "${status}" == "error" ]] && break
sleep 3
echo -n "."
done
echo " done"
if [[ ${fresh} != "true" ]] ; then
${lxc_exec} ${inst_name} -- sudo apt update
${lxc_exec} ${inst_name} -- sudo apt -y upgrade
fi
${lxc_exec} ${inst_name} -- bash /root/scripts/deb_build_check.sh ${prod}
${lxc} file pull ${inst_name}/root/logs/build-logs-${prod}.tgz build-logs-${distro}-${prod}.tgz
${lxc} stop ${inst_name}
rm -rf build-logs-${distro}-${prod}
mkdir -p build-logs-${distro}-${prod}
tar -C build-logs-${distro}-${prod} -xf build-logs-${distro}-${prod}.tgz
done