Add scripts to test debian packaging from salsa

This commit is contained in:
2024-07-15 15:10:23 +01:00
parent 0afb518f0c
commit 09662dd595
2 changed files with 195 additions and 0 deletions

70
do_sos_deb.sh Executable file
View File

@@ -0,0 +1,70 @@
#!/bin/bash
#set -ax
script_cmd=${0##*/}
declare -A all_series
all_series=(
['sid']="debian/sid/cloud"
)
project_name="sos-testing-debian"
project="--project ${project_name}"
lxc="lxc ${project}"
lxc_exec="${lxc} exec"
sos_location="$HOME/gitRepos/sos-salsa"
lxc project create ${project_name}
${lxc} profile edit default < lxd_profile_deb.yaml
for distro in "${!all_series[@]}"
do
inst_name=sos-avocado-${distro}
${lxc} delete ${inst_name} --force
image="images:${all_series[${distro}]}"
${lxc} launch ${image} ${inst_name} --vm -c limits.cpu=4 -c limits.memory=4GiB
cd ${sos_location}
find . -type f -name "*.pyc" -exec sudo rm -f {} \;
rm -rf .tox *.snap *.deb
tar cfz /tmp/sos.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} file push /tmp/sos.tgz ${inst_name}/root/sos.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
${lxc_exec} ${inst_name} -- bash /root/deb_build_check.sh
${lxc} file pull ${inst_name}/root/build-logs.tgz .
${lxc} stop ${inst_name}
done

125
lxd_profile_deb.yaml Normal file
View File

@@ -0,0 +1,125 @@
devices:
eth0:
name: eth0
network: lxdbr0
type: nic
root:
path: /
pool: virtual
type: disk
config:
user.user-data: |
#cloud-config
packages:
- python3-pip
- tox
- sbuild
- mmdebstrap
- uidmap
- lintian
- pbuilder
- dh-python
- reprotest
- licenserecon
write_files:
- path: /root/setup.sh
permissions: '0755'
owner: root:root
content: |
#!bin/bash
sudo apt update --allow-releaseinfo-change
sudo apt -y purge sosreport
- path: /root/.sbuildrc
owner: root:root
content: |
$chroot_mode = 'unshare';
#$run_autopkgtest = 1;
$autopkgtest_root_args = '';
$autopkgtest_opts = [ '--apt-upgrade', '--', 'unshare', '--release', '%r', '--arch', '%a' ];
- path: /root/deb_build_check.sh
permissions: '0755'
owner: root:root
content: |
#!bin/bash
mkdir -p ~/.cache/sbuild /root/sos
cd /root/sos
tar xfz ../sos.tgz
export EMAIL="Some One <some.one@canonical.com>"
export DEBEMAIL="Some One <some.one@canonical.com>"
uscan --download-current-version --rename
dpkg-buildpackage -S -d
pbuilder create
pbuilder build --twice ../sos*.dsc \
| tee /root/pbuilder.log
lintian -v -i -I -E --pedantic --profile debian ../sos*.dsc \
| tee /root/lintian-dsc.log
lintian -v -i -I -E --pedantic --profile debian ../sos*.changes \
| tee /root/lintian-changes.log
lintian -v -i -I -E --pedantic --profile debian ../sos*.buildinfo \
| tee /root/lintian-buildinfo.log
lrc | tee /root/license-check.log
sbuild-createchroot --include=eatmydata,ccache unstable /srv/chroot/unstable-amd64-sbuild
reprotest --print-sudoers \
--variations=user_group.available+=guest-builder,domain_host.use_sudo=1 \
| EDITOR=tee visudo -f /etc/sudoers.d/local-reprotest
echo "/etc/sudoers.d/local-reprotest /etc/sudoers.d/local-reprotest none bind 0 0" \
| tee -a /srv/chroot/unstable-amd64-sbuild/etc/fstab
cd -
reprotest --vary=-build_path,domain_host.use_sudo=1 --auto-build ./sos*.dsc -- schroot unstable-amd64-sbuild \
| tee /root/reprotest.log
tar cf build-logs.tgz *.log
- 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
content: |
#!bin/bash
mkdir -p /root/sos
cd /root/sos
tar xfz ../sos.tgz
git config --global --add safe.directory /root/sos
mkdir -p /etc/sos
cp sos.conf /etc/sos/sos.conf
echo "Cleaning up any old .tox environments ..."
rm -rf .tox
echo "Running Unit Tests ..."
tox -e unit_tests
echo "Running Stage One Tests ..."
tox -e stageone_tests
echo "Running Stage Two Tests ..."
tox -e stagetwo_tests
- path: /root/run_sos.sh
permissions: '0755'
owner: root:root
content: |
#!bin/bash
sos report -a --all-logs --batch
runcmd:
- [ /root/setup.sh ]