slackbuilds/a/nct6687d/SlackBuild
2024-09-02 17:52:36 +02:00

103 lines
2.3 KiB
Bash
Executable file

#!/bin/bash
# variables
TAG=gwh
TMP=/tmp/$TAG
OUTPUT=/tmp
CWD=$(pwd)
PRGNAM=$(basename "$CWD")
PKG=$TMP/pkg-$PRGNAM
REPOSITORY=/home/installs/SlackBuilds/_repositories/$PRGNAM
GITHUB_REPO=Fred78290/nct6687d
#GITHUB_REPO=gwenhael-le-moine/nct6687d
VERSION=${VERSION:-"trunk"}
KERNEL_VERSION=$(uname -r)
ARCH=$(uname -m)
BUILD=7
mkdir -p "$PKG"
# mise en place
[ ! -e "$REPOSITORY" ] && git clone https://github.com/${GITHUB_REPO} "$REPOSITORY"
cd "$REPOSITORY" || exit 1
git pull --all
rm -fr "$PKG" "${TMP:?}/$PRGNAM"
cp -R "$REPOSITORY" "$TMP/$PRGNAM"
cd "$TMP/$PRGNAM" || exit 1
case $VERSION in
trunk)
VERSION="git_r$(git rev-list --count HEAD)_$(git log -1 --format=%h)"
;;
latest)
VERSION=$(git tag --sort=-version:refname | head -n1)
git checkout "$VERSION"
;;
*)
git checkout "$VERSION"
;;
esac
# if [ -e "$CWD"/66c35797a515d14a6482fbb9da2f58b407083591.patch ]; then
# patch -p1 < "$CWD"/66c35797a515d14a6482fbb9da2f58b407083591.patch
# VERSION="${VERSION}_patched"
# fi
# if [ -e "$CWD"/ec431bf2ce2c017e4d3ec9a4bda6300ac5a46780.patch ]; then
# patch -p1 < "$CWD"/ec431bf2ce2c017e4d3ec9a4bda6300ac5a46780.patch
# VERSION="${VERSION}_patched"
# fi
# compilation
make
# installation
mkdir -p "$PKG/lib/modules/${KERNEL_VERSION}/kernel/drivers/hwmon/"
cp "${KERNEL_VERSION}/nct6687.ko" "$PKG/lib/modules/${KERNEL_VERSION}/kernel/drivers/hwmon/"
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
mkdir -p "$PKG/usr/doc/$PRGNAM/"
cp -R images/ LICENSE ./*.md "$PKG/usr/doc/$PRGNAM/"
# correction
cd "$PKG" || exit 1
chown -R root:root ./*
# embaumement
mkdir -p "$PKG"/install
cat <<EOF > "$PKG"/install/doinst.sh
#!/bin/bash
depmod
modprobe nct6687
EOF
cat <<EOF > "$PKG"/install/slack-desc
$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"