ZTS: Add LUKS sanity test
[zfs.git] / .github / workflows / scripts / qemu-3-deps.sh
blobbf06c1892ceb0a888a6ba433683fc5b419982a11
1 #!/usr/bin/env bash
3 ######################################################################
4 # 3) install dependencies for compiling and loading
5 ######################################################################
7 set -eu
9 function archlinux() {
10 echo "##[group]Running pacman -Syu"
11 sudo btrfs filesystem resize max /
12 sudo pacman -Syu --noconfirm
13 echo "##[endgroup]"
15 echo "##[group]Install Development Tools"
16 sudo pacman -Sy --noconfirm base-devel bc cpio cryptsetup dhclient dkms \
17 fakeroot fio gdb inetutils jq less linux linux-headers lsscsi nfs-utils \
18 parted pax perf python-packaging python-setuptools qemu-guest-agent ksh \
19 samba sysstat rng-tools rsync wget xxhash
20 echo "##[endgroup]"
23 function debian() {
24 export DEBIAN_FRONTEND="noninteractive"
26 echo "##[group]Running apt-get update+upgrade"
27 sudo apt-get update -y
28 sudo apt-get upgrade -y
29 echo "##[endgroup]"
31 echo "##[group]Install Development Tools"
32 sudo apt-get install -y \
33 acl alien attr autoconf bc cpio cryptsetup curl dbench dh-python dkms \
34 fakeroot fio gdb gdebi git ksh lcov isc-dhcp-client jq libacl1-dev \
35 libaio-dev libattr1-dev libblkid-dev libcurl4-openssl-dev libdevmapper-dev \
36 libelf-dev libffi-dev libmount-dev libpam0g-dev libselinux-dev libssl-dev \
37 libtool libtool-bin libudev-dev libunwind-dev linux-headers-$(uname -r) \
38 lsscsi nfs-kernel-server pamtester parted python3 python3-all-dev \
39 python3-cffi python3-dev python3-distlib python3-packaging \
40 python3-setuptools python3-sphinx qemu-guest-agent rng-tools rpm2cpio \
41 rsync samba sysstat uuid-dev watchdog wget xfslibs-dev xxhash zlib1g-dev
42 echo "##[endgroup]"
45 function freebsd() {
46 export ASSUME_ALWAYS_YES="YES"
48 echo "##[group]Install Development Tools"
49 sudo pkg install -y autoconf automake autotools base64 checkbashisms fio \
50 gdb gettext gettext-runtime git gmake gsed jq ksh93 lcov libtool lscpu \
51 pkgconf python python3 pamtester pamtester qemu-guest-agent rsync xxhash
52 sudo pkg install -xy \
53 '^samba4[[:digit:]]+$' \
54 '^py3[[:digit:]]+-cffi$' \
55 '^py3[[:digit:]]+-sysctl$' \
56 '^py3[[:digit:]]+-packaging$'
57 echo "##[endgroup]"
60 # common packages for: almalinux, centos, redhat
61 function rhel() {
62 echo "##[group]Running dnf update"
63 echo "max_parallel_downloads=10" | sudo -E tee -a /etc/dnf/dnf.conf
64 sudo dnf clean all
65 sudo dnf update -y --setopt=fastestmirror=1 --refresh
66 echo "##[endgroup]"
68 echo "##[group]Install Development Tools"
69 sudo dnf group install -y "Development Tools"
70 sudo dnf install -y \
71 acl attr bc bzip2 cryptsetup curl dbench dkms elfutils-libelf-devel fio \
72 gdb git jq kernel-rpm-macros ksh libacl-devel libaio-devel \
73 libargon2-devel libattr-devel libblkid-devel libcurl-devel libffi-devel \
74 ncompress libselinux-devel libtirpc-devel libtool libudev-devel \
75 libuuid-devel lsscsi mdadm nfs-utils openssl-devel pam-devel pamtester \
76 parted perf python3 python3-cffi python3-devel python3-packaging \
77 kernel-devel python3-setuptools qemu-guest-agent rng-tools rpcgen \
78 rpm-build rsync samba sysstat systemd watchdog wget xfsprogs-devel xxhash \
79 zlib-devel
80 echo "##[endgroup]"
83 function tumbleweed() {
84 echo "##[group]Running zypper is TODO!"
85 sleep 23456
86 echo "##[endgroup]"
89 # Install dependencies
90 case "$1" in
91 almalinux8)
92 echo "##[group]Enable epel and powertools repositories"
93 sudo dnf config-manager -y --set-enabled powertools
94 sudo dnf install -y epel-release
95 echo "##[endgroup]"
96 rhel
97 echo "##[group]Install kernel-abi-whitelists"
98 sudo dnf install -y kernel-abi-whitelists
99 echo "##[endgroup]"
101 almalinux9|centos-stream9)
102 echo "##[group]Enable epel and crb repositories"
103 sudo dnf config-manager -y --set-enabled crb
104 sudo dnf install -y epel-release
105 echo "##[endgroup]"
106 rhel
107 echo "##[group]Install kernel-abi-stablelists"
108 sudo dnf install -y kernel-abi-stablelists
109 echo "##[endgroup]"
111 archlinux)
112 archlinux
114 debian*)
115 echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections
116 debian
117 echo "##[group]Install Debian specific"
118 sudo apt-get install -yq linux-perf dh-sequence-dkms
119 echo "##[endgroup]"
121 fedora*)
122 rhel
124 freebsd*)
125 freebsd
127 tumbleweed)
128 tumbleweed
130 ubuntu*)
131 debian
132 echo "##[group]Install Ubuntu specific"
133 sudo apt-get install -yq linux-tools-common libtirpc-dev \
134 linux-modules-extra-$(uname -r)
135 if [ "$1" != "ubuntu20" ]; then
136 sudo apt-get install -yq dh-sequence-dkms
138 echo "##[endgroup]"
139 echo "##[group]Delete Ubuntu OpenZFS modules"
140 for i in $(find /lib/modules -name zfs -type d); do sudo rm -rvf $i; done
141 echo "##[endgroup]"
143 esac
145 # This script is used for checkstyle + zloop deps also.
146 # Install only the needed packages and exit - when used this way.
147 test -z "${ONLY_DEPS:-}" || exit 0
149 # Start services
150 echo "##[group]Enable services"
151 case "$1" in
152 freebsd*)
153 # add virtio things
154 echo 'virtio_load="YES"' | sudo -E tee -a /boot/loader.conf
155 for i in balloon blk console random scsi; do
156 echo "virtio_${i}_load=\"YES\"" | sudo -E tee -a /boot/loader.conf
157 done
158 echo "fdescfs /dev/fd fdescfs rw 0 0" | sudo -E tee -a /etc/fstab
159 sudo -E mount /dev/fd
160 sudo -E touch /etc/zfs/exports
161 sudo -E sysrc mountd_flags="/etc/zfs/exports"
162 echo '[global]' | sudo -E tee /usr/local/etc/smb4.conf >/dev/null
163 sudo -E service nfsd enable
164 sudo -E service qemu-guest-agent enable
165 sudo -E service samba_server enable
167 debian*|ubuntu*)
168 sudo -E systemctl enable nfs-kernel-server
169 sudo -E systemctl enable qemu-guest-agent
170 sudo -E systemctl enable smbd
173 # All other linux distros
174 sudo -E systemctl enable nfs-server
175 sudo -E systemctl enable qemu-guest-agent
176 sudo -E systemctl enable smb
178 esac
179 echo "##[endgroup]"
181 # Setup Kernel cmdline
182 CMDLINE="console=tty0 console=ttyS0,115200n8"
183 CMDLINE="$CMDLINE selinux=0"
184 CMDLINE="$CMDLINE random.trust_cpu=on"
185 CMDLINE="$CMDLINE no_timer_check"
186 case "$1" in
187 almalinux*|centos*|fedora*)
188 GRUB_CFG="/boot/grub2/grub.cfg"
189 GRUB_MKCONFIG="grub2-mkconfig"
190 CMDLINE="$CMDLINE biosdevname=0 net.ifnames=0"
191 echo 'GRUB_SERIAL_COMMAND="serial --speed=115200"' \
192 | sudo tee -a /etc/default/grub >/dev/null
194 ubuntu24)
195 GRUB_CFG="/boot/grub/grub.cfg"
196 GRUB_MKCONFIG="grub-mkconfig"
197 echo 'GRUB_DISABLE_OS_PROBER="false"' \
198 | sudo tee -a /etc/default/grub >/dev/null
201 GRUB_CFG="/boot/grub/grub.cfg"
202 GRUB_MKCONFIG="grub-mkconfig"
204 esac
206 case "$1" in
207 archlinux|freebsd*)
208 true
211 echo "##[group]Edit kernel cmdline"
212 sudo sed -i -e '/^GRUB_CMDLINE_LINUX/d' /etc/default/grub || true
213 echo "GRUB_CMDLINE_LINUX=\"$CMDLINE\"" \
214 | sudo tee -a /etc/default/grub >/dev/null
215 sudo $GRUB_MKCONFIG -o $GRUB_CFG
216 echo "##[endgroup]"
218 esac
220 # reset cloud-init configuration and poweroff
221 sudo cloud-init clean --logs
222 sleep 2 && sudo poweroff &
223 exit 0