123 lines
4.0 KiB
Bash
Executable File
123 lines
4.0 KiB
Bash
Executable File
#!/bin/sh
|
|
# Prepare an offline mars-nwe checkout from uploaded bundles and release tarballs.
|
|
#
|
|
# This helper is intentionally a developer/test bootstrap tool. It does not add
|
|
# the generated dependency trees to git. The mars-nwe root repository remains the
|
|
# only superproject; mars-* bundles are materialized as the configured submodule
|
|
# working trees, while selected upstream release tarballs are unpacked into the
|
|
# submodule paths that the build already expects. FLAIM no longer needs a
|
|
# staged ncurses header snapshot; its CMake import uses the bundled curses
|
|
# compatibility shim, and termbox2 is unpacked as its terminal UI dependency.
|
|
# GDBM and PAM are faked for compile-only local builds; the generated archives
|
|
# live under the out-of-tree local dependency build directory.
|
|
|
|
set -eu
|
|
|
|
SRC_DIR=${1:-..}
|
|
BUILD_DIR=${MARS_NWE_LOCAL_DEPS_BUILD_DIR:-.local-deps/build}
|
|
PREFIX=${MARS_NWE_LOCAL_DEPS_PREFIX:-.local-deps/prefix}
|
|
FAKE_DEPS_DIR=${MARS_NWE_FAKE_SYSTEM_DEPS_DIR:-$BUILD_DIR/fake-system-deps}
|
|
JOBS=${JOBS:-${MAKEFLAGS:-}}
|
|
|
|
find_one() {
|
|
pattern=$1
|
|
set -- "$SRC_DIR"/$pattern
|
|
if [ ! -e "$1" ]; then
|
|
echo "error: missing $pattern in $SRC_DIR" >&2
|
|
exit 1
|
|
fi
|
|
printf '%s\n' "$1"
|
|
}
|
|
|
|
require_root() {
|
|
if [ ! -f .gitmodules ] || [ ! -f CMakeLists.txt ]; then
|
|
echo "error: run this script from the mars-nwe root" >&2
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
clone_bundle() {
|
|
path=$1
|
|
bundle=$2
|
|
|
|
if [ -d "$path/.git" ] || [ -f "$path/.git" ]; then
|
|
echo "==> $path already exists; fetching from $bundle"
|
|
git -C "$path" fetch "$bundle" '+refs/heads/*:refs/remotes/uploaded/*' '+refs/tags/*:refs/tags/*' || true
|
|
return
|
|
fi
|
|
|
|
rm -rf "$path"
|
|
mkdir -p "$(dirname "$path")"
|
|
echo "==> cloning $path from $bundle"
|
|
git clone "$bundle" "$path"
|
|
}
|
|
|
|
copy_tree_from_tar() {
|
|
tarball=$1
|
|
dest=$2
|
|
|
|
rm -rf "$dest"
|
|
mkdir -p "$dest"
|
|
echo "==> unpacking $(basename "$tarball") -> $dest"
|
|
tar -xf "$tarball" -C "$dest" --strip-components=1
|
|
}
|
|
|
|
install_header_tree() {
|
|
src=$1
|
|
dest=$2
|
|
mkdir -p "$dest"
|
|
if [ -d "$src" ]; then
|
|
cp -R "$src"/. "$dest"/
|
|
fi
|
|
}
|
|
|
|
build_fake_system_deps() {
|
|
echo "==> building compile-only fake GDBM/PAM -> $FAKE_DEPS_DIR"
|
|
./tests/fake/bin/build-fake-system-deps.sh "$FAKE_DEPS_DIR" >/dev/null
|
|
}
|
|
|
|
|
|
print_cmake_hints() {
|
|
cat <<HINTS
|
|
|
|
Prepared local dependency prefix: $PREFIX
|
|
Prepared fake system dependency output: $FAKE_DEPS_DIR
|
|
|
|
Use the local fake GDBM/PAM stubs like this for compile-only checks:
|
|
|
|
cmake -S . -B build \
|
|
-DCMAKE_PREFIX_PATH=$PWD/$PREFIX \
|
|
-DGDBM_INCLUDE_DIR=$PWD/tests/fake/include \
|
|
-DGDBM_LIBRARY=$PWD/$FAKE_DEPS_DIR/libgdbm.a \
|
|
-DPAM_INCLUDE_DIR=$PWD/tests/fake/include \
|
|
-DPAM_LIBRARY=$PWD/$FAKE_DEPS_DIR/libpam.a
|
|
|
|
These fake GDBM/PAM libraries are for local compile-only builds. They are not
|
|
runtime replacements for real system dependencies and are not wired into the
|
|
CMake build graph.
|
|
HINTS
|
|
}
|
|
|
|
require_root
|
|
mkdir -p "$BUILD_DIR" "$PREFIX"
|
|
|
|
clone_bundle dosutils "$(find_one 'mars-dosutils-master*.bundle')"
|
|
clone_bundle mail "$(find_one 'mars-mail-master*.bundle')"
|
|
clone_bundle smart "$(find_one 'mars-smart-master*.bundle')"
|
|
clone_bundle admin "$(find_one 'mars-nweadmin-master*.bundle')"
|
|
clone_bundle directory "$(find_one 'mars-tinyldap-master*.bundle')"
|
|
clone_bundle third_party/libowfat "$(find_one 'mars-libowfat-master*.bundle')"
|
|
clone_bundle third_party/libsodium "$(find_one 'mars-libsodium-master*.bundle')"
|
|
clone_bundle third_party/matrixssl "$(find_one 'mars-matrixssl-master*.bundle')"
|
|
clone_bundle third_party/flaim "$(find_one 'mars-flaim-master*.bundle')"
|
|
clone_bundle third_party/unicodeTables "$(find_one 'mars-unicode-tables-master*.bundle')"
|
|
|
|
copy_tree_from_tar "$(find_one 'yyjson-0.12.0.tar*.gz')" third_party/yyjson
|
|
copy_tree_from_tar "$(find_one 'libsodium-1.0.20.tar*.gz')" third_party/libsodium/libsodium
|
|
copy_tree_from_tar "$(find_one 'termbox2-2.5.0.tar*.gz')" third_party/termbox2
|
|
copy_tree_from_tar "$(find_one 'iniparser-4.2.6.tar*.gz')" third_party/iniparser
|
|
|
|
build_fake_system_deps
|
|
|
|
print_cmake_hints
|