Hi everyone,

On Fri, 08 Apr 2022 13:04:04 +0300 Jaak Pruulmann-Vengerfeldt <j...@meso.ee> 
wrote:
> With the new upstream version arriving in unstable, it is not clear what
> is now the proper way to create binary-only module packages, for
> example?

Now it reached stable/bookworm ...

I just ran into it and are in desperate need for packaging (also zfs), do first
tried to manually reverse the changes referenced above, but there were too many
changes, so I started to manually craft the package on basis of a working 
bullseye
package.

This needs polishing, yet it "works for me", so maybe it is of some use for
anyone trying to package zfs modules.

-----------------------------------------------%<
#!/bin/bash

export LANG=C

DETECTED_VERSION=""

# be smart and try to detect if we have only one kernel
if [ "$( find /lib/modules/  -maxdepth 1 -mindepth 1 -type d | sed -e 's%/% %g' 
| awk '{print $NF }' | wc -l )" == "1" ]
then
    DETECTED_VERSION=$( find /lib/modules/  -maxdepth 1 -mindepth 1 -type d | 
sed -e 's%/% %g' | awk '{print $NF }' )
fi

KERNEL_VERSION=${1:-$DETECTED_VERSION}

if [ "$KERNEL_VERSION" == "" ]
then
    echo "ERROR: Please provide kernel version!"
    exit 1
fi

if [ ! -e "/usr/lib/modules/$KERNEL_VERSION/updates/dkms/zfs.ko" ]
then
    if [ -e "/usr/lib/modules/${KERNEL_VERSION}-amd64/updates/dkms/zfs.ko" ]
    then
        KERNEL_VERSION=${KERNEL_VERSION}-amd64
    else
        echo "ERROR: ZFS module for kernel $KERNEL_VERSION was not found, 
cannot continue!"
        echo ""
        find /usr/lib/modules/*/updates/* -type f
        exit 1
    fi
fi

ZFS_VERSION=$( modinfo /lib/modules/${KERNEL_VERSION}/updates/dkms/zfs.ko | 
grep ^version | awk '{ print $NF }' | cut -d- -f1 )

TMPDIR="/tmp/build.$KERNEL_VERSION"
rm -rf $TMPDIR
mkdir -p $TMPDIR/debian
cd $TMPDIR

mkdir -p src/lib/modules/$KERNEL_VERSION/updates/dkms
cp -R /usr/lib/modules/$KERNEL_VERSION/updates/dkms/*.ko 
src/lib/modules/$KERNEL_VERSION/updates/dkms

cat > debian/changelog <<EOF
zfs-modules-${KERNEL_VERSION} ($ZFS_VERSION) stable; urgency=low

  * ZFS ${ZFS_VERSION} modules for kernel ${KERNEL_VERSION}

 -- Author <aut...@redact.ed>  $( date +"%a, %d %b %Y %H:%M:%S %z" )
EOF

cat > debian/control <<EOF
Source: zfs-modules-${KERNEL_VERSION}
Maintainer: Author <aut...@redact.ed>
Section: misc
Priority: optional
Standards-Version: 4.5.1
Build-Depends: bash (>= 4.2), debhelper (>= 13)


Package: zfs-modules-${KERNEL_VERSION}
Architecture: amd64
Depends: linux-image-${KERNEL_VERSION}
Provides: zfs-modules
Description: zfs binary drivers for linux-image-${KERNEL_VERSION}
 This package contains zfs drivers for the ${KERNEL_VERSION} Linux kernel,
 built from zfs-dkms for the amd64 architecture.
EOF

echo 13 > debian/compat

cat > Makefile <<'EOF'
all:

install:
        @cp -R src/* $(DESTDIR)

clean-all:
        @rm -rf src/*
EOF

cat >debian/rules <<'EOF'
#!/usr/bin/make -f

%:
        dh $@
EOF
chmod +x debian/rules

dpkg-buildpackage -d -b -us -uc 1>/dev/null

rm -rf $TMPDIR

>%-----------------------------------------------

-- 
Best regards

Andreas STEINEL 
M.Sc. Visual Computing, M.Sc. Informatik 
Durchwahl: +49 6881 99995 91
eXirius IT Dienstleistungen GmbH
Juchem-Straße 24 | 66571 Eppelborn
T +49 6881 99995 0 | i...@exirius.de
http://www.exirius.de

Amtsgericht Saarbrücken HRB 12124
Geschäftsführer: Michael Royar, Claus Cullmann

eXirius ist Mitglied im Netzwerk Digital Fellows
www.fellows.digital

Reply via email to