Skip to content

Commit 04c702f

Browse files
committed
First working revision (requires kernel-latest-devel)
1 parent 34b122e commit 04c702f

10 files changed

+208
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pkgs/
2+
*.tar.bz2
3+
*.tar.gz

.gitlab-ci.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
include:
2+
- file: /r4.2/gitlab-base.yml
3+
project: QubesOS/qubes-continuous-integration
4+
- file: /r4.2/gitlab-host.yml
5+
project: QubesOS/qubes-continuous-integration

.qubesbuilder

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
host:
2+
rpm:
3+
build:
4+
- zfs-dkms.spec
5+
source:
6+
files:
7+
- url: https://github.com/openzfs/zfs/releases/download/zfs-@VERSION@/zfs-@VERSION@.tar.gz
8+
sha512: zfs-@VERSION@.tar.gz.sha512

Makefile

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
VERSION := $(file <version)
2+
URL := https://github.com/openzfs/zfs/releases/download/zfs-$(VERSION)/zfs-$(VERSION).tar.gz
3+
4+
UNTRUSTED_SUFF := .UNTRUSTED
5+
6+
FETCH_CMD := wget --no-use-server-timestamps -q -O
7+
8+
SHELL := /bin/bash
9+
%: %.sha512
10+
@$(FETCH_CMD) $@$(UNTRUSTED_SUFF) $(URL)
11+
@sha512sum --status -c <(printf "$$(cat $<) -\n") <$@$(UNTRUSTED_SUFF) || \
12+
{ echo "Wrong SHA512 checksum on $@$(UNTRUSTED_SUFF)!"; exit 1; }
13+
@mv $@$(UNTRUSTED_SUFF) $@
14+
15+
.PHONY: get-sources
16+
get-sources: $(SRC_FILE)
17+
18+
verify-sources:
19+
@true

Makefile.builder

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ifeq ($(PACKAGE_SET),dom0)
2+
RPM_SPEC_FILES := zfs-dkms.spec
3+
endif
4+
5+
NO_ARCHIVE := 1

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# qubes-zfs-dkms
2+
3+
ZFS-DKMS fork for Qubes OS

rel

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1

version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.3.0

zfs-2.3.0.tar.gz.sha512

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
f0bb1c6e28b325765be809dbc5d38ba294daa38b54eafd7d129cf6081fb209b200580437019faeed3614bbb0687d6583698a9282f3275905a1f5a8314a66cf0b

zfs-dkms.spec.in

+162
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
%{?!packager: %define packager Brian Behlendorf <behlendorf1@llnl.gov>}
2+
3+
%if ! 0%{?rhel}%{?fedora}%{?mageia}%{?suse_version}%{?openEuler}
4+
%define not_rpm 1
5+
%endif
6+
7+
# Exclude input files from mangling
8+
%global __brp_mangle_shebangs_exclude_from ^/usr/src/.*$
9+
10+
%define module zfs
11+
%define mkconf scripts/dkms.mkconf
12+
13+
Name: %{module}-dkms
14+
15+
Version: @VERSION@
16+
Release: @REL@%{dist}
17+
Summary: Kernel module(s) (dkms)
18+
19+
Group: System Environment/Kernel
20+
License: CDDL
21+
URL: https://github.com/openzfs/zfs
22+
Source0: %{module}-%{version}.tar.gz
23+
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
24+
BuildArch: noarch
25+
26+
Requires: dkms >= 2.2.0.3
27+
Requires(pre): dkms >= 2.2.0.3
28+
Requires(post): dkms >= 2.2.0.3
29+
Requires(preun): dkms >= 2.2.0.3
30+
Requires: gcc, make, perl, diffutils
31+
Requires(post): gcc, make, perl, diffutils
32+
%if 0%{?rhel}%{?fedora}%{?mageia}%{?suse_version}%{?openEuler}
33+
Requires: kernel-devel <= 6.12.1000
34+
Requires(post): kernel-devel <= 6.12.1000
35+
Conflicts: kernel-devel > 6.12.1000
36+
Obsoletes: spl-dkms <= %{version}
37+
%endif
38+
Provides: %{module}-kmod = %{version}
39+
AutoReqProv: no
40+
41+
%if (0%{?fedora}%{?suse_version}%{?openEuler}) || (0%{?rhel} && 0%{?rhel} < 9)
42+
# We don't directly use it, but if this isn't installed, rpmbuild as root can
43+
# crash+corrupt rpmdb
44+
# See issue #12071
45+
BuildRequires: ncompress
46+
%endif
47+
48+
%description
49+
This package contains the dkms ZFS kernel modules.
50+
51+
%prep
52+
%setup -q -n %{module}-%{version}
53+
54+
%build
55+
%{mkconf} -n %{module} -v %{version} -f dkms.conf
56+
57+
%install
58+
if [ "$RPM_BUILD_ROOT" != "/" ]; then
59+
rm -rf $RPM_BUILD_ROOT
60+
fi
61+
mkdir -p $RPM_BUILD_ROOT/usr/src/
62+
cp -rf ${RPM_BUILD_DIR}/%{module}-%{version} $RPM_BUILD_ROOT/usr/src/
63+
64+
%clean
65+
if [ "$RPM_BUILD_ROOT" != "/" ]; then
66+
rm -rf $RPM_BUILD_ROOT
67+
fi
68+
69+
%files
70+
%defattr(-,root,root)
71+
/usr/src/%{module}-%{version}
72+
73+
%pre
74+
echo "Running pre installation script: $0. Parameters: $*"
75+
# We don't want any other versions lingering around in dkms.
76+
# Tests with 'dnf' showed that in case of reinstall, or upgrade
77+
# the preun scriptlet removed the version we are trying to install.
78+
# Because of this, find all zfs dkms sources in /var/lib/dkms and
79+
# remove them, if we find a matching version in dkms.
80+
81+
dkms_root=/var/lib/dkms
82+
if [ -d ${dkms_root}/%{module} ]; then
83+
cd ${dkms_root}/%{module}
84+
for x in [[:digit:]]*; do
85+
[ -d "$x" ] || continue
86+
otherver="$x"
87+
opath="${dkms_root}/%{module}/${otherver}"
88+
if [ "$otherver" != %{version} ]; then
89+
# This is a workaround for a broken 'dkms status', we caused in a previous version.
90+
# One day it might be not needed anymore, but it does not hurt to keep it.
91+
if dkms status -m %{module} -v "$otherver" 2>&1 | grep "${opath}/source/dkms.conf does not exist"
92+
then
93+
echo "ERROR: dkms status is broken!" >&2
94+
if [ -L "${opath}/source" -a ! -d "${opath}/source" ]
95+
then
96+
echo "Trying to fix it by removing the symlink: ${opath}/source" >&2
97+
echo "You should manually remove ${opath}" >&2
98+
rm -f "${opath}/source" || echo "Removal failed!" >&2
99+
fi
100+
fi
101+
if [ `dkms status -m %{module} -v "$otherver" | grep -c %{module}` -gt 0 ]; then
102+
echo "Removing old %{module} dkms modules version $otherver from all kernels."
103+
dkms remove -m %{module} -v "$otherver" --all ||:
104+
fi
105+
fi
106+
done
107+
cd ${dkms_root}
108+
fi
109+
110+
# Uninstall this version of zfs dkms modules before installation of the package.
111+
if [ `dkms status -m %{module} -v %{version} | grep -c %{module}` -gt 0 ]; then
112+
echo "Removing %{module} dkms modules version %{version} from all kernels."
113+
dkms remove -m %{module} -v %{version} --all ||:
114+
fi
115+
116+
%post
117+
echo "Running post installation script: $0. Parameters: $*"
118+
# Add the module to dkms, as reccommended in the dkms man page.
119+
# This is generally rpm specfic.
120+
# But this also may help, if we have a broken 'dkms status'.
121+
# Because, if the sources are available and only the symlink pointing
122+
# to them is missing, this will resolve the situation
123+
echo "Adding %{module} dkms modules version %{version} to dkms."
124+
dkms add -m %{module} -v %{version} %{!?not_rpm:--rpm_safe_upgrade} ||:
125+
126+
# After installing the package, dkms install this zfs version for the current kernel.
127+
# Force the overwriting of old modules to avoid diff warnings in dkms status.
128+
# Or in case of a downgrade to overwrite newer versions.
129+
# Or if some other backed up versions have been restored before.
130+
echo "Installing %{module} dkms modules version %{version} for the current kernel."
131+
dkms install --force -m %{module} -v %{version} ||:
132+
133+
%preun
134+
dkms_root="/var/lib/dkms/%{module}/%{version}"
135+
echo "Running pre uninstall script: $0. Parameters: $*"
136+
# In case of upgrade we do nothing. See above comment in pre hook.
137+
if [ "$1" = "1" -o "$1" = "upgrade" ] ; then
138+
echo "This is an upgrade. Skipping pre uninstall action."
139+
exit 0
140+
fi
141+
142+
# Check if we uninstall the package. In that case remove the dkms modules.
143+
# '0' is the value for the first parameter for rpm packages.
144+
# 'remove' or 'purge' are the possible names for deb packages.
145+
if [ "$1" = "0" -o "$1" = "remove" -o "$1" = "purge" ] ; then
146+
if [ `dkms status -m %{module} -v %{version} | grep -c %{module}` -gt 0 ]; then
147+
echo "Removing %{module} dkms modules version %{version} from all kernels."
148+
dkms remove -m %{module} -v %{version} --all %{!?not_rpm:--rpm_safe_upgrade} && exit 0
149+
fi
150+
# If removing the modules failed, it might be because of the broken 'dkms status'.
151+
if dkms status -m %{module} -v %{version} 2>&1 | grep "${dkms_root}/source/dkms.conf does not exist"
152+
then
153+
echo "ERROR: dkms status is broken!" >&2
154+
echo "You should manually remove ${dkms_root}" >&2
155+
echo "WARNING: installed modules in /lib/modules/`uname -r`/extra could not be removed automatically!" >&2
156+
fi
157+
else
158+
echo "Script parameter $1 did not match any removal condition."
159+
fi
160+
161+
exit 0
162+

0 commit comments

Comments
 (0)