1#!/usr/bin/env bash 2 3set -eu 4 5function prerun() { 6 echo "::group::Install build dependencies" 7 # remove snap things, update+upgrade will be faster then 8 for x in lxd core20 snapd; do sudo snap remove $x; done 9 sudo apt-get purge snapd google-chrome-stable firefox 10 # https://github.com/orgs/community/discussions/47863 11 sudo apt-get remove grub-efi-amd64-bin grub-efi-amd64-signed shim-signed --allow-remove-essential 12 sudo apt-get update 13 sudo apt upgrade 14 sudo xargs --arg-file=.github/workflows/build-dependencies.txt apt-get install -qq 15 sudo apt-get clean 16 sudo dmesg -c > /var/tmp/dmesg-prerun 17 echo "::endgroup::" 18} 19 20function mod_build() { 21 echo "::group::Generate debian packages" 22 ./autogen.sh 23 ./configure --enable-debug --enable-debuginfo --enable-asan --enable-ubsan 24 make --no-print-directory --silent native-deb-utils native-deb-kmod 25 mv ../*.deb . 26 rm ./openzfs-zfs-dracut*.deb ./openzfs-zfs-dkms*.deb 27 echo "$ImageOS-$ImageVersion" > tests/ImageOS.txt 28 echo "::endgroup::" 29} 30 31function mod_install() { 32 # install the pre-built module only on the same runner image 33 MOD=`cat tests/ImageOS.txt` 34 if [ "$MOD" != "$ImageOS-$ImageVersion" ]; then 35 rm -f *.deb 36 mod_build 37 fi 38 39 echo "::group::Install and load modules" 40 # don't use kernel-shipped zfs modules 41 sudo sed -i.bak 's/updates/extra updates/' /etc/depmod.d/ubuntu.conf 42 sudo apt-get install --fix-missing ./*.deb 43 44 # Native Debian packages enable and start the services 45 # Stop zfs-zed daemon, as it may interfere with some ZTS test cases 46 sudo systemctl stop zfs-zed 47 sudo depmod -a 48 sudo modprobe zfs 49 sudo dmesg 50 sudo dmesg -c > /var/tmp/dmesg-module-load 51 echo "::endgroup::" 52 53 echo "::group::Report CPU information" 54 lscpu 55 cat /proc/spl/kstat/zfs/chksum_bench 56 echo "::endgroup::" 57 58 echo "::group::Optimize storage for ZFS testings" 59 # remove swap and umount fast storage 60 # 89GiB -> rootfs + bootfs with ~80MB/s -> don't care 61 # 64GiB -> /mnt with 420MB/s -> new testing ssd 62 sudo swapoff -a 63 64 # this one is fast and mounted @ /mnt 65 # -> we reformat with ext4 + move it to /var/tmp 66 DEV="/dev/disk/azure/resource-part1" 67 sudo umount /mnt 68 sudo mkfs.ext4 -O ^has_journal -F $DEV 69 sudo mount -o noatime,barrier=0 $DEV /var/tmp 70 sudo chmod 1777 /var/tmp 71 72 # disk usage afterwards 73 sudo df -h / 74 sudo df -h /var/tmp 75 sudo fstrim -a 76 echo "::endgroup::" 77} 78 79case "$1" in 80 build) 81 prerun 82 mod_build 83 ;; 84 tests) 85 prerun 86 mod_install 87 ;; 88esac 89