social-kit / deploy / publish-repo.sh
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env bash
# Builds this repo's public source mirror: landing page + the repo as a
# dumb-HTTP-clonable bare mirror (plain static files — IPFS-friendly).
# Published as part of the git.ardegazu.ro ecosystem root by
# the workspace assembler (git/assemble.sh), which serves it at
# https://git.ardegazu.ro/social-kit/ (page) and https://git.ardegazu.ro/social-kit.git (clone).
set -euo pipefail
cd "$(dirname "$0")/.."

APP=social-kit               # path under git.ardegazu.ro
IDENT=social-kit             # anonymous commit identity
OUT=deploy/.site
rm -rf "$OUT"
mkdir -p "$OUT"

cp site/index.html "$OUT/index.html"

# this ecosystem's assembler rsyncs only — each repo generates its own
# in-browser source browser (git.ardegazu.ro/<APP>/browse/)
python3 deploy/gen-browse.py --repo . --app "$APP" --out "$OUT/browse" \
  --clone-url "https://git.ardegazu.ro/$APP.git"

# --no-local: a plain path clone hardlinks the whole objects dir, which can
# drag along unreachable/rewritten history — transport clone copies only
# what's reachable from refs
git clone --no-local --bare --quiet . "$OUT/$APP.git"

# Explode packs into loose objects: the IPFS gateway answers missing paths
# with a 200 fallback page, which makes git's loose-object probes error
# noisily before the pack fallback. All-loose means every requested path
# exists, so dumb-HTTP clones stay clean.
(
  cd "$OUT/$APP.git"
  for p in objects/pack/pack-*.pack; do
    [ -e "$p" ] || continue
    tmp=$(mktemp)
    mv "$p" "$tmp"
    rm -f "${p%.pack}".*
    git unpack-objects -q < "$tmp"
    rm -f "$tmp"
  done
  git update-server-info
)
# strip local-only noise from the published mirror
rm -rf "$OUT/$APP.git/hooks" "$OUT/$APP.git/config" 2>/dev/null || true

# ---- anonymity gate: refuse to build a mirror that leaks identity ----------
AUTHORS=$(git -C "$OUT/$APP.git" log --all --format='%an <%ae>%n%cn <%ce>' | sort -u)
if [ "$AUTHORS" != "$IDENT <$IDENT@noreply.local>" ]; then
  echo "ABORT: non-anonymous commit identity in mirror:" >&2
  echo "$AUTHORS" >&2
  exit 1
fi
if git -C "$OUT/$APP.git" ls-tree -r --name-only HEAD | grep -q '\.site'; then
  echo "ABORT: nested site build committed into the repo (deploy/.site leak)" >&2
  exit 1
fi
# pattern assembled from pieces so this script never matches itself
IDPAT="$(printf 'koko%s|rober%s@|@mu%s' s t k)"
LEAK=$(cd "$OUT/$APP.git" && find objects -type f | while read -r f; do
  # filename via argv, never interpolated into source (injection-proof pattern)
  python3 -c "import zlib,sys;sys.stdout.buffer.write(zlib.decompress(open(sys.argv[1],'rb').read()))" "$f" 2>/dev/null
done | grep -aicE "$IDPAT" || true)
if [ "${LEAK:-0}" != "0" ]; then
  echo "ABORT: identity strings found inside $LEAK mirror object(s)" >&2
  exit 1
fi
echo "anonymity gate: OK (single anonymous author, no identity bytes, no nested site)"
# -----------------------------------------------------------------------------

echo "mirror built at $OUT ($(du -sh "$OUT" | cut -f1)) — publish via ardegazu-git/assemble.sh $APP"

static mirror of HEAD · about · clone: git clone https://git.ardegazu.ro/social-kit.git