Files
qt6-migration-pipeline/app/install_bgviewer.sh
T

42 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# install_bgviewer.sh
# Extract or copy a BgViewer/dtEntity vendor archive or directory into ./external/BgViewer
# Usage: ./install_bgviewer.sh /path/to/bgviewer.tar.gz_or_dir [target_dir]
SRC="$1"
TARGET_DIR="${2:-./external/BgViewer}"
if [[ -z "$SRC" ]]; then
echo "Usage: $0 /path/to/bgviewer.tar.gz_or_dir [target_dir]"
exit 1
fi
# Create target dir (prefer non-root)
if ! mkdir -p "$TARGET_DIR" 2>/dev/null; then
sudo mkdir -p "$TARGET_DIR"
fi
if ! chown $(id -u):$(id -g) "$TARGET_DIR" 2>/dev/null; then
sudo chown $(id -u):$(id -g) "$TARGET_DIR" || true
fi
if [[ -d "$SRC" ]]; then
echo "Copying BgViewer directory $SRC -> $TARGET_DIR"
rsync -a --delete "$SRC/" "$TARGET_DIR/"
elif [[ -f "$SRC" ]]; then
echo "Extracting archive $SRC -> $TARGET_DIR"
case "$SRC" in
*.tar.gz|*.tgz) tar xzf "$SRC" -C "$TARGET_DIR" --strip-components=1 ;;
*.tar.bz2) tar xjf "$SRC" -C "$TARGET_DIR" --strip-components=1 ;;
*.zip) unzip -q "$SRC" -d "$TARGET_DIR" ;;
*) echo "Unknown archive format: $SRC"; exit 1 ;;
esac
else
echo "Source $SRC not found" >&2
exit 1
fi
echo "BgViewer installed to $TARGET_DIR"
echo "You may set -DBGVIEWER_DIR=$TARGET_DIR or ensure CMAKE_PREFIX_PATH includes $TARGET_DIR when configuring CMake."