buildbot-scripts/test-checkdeps.sh
Peter Surda ee7a93c2fd
Docker and permissions
- add dockerfile for bionic builder
- chmod scripts sexecutable
- add docker-install-all.sh
2021-02-11 10:26:44 +01:00

103 lines
2.6 KiB
Bash
Executable File

#!/bin/bash
# tests checkdeps.py with all possible subsets of dependency packages installed
distro=$(grep ^VERSION_CODENAME= /etc/os-release | cut -d= -f2)
case $distro in
trusty)
method="apt-get"
packages=(python-qt4 python-msgpack python-pyopencl python-setuptools build-essential libssl-dev libcap-dev python-prctl)
;;
xenial)
method="apt-get"
packages=(python-qt4 python-msgpack python-pyopencl python-setuptools build-essential libssl-dev libcap-dev python-prctl)
;;
bionic)
method="apt-get"
packages=(python-qt4 python-msgpack python-pyopencl python-setuptools build-essential libssl-dev libcap-dev python-prctl)
;;
focal)
method="apt-get"
packages=(python-setuptools build-essential libssl-dev libcap-dev)
;;
*)
echo "Unknown distro"
exit 0
esac
echo "Using $method on $distro"
output=$(mktemp)
succeeded=0
failed=0
# 0 - 2^n -1
for i in $(seq 0 $((2**${#packages[@]}-1))); do
declare -a missing
missing=()
case $method in
apt-get)
cmd="sudo apt-get remove --autoremove -y -qq"
;;
*);;
esac
# iterate packages
for j in $(seq 0 $((${#packages[@]}-1))); do
# should j-th item be included in i-th iteration?
if [ $(((i>>j)%2)) -eq 1 ]; then
case $method in
apt-get)
cmd="$cmd ${packages[j]}+"
;;
esac
else
case $method in
apt-get)
missing+=("${packages[j]}")
cmd="$cmd ${packages[j]}"
;;
esac
fi
done
echo -n "${missing[*]}: "
$cmd &> /dev/null
#echo "python checkdeps.py"
python checkdeps.py > "$output" 2> /dev/null
toinstall=$(sed -E 's/.*apt-get install (.*)(`.*|$)/\1/p;d' < "$output" | xargs -n 1 echo)
toinstalla=($toinstall)
fail=0
for a in ${missing[*]}; do
for b in ${toinstalla[*]}; do
if [ "$a" == "$b" ]; then
break
fi
done
if ! [ "$a" == "$b" ]; then
fail=1
fi
done
for a in ${toinstalla[*]}; do
for b in ${missing[*]}; do
if [ "$a" == "$b" ]; then
break
fi
done
if ! [ "$a" == "$b" ]; then
fail=1
fi
done
if [ $fail -eq 0 ]; then
echo "OK"
succeeded=$((succeeded+1))
else
echo "FAIL"
echo " " $toinstall
failed=$((failed+1))
fi
done
echo "Succeeded: $succeeded"
echo " Failed: $failed"