-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathbuild-deb.sh
More file actions
executable file
·78 lines (66 loc) · 2.16 KB
/
build-deb.sh
File metadata and controls
executable file
·78 lines (66 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env bash
# Build a .deb package for mediatek-mt7927-dkms.
# Usage: ./build-deb.sh
#
# Prerequisites: dpkg-deb, make, python3, curl
set -euo pipefail
PKGNAME="mediatek-mt7927-dkms"
VERSION=$(sed -n "s/^PACKAGE_VERSION=\"\(.*\)\"/\1/p" dkms.conf)
ARCH="all"
OUTDIR="${PWD}"
BUILDDIR=$(mktemp -d)
STAGEDIR="${BUILDDIR}/${PKGNAME}_${VERSION}_${ARCH}"
trap 'rm -rf "${BUILDDIR}"' EXIT
echo "==> Building ${PKGNAME} ${VERSION} .deb"
# Prepare sources using the Makefile
make download
make sources SRCDIR="${BUILDDIR}/_build"
# Install to staging area
make install \
SRCDIR="${BUILDDIR}/_build" \
DESTDIR="${STAGEDIR}" \
VERSION="${VERSION}"
# Create DEBIAN control files
mkdir -p "${STAGEDIR}/DEBIAN"
cat > "${STAGEDIR}/DEBIAN/control" <<EOF
Package: ${PKGNAME}
Version: ${VERSION}-1
Architecture: ${ARCH}
Maintainer: Javier Tia <floss@jetm.me>
Depends: dkms
Conflicts: btusb-mt7925-dkms, btusb-mt7927-dkms
Section: kernel
Priority: optional
Homepage: https://github.com/jetm/mediatek-mt7927-dkms
Description: DKMS WiFi 7 and Bluetooth 5.4 drivers for MediaTek MT7927
Builds out-of-tree btusb/btmtk (Bluetooth) and mt76 (WiFi) kernel
modules with device IDs and patches not yet in mainline Linux.
Supports kernels 6.17+.
EOF
cat > "${STAGEDIR}/DEBIAN/postinst" <<'EOF'
#!/bin/sh
set -e
DKMS_NAME="mediatek-mt7927"
DKMS_VERSION="@VERSION@"
if [ "$1" = "configure" ]; then
dkms add -m "${DKMS_NAME}" -v "${DKMS_VERSION}" || true
dkms build -m "${DKMS_NAME}" -v "${DKMS_VERSION}" || true
dkms install -m "${DKMS_NAME}" -v "${DKMS_VERSION}" --force || true
fi
EOF
sed -i "s/@VERSION@/${VERSION}/" "${STAGEDIR}/DEBIAN/postinst"
chmod 755 "${STAGEDIR}/DEBIAN/postinst"
cat > "${STAGEDIR}/DEBIAN/prerm" <<'EOF'
#!/bin/sh
set -e
DKMS_NAME="mediatek-mt7927"
DKMS_VERSION="@VERSION@"
if [ "$1" = "remove" ] || [ "$1" = "purge" ]; then
dkms remove -m "${DKMS_NAME}" -v "${DKMS_VERSION}" --all || true
fi
EOF
sed -i "s/@VERSION@/${VERSION}/" "${STAGEDIR}/DEBIAN/prerm"
chmod 755 "${STAGEDIR}/DEBIAN/prerm"
# Build the .deb
dpkg-deb --root-owner-group --build "${STAGEDIR}" "${OUTDIR}/${PKGNAME}_${VERSION}-1_${ARCH}.deb"
echo "==> Built: ${PKGNAME}_${VERSION}-1_${ARCH}.deb"