Skip to content

Commit 549e280

Browse files
committed
Add new packaging base
- Increase version to 2.0.1
1 parent 429fb62 commit 549e280

File tree

12 files changed

+1281
-5
lines changed

12 files changed

+1281
-5
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,9 @@ Module.symvers
1616
Mkfile.old
1717

1818
.vscode/
19+
20+
# Packaging
21+
rpm
22+
deb/tuxedo-keyboard-*
23+
*.deb
24+
*.rpm

LICENSE

Lines changed: 675 additions & 0 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
obj-m := ./src/tuxedo_keyboard.o
22

3-
tuxedo_tuxedo-objs := ./src/tuxedo_keyboard.o
4-
53
PWD := $(shell pwd)
64
KDIR := /lib/modules/$(shell uname -r)/build
75

@@ -21,3 +19,92 @@ dkmsadd:
2119
dkmsremove:
2220
dkms remove -m tuxedo_keyboard -v 2.0.0 --all
2321
rm -rf /usr/src/tuxedo_keyboard-2.0.0
22+
23+
# --------------
24+
# Packaging only
25+
# ---------------
26+
27+
# Package version and name from dkms.conf
28+
VER := $(shell sed -n 's/^PACKAGE_VERSION=\([^\n]*\)/\1/p' dkms.conf)
29+
MODULE_NAME := $(shell sed -n 's/^PACKAGE_NAME=\([^\n]*\)/\1/p' dkms.conf)
30+
31+
DEB_PACKAGE_NAME := $(MODULE_NAME)-$(VER)
32+
33+
# Deb package folder variables
34+
DEB_PACKAGE_BASE := deb/$(DEB_PACKAGE_NAME)
35+
DEB_PACKAGE_SRC := $(DEB_PACKAGE_BASE)/usr/src/$(DEB_PACKAGE_NAME)
36+
DEB_PACKAGE_CTRL := $(DEB_PACKAGE_BASE)/DEBIAN
37+
38+
package: package-deb package-rpm
39+
package-clean: package-deb-clean package-rpm-clean
40+
41+
package-deb:
42+
# Create/complete folder structure according to current version
43+
rm -rf $(DEB_PACKAGE_BASE) || true
44+
cp -rf deb/module-name $(DEB_PACKAGE_BASE)
45+
mv $(DEB_PACKAGE_BASE)/usr/share/doc/module-name $(DEB_PACKAGE_BASE)/usr/share/doc/$(MODULE_NAME)
46+
mkdir -p $(DEB_PACKAGE_BASE)/usr/src || true
47+
mkdir -p $(DEB_PACKAGE_SRC) || true
48+
mkdir -p $(DEB_PACKAGE_BASE)/usr/share/$(MODULE_NAME) || true
49+
50+
# Replace name/version numbers in control/script files
51+
sed -i 's/^Version:[^\n]*/Version: $(VER)/g' $(DEB_PACKAGE_CTRL)/control
52+
sed -i 's/^Package:[^\n]*/Package: $(MODULE_NAME)/g' $(DEB_PACKAGE_CTRL)/control
53+
sed -i 's/^version=[^\n]*/version=$(VER)/g' $(DEB_PACKAGE_CTRL)/postinst
54+
sed -i 's/^module=[^\n]*/module=$(MODULE_NAME)/g' $(DEB_PACKAGE_CTRL)/postinst
55+
sed -i 's/^version=[^\n]*/version=$(VER)/g' $(DEB_PACKAGE_CTRL)/prerm
56+
sed -i 's/^module=[^\n]*/module=$(MODULE_NAME)/g' $(DEB_PACKAGE_CTRL)/prerm
57+
# Copy source
58+
cp -rf dkms.conf $(DEB_PACKAGE_SRC)
59+
cp -rf Makefile $(DEB_PACKAGE_SRC)
60+
cp -rf src $(DEB_PACKAGE_SRC)
61+
cp -rf src_pkg/dkms_postinst $(DEB_PACKAGE_BASE)/usr/share/$(MODULE_NAME)/postinst
62+
# Make sure files and folders have acceptable permissions
63+
chmod -R 755 $(DEB_PACKAGE_CTRL)
64+
chmod 644 $(DEB_PACKAGE_CTRL)/control
65+
find deb/$(DEB_PACKAGE_NAME)/usr -type d -exec chmod 755 {} \;
66+
find deb/$(DEB_PACKAGE_NAME)/usr -type f -exec chmod 644 {} \;
67+
chmod 755 $(DEB_PACKAGE_BASE)/usr/share/$(MODULE_NAME)/postinst
68+
69+
gunzip $(DEB_PACKAGE_BASE)/usr/share/doc/$(MODULE_NAME)/changelog.gz
70+
gzip -n9 $(DEB_PACKAGE_BASE)/usr/share/doc/$(MODULE_NAME)/changelog
71+
72+
# Make deb package
73+
dpkg-deb --root-owner-group -b $(DEB_PACKAGE_BASE) $(DEB_PACKAGE_NAME).deb
74+
75+
package-deb-clean:
76+
rm -rf deb/$(MODULE_NAME)-* > /dev/null 2>&1 || true
77+
rm *.deb > /dev/null 2>&1 || true
78+
79+
RPM_PACKAGE_NAME := $(MODULE_NAME)-$(VER)
80+
RPM_PACKAGE_SRC := rpm/SOURCES/$(RPM_PACKAGE_NAME)
81+
RPM_SPEC := rpm/SPECS/$(MODULE_NAME).spec
82+
RELEASE := 0
83+
84+
package-rpm:
85+
# Create folder source structure according to current version
86+
rm -rf rpm || true
87+
mkdir -p $(RPM_PACKAGE_SRC)
88+
mkdir -p rpm/SPECS
89+
# Copy spec template
90+
cp -rf src_pkg/rpm_pkg.spec $(RPM_SPEC)
91+
# Modify spec file with version etc.
92+
sed -i 's/^%define module[^\n]*/%define module $(MODULE_NAME)/g' $(RPM_SPEC)
93+
sed -i 's/^Version:[^\n]*/Version: $(VER)/g' $(RPM_SPEC)
94+
sed -i 's/^Release:[^\n]*/Release: $(RELEASE)/g' $(RPM_SPEC)
95+
# Copy source
96+
cp -rf dkms.conf $(RPM_PACKAGE_SRC)
97+
cp -rf Makefile $(RPM_PACKAGE_SRC)
98+
cp -rf src $(RPM_PACKAGE_SRC)
99+
cp -rf LICENSE $(RPM_PACKAGE_SRC)
100+
cp -rf src_pkg/dkms_postinst $(RPM_PACKAGE_SRC)/postinst
101+
# Compress/package source
102+
cd rpm/SOURCES && tar cjvf $(RPM_PACKAGE_NAME).tar.bz2 $(RPM_PACKAGE_NAME)
103+
# Make rpm package
104+
rpmbuild --debug -bb --define "_topdir `pwd`/rpm" $(RPM_SPEC)
105+
# Copy built package
106+
cp rpm/RPMS/noarch/*.rpm .
107+
108+
package-rpm-clean:
109+
rm -rf rpm > /dev/null 2>&1 || true
110+
rm *.rpm > /dev/null 2>&1 || true

deb/module-name/DEBIAN/control

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Package: module-name
2+
Version: x.x.x
3+
Section: admin
4+
Priority: optional
5+
Depends: dkms (>= 1.95)
6+
Maintainer: TUXEDO Computers GmbH <[email protected]>
7+
Homepage: https://www.tuxedocomputers.com
8+
Architecture: all
9+
Description: Driver for backlit keyboards on TUXEDO notebooks meant for DKMS framework.

deb/module-name/DEBIAN/postinst

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/sh
2+
# Copyright (c) 2020 TUXEDO Computers GmbH
3+
4+
set -e
5+
6+
module=module-name
7+
version=x.x.x
8+
9+
10+
NAME=${module}
11+
PACKAGE_NAME=${NAME}
12+
13+
# From dkms standard postinst
14+
# Copyright (C) 2002-2005 Flavio Stanchina
15+
# Copyright (C) 2005-2006 Aric Cyr
16+
# Copyright (C) 2007 Mario Limonciello
17+
# Copyright (C) 2009 Alberto Milone
18+
DEB_NAME=$(echo $PACKAGE_NAME | sed 's,_,-,')
19+
CVERSION=`dpkg-query -W -f='${Version}' $DEB_NAME | awk -F "-" '{print $1}' | cut -d\: -f2`
20+
ARCH=`dpkg --print-architecture`
21+
22+
dkms_configure () {
23+
for POSTINST in /usr/lib/dkms/common.postinst "/usr/share/$PACKAGE_NAME/postinst"; do
24+
if [ -f "$POSTINST" ]; then
25+
"$POSTINST" "$NAME" "$CVERSION" "/usr/share/$PACKAGE_NAME" "$ARCH" "$2"
26+
return $?
27+
fi
28+
echo "WARNING: $POSTINST does not exist." >&2
29+
done
30+
echo "ERROR: DKMS version is too old and $PACKAGE_NAME was not" >&2
31+
echo "built with legacy DKMS support." >&2
32+
echo "You must either rebuild $PACKAGE_NAME with legacy postinst" >&2
33+
echo "support or upgrade DKMS to a more current version." >&2
34+
return 1
35+
}
36+
37+
# End dkms standard postinst
38+
39+
case "$1" in
40+
configure)
41+
# Run standard dkms build/install for all kernels with headers installed
42+
dkms_configure
43+
44+
# Attempt to (re-)load module immediately, fail silently if not possible at this stage
45+
rmmod ${module} > /dev/null 2>&1 || true
46+
modprobe ${module} > /dev/null 2>&1 || true
47+
;;
48+
49+
abort-upgrade|abort-remove|abort-deconfigure)
50+
;;
51+
52+
*)
53+
echo "postinst called with unknown argument \`$1'" >&2
54+
exit 1
55+
;;
56+
esac
57+
58+
exit 0

deb/module-name/DEBIAN/prerm

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/sh
2+
3+
module=module-name
4+
version=x.x.x
5+
6+
set -e
7+
8+
case "$1" in
9+
remove|upgrade|deconfigure)
10+
if [ "`dkms status -m $module`" ]
11+
then
12+
dkms remove -m $module -v $version --all
13+
# Attempt to remove module, fail silently if module is already unloaded
14+
rmmod -s $module > /dev/null 2>&1 || true
15+
fi
16+
;;
17+
18+
failed-upgrade)
19+
;;
20+
21+
*)
22+
echo "prerm called with unknown argument \`$1'" >&2
23+
exit 1
24+
;;
25+
esac
26+
27+
28+
29+
exit 0
30+
31+
Binary file not shown.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
2+
Upstream-Name: tuxedo-keyboard
3+
Upstream-Contact: TUXEDO Computers GmbH <[email protected]>
4+
5+
Files: *
6+
Copyright: 2020 TUXEDO Computers GmbH <[email protected]>
7+
License: GPL-3+
8+
9+
License: GPL-3+
10+
This program is free software: you can redistribute it and/or modify
11+
it under the terms of the GNU General Public License as published by
12+
the Free Software Foundation, either version 3 of the License, or
13+
(at your option) any later version.
14+
.
15+
This package is distributed in the hope that it will be useful,
16+
but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
GNU General Public License for more details.
19+
.
20+
You should have received a copy of the GNU General Public License
21+
along with this program. If not, see <http://www.gnu.org/licenses/>.
22+
.
23+
On Debian systems, the complete text of the GNU General
24+
Public License version 3 can be found in '/usr/share/common-licenses/GPL-3'.

dkms.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
PACKAGE_NAME=tuxedo-keyboard
2-
PACKAGE_VERSION=2.0.0
2+
PACKAGE_VERSION=2.0.1
33

44
DEST_MODULE_LOCATION[0]="/kernel/lib/"
55
BUILT_MODULE_NAME[0]="tuxedo_keyboard"
66
BUILT_MODULE_LOCATION[0]="src/"
77

8-
MAKE[0]="make -C . KERNELDIR=/lib/modules/${kernelver}/build"
8+
MAKE[0]="make -C . KDIR=/lib/modules/${kernelver}/build"
99
CLEAN="make -C . clean"
1010
AUTOINSTALL="yes"

src/tuxedo_keyboard.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ MODULE_AUTHOR
3232
("Christian Loritz / TUXEDO Computers GmbH <[email protected]>");
3333
MODULE_DESCRIPTION("TUXEDO Computers Keyboard Backlight Driver");
3434
MODULE_LICENSE("GPL");
35-
MODULE_VERSION("2.0.0");
35+
MODULE_VERSION("2.0.1");
3636

3737
/* :::: Module specific Constants and simple Macros :::: */
3838

0 commit comments

Comments
 (0)