k/kmod-i2c-ch341: improve versioning and building.

Module versioning schema changed, now it is DATE_COMMIT_KERNEL.
Allow to build module against any kernel source specified by KERNSRC
environment variable.

Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
This commit is contained in:
Michal Cieslakiewicz 2022-01-30 18:36:09 +01:00
parent 167dbce1f8
commit c9892a0f03
4 changed files with 31 additions and 27 deletions

View File

@ -2,9 +2,8 @@
set -x
SRC=i2c-ch341
APP=kmod-${SRC}
VERSION=`date '+%Y%m%d'`git
git clone https://github.com/gmarco/${SRC}.git
mv ${SRC} ${APP}-${VERSION}
( cd ${APP}-${VERSION} && rm -rf .git )
VERSION=$(cd $SRC && git log -n 1 --format='%cs_%h' --abbrev=8 | sed -e 's/-//g')
mv $SRC ${APP}-${VERSION}
tar cf - ${APP}-${VERSION} | xz -c9 > ${APP}-${VERSION}.tar.xz
[ -s ${APP}-${VERSION}.tar.xz ] && rm -rf ${APP}-${VERSION}

View File

@ -4,7 +4,7 @@ CWD=$(pwd)
MOD=i2c-ch341
APP=kmod-${MOD}
KERNSRC=/usr/src/linux
KERNSRC=${KERNSRC:-/usr/src/linux}
VERSION=${VERSION:-$(echo $APP-*.tar.?z* | rev | cut -f 3- -d . | cut -f 1 -d - | rev)}
ARCH=${ARCH:-x86_64}
BUILD=${BUILD:-1}
@ -15,7 +15,7 @@ if [ ! -f ${KERNSRC}/include/config/kernel.release ] ; then
echo "Run 'make *config' then 'make modules_prepare' in kernel source dir first."
exit 1
else
KERNVER=`cat ${KERNSRC}/include/config/kernel.release`
KERNVER=$(cat ${KERNSRC}/include/config/kernel.release)
fi
MAKE="make"
@ -35,9 +35,9 @@ find . -perm 444 -exec chmod 644 {} \;
find . -perm 777 -exec chmod 755 {} \;
find . -perm 666 -exec chmod 644 {} \;
patch -p1 < $CWD/makefile-kern-ver.patch
patch -p1 < $CWD/makefile-kernsrc.patch
$MAKE KERN_VER=${KERNVER} || exit 1
$MAKE KERNSRC=${KERNSRC} || exit 1
# install manually
mkdir -p $PKG/lib/modules/${KERNVER}/misc/
@ -62,6 +62,12 @@ fi
EOF
# ----------------
# Allow to run as non-root until now:
if [ $(id -u) -ne 0 ]; then
echo "*** Running as non-root, skipping makepkg."
echo "*** Package contents is in $PKG directory."
exit 0
fi
cd $PKG
makepkg -l y -c n $TMP/$APP-${VERSION}_${KERNVER}-$ARCH-${BUILD}${TAG}.txz

View File

@ -1,20 +0,0 @@
--- a/Makefile 2017-03-30 19:42:29.000000000 +0200
+++ b/Makefile 2017-11-19 23:25:14.220702982 +0100
@@ -1,11 +1,13 @@
obj-m += i2c-ch341.o
+KERN_VER ?= $(shell uname -r)
+
all:
- make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+ make -C /lib/modules/$(KERN_VER)/build M=$(PWD) modules
clean:
- make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
+ make -C /lib/modules/$(KERN_VER)/build M=$(PWD) clean
reload: all
sudo rmmod i2c-ch341 ||true
- sudo insmod ./i2c-ch341.ko
\ No newline at end of file
+ sudo insmod ./i2c-ch341.ko

View File

@ -0,0 +1,19 @@
diff --color -ruN a/Makefile b/Makefile
--- a/Makefile 2022-01-30 17:41:11.000000000 +0100
+++ b/Makefile 2022-01-30 17:43:20.944541879 +0100
@@ -1,11 +1,8 @@
obj-m += i2c-ch341.o
+KERNSRC ?= /usr/src/linux
all:
- make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+ make -C $(KERNSRC) M=$(PWD) modules
clean:
- make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
-
-reload: all
- sudo rmmod i2c-ch341 ||true
- sudo insmod ./i2c-ch341.ko
\ No newline at end of file
+ make -C $(KERNSRC) M=$(PWD) clean