54 lines
1.9 KiB
Bash
Executable file
54 lines
1.9 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
program_name="wluma"
|
|
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
|
|
|
# prep
|
|
workdir=$(mktemp -d)
|
|
built_dir=${COMPILED_DIR:-/compiled}/$program_name
|
|
mkdir -p $built_dir
|
|
apt update && apt install curl jq -y
|
|
|
|
# check whether it's up-to-date
|
|
version_file=$built_dir/version
|
|
touch $version_file
|
|
# also available via gitlab.com/librewolf-community/browser/source/-/raw/main/{version,release}
|
|
version=$(curl 'https://api.github.com/repos/maximbaz/wluma/releases/latest' | jq '.tag_name' -r)
|
|
if grep -q $version $version_file; then
|
|
echo "already up to date, exiting"
|
|
exit
|
|
fi
|
|
|
|
## get source and build
|
|
# get build deps
|
|
# note: npm/npx is also required, but this just assumes it's already installed since i'll be running it in docker with the node image - and doing that's faster than installing it manually
|
|
apt install gcc libclang-dev v4l-utils libv4l-dev libudev-dev libvulkan-dev libdbus-1-dev zstd -y # zstd is for archive creation
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
. ~/.cargo/env
|
|
|
|
cd $workdir
|
|
curl -L $(curl 'https://api.github.com/repos/maximbaz/wluma/releases/latest' | jq '.tarball_url' -r) -o $program_name-$version.tar.gz
|
|
tar -xzf $program_name-$version.tar.gz
|
|
src_dir=$(find $(pwd) -name "maximbaz-wluma*")
|
|
cd $src_dir
|
|
cargo install --path .
|
|
|
|
## create .tar.zst archive
|
|
# prep
|
|
cd $src_dir
|
|
wluma_archive=$(mktemp -d)
|
|
cp $(which wluma) $wluma_archive
|
|
sed -i 's/\/usr\/bin\/wluma/\/usr\/bin\/env wluma/g' ./wluma.service
|
|
npx -y marked-man README.md | gzip > $wluma_archive/wluma.7.gz
|
|
cp README.md $wluma_archive
|
|
cp config.toml $wluma_archive
|
|
cp wluma.service $wluma_archive
|
|
cp 90-wluma-backlight.rules $wluma_archive
|
|
|
|
# actually create it and finish up
|
|
cd $wluma_archive
|
|
tar --zstd -cf $built_dir/$program_name.tar.zst .
|
|
echo $version >$version_file
|
|
|
|
echo "$program_name updated to $version"
|