~bigbes/sr-ht-spec

64488fc9b58e969f624f7615e5baf9e86942914c — bigbes 27 days ago 4562b44
fix: anchor installed data paths to ASSETS, and install schema.sql

Two install-time bugs that only show up on a packaged deploy, never in a
checkout.

MIGRATIONDIR derived from PREFIX, so a default build installed migrations
to /usr/local/share/sourcehut/migrations while specsrht-migrate looked
under [sr.ht]assets, default /usr/share/sourcehut. The two agreed only at
PREFIX=/usr. Every installed data path now anchors to ASSETS, which is the
runtime lookup root.

schema.sql was never installed, so specsrht-migrate init could not find
the schema it applies wholesale on a fresh database. sourcehut-dolt has
the same latent path mismatch.

Static assets are guarded so install works before web/ exists.
1 files changed, 19 insertions(+), 4 deletions(-)

M Makefile
M Makefile => Makefile +19 -4
@@ 10,10 10,16 @@ MIGRATE_BIN=specsrht-migrate

PREFIX?=/usr/local
BINDIR?=$(PREFIX)/bin
SHAREDIR?=$(PREFIX)/share
# ASSETS is the RUNTIME lookup root: specsrht-migrate resolves migrations and
# the schema under [sr.ht]assets (default /usr/share/sourcehut), NOT under
# PREFIX. Deriving these from PREFIX instead would install to
# /usr/local/share/... on a default build while the binary kept looking in
# /usr/share/sourcehut — the two would only agree at PREFIX=/usr. Keep every
# installed data path anchored to ASSETS so a default `make install` works.
ASSETS?=/usr/share/sourcehut
STATICDIR?=$(ASSETS)/$(SERVICE)/static
MIGRATIONDIR?=$(SHAREDIR)/sourcehut/migrations/$(SERVICE)
MIGRATIONDIR?=$(ASSETS)/migrations/$(SERVICE)
SCHEMAFILE?=$(ASSETS)/$(SERVICE).sql

SASSC?=sassc
SASSC_INCLUDE=-I$(ASSETS)/scss


@@ 65,12 71,21 @@ css:
run-dev: build
	./$(BIN) -b localhost:5091

# schema.sql is installed as $(SCHEMAFILE) because `specsrht-migrate init`
# applies it wholesale on a fresh database; without it, init works from a
# checkout and fails on a packaged install.
install: build
	install -Dm755 $(BIN) $(DESTDIR)$(BINDIR)/$(BIN)
	install -Dm755 $(MIGRATE_BIN) $(DESTDIR)$(BINDIR)/$(MIGRATE_BIN)
	mkdir -p $(DESTDIR)$(STATICDIR) $(DESTDIR)$(MIGRATIONDIR)
	install -Dm644 -t $(DESTDIR)$(STATICDIR) web/static/*
	mkdir -p $(DESTDIR)$(MIGRATIONDIR)
	install -Dm644 -t $(DESTDIR)$(MIGRATIONDIR) migrations/*.sql
	install -Dm644 schema.sql $(DESTDIR)$(SCHEMAFILE)
	@if [ -d web/static ]; then \
		mkdir -p $(DESTDIR)$(STATICDIR); \
		install -Dm644 -t $(DESTDIR)$(STATICDIR) web/static/*; \
	else \
		echo "skip static assets: web/static not present yet"; \
	fi

clean:
	rm -f $(BIN) $(MIGRATE_BIN)