sirius-press/tools/build.sh

141 lines
4.8 KiB
Bash
Raw Normal View History

feat(sirius-press): a WordPress where the account is a key, not a mailbox WordPress makes two assumptions this project cannot accept: that identity comes from an email address, and that a site lives at one server. Both are things somebody else can take away — a mailbox is rented from a provider who can close it or be compelled to open it, and a server is one seizure from being gone. Sirius Press replaces the first and hedges the second. Signing in means signing a challenge with the key that controls a CashAddress. The address is recovered from the signature, so nothing is typed but the signature itself, and the result is an ordinary WordPress session cookie — roles, capabilities, nonces and the REST API never learn the login was different. Three ways to produce one: a wallet the browser already exposes, a phrase used once in the page and wiped, or a signature pasted in from any BIP-137 wallet, which needs no JavaScript and lets the key stay on a machine that never touches the web. There is no password reset, and the recovery page says so plainly rather than offering a form that cannot work. A reset mechanism is by construction a way to take an account from its owner, and it is always easier to attack than the cryptography it bypasses. Publishing a post also exports it as static HTML to the name's storage on Sia, signed by the key that owns the name, so the site keeps answering when the server does not. Email as a feature is untouched. wp_mail() still works, SMTP still sends, and contact forms still deliver to addresses real people typed. Only mail to the site's own unroutable placeholder addresses is diverted to an in-app inbox. The objection was to email as identity, not to email. Core is pinned and patched rather than vendored. WordPress 7.1.1 is 149 MB and 5,008 files; the fork's entire core diff is 75 lines in wp-admin/install.php. Carrying the former to express the latter would bury the patch where nobody reviews it and make every clone of the monorepo pay for it. Upstream releases still merge through tools/update-wordpress.sh, which reapplies the series and says exactly which hunk needs a human. The cryptography is implemented twice — PHP on the server, JavaScript in the page — because the server must verify and the browser must sign. Both are pinned against libauth, the library the Sirius portal wallet and the BNS gateway already use, so a disagreement of one byte fails the test suite rather than presenting as a rejected login at three in the morning. 132 checks, no framework, about a second.
2026-09-21 01:39:38 +02:00
#!/usr/bin/env bash
# build.sh — assemble a complete, patched Sirius Press tree.
#
# Downloads the pinned WordPress, verifies it against the checksum in
# tools/wordpress.lock, applies the patch series in patches/, drops this
# repository's plugins and must-use plugins into place, and leaves the result
# in dist/sirius-press/.
#
# With --zip it also produces dist/sirius-press-<version>.zip, which is the
# artifact shared-hosting users upload.
#
# The verification is not a formality. This script fetches executable code
# over the network and then runs it as a web server; the checksum is the only
# thing standing between a compromised mirror and every site built from it.
# If it fails, the build stops — there is no --skip-verify, on purpose.
set -euo pipefail
here="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$here"
# shellcheck source=wordpress.lock
source tools/wordpress.lock
VERSION="$(grep -m1 "^ \* Version:" plugins/sirius-press-core/sirius-press-core.php | awk '{print $3}')"
DIST="$here/dist"
TARGET="$DIST/sirius-press"
CACHE="${SIRIUS_BUILD_CACHE:-$DIST/.cache}"
MAKE_ZIP=0
for arg in "$@"; do
case "$arg" in
--zip) MAKE_ZIP=1 ;;
*) echo "unknown option: $arg" >&2; exit 2 ;;
esac
done
say() { printf '\033[1m→\033[0m %s\n' "$*"; }
die() { printf '\033[31merror:\033[0m %s\n' "$*" >&2; exit 1; }
command -v curl >/dev/null || die "curl is required"
command -v tar >/dev/null || die "tar is required"
command -v patch >/dev/null || die "patch is required (used to apply the core patch series)"
# ---------------------------------------------------------------- fetch core
mkdir -p "$CACHE"
tarball="$CACHE/wordpress-$WP_VERSION.tar.gz"
if [ ! -f "$tarball" ]; then
say "downloading WordPress $WP_VERSION"
curl -fsSL -o "$tarball.part" "$WP_URL" || die "download failed"
mv "$tarball.part" "$tarball"
fi
say "verifying checksum"
actual="$(sha256sum "$tarball" | cut -d' ' -f1)"
if [ "$actual" != "$WP_SHA256" ]; then
rm -f "$tarball"
die "checksum mismatch for WordPress $WP_VERSION
expected $WP_SHA256
got $actual
The cached download has been deleted. If this repeats, the mirror is serving
something other than what this fork was built against — do not work around it."
fi
# --------------------------------------------------------------- assemble
say "unpacking into dist/sirius-press"
rm -rf "$TARGET"
mkdir -p "$TARGET"
tar -xzf "$tarball" -C "$DIST"
mv "$DIST/wordpress"/* "$TARGET"/
mv "$DIST/wordpress"/.[!.]* "$TARGET"/ 2>/dev/null || true
rmdir "$DIST/wordpress"
# ------------------------------------------------------------ patch series
shopt -s nullglob
patches=(patches/*.patch)
shopt -u nullglob
if [ ${#patches[@]} -eq 0 ]; then
say "no core patches to apply"
else
say "applying ${#patches[@]} core patch(es)"
for patch in "${patches[@]}"; do
# -F3 tolerates a few lines of drift around the hunk, so a WordPress
# point release that shifts the surrounding code still takes the patch.
# If it genuinely no longer fits, stop: a half-patched installer is
# worse than a failed build.
if (cd "$TARGET" && patch -p1 -F3 --forward --silent < "$here/$patch"); then
echo " ok $(basename "$patch")"
else
die "$(basename "$patch") did not apply to WordPress $WP_VERSION.
Run tools/update-wordpress.sh to refresh the series against this version."
fi
done
fi
# ---------------------------------------------------------------- our code
say "installing Sirius Press plugins"
mkdir -p "$TARGET/wp-content/plugins" "$TARGET/wp-content/mu-plugins"
for plugin in plugins/*/; do
cp -R "$plugin" "$TARGET/wp-content/plugins/"
done
cp mu-plugins/*.php "$TARGET/wp-content/mu-plugins/"
# The stock wp-config-sample.php has no SIRIUS_PRESS_KEY, and a site that
# never sets one falls back to its auth salts — which works, but means
# rotating salts orphans the stored publishing key.
if [ -f docker/wp-config-sirius.php ]; then
cp docker/wp-config-sirius.php "$TARGET/wp-config-sirius-sample.php"
fi
say "built dist/sirius-press ($(du -sh "$TARGET" | cut -f1))"
# --------------------------------------------------------------------- zip
if [ "$MAKE_ZIP" -eq 1 ]; then
command -v zip >/dev/null || die "zip is required for --zip"
archive="$DIST/sirius-press-$VERSION.zip"
say "packing $(basename "$archive")"
rm -f "$archive"
(cd "$DIST" && zip -qr "$archive" sirius-press)
sha256sum "$archive" | cut -d' ' -f1 > "$archive.sha256"
say "$(basename "$archive")$(du -h "$archive" | cut -f1), sha256 $(cat "$archive.sha256")"
fi
cat <<EOF
Sirius Press $VERSION, built on WordPress $WP_VERSION.
dist/sirius-press/ a complete, patched WordPress tree
$( [ "$MAKE_ZIP" -eq 1 ] && echo " dist/sirius-press-$VERSION.zip upload this to a shared host" )
To run it locally: cd docker && docker compose up -d
To install on a VPS: see docs/install.md
EOF