slackbuilds/ap/rkvm/SlackBuild

176 lines
4.3 KiB
Text
Raw Permalink Normal View History

2021-06-15 10:26:26 +02:00
#!/bin/bash
2021-04-27 13:03:56 +02:00
# variables
2022-07-08 22:36:59 +02:00
#GITHUB_REPO=leonardolang/rkvm
GITHUB_REPO=htrefil/rkvm
2022-01-22 10:52:07 +01:00
VERSION=${VERSION:-latest}
2024-01-22 09:04:46 +01:00
BUILD=${BUILD:-2}
2021-04-27 13:03:56 +02:00
TAG=gwh
TMP=/tmp/$TAG
CWD=$(pwd)
PRGNAM=$(basename $CWD)
PKG=$TMP/pkg-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
ARCH=${ARCH:-$(uname -m)}
REPOSITORY=${REPOSITORY:-/var/cache/SlackBuilds.gwh/$PRGNAM}
2021-04-27 13:03:56 +02:00
PREFIX=${PREFIX:-/usr}
# nettoyage préalable
rm -fr $PKG $TMP/$PRGNAM
mkdir -p $PKG
# mise en place
cd $TMP
[ ! -e $REPOSITORY ] && git clone https://github.com/${GITHUB_REPO}.git $REPOSITORY
2021-06-15 10:59:49 +02:00
cd $REPOSITORY
git pull --all
2021-04-27 13:03:56 +02:00
cp -R $REPOSITORY $TMP/
cd $TMP/$PRGNAM
2024-01-22 09:04:46 +01:00
[ "x$VERSION" == "xlatest" ] && VERSION=$(git describe --tags --abbrev=0)
2022-01-22 10:52:07 +01:00
[ "x$VERSION" == "x" ] && VERSION=trunk
2023-03-23 09:54:21 +01:00
[ "x$VERSION" == "xtrunk" ] && VERSION="git_r$(git rev-list --count HEAD)_$(git log -1 --format=%h)" || git checkout $VERSION
2021-04-27 13:03:56 +02:00
cargo build --release
mkdir -p $PKG$PREFIX/bin
find target/release/ -type f -executable -maxdepth 1 -exec cp {} $PKG$PREFIX/bin/ \;
chmod 755 $PKG$PREFIX/bin/*
2024-01-22 09:04:46 +01:00
# (cd $PKG$PREFIX/bin/
# for i in *; do
# mv $i rkvm-$i;
# done
# )
2021-04-27 13:03:56 +02:00
# move doc/ to the appropriate location
mkdir -p $PKG$PREFIX/doc/$PRGNAM
cp -R example/ LICENSE *.md $PKG$PREFIX/doc/$PRGNAM
cat <<EOF > $PKG$PREFIX/doc/$PRGNAM/setup-keys.sh
#!/bin/bash
$PREFIX/bin/rkvm-certificate-gen /etc/rkvm/identity.p12.new /etc/rkvm/certificate.pem.new /etc/rkvm/key.pem.new -i \$(hostname -I | cut -d\\ -f1)
EOF
chmod +x $PKG$PREFIX/doc/$PRGNAM/setup-keys.sh
mkdir -p $PKG/etc/rc.d
cat <<EOF > $PKG/etc/rc.d/rc.rkvm-server
#!/bin/bash
start() {
echo "Starting rkvm server..."
/usr/bin/rkvm-server /etc/rkvm/server.toml &
2022-04-25 08:56:42 +02:00
[ \$? -ne 0 ] && echo "Could not start rkvm-server."
}
stop() {
2022-04-25 09:10:07 +02:00
killall rkvm-server
}
case \$1 in
start )
start
;;
stop )
stop
;;
restart )
stop
2022-04-25 09:10:07 +02:00
sleep 1
start
;;
* )
echo "Unrecognized command: \$1"
echo "Try one of the following: (start|stop|restart)"
;;
esac
EOF
cat <<EOF > $PKG/etc/rc.d/rc.rkvm-client
#!/bin/bash
start() {
echo "Starting rkvm client..."
/usr/bin/rkvm-client /etc/rkvm/client.toml &
2022-04-25 08:56:42 +02:00
[ \$? -ne 0 ] && echo "Could not start rkvm-client."
}
stop() {
2022-04-25 09:10:07 +02:00
killall rkvm-client
}
case \$1 in
start )
start
;;
stop )
stop
;;
restart )
stop
2022-04-25 09:10:07 +02:00
sleep 1
start
;;
* )
echo "Unrecognized command: \$1"
echo "Try one of the following: (start|stop|restart)"
;;
esac
EOF
mkdir -p $PKG/etc/rkvm
cat <<EOF > $PKG/etc/rkvm/server.toml.new
listen-address = "0.0.0.0:5258"
# Switch to next client by pressing the right alt key.
switch-keys = ["RightAlt"]
identity-path = "/etc/rkvm/identity.p12"
# Leave unset if no password is set.
#identity-password = "123456789"
EOF
cat <<EOF > $PKG/etc/rkvm/client.toml.new
server = "$(hostname -I | cut -d\ -f1):5258"
certificate-path = "/etc/rkvm/certificate.pem"
EOF
2021-04-27 13:03:56 +02:00
# correction
cd $PKG
chown -R root:root *
[ -d $PKG$PREFIX/man ] && find $PKG$PREFIX/man -type f -not -name \*.gz -exec gzip -9 {} \;
2021-04-27 13:03:56 +02:00
# embaumement
mkdir -p $PKG/install
cat <<EOF > $PKG/install/slack-desc
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description. Line
# up the first '|' above the ':' following the base package name, and the '|'
# on the right side marks the last column you can put a character in. You must
# make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':'.
|-----handy-ruler------------------------------------------------------|
$PRGNAM: $PRGNAM ( Virtual KVM switch for Linux machines )
$PRGNAM:
$PRGNAM: rkvm is a tool for sharing keyboard and mouse across multiple Linux
$PRGNAM: and Windows machines. It is based on a client/server architecture,
$PRGNAM: where server is the machine controlling mouse and keyboard and relays
$PRGNAM: events (mouse move, key presses, ...) to clients.
$PRGNAM: Switching between different clients is done by a configurable keyboard
$PRGNAM: shortcut.
$PRGNAM:
$PRGNAM: (use $PREFIX/doc/$PRGNAM/gen-keys.sh)
$PRGNAM: https://github.com/${GITHUB_REPO}
2021-04-27 13:03:56 +02:00
EOF
# empaquetage
rm -f $PKG/{,usr/}lib$(uname -m | grep -o 64)/*.la
2023-08-16 12:23:26 +02:00
/sbin/makepkg --linkadd y --chown n --prepend $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.txz