This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild-kmod-zfs.sh
executable file
·62 lines (48 loc) · 2.41 KB
/
build-kmod-zfs.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/sh
set -oeux pipefail
ARCH="$(rpm -E '%_arch')"
KERNEL="$(rpm -q kernel --queryformat '%{VERSION}-%{RELEASE}.%{ARCH}')"
RELEASE="$(rpm -E '%fedora')"
# allow pinning to a specific release series (eg, 2.0.x or 2.1.x)
ZFS_MINOR_VERSION="${ZFS_MINOR_VERSION:-}"
cd /tmp
# Use cURL to fetch the given URL, saving the response to `data.json`
curl "https://api.github.com/repos/openzfs/zfs/releases" -o data.json
ZFS_VERSION=$(jq -r --arg ZMV "zfs-${ZFS_MINOR_VERSION}" '[ .[] | select(.prerelease==false and .draft==false) | select(.tag_name | startswith($ZMV))][0].tag_name' data.json|cut -f2- -d-)
echo "ZFS_VERSION==$ZFS_VERSION"
### zfs specific build deps
rpm-ostree install libtirpc-devel libblkid-devel libuuid-devel libudev-devel openssl-devel zlib-devel libaio-devel libattr-devel elfutils-libelf-devel python3-devel libffi-devel libcurl-devel
### BUILD zfs
echo "getting zfs-${ZFS_VERSION}.tar.gz"
curl -L -O https://github.com/openzfs/zfs/releases/download/zfs-${ZFS_VERSION}/zfs-${ZFS_VERSION}.tar.gz
# no-same-owner/no-same-permissions required for F40 based images building on podman 3.4.4 (ubuntu 22.04)
tar -z -x --no-same-owner --no-same-permissions -f zfs-${ZFS_VERSION}.tar.gz
# patch the zfs-kmod.spec.in file for older zfs versions
ZFS_MAJ=$(echo $ZFS_VERSION | cut -f1 -d.)
ZFS_MIN=$(echo $ZFS_VERSION | cut -f2 -d.)
ZFS_PATCH=$(echo $ZFS_VERSION | cut -f3 -d.)
DO_PATCH=1
if [ "${ZFS_MAJ}" -lt "2" ]; then
DO_PATCH=0
elif [ "${ZFS_MAJ}" -eq "2" ] && [ "${ZFS_MIN}" -lt "2" ]; then
DO_PATCH=0
elif [ "${ZFS_MAJ}" -eq "2" ] && [ "${ZFS_MIN}" -eq "2" ] && [ "${ZFS_PATCH}" -lt "3" ]; then
DO_PATCH=0
fi
if [ "${DO_PATCH}" -eq "0" ]; then
patch -b -uN -i zfs-kmod-spec-in.patch zfs-${ZFS_VERSION}/rpm/generic/zfs-kmod.spec.in
fi
cd /tmp/zfs-${ZFS_VERSION}
./configure \
-with-linux=/usr/src/kernels/${KERNEL}/ \
-with-linux-obj=/usr/src/kernels/${KERNEL}/ \
&& make -j $(nproc) rpm-utils rpm-kmod \
|| (cat config.log && exit 1)
# create a directory for later copying of resulting zfs specific artifacts
mkdir -p /var/cache/rpms/kmods/zfs/{debug,devel,other,src} \
&& mv *src.rpm /var/cache/rpms/kmods/zfs/src/ \
&& mv *devel*.rpm /var/cache/rpms/kmods/zfs/devel/ \
&& mv *debug*.rpm /var/cache/rpms/kmods/zfs/debug/ \
&& mv zfs-dracut*.rpm /var/cache/rpms/kmods/zfs/other/ \
&& mv zfs-test*.rpm /var/cache/rpms/kmods/zfs/other/ \
&& mv *.rpm /var/cache/rpms/kmods/zfs/