From 0afb518f0c477d4b2bb4c1b93db188e5d03e1ba0 Mon Sep 17 00:00:00 2001 From: Arif Ali Date: Fri, 5 Jul 2024 12:20:41 +0100 Subject: [PATCH] Add proposed to script, and fine tuning with arrays --- do_autopkg_tests.sh | 21 +++++++++++++-------- do_sos_avocado.sh | 35 ++++++++++++++++++++++++----------- lxd_profile.yaml | 18 ++++++++++++++++++ 3 files changed, 55 insertions(+), 19 deletions(-) diff --git a/do_autopkg_tests.sh b/do_autopkg_tests.sh index 1c8ad33..36041a6 100755 --- a/do_autopkg_tests.sh +++ b/do_autopkg_tests.sh @@ -2,24 +2,29 @@ #set -ax +declare -A all_series + +all_series=( + ['focal']="ubuntu:focal" + ['jammy']="ubuntu:jammy" + ['noble']="ubuntu:noble" + ['mantic']="ubuntu:mantic" + ['oracular']="ubuntu-daily:devel" +) + latest_dev_series="oracular" latest_sup_series="noble" non_lts_releases="mantic" -all_series="focal jammy noble ${non_lts_releases} ${latest_dev_series}" ppa_user="arif-ali" ppa_name="sosreport-dev" -for distro in ${all_series} +for distro in "${!all_series[@]}" do - inst_name=sos-avocado01-${distro} + inst_name=sos-avocado-${distro} - if [[ "${distro}" == "${latest_dev_series}" ]] ; then - image="ubuntu-daily:${distro}" - else - image="ubuntu:${distro}" - fi + image="${all_series[${distro}]}" image_list="$(lxc image list --format json | jq -rc '.[] | select(.aliases[].name | contains("autopkgtest")) | .aliases[].name' | xargs)" diff --git a/do_sos_avocado.sh b/do_sos_avocado.sh index 0803168..553db06 100755 --- a/do_sos_avocado.sh +++ b/do_sos_avocado.sh @@ -4,10 +4,20 @@ script_cmd=${0##*/} +declare -A all_series + +all_series=( + ['bionic']="ubuntu:bionic" + ['focal']="ubuntu:focal" + ['jammy']="ubuntu:jammy" + ['noble']="ubuntu:noble" + ['mantic']="ubuntu:mantic" + ['oracular']="ubuntu-daily:devel" +) + latest_dev_series="oracular" latest_sup_series="noble" non_lts_releases="mantic" -all_series="bionic focal jammy noble ${non_lts_releases} ${latest_dev_series}" sos_type="deb" sos_channel="latest/candidate" @@ -15,6 +25,9 @@ sos_channel="latest/candidate" ppa_user="arif-ali" ppa_name="sosreport-dev" +# this can be "ppa" or "proposed" +deb_type="proposed" + project_name="sos-testing" project="--project ${project_name}" lxc="lxc ${project}" @@ -26,18 +39,14 @@ lxc project create ${project_name} ${lxc} profile edit default < lxd_profile.yaml -for distro in ${all_series} +for distro in "${!all_series[@]}" do inst_name=sos-avocado-${distro} ${lxc} delete ${inst_name} --force - if [[ "${distro}" == "${latest_dev_series}" ]] ; then - image="ubuntu-daily:devel" - else - image="ubuntu:${distro}" - fi + image="${all_series[${distro}]}" ${lxc} launch ${image} ${inst_name} --vm -c limits.cpu=4 -c limits.memory=4GiB @@ -78,10 +87,14 @@ do echo done if [[ "${script_cmd}" == "do_sos_testing.sh" ]] ; then - ${lxc_exec} ${inst_name} -- sudo add-apt-repository -y ppa:${ppa_user}/${ppa_name} - if [[ "${distro}" == "${latest_dev_series}" ]] ; then - filename="$(echo ${ppa_name} | sed 's/\./_/g')" - ${lxc_exec} ${inst_name} -- sed -i s/i${latest_sup_series}/${latest_dev_series}/g /etc/apt/sources.list.d/${ppa_user}-ubuntu-${filename}-${latest_sup_series}.list + if [[ "${deb_type}" == "ppa" ]] ; then + ${lxc_exec} ${inst_name} -- sudo add-apt-repository -y ppa:${ppa_user}/${ppa_name} + if [[ "${distro}" == "${latest_dev_series}" ]] ; then + filename="$(echo ${ppa_name} | sed 's/\./_/g')" + ${lxc_exec} ${inst_name} -- sed -i s/i${latest_sup_series}/${latest_dev_series}/g /etc/apt/sources.list.d/${ppa_user}-ubuntu-${filename}-${latest_sup_series}.list + fi + elif [[ "${deb_type}" == "proposed" ]] ; then + ${lxc_exec} ${inst_name} -- bash /root/enable_proposed.sh fi cat > setup_sos.sh << EOF #!/bin/bash diff --git a/lxd_profile.yaml b/lxd_profile.yaml index c050c64..f4f0f44 100644 --- a/lxd_profile.yaml +++ b/lxd_profile.yaml @@ -10,6 +10,15 @@ devices: config: user.user-data: | #cloud-config + apt: + disable_suites: + - $RELEASE-proposed + sources_list: | + deb $MIRROR $RELEASE main restricted multiverse universe + deb $MIRROR $RELEASE-updates main restricted multiverse universe + deb $MIRROR $RELEASE-backports main restricted multiverse universe + deb $MIRROR $RELEASE-security main restricted multiverse universe + deb $MIRROR $RELEASE-proposed main restricted multiverse universe packages: - python3-pip - snapd @@ -22,6 +31,15 @@ config: #!bin/bash sudo apt update --allow-releaseinfo-change sudo apt -y purge sosreport + - path: /root/enable_proposed.sh + permissions: '0755' + owner: root:root + content: | + #!bin/bash + + echo "Enabling proposed repo ..." + sudo sed -i 's/# suite disabled by cloud-init: //g' /etc/apt/sources.list + sudo apt update - path: /root/run_avocado.sh permissions: '0755' owner: root:root