Files
sos_testing/do_sos_deb.sh
T

112 lines
2.5 KiB
Bash
Executable File

#!/bin/bash
#set -ax
script_cmd=${0##*/}
. functions.sh
declare -A all_series
all_series=(
['debian']="images:debian/sid/cloud"
['ubuntu']="ubuntu-daily:devel"
)
project_name="deb-testing"
project="--project ${project_name}"
lxc="lxc ${project}"
lxc_exec="${lxc} exec"
fresh="false"
distro="debian"
show_help() {
echo "
-p <product> The product need testing
-o <origin> The orig file to download
-d <distro> The distro to run on
One of: ubuntu, debian
Default: debian
-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:o:d:f" opt; do
case $opt in
p)
prod="$OPTARG"
;;
f)
fresh="true"
;;
o)
origin="$OPTARG"
;;
d)
distro="$OPTARG"
;;
:)
printf "Option -%s needs an argument.\n" "$OPTARG" >&2
show_help
echo ""
exit 1
;;
esac
done
if [[ $distro == "debian" ]] ; then
prod_location="$HOME/packaging/${prod}"
else
prod_location="$HOME/packaging/git-ubuntu/${prod}"
fi
lxc project create ${project_name}
${lxc} profile edit default < lxd_profile_deb.yaml
inst_name=${prod}-${distro}
if [[ ${fresh} == "true" ]] ; then
image="${all_series[${distro}]}"
${lxc} delete ${inst_name} --force
${lxc} launch ${image} ${inst_name} --vm -c limits.cpu=4 -c limits.memory=4GiB -d root,size=50GiB
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 -
check_vm_status ${inst_name} ${project}
${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
check_cloud_init_status ${inst_name} ${project}
if [[ ${fresh} != "true" ]] ; then
${lxc_exec} ${inst_name} -- sudo apt update
${lxc_exec} ${inst_name} -- sudo apt -y upgrade
fi
${lxc_exec} ${inst_name} -- usermod -G sbuild root
${lxc_exec} ${inst_name} -- id root
${lxc_exec} ${inst_name} -- bash /root/scripts/deb_build_check.sh ${prod} ${origin}
${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