Skip to content

Commit c14141c

Browse files
author
刘鑫
committedJan 11, 2021
feat: add postinst and prerm for the dkms format package generated by Debian format packaging
1 parent deff094 commit c14141c

File tree

3 files changed

+81
-1
lines changed

3 files changed

+81
-1
lines changed
 

‎debian/rtl8821cu-dkms.postinst

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/sh
2+
# Copyright (C) 2002-2005 Flavio Stanchina
3+
# Copyright (C) 2005-2006 Aric Cyr
4+
# Copyright (C) 2007 Mario Limonciello
5+
# Copyright (C) 2009 Alberto Milone
6+
7+
set -e
8+
9+
NAME=rtl8821cu
10+
PACKAGE_NAME=$NAME-dkms
11+
DEB_NAME=$(echo $PACKAGE_NAME | sed 's,_,-,')
12+
CVERSION=`dpkg-query -W -f='${Version}' $DEB_NAME | awk -F "-" '{print $1}' | cut -d\: -f2`
13+
ARCH=`dpkg-architecture -qDEB_BUILD_GNU_CPU`
14+
15+
dkms_configure () {
16+
for POSTINST in /usr/lib/dkms/common.postinst "/usr/share/$PACKAGE_NAME/postinst"; do
17+
if [ -f "$POSTINST" ]; then
18+
"$POSTINST" "$NAME" "$CVERSION" "/usr/share/$PACKAGE_NAME" "$ARCH" "$2"
19+
return $?
20+
fi
21+
echo "WARNING: $POSTINST does not exist." >&2
22+
done
23+
echo "ERROR: DKMS version is too old and $PACKAGE_NAME was not" >&2
24+
echo "built with legacy DKMS support." >&2
25+
echo "You must either rebuild $PACKAGE_NAME with legacy postinst" >&2
26+
echo "support or upgrade DKMS to a more current version." >&2
27+
return 1
28+
}
29+
30+
case "$1" in
31+
configure)
32+
dkms_configure
33+
;;
34+
35+
abort-upgrade|abort-remove|abort-deconfigure)
36+
;;
37+
38+
*)
39+
echo "postinst called with unknown argument \`$1'" >&2
40+
exit 1
41+
;;
42+
esac
43+
44+
# dh_installdeb will replace this with shell code automatically
45+
# generated by other debhelper scripts.
46+
47+
48+
49+
exit 0

‎debian/rtl8821cu-dkms.prerm

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
3+
NAME=rtl8821cu
4+
VERSION=5.4.1
5+
6+
set -e
7+
8+
case "$1" in
9+
remove|upgrade|deconfigure)
10+
if [ "`dkms status -m $NAME`" ]; then
11+
dkms remove -m $NAME -v $VERSION --all
12+
fi
13+
;;
14+
15+
failed-upgrade)
16+
;;
17+
18+
*)
19+
echo "prerm called with unknown argument \`$1'" >&2
20+
exit 1
21+
;;
22+
esac
23+
24+
25+
26+
exit 0
27+
28+
29+
30+

‎debian/rules

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ override_dh_auto_install:
1919
dh_install -prtl8821cu-dkms -X.o -X.ko platform/ usr/src/rtl8821cu-$(VERSION)
2020
dh_install -prtl8821cu-dkms -X.o -X.ko include/ usr/src/rtl8821cu-$(VERSION)
2121
dh_install -prtl8821cu-dkms Makefile usr/src/rtl8821cu-$(VERSION)
22-
dh_install -prtl8821cu-dkms rtl8821c.mk usr/src/rtl8821cu-$(VERSION)
22+
dh_install -prtl8821cu-dkms rtl8821c.mk usr/src/rtl8821cu-$(VERSION)
23+
dh_install -prtl8821cu-dkms dkms.conf usr/src/rtl8821cu-$(VERSION)
2324
install -d $(XDIR)/debian
2425
cd debian && install rules.m-a ../$(XDIR)/debian/rules && cp -r *modules.in* changelog copyright compat *_KVERS_* ../$(XDIR)/debian/
2526
cd debian/rtl8821cu-src/usr/src && cp -a ../../../rtl8821cu-dkms/usr/src/rtl8821cu-$(VERSION)/* modules/rtl8821cu-src/ && XZ_OPT=-9 tar --xz -c -f rtl8821cu.tar.xz modules && rm -rf modules

0 commit comments

Comments
 (0)
Please sign in to comment.