88 lines
2.3 KiB
Bash
Executable file
88 lines
2.3 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# variables
|
|
CWD=$(pwd)
|
|
|
|
PRGNAM=$(basename $(pwd))
|
|
GITHUB_REPO=Hummer12007/brightnessctl
|
|
VERSION=${VERSION:-latest}
|
|
ARCH=${ARCH:-$(uname -m)}
|
|
BUILD=1
|
|
|
|
TAG=gwh
|
|
TMP=/tmp/$TAG
|
|
PKG=$TMP/pkg-$PRGNAM
|
|
OUTPUT=/tmp
|
|
|
|
REPOSITORIES=/var/cache/SlackBuilds.gwh
|
|
|
|
PREFIX=/usr
|
|
|
|
[ ! -e $REPOSITORIES/$PRGNAM ] && git clone https://github.com/${GITHUB_REPO}.git $REPOSITORIES/$PRGNAM
|
|
cd $REPOSITORIES/$PRGNAM
|
|
git pull --all
|
|
|
|
# nettoyage préalable
|
|
rm -fr $PKG $TMP/$PRGNAM
|
|
|
|
mkdir -p $PKG
|
|
|
|
# mise en place
|
|
cd $TMP
|
|
cp -R $REPOSITORIES/$PRGNAM $TMP/$PRGNAM
|
|
|
|
cd $TMP/$PRGNAM
|
|
[ "x$VERSION" == "xlatest" ] && VERSION=$(git tag --sort=-version:refname | head -n1)
|
|
[ "x$VERSION" == "x" ] && VERSION=trunk
|
|
[ "x$VERSION" == "xtrunk" ] && VERSION="git_r$(git rev-list --count HEAD)_$(git log -1 --format=%h)" || git checkout $VERSION
|
|
|
|
./configure \
|
|
--prefix=/usr
|
|
|
|
# compilation
|
|
make -j3 PREFIX=$PREFIX
|
|
|
|
# installation
|
|
make install DESTDIR=$PKG PREFIX=$PREFIX MANDIR=$PKG$PREFIX/man
|
|
|
|
chmod a+s $PKG/usr/bin/brightnessctl
|
|
|
|
mkdir -p $PKG/usr/doc/$PRGNAM
|
|
cp LICENSE README.md $PKG/usr/doc/$PRGNAM/
|
|
|
|
# correction
|
|
cd $PKG
|
|
chown -R root:root *
|
|
|
|
[ -d $PKG/usr/man ] && find $PKG/usr/man -type f -name "*.?" -exec gzip -9f {} \;
|
|
|
|
# Strip binaries
|
|
( cd $PKG
|
|
find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
|
|
find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
|
|
)
|
|
|
|
# embaumement
|
|
mkdir -p $PKG/install
|
|
cat <<EOF > $PKG/install/doinst.sh
|
|
chmod a+s /usr/bin/brightnessctl
|
|
EOF
|
|
|
|
cat <<EOF > $PKG/install/slack-desc
|
|
$PRGNAM: $PRGNAM ( A program to read and control device brightness)
|
|
$PRGNAM:
|
|
$PRGNAM: This program allows you read and control device brightness. Devices, by default,
|
|
$PRGNAM: include backlight and LEDs (searched for in corresponding classes). If omitted,
|
|
$PRGNAM: the first found device is selected.
|
|
$PRGNAM:
|
|
$PRGNAM: It can also preserve current brightness before applying the operation
|
|
$PRGNAM: (allowing for usecases like disabling backlight on lid close).
|
|
$PRGNAM:
|
|
$PRGNAM: https://github.com/${GITHUB_REPO}
|
|
$PRGNAM:
|
|
EOF
|
|
|
|
# empaquetage
|
|
cd $PKG
|
|
rm -f $PKG/{,usr/}lib$(uname -m | grep -o 64)/*.la
|
|
/sbin/makepkg --linkadd y --chown n --prepend $OUTPUT/$PRGNAM-$(echo $VERSION | sed 's/-//g')-$ARCH-$BUILD$TAG.txz
|