Skip to content

Commit

Permalink
Fix version header generation for dkms
Browse files Browse the repository at this point in the history
The dkms build fails for the latest release:

  #60

The problem is that dkms does not call my Makefile at all, so the
version header is never generated. Dkms does have a PRE_BUILD hook
though, so use that to call a script that takes care of this.

From now on, I must always remember to run a dkms build before a new
release.

Signed-off-by: Ernesto A. Fernández <ernesto@corellium.com>
  • Loading branch information
eafer committed Jan 18, 2024
1 parent 9ae07db commit 5e133a2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
KERNELRELEASE ?= $(shell uname -r)
KERNEL_DIR ?= /lib/modules/$(KERNELRELEASE)/build
PWD := $(shell pwd)
GIT_COMMIT = $(shell git describe HEAD | tail -c 9)

obj-m = apfs.o
apfs-y := btree.o compress.o dir.o extents.o file.o inode.o key.o libzbitmap.o \
Expand All @@ -15,7 +14,7 @@ apfs-y := btree.o compress.o dir.o extents.o file.o inode.o key.o libzbitmap.o \
spaceman.o super.o symlink.o transaction.o unicode.o xattr.o xfield.o

default:
@printf '#define GIT_COMMIT\t"%s"\n' $(GIT_COMMIT) > version.h
./genver.sh
make -C $(KERNEL_DIR) M=$(PWD)
install:
make -C $(KERNEL_DIR) M=$(PWD) modules_install
Expand Down
1 change: 1 addition & 0 deletions dkms.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ BUILT_MODULE_NAME[0]="apfs"
DEST_MODULE_LOCATION[0]="/extra"

AUTOINSTALL="yes"
PRE_BUILD="genver.sh"
13 changes: 13 additions & 0 deletions genver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-only
#
# Script to generate the module version header
#

if command -v git >/dev/null 2>&1; then
GIT_COMMIT=$(git describe HEAD | tail -c 9)
else
GIT_COMMIT="unknown"
fi

printf '#define GIT_COMMIT\t"%s"\n' "$GIT_COMMIT" > version.h

0 comments on commit 5e133a2

Please sign in to comment.