Harden automation: apply only build patches, default clean, install binaries
This commit is contained in:
@@ -1,16 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Convenience wrapper:
|
||||
# apply patches -> build -> install
|
||||
#
|
||||
# Env:
|
||||
# SSLTYPE, TARGET, JOBS (see build.sh)
|
||||
# PREFIX (see install.sh)
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
cd "$ROOT"
|
||||
|
||||
# Defaults suitable for automation
|
||||
: "${CLEAN:=1}"
|
||||
: "${PREFIX:=/usr/local/imap}"
|
||||
|
||||
./scripts/apply-patches.sh
|
||||
./scripts/build.sh
|
||||
./scripts/install.sh
|
||||
CLEAN="$CLEAN" ./scripts/build.sh
|
||||
PREFIX="$PREFIX" ./scripts/install.sh
|
||||
|
||||
@@ -7,7 +7,7 @@ PATCHDIR="${ROOT}/patches"
|
||||
usage() {
|
||||
cat <<USAGE
|
||||
Usage: $0
|
||||
Applies patches/*.patch to the working tree (idempotent).
|
||||
Applies patches 0001–0004 to the working tree (idempotent).
|
||||
USAGE
|
||||
}
|
||||
|
||||
@@ -23,18 +23,16 @@ if [[ ! -d "$PATCHDIR" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Apply patches only if they are not already applied.
|
||||
# We use --dry-run to test applicability; if it fails, we assume it's already applied.
|
||||
shopt -s nullglob
|
||||
patches=( "$PATCHDIR"/000[1-4]-*.patch )
|
||||
#patches=( "$PATCHDIR"/*.patch )
|
||||
|
||||
if (( ${#patches[@]} == 0 )); then
|
||||
echo "ERROR: no patches found in $PATCHDIR" >&2
|
||||
echo "ERROR: no 0001–0004 patches found in $PATCHDIR" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for p in "${patches[@]}"; do
|
||||
echo "==> Checking $p"
|
||||
echo "==> Checking $(basename "$p")"
|
||||
if patch --dry-run -p1 < "$p" >/dev/null 2>&1; then
|
||||
echo "==> Applying $(basename "$p")"
|
||||
patch -p1 < "$p"
|
||||
|
||||
@@ -14,9 +14,7 @@ Environment:
|
||||
Installs:
|
||||
- headers to: \$PREFIX/include
|
||||
- static lib to: \$PREFIX/lib/libc-client.a
|
||||
|
||||
Note:
|
||||
Requires a successful build (c-client/c-client.a exists).
|
||||
- binaries to: \$PREFIX/bin (if present)
|
||||
USAGE
|
||||
}
|
||||
|
||||
@@ -36,16 +34,43 @@ if [[ ! -f "$SRC_LIB" ]]; then
|
||||
fi
|
||||
|
||||
echo "==> Installing to PREFIX=$PREFIX"
|
||||
install -d -m 0755 "$PREFIX/include" "$PREFIX/lib"
|
||||
install -d -m 0755 "$PREFIX/include" "$PREFIX/lib" "$PREFIX/bin"
|
||||
|
||||
echo "==> Installing headers"
|
||||
# Only install the public headers (all .h in c-client/)
|
||||
install -m 0644 "$SRC_HDR_DIR"/*.h "$PREFIX/include/"
|
||||
|
||||
echo "==> Installing libc-client.a"
|
||||
install -m 0644 "$SRC_LIB" "$PREFIX/lib/libc-client.a"
|
||||
|
||||
echo "==> Installing binaries (if present)"
|
||||
# Common outputs after 'make bundled'
|
||||
bins=(
|
||||
"$ROOT/mtest/mtest"
|
||||
"$ROOT/imapd/imapd"
|
||||
"$ROOT/ipopd/ipopd"
|
||||
"$ROOT/mailutil/mailutil"
|
||||
"$ROOT/mlock/mlock"
|
||||
"$ROOT/dmail/dmail"
|
||||
"$ROOT/tmail/tmail"
|
||||
)
|
||||
|
||||
installed_any=0
|
||||
for b in "${bins[@]}"; do
|
||||
if [[ -x "$b" ]]; then
|
||||
install -m 0755 "$b" "$PREFIX/bin/"
|
||||
echo " installed: $(basename "$b")"
|
||||
installed_any=1
|
||||
else
|
||||
echo " skipped: $(basename "$b") (not found/executable)"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "==> Done."
|
||||
echo "Installed:"
|
||||
echo " Headers: $PREFIX/include/*.h"
|
||||
echo " Library: $PREFIX/lib/libc-client.a"
|
||||
if [[ "$installed_any" -eq 1 ]]; then
|
||||
echo " Binaries: $PREFIX/bin/"
|
||||
else
|
||||
echo " Binaries: none (run ./scripts/build.sh to build bundled tools)"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user