48 lines
2.6 KiB
Bash
Executable File
48 lines
2.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
command -v zip >/dev/null || { echo "zip is required to register the GNOME extension" >&2; exit 1; }
|
|
APP_DIR="${HOME}/.local/share/jarvis-qvac"
|
|
EXT_DIR="${HOME}/.local/share/gnome-shell/extensions/[email protected]"
|
|
CONFIG_DIR="${HOME}/.config/jarvis"
|
|
CACHE_DIR="${XDG_CACHE_HOME:-${HOME}/.cache}/jarvis/models"
|
|
mkdir -p "${APP_DIR}" "${EXT_DIR}" "${CONFIG_DIR}" "${HOME}/.config/systemd/user" "${CACHE_DIR}"
|
|
if [[ -f "${ROOT_DIR}/node_modules/bare-runtime-linux-x64/bin/bare" || -f "${ROOT_DIR}/node_modules/bare-runtime-linux-arm64/bin/bare" ]]; then
|
|
tar --exclude='.git' --exclude='./.agents' --exclude='./.codex' --exclude='./dist' --exclude='./vendor/agent-harness/node_modules' --exclude='*/__pycache__' --exclude='*.pyc' -cf - -C "${ROOT_DIR}" . | tar -xf - -C "${APP_DIR}"
|
|
else
|
|
tar --exclude='.git' --exclude='./.agents' --exclude='./.codex' --exclude='./dist' --exclude='./node_modules' --exclude='*/node_modules' --exclude='*/__pycache__' --exclude='*.pyc' -cf - -C "${ROOT_DIR}" . | tar -xf - -C "${APP_DIR}"
|
|
fi
|
|
case "$(uname -m)" in
|
|
x86_64|amd64) BARE_BIN="${APP_DIR}/node_modules/bare-runtime-linux-x64/bin/bare" ;;
|
|
aarch64|arm64) BARE_BIN="${APP_DIR}/node_modules/bare-runtime-linux-arm64/bin/bare" ;;
|
|
*) BARE_BIN="" ;;
|
|
esac
|
|
if [[ ! -x "${BARE_BIN}" ]]; then BARE_BIN="$(command -v bare || true)"; fi
|
|
if [[ -z "${BARE_BIN}" || ! -x "${BARE_BIN}" ]]; then
|
|
echo "The installed bundle does not contain a Bare runtime for $(uname -m). Install the official rolling bundle or build it with npm run package:bare." >&2
|
|
exit 1
|
|
fi
|
|
chmod 755 "${BARE_BIN}"
|
|
rm -rf "${EXT_DIR}"
|
|
mkdir -p "${EXT_DIR}"
|
|
EXT_TMP_DIR="$(mktemp -d "${TMPDIR:-/tmp}/jarvis-extension.XXXXXX")"
|
|
EXT_ZIP="${EXT_TMP_DIR}/jarvis-extension.zip"
|
|
cleanup_ext() { rm -rf "${EXT_TMP_DIR}"; }
|
|
trap cleanup_ext EXIT
|
|
( cd "${ROOT_DIR}/apps/gnome-extension" && zip -q -r "${EXT_ZIP}" "[email protected]" )
|
|
if command -v gnome-extensions >/dev/null && gnome-extensions install --force "${EXT_ZIP}" >/dev/null 2>&1; then
|
|
:
|
|
else
|
|
cp -a "${ROOT_DIR}/apps/gnome-extension/[email protected]/." "${EXT_DIR}/"
|
|
fi
|
|
sed "s#__JARVIS_BARE__#${BARE_BIN}#" "${ROOT_DIR}/packaging/jarvisd.service" > "${HOME}/.config/systemd/user/jarvisd.service"
|
|
if [[ ! -f "${CONFIG_DIR}/qvac.config.json" ]]; then
|
|
sed "s#__JARVIS_CACHE__#${CACHE_DIR}#g" "${ROOT_DIR}/packaging/qvac.config.template.json" > "${CONFIG_DIR}/qvac.config.json"
|
|
fi
|
|
if [[ "${1:-}" == "--enable" ]]; then
|
|
systemctl --user daemon-reload
|
|
systemctl --user enable --now jarvisd.service
|
|
fi
|
|
echo "Installed JARVIS-QVAC to ${APP_DIR}"
|
|
echo "Run: ${APP_DIR}/packaging/first-run.sh"
|