first commit

This commit is contained in:
Joakim
2026-10-15 17:27:46 +02:00
parent 0232909b8a
commit 0e0febffda
38 changed files with 8068 additions and 0 deletions

81
build.sh Executable file
View File

@@ -0,0 +1,81 @@
#!/usr/bin/env bash
# Builds patched JOE. Does not touch anything outside this repo -- run
# install.sh afterward to actually put the binary somewhere on PATH.
#
# Usage: ./build.sh [--clean]
# --clean Remove any existing checkout under joe-patch/build/ first
# (use if a previous build is in a bad state).
#
# Env overrides:
# JOE_SRC_DIR Use an existing joe source tree instead of cloning one.
# Must be named .../joe-4.8 (the patch is rooted on that
# directory name) and be a clean, unpatched checkout.
# PREFIX configure --prefix (default: $HOME/.local)
set -euo pipefail
SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
PATCH_FILE="$SCRIPT_DIR/joe-patch/joe-4.8-hedgedoc-0.7.13.patch"
BUILD_ROOT="$SCRIPT_DIR/joe-patch/build"
JOE_SRC_DIR="${JOE_SRC_DIR:-$BUILD_ROOT/joe-4.8}"
PREFIX="${PREFIX:-$HOME/.local}"
if [ "${1:-}" = "--clean" ]; then
echo "==> --clean: removing $BUILD_ROOT"
rm -rf "$BUILD_ROOT"
fi
echo "==> Checking build tools"
missing=""
for cmd in git patch autoreconf automake make gcc; do
command -v "$cmd" >/dev/null 2>&1 || missing="$missing $cmd"
done
if [ -n "$missing" ]; then
echo "Missing:$missing" >&2
echo "On Debian/Ubuntu: sudo apt install build-essential autoconf automake git" >&2
exit 1
fi
if [ ! -f /usr/include/ncurses.h ] && [ ! -f /usr/include/ncursesw/ncurses.h ]; then
echo "Warning: ncurses headers not found in the usual places -- the build" >&2
echo "may fail linking -lncurses. On Debian/Ubuntu: sudo apt install libncurses-dev" >&2
fi
if [ ! -d "$JOE_SRC_DIR" ]; then
echo "==> Cloning joe 4.8 source into $JOE_SRC_DIR"
mkdir -p "$BUILD_ROOT"
git clone --quiet https://github.com/joe-editor/joe.git "$JOE_SRC_DIR"
git -C "$JOE_SRC_DIR" checkout --quiet releases/joe-4.8
else
echo "==> Using existing source at $JOE_SRC_DIR"
fi
if [ -f "$JOE_SRC_DIR/joe/hd_ipc.c" ]; then
echo "==> Patch already applied (hd_ipc.c exists) -- skipping"
else
echo "==> Applying $(basename "$PATCH_FILE")"
( cd "$(dirname "$JOE_SRC_DIR")" && patch -p1 < "$PATCH_FILE" )
fi
echo "==> autoreconf (required: the patch touches Makefile.am, not Makefile.in)"
( cd "$JOE_SRC_DIR" && autoreconf -fi )
echo "==> configure --prefix=$PREFIX"
( cd "$JOE_SRC_DIR" && ./configure --prefix="$PREFIX" )
echo "==> make"
JOBS="$(command -v nproc >/dev/null 2>&1 && nproc || echo 1)"
( cd "$JOE_SRC_DIR" && make -j"$JOBS" )
BUILT="$JOE_SRC_DIR/joe/joe"
if [ ! -x "$BUILT" ]; then
echo "Build finished but $BUILT isn't executable -- something's wrong." >&2
exit 1
fi
if [ ! -f "$JOE_SRC_DIR/joe/hd_ipc.o" ]; then
echo "Warning: $BUILT was built WITHOUT hd_ipc.o -- it's plain upstream" >&2
echo "joe, not the patched version. Check the autoreconf step ran." >&2
exit 1
fi
echo
echo "Built: $BUILT"
echo "Next: ./install.sh"