Update setup script to perform local build if a binary isn't available for download

This commit is contained in:
wheaney 2025-09-02 12:05:04 -07:00
parent b266a20949
commit dbb2196819
5 changed files with 102 additions and 28 deletions

View File

@ -52,9 +52,52 @@ fi
if [ -z "$binary_path_arg" ]
then
# download and unzip the binary
echo "Downloading to: ${tmp_dir}/$FILE_NAME"
curl -L "$binary_download_url" > "$FILE_NAME"
http_code=$(curl -s -o /dev/null -w "%{http_code}" -L "$binary_download_url" || echo "000")
if [[ "$http_code" =~ ^(2|3) ]]; then
echo "Downloading to: ${tmp_dir}/$FILE_NAME"
curl -L "$binary_download_url" -o "$FILE_NAME"
else
check_command "git"
# handle -v / --tag like the rest of the script
if [ "$1" = "--tag" ] && [ -n "$2" ]; then
requested_tag="$2"
fi
# resolve tag: prefer requested_tag, then LATEST_RELEASE if already fetched, else query GitHub API
if [ -n "$requested_tag" ]; then
tag="$requested_tag"
else
tag=$(curl -s "https://api.github.com/repos/wheaney/breezy-desktop/releases/latest" \
| grep -m1 '"tag_name":' \
| sed -E 's/.*"tag_name":[[:space:]]*"([^"]+)".*/\1/')
fi
if [ -z "$tag" ]; then
echo "Failed to determine latest tag for wheaney/breezy-desktop" 1>&2
exit 1
fi
echo "Cloning wheaney/breezy-desktop (tag: ${tag})"
if git clone --depth 1 --branch "$tag" "https://github.com/wheaney/breezy-desktop.git" breezy-desktop 2>/dev/null; then
pushd breezy-desktop > /dev/null
else
git clone "https://github.com/wheaney/breezy-desktop.git" breezy-desktop
pushd breezy-desktop > /dev/null
git checkout "$tag"
fi
echo "Downloading git submodules"
git submodule sync --recursive || true
git submodule update --init --recursive modules/XRLinuxDriver
git submodule update --init --recursive ui/modules/PyXRLinuxDriverIPC
LOCAL_BUILD_SYSTEM=1 bin/package_kwin --download-driver
FILE_NAME="breezyKWin-$ARCH.tar.gz"
cp "out/$FILE_NAME" "$tmp_dir"
popd > /dev/null
fi
else
FILE_NAME=$(basename $binary_path_arg)
if [[ "$binary_path_arg" = /* ]]; then

View File

@ -30,43 +30,60 @@ mkdir -p $PACKAGE_DIR/bin
copy_and_inject_ua "$XR_DRIVER_DIR/bin/ua.sh" "$PACKAGE_DIR/bin" "$KWIN_DIR/bin/setup" "$KWIN_DIR/bin/breezy_kwin_uninstall"
XR_DRIVER_BINARY=$XR_DRIVER_DIR/out/xrDriver-$ARCH.tar.gz
if [ "$1" == "--download-driver" ]; then
driver_download_url="https://github.com/wheaney/XRLinuxDriver/releases/latest/download/xrDriver-$ARCH.tar.gz"
setup_download_url="https://github.com/wheaney/XRLinuxDriver/releases/latest/download/xr_driver_setup"
if [ ! -e "$XR_DRIVER_BINARY" ] || [ "$1" == "--rebuild-driver" ] || [ "$1" == "--rebuild-all" ]; then
# if a file exists at custom_banner_config.yml, copy it to the xrealAirLinuxDriver directory
if [ -e "$VULKAN_DIR/custom_banner_config.yml" ]; then
cp $VULKAN_DIR/custom_banner_config.yml $XR_DRIVER_DIR
curl -L "$driver_download_url" > "$PACKAGE_DIR/xrDriver.tar.gz"
curl -L "$setup_download_url" > "$PACKAGE_DIR/bin/xr_driver_setup"
chmod +x "$PACKAGE_DIR/bin/xr_driver_setup"
echo "Downloaded XRLinuxDriver binary and setup script, with hashes:"
echo "xrDriver-$ARCH.tar.gz: $(sha256sum "$PACKAGE_DIR/xrDriver.tar.gz")"
echo "xr_driver_setup: $(sha256sum "$PACKAGE_DIR/bin/xr_driver_setup")"
else
if [ ! -e "$XR_DRIVER_BINARY" ] || [ "$1" == "--rebuild-driver" ] || [ "$1" == "--rebuild-all" ]; then
# if a file exists at custom_banner_config.yml, copy it to the xrealAirLinuxDriver directory
if [ -e "$VULKAN_DIR/custom_banner_config.yml" ]; then
cp $VULKAN_DIR/custom_banner_config.yml $XR_DRIVER_DIR
fi
pushd $XR_DRIVER_DIR
# strange issue where the base library produces a .so file if the build is not cleaned
rm -rf build/
docker-build/init.sh
docker-build/run-build.sh $ARCH
popd
fi
pushd $XR_DRIVER_DIR
XR_DRIVER_TMP_DIR=$(mktemp -d -t xr-driver-XXXXXXXXXX)
pushd $XR_DRIVER_TMP_DIR
cp $XR_DRIVER_BINARY $XR_DRIVER_TMP_DIR/xrDriver.tar.gz
tar -xf $XR_DRIVER_TMP_DIR/xrDriver.tar.gz
# strange issue where the base library produces a .so file if the build is not cleaned
rm -rf build/
docker-build/init.sh
docker-build/run-build.sh $ARCH
XR_DRIVER_MANIFEST_LINE=$(sha256sum xr_driver/manifest)
popd
rm -rf $XR_DRIVER_TMP_DIR
cp $XR_DRIVER_BINARY $PACKAGE_DIR/xrDriver.tar.gz
cp $XR_DRIVER_DIR/bin/xr_driver_setup $PACKAGE_DIR/bin/xr_driver_setup
fi
XR_DRIVER_TMP_DIR=$(mktemp -d -t xr-driver-XXXXXXXXXX)
pushd $XR_DRIVER_TMP_DIR
cp $XR_DRIVER_BINARY $XR_DRIVER_TMP_DIR/xrDriver.tar.gz
tar -xf $XR_DRIVER_TMP_DIR/xrDriver.tar.gz
XR_DRIVER_MANIFEST_LINE=$(sha256sum xr_driver/manifest)
popd
rm -rf $XR_DRIVER_TMP_DIR
cp $XR_DRIVER_BINARY $PACKAGE_DIR/xrDriver.tar.gz
cp $XR_DRIVER_DIR/bin/xr_driver_setup $PACKAGE_DIR/bin
# alternative to symlinking, since the Docker build can't resolve to the parent directory
# this file is in .gitignore so it doesn't get duplicated
cp ui/modules/PyXRLinuxDriverIPC/xrdriveripc.py $KWIN_DIR/src/xrdriveripc/xrdriveripc.py
cp VERSION $KWIN_DIR
pushd $KWIN_DIR
docker-build/init.sh
docker-build/run-build.sh $BUILD_ARCH
if [ -z "${LOCAL_BUILD_SYSTEM+x}" ]; then
docker-build/init.sh
docker-build/run-build.sh "$BUILD_ARCH"
else
echo "LOCAL_BUILD_SYSTEM set; skipping Docker build"
bin/package_kwin_plugin
fi
popd
cp $KWIN_DIR/out/breezyKWinPlugin-$BUILD_ARCH.tar.gz $PACKAGE_DIR/breezyKWinPlugin.tar.gz

View File

@ -31,6 +31,7 @@ EFFECT_ID="breezy_desktop"
EFFECT_DIR="$XDG_DATA_HOME/kwin/effects/$EFFECT_ID"
PLUGIN_SO="$LIB_HOME/qt6/plugins/kwin/effects/plugins/${EFFECT_ID}.so"
CONFIG_SO="$LIB_HOME/qt6/plugins/kwin/effects/configs/${EFFECT_ID}_config.so"
BREEZY_LIBRARY_DIR="$LIB_HOME/breezy_kwin"
if [[ -d "$EFFECT_DIR" ]]; then
[ "$for_install" -eq 0 ] && echo "Removing $EFFECT_DIR and its contents"
@ -47,6 +48,11 @@ if [[ -f "$CONFIG_SO" ]]; then
$SUDO rm -f "$CONFIG_SO"
fi
if [[ -d "$BREEZY_LIBRARY_DIR" ]]; then
[ "$for_install" -eq 0 ] && echo "Removing $BREEZY_LIBRARY_DIR and its contents"
$SUDO rm -rf "$BREEZY_LIBRARY_DIR"
fi
if [[ -e "$XDG_BIN_HOME/xr_driver_uninstall" && "$for_install" -eq 0 ]]; then
echo "Uninstalling XRLinuxDriver"
sudo "$XDG_BIN_HOME/xr_driver_uninstall"

View File

@ -3,6 +3,15 @@
# exit when any command fails
set -e
check_command() {
if ! command -v "$1" &>/dev/null; then
echo "Please install \"$1\" and make sure it's available in your \$PATH, then rerun the setup."
exit 1
fi
}
check_command "cmake"
check_command "make"
ARCH=${ARCH:-$(uname -m)}
if [ -n "${STEAMOS+x}" ]; then
ARCH="steamos"

View File

@ -18,7 +18,6 @@
#include <QHeaderView>
#include <QPushButton>
#include <QLineEdit>
#include <QProgressBar>
#include <QLabel>
#include <QJsonValue>
#include <QJsonArray>