Fix dependency install on Debian 11 (#16683)
[zfs.git] / .github / workflows / scripts / qemu-3-deps.sh
blob4c6227b88ed09bb1829c36c1403e7d4e7fa29447
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 dhclient dkms fakeroot \
17 fio gdb inetutils jq less linux linux-headers lsscsi nfs-utils parted \
18 pax perf python-packaging python-setuptools qemu-guest-agent ksh samba \
19 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 curl dbench dh-python dkms fakeroot \
34 fio gdb gdebi git ksh lcov isc-dhcp-client jq libacl1-dev libaio-dev \
35 libattr1-dev libblkid-dev libcurl4-openssl-dev libdevmapper-dev libelf-dev \
36 libffi-dev libmount-dev libpam0g-dev libselinux-dev libssl-dev libtool \
37 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 curl dbench dkms elfutils-libelf-devel fio gdb git \
72 jq kernel-rpm-macros ksh libacl-devel libaio-devel libargon2-devel \
73 libattr-devel libblkid-devel libcurl-devel libffi-devel ncompress \
74 libselinux-devel libtirpc-devel libtool libudev-devel libuuid-devel \
75 lsscsi mdadm nfs-utils openssl-devel pam-devel pamtester parted perf \
76 python3 python3-cffi python3-devel python3-packaging kernel-devel \
77 python3-setuptools qemu-guest-agent rng-tools rpcgen rpm-build rsync \
78 samba sysstat systemd watchdog wget xfsprogs-devel xxhash zlib-devel
79 echo "##[endgroup]"
82 function tumbleweed() {
83 echo "##[group]Running zypper is TODO!"
84 sleep 23456
85 echo "##[endgroup]"
88 # Install dependencies
89 case "$1" in
90 almalinux8)
91 echo "##[group]Enable epel and powertools repositories"
92 sudo dnf config-manager -y --set-enabled powertools
93 sudo dnf install -y epel-release
94 echo "##[endgroup]"
95 rhel
96 echo "##[group]Install kernel-abi-whitelists"
97 sudo dnf install -y kernel-abi-whitelists
98 echo "##[endgroup]"
100 almalinux9|centos-stream9)
101 echo "##[group]Enable epel and crb repositories"
102 sudo dnf config-manager -y --set-enabled crb
103 sudo dnf install -y epel-release
104 echo "##[endgroup]"
105 rhel
106 echo "##[group]Install kernel-abi-stablelists"
107 sudo dnf install -y kernel-abi-stablelists
108 echo "##[endgroup]"
110 archlinux)
111 archlinux
113 debian*)
114 echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections
115 debian
116 echo "##[group]Install Debian specific"
117 sudo apt-get install -yq linux-perf dh-sequence-dkms
118 echo "##[endgroup]"
120 fedora*)
121 rhel
123 freebsd*)
124 freebsd
126 tumbleweed)
127 tumbleweed
129 ubuntu*)
130 debian
131 echo "##[group]Install Ubuntu specific"
132 sudo apt-get install -yq linux-tools-common libtirpc-dev \
133 linux-modules-extra-$(uname -r)
134 if [ "$1" != "ubuntu20" ]; then
135 sudo apt-get install -yq dh-sequence-dkms
137 echo "##[endgroup]"
138 echo "##[group]Delete Ubuntu OpenZFS modules"
139 for i in $(find /lib/modules -name zfs -type d); do sudo rm -rvf $i; done
140 echo "##[endgroup]"
142 esac
144 # This script is used for checkstyle + zloop deps also.
145 # Install only the needed packages and exit - when used this way.
146 test -z "${ONLY_DEPS:-}" || exit 0
148 # Start services
149 echo "##[group]Enable services"
150 case "$1" in
151 freebsd*)
152 # add virtio things
153 echo 'virtio_load="YES"' | sudo -E tee -a /boot/loader.conf
154 for i in balloon blk console random scsi; do
155 echo "virtio_${i}_load=\"YES\"" | sudo -E tee -a /boot/loader.conf
156 done
157 echo "fdescfs /dev/fd fdescfs rw 0 0" | sudo -E tee -a /etc/fstab
158 sudo -E mount /dev/fd
159 sudo -E touch /etc/zfs/exports
160 sudo -E sysrc mountd_flags="/etc/zfs/exports"
161 echo '[global]' | sudo -E tee /usr/local/etc/smb4.conf >/dev/null
162 sudo -E service nfsd enable
163 sudo -E service qemu-guest-agent enable
164 sudo -E service samba_server enable
166 debian*|ubuntu*)
167 sudo -E systemctl enable nfs-kernel-server
168 sudo -E systemctl enable qemu-guest-agent
169 sudo -E systemctl enable smbd
172 # All other linux distros
173 sudo -E systemctl enable nfs-server
174 sudo -E systemctl enable qemu-guest-agent
175 sudo -E systemctl enable smb
177 esac
178 echo "##[endgroup]"
180 # Setup Kernel cmdline
181 CMDLINE="console=tty0 console=ttyS0,115200n8"
182 CMDLINE="$CMDLINE selinux=0"
183 CMDLINE="$CMDLINE random.trust_cpu=on"
184 CMDLINE="$CMDLINE no_timer_check"
185 case "$1" in
186 almalinux*|centos*|fedora*)
187 GRUB_CFG="/boot/grub2/grub.cfg"
188 GRUB_MKCONFIG="grub2-mkconfig"
189 CMDLINE="$CMDLINE biosdevname=0 net.ifnames=0"
190 echo 'GRUB_SERIAL_COMMAND="serial --speed=115200"' \
191 | sudo tee -a /etc/default/grub >/dev/null
193 ubuntu24)
194 GRUB_CFG="/boot/grub/grub.cfg"
195 GRUB_MKCONFIG="grub-mkconfig"
196 echo 'GRUB_DISABLE_OS_PROBER="false"' \
197 | sudo tee -a /etc/default/grub >/dev/null
200 GRUB_CFG="/boot/grub/grub.cfg"
201 GRUB_MKCONFIG="grub-mkconfig"
203 esac
205 case "$1" in
206 archlinux|freebsd*)
207 true
210 echo "##[group]Edit kernel cmdline"
211 sudo sed -i -e '/^GRUB_CMDLINE_LINUX/d' /etc/default/grub || true
212 echo "GRUB_CMDLINE_LINUX=\"$CMDLINE\"" \
213 | sudo tee -a /etc/default/grub >/dev/null
214 sudo $GRUB_MKCONFIG -o $GRUB_CFG
215 echo "##[endgroup]"
217 esac
219 # reset cloud-init configuration and poweroff
220 sudo cloud-init clean --logs
221 sleep 2 && sudo poweroff &
222 exit 0