1#!/bin/bash 2# 3# Do a test install of ZFS from an external repository. 4# 5# USAGE: 6# 7# ./qemu-test-repo-vm [URL] 8# 9# URL: URL to use instead of http://download.zfsonlinux.org 10# If blank, use the default repo from zfs-release RPM. 11 12set -e 13 14source /etc/os-release 15OS="$ID" 16VERSION="$VERSION_ID" 17 18ALTHOST="" 19if [ -n "$1" ] ; then 20 ALTHOST="$1" 21fi 22 23# Write summary to /tmp/repo so our artifacts scripts pick it up 24mkdir /tmp/repo 25SUMMARY=/tmp/repo/$OS-$VERSION-summary.txt 26 27# $1: Repo 'zfs' 'zfs-kmod' 'zfs-testing' 'zfs-testing-kmod' 28# $2: (optional) Alternate host than 'http://download.zfsonlinux.org' to 29# install from. Blank means use default from zfs-release RPM. 30function test_install { 31 repo=$1 32 host="" 33 if [ -n "$2" ] ; then 34 host=$2 35 fi 36 37 args="--disablerepo=zfs --enablerepo=$repo" 38 39 # If we supplied an alternate repo URL, and have not already edited 40 # zfs.repo, then update the repo file. 41 if [ -n "$host" ] && ! grep -q $host /etc/yum.repos.d/zfs.repo ; then 42 sudo sed -i "s;baseurl=http://download.zfsonlinux.org;baseurl=$host;g" /etc/yum.repos.d/zfs.repo 43 fi 44 45 sudo dnf -y install $args zfs zfs-test 46 47 # Load modules and create a simple pool as a sanity test. 48 sudo /usr/share/zfs/zfs.sh -r 49 truncate -s 100M /tmp/file 50 sudo zpool create tank /tmp/file 51 sudo zpool status 52 53 # Print out repo name, rpm installed (kmod or dkms), and repo URL 54 baseurl=$(grep -A 5 "\[$repo\]" /etc/yum.repos.d/zfs.repo | awk -F'=' '/baseurl=/{print $2; exit}') 55 package=$(sudo rpm -qa | grep zfs | grep -E 'kmod|dkms') 56 57 echo "$repo $package $baseurl" >> $SUMMARY 58 59 sudo zpool destroy tank 60 sudo rm /tmp/file 61 sudo dnf -y remove zfs 62} 63 64echo "##[group]Installing from repo" 65# The openzfs docs are the authoritative instructions for the install. Use 66# the specific version of zfs-release RPM it recommends. 67case $OS in 68almalinux*) 69 url='https://raw.githubusercontent.com/openzfs/openzfs-docs/refs/heads/master/docs/Getting%20Started/RHEL-based%20distro/index.rst' 70 name=$(curl -Ls $url | grep 'dnf install' | grep -Eo 'zfs-release-[0-9]+-[0-9]+') 71 sudo dnf -y install https://zfsonlinux.org/epel/$name$(rpm --eval "%{dist}").noarch.rpm 2>&1 72 sudo rpm -qi zfs-release 73 test_install zfs $ALTHOST 74 test_install zfs-kmod $ALTHOST 75 test_install zfs-testing $ALTHOST 76 test_install zfs-testing-kmod $ALTHOST 77 ;; 78fedora*) 79 url='https://raw.githubusercontent.com/openzfs/openzfs-docs/refs/heads/master/docs/Getting%20Started/Fedora/index.rst' 80 name=$(curl -Ls $url | grep 'dnf install' | grep -Eo 'zfs-release-[0-9]+-[0-9]+') 81 sudo dnf -y install -y https://zfsonlinux.org/fedora/$name$(rpm --eval "%{dist}").noarch.rpm 82 test_install zfs $ALTHOST 83 ;; 84esac 85echo "##[endgroup]" 86 87# Write out a simple version of the summary here. Later on we will collate all 88# the summaries and put them into a nice table in the workflow Summary page. 89echo "Summary: " 90cat $SUMMARY 91