slackbuilds/a/nct6687d/SlackBuild

103 lines
2.1 KiB
Text
Raw Normal View History

2021-11-02 14:35:30 +01:00
#!/bin/bash
# variables
TAG=gwh
TMP=/tmp/$TAG
OUTPUT=/tmp
CWD=$(pwd)
2024-06-17 09:37:04 +02:00
PRGNAM=$(basename "$CWD")
2021-11-02 14:35:30 +01:00
PKG=$TMP/pkg-$PRGNAM
2022-01-22 19:52:02 +01:00
REPOSITORY=/home/installs/SlackBuilds/_repositories/$PRGNAM
2021-11-02 14:35:30 +01:00
GITHUB_REPO=Fred78290/nct6687d
2024-09-02 13:59:17 +02:00
#GITHUB_REPO=gwenhael-le-moine/nct6687d
VERSION=${VERSION:-"trunk"}
2021-11-02 14:35:30 +01:00
KERNEL_VERSION=$(uname -r)
ARCH=$(uname -m)
2024-06-17 09:37:04 +02:00
BUILD=4
2021-11-02 14:35:30 +01:00
PREFIX=/usr
SLCKFLAGS="-fPIC -O2"
2024-06-17 09:37:04 +02:00
mkdir -p "$PKG"
2021-11-02 14:35:30 +01:00
# mise en place
2024-06-17 09:37:04 +02:00
[ ! -e "$REPOSITORY" ] && git clone https://github.com/${GITHUB_REPO} "$REPOSITORY"
cd "$REPOSITORY" || exit 1
2021-11-02 14:35:30 +01:00
git pull --all
2024-09-02 13:59:17 +02:00
rm -fr "$PKG" "$TMP/$PRGNAM"
2021-11-02 14:35:30 +01:00
2024-06-17 09:37:04 +02:00
cp -R "$REPOSITORY" "$TMP/$PRGNAM"
cd "$TMP/$PRGNAM" || exit 1
2022-01-21 11:29:29 +01:00
case $VERSION in
trunk)
2023-03-23 09:54:21 +01:00
VERSION="git_r$(git rev-list --count HEAD)_$(git log -1 --format=%h)"
2022-01-21 11:29:29 +01:00
;;
latest)
2024-05-27 07:53:51 +02:00
VERSION=$(git tag --sort=-version:refname | head -n1)
2024-06-17 09:37:04 +02:00
git checkout "$VERSION"
2022-01-21 11:29:29 +01:00
;;
*)
2024-06-17 09:37:04 +02:00
git checkout "$VERSION"
2022-01-21 11:29:29 +01:00
;;
esac
2021-11-02 14:35:30 +01:00
2024-09-02 13:59:17 +02:00
if [ -e "$CWD"/66c35797a515d14a6482fbb9da2f58b407083591.patch ]; then
patch -p1 < "$CWD"/66c35797a515d14a6482fbb9da2f58b407083591.patch
VERSION="${VERSION}_patched"
fi
2021-11-02 14:35:30 +01:00
# compilation
make
# installation
2024-06-17 09:37:04 +02:00
mkdir -p "$PKG/lib/modules/${KERNEL_VERSION}/kernel/drivers/hwmon/"
cp "${KERNEL_VERSION}/nct6687.ko" "$PKG/lib/modules/${KERNEL_VERSION}/kernel/drivers/hwmon/"
2021-11-02 14:35:30 +01:00
2024-06-17 09:37:04 +02:00
mkdir -p "$PKG/etc/modprobe.d/"
cat <<EOF > "$PKG"/etc/modprobe.d/blacklist_nct6683.conf
# Do not load the nct6683 module on boot.
blacklist nct6683
# uncomment the line below if blacklisting is not sufficient
# install nct6683 /bin/true
EOF
2024-06-17 09:37:04 +02:00
mkdir -p "$PKG/usr/doc/$PRGNAM/"
cp -R images/ LICENSE ./*.md "$PKG/usr/doc/$PRGNAM/"
2021-11-02 14:35:30 +01:00
# correction
2024-06-17 09:37:04 +02:00
cd "$PKG" || exit 1
chown -R root:root ./*
2021-11-02 14:35:30 +01:00
2024-06-17 09:37:04 +02:00
# embaumement
mkdir -p "$PKG"/install
cat <<EOF > "$PKG"/install/doinst.sh
#!/bin/bash
2021-11-02 14:35:30 +01:00
2024-06-17 09:37:04 +02:00
depmod
2021-11-02 14:35:30 +01:00
2024-06-17 09:37:04 +02:00
modprobe nct6687
EOF
2021-11-02 14:35:30 +01:00
2024-06-17 09:37:04 +02:00
cat <<EOF > "$PKG"/install/slack-desc
2021-11-02 14:35:30 +01:00
$PRGNAM: $PRGNAM (Linux kernel module for Nuvoton NCT6687-R)
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM: https://github.com/${GITHUB_REPO}
$PRGNAM:
EOF
# empaquetage
/sbin/makepkg --linkadd y --chown n --prepend "$OUTPUT/$PRGNAM-${VERSION//-/}_${KERNEL_VERSION//-/}-$ARCH-$BUILD$TAG.txz"