This commit is contained in:
Joakim
2026-10-17 20:50:40 +02:00
parent e223ca0cdd
commit aa507d3cc4

View File

@@ -5,11 +5,8 @@ set -euo pipefail
# HedgeDoc JOE - user local installer
#
# No sudo.
# No modification of /usr/bin/joe.
# Everything required at runtime is copied below ~/.local.
#
# After a successful installation the source tree can be
# removed.
# Does not modify /usr/bin/joe.
# Everything needed at runtime is installed below ~/.local.
# ============================================================
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
@@ -54,7 +51,6 @@ EOF
while [[ $# -gt 0 ]]; do
case "$1" in
--force)
FORCE=1
shift
@@ -65,7 +61,6 @@ while [[ $# -gt 0 ]]; do
echo "ERROR: --install-dir requires a directory"
exit 1
}
INSTALL_DIR="$2"
shift 2
;;
@@ -75,7 +70,6 @@ while [[ $# -gt 0 ]]; do
echo "ERROR: --bin-dir requires a directory"
exit 1
}
BIN_DIR="$2"
shift 2
;;
@@ -110,7 +104,7 @@ HD_JOE_WRAPPER="$BIN_DIR/hd-joe"
BUILT="$SCRIPT_DIR/joe-patch/build/joe-4.8/joe/joe"
# ------------------------------------------------------------
# Functions
# Helpers
# ------------------------------------------------------------
die() {
@@ -130,22 +124,28 @@ info() {
info "Checking source tree"
[[ -d "$SCRIPT_DIR/hd_common" ]] ||
die "Missing $SCRIPT_DIR/hd_common"
die "Missing: $SCRIPT_DIR/hd_common"
[[ -d "$SCRIPT_DIR/hd-cli" ]] ||
die "Missing $SCRIPT_DIR/hd-cli"
die "Missing: $SCRIPT_DIR/hd-cli"
[[ -d "$SCRIPT_DIR/hd-joe" ]] ||
die "Missing $SCRIPT_DIR/hd-joe"
die "Missing: $SCRIPT_DIR/hd-joe"
[[ -f "$SCRIPT_DIR/hd_common/requirements.txt" ]] ||
die "Missing hd_common/requirements.txt"
die "Missing: hd_common/requirements.txt"
[[ -f "$SCRIPT_DIR/hd-cli/requirements.txt" ]] ||
die "Missing hd-cli/requirements.txt"
die "Missing: hd-cli/requirements.txt"
[[ -f "$SCRIPT_DIR/hd-joe/requirements.txt" ]] ||
die "Missing hd-joe/requirements.txt"
die "Missing: hd-joe/requirements.txt"
[[ -f "$SCRIPT_DIR/hd-cli/hdc" ]] ||
die "Missing: hd-cli/hdc"
[[ -f "$SCRIPT_DIR/hd-joe/joe_wrapper.py" ]] ||
die "Missing: hd-joe/joe_wrapper.py"
[[ -f "$BUILT" ]] ||
die "Built JOE binary not found:
@@ -195,10 +195,16 @@ chmod 0755 "$INSTALLED_JOE"
# Install Python applications
# ------------------------------------------------------------
info "Installing Python applications"
info "Installing hd_common"
cp -a "$SCRIPT_DIR/hd_common" "$INSTALLED_COMMON"
info "Installing hd-cli"
cp -a "$SCRIPT_DIR/hd-cli" "$INSTALLED_HDC"
info "Installing hd-joe"
cp -a "$SCRIPT_DIR/hd-joe" "$INSTALLED_HD_JOE"
# ------------------------------------------------------------
@@ -215,42 +221,40 @@ PYTHON="$VENV_DIR/bin/python3"
die "Python virtual environment could not be created"
# ------------------------------------------------------------
# Install Python dependencies
# Upgrade pip
# ------------------------------------------------------------
info "Upgrading pip"
"$PYTHON" -m pip install --upgrade pip
info "Installing Python dependencies"
# ------------------------------------------------------------
# Install dependencies
# ------------------------------------------------------------
info "Installing hd_common dependencies"
"$PYTHON" -m pip install \
-r "$INSTALLED_COMMON/requirements.txt"
info "Installing hd-cli dependencies"
"$PYTHON" -m pip install \
-r "$INSTALLED_HDC/requirements.txt"
info "Installing hd-joe dependencies"
"$PYTHON" -m pip install \
-r "$INSTALLED_HD_JOE/requirements.txt"
# ------------------------------------------------------------
# Python import path
#
# Include both:
#
# ~/.local/lib/hedgedoc-joe
#
# and:
#
# ~/.local/lib/hedgedoc-joe/hd_common
#
# This supports both package-style and direct imports.
# ------------------------------------------------------------
PYTHONPATH_VALUE="$INSTALL_DIR:$INSTALLED_COMMON"
# ------------------------------------------------------------
# Verify Python installation
# Test hd_common
# ------------------------------------------------------------
info "Testing Python installation"
@@ -262,7 +266,7 @@ print(" hd_common: OK")
'
# ------------------------------------------------------------
# Create joe wrapper
# Install joe wrapper
# ------------------------------------------------------------
info "Creating joe wrapper"
@@ -281,7 +285,7 @@ EOF
chmod 0755 "$JOE_WRAPPER"
# ------------------------------------------------------------
# Create hdc wrapper
# Install hdc wrapper
# ------------------------------------------------------------
info "Creating hdc wrapper"
@@ -296,13 +300,13 @@ VENV_DIR="$VENV_DIR"
export PYTHONPATH="\$INSTALL_DIR:\$INSTALL_DIR/hd_common\${PYTHONPATH:+:\$PYTHONPATH}"
exec "\$VENV_DIR/bin/python3" \
"\$INSTALL_DIR/hd-cli/hd_cli.py" "\$@"
"\$INSTALL_DIR/hd-cli/hdc" "\$@"
EOF
chmod 0755 "$HDC_WRAPPER"
# ------------------------------------------------------------
# Create hd-joe wrapper
# Install hd-joe wrapper
# ------------------------------------------------------------
info "Creating hd-joe wrapper"
@@ -323,7 +327,7 @@ EOF
chmod 0755 "$HD_JOE_WRAPPER"
# ------------------------------------------------------------
# Verify files
# Verify installed files
# ------------------------------------------------------------
info "Verifying installation"
@@ -353,10 +357,10 @@ info "Verifying installation"
die "Python environment is missing"
# ------------------------------------------------------------
# Test installed Python environment
# Test installed runtime
# ------------------------------------------------------------
info "Testing installed runtime"
info "Testing installed Python runtime"
PYTHONPATH="$PYTHONPATH_VALUE" \
"$PYTHON" -c '
@@ -365,7 +369,18 @@ print(" Python runtime: OK")
'
# ------------------------------------------------------------
# Test JOE binary
# Test hdc
# ------------------------------------------------------------
info "Testing installed hdc"
PYTHONPATH="$PYTHONPATH_VALUE" \
"$PYTHON" "$INSTALLED_HDC/hdc" --help >/dev/null 2>&1 || {
echo " WARNING: hdc --help failed"
}
# ------------------------------------------------------------
# Test JOE
# ------------------------------------------------------------
info "Testing installed JOE"
@@ -393,7 +408,7 @@ echo " $JOE_WRAPPER"
echo " $HDC_WRAPPER"
echo " $HD_JOE_WRAPPER"
echo
echo "Installed:"
echo "Installed components:"
echo " $INSTALLED_JOE"
echo " $INSTALLED_COMMON"
echo " $INSTALLED_HDC"
@@ -406,11 +421,7 @@ echo
echo "The installation is independent of:"
echo " $SCRIPT_DIR"
echo
echo "You can remove the source tree after verifying the"
echo "installed commands."
echo
echo "If ~/.local/bin is not in PATH:"
echo
echo ' export PATH="$HOME/.local/bin:$PATH"'
echo "You can remove the source tree after testing."
echo
echo "============================================================"