Convert to new shared asset distribution

This comes with the following changes:

* All executables renamed to "service.sr.ht-exe"
* Makefile
  - becomes standalone, setting SRHT_PATH no longer required
  - expects SCSS in $(PREFIX)/share/sourcehut
  - installs assets in $(PREFIX)/share/sourcehut
* Python module
  - no longer contains any static assets (except for the GQL schema)
  - setup.py reduced to stub
  - no longer calls `make` when building
19 files changed, 86 insertions(+), 50 deletions(-)

M .hgignore
M Makefile
M api/graph/schema.resolvers.go
M config.example.ini
M hgsrht-clonebundles => hg.sr.ht-clonebundles
M hgsrht-hook-changegroup => hg.sr.ht-hook-changegroup
M hgsrht-initdb => hg.sr.ht-initdb
M hgsrht-install-ext => hg.sr.ht-install-ext
M hgsrht-migrate => hg.sr.ht-migrate
M hgsrht-periodic => hg.sr.ht-periodic
M hgsrht-shell => hg.sr.ht-shell
M hgsrht-upgraderepos => hg.sr.ht-upgraderepos
M hgsrht/blueprints/internal.py
M hgsrht/submit.py
M hgsrht/urls.py
M keys/main.go
M pyproject.toml
M setup.py
R static => 
M .hgignore +2 -2
@@ 16,5 16,5 @@ overrides/
 .pgp
 build
 *_gen.go
-hgsrht-keys/hgsrht-keys
-api/api
+hg.sr.ht-keys
+hg.sr.ht-api

          
M Makefile +63 -9
@@ 1,15 1,69 @@ 
-SRHT_PATH?=/usr/lib/python3.12/site-packages/srht
-MODULE=hgsrht/
-include ${SRHT_PATH}/Makefile
+PREFIX?=/usr/local
+BINDIR?=$(PREFIX)/bin
+LIBDIR?=$(PREFIX)/lib
+SHAREDIR?=$(PREFIX)/share/sourcehut
+
+SERVICE=hg.sr.ht
+STATICDIR=$(SHAREDIR)/static/$(SERVICE)
+
+SASSC?=sassc
+SASSC_INCLUDE=-I$(SHAREDIR)/scss/
+
+BINARIES=\
+	$(SERVICE)-api \
+	$(SERVICE)-keys
+
+all: all-bin all-share
+
+install: install-bin install-share
+
+clean: clean-bin clean-share
+
+all-bin: $(BINARIES)
+
+all-share: static/main.min.css
 
-all: api hgsrht-keys
+install-bin: all-bin
+	mkdir -p $(BINDIR)
+	for bin in $(BINARIES); \
+	do \
+		install -Dm755 $$bin $(BINDIR)/; \
+	done
+
+install-share: all-share
+	mkdir -p $(STATICDIR)
+	install -Dm644 static/*.css $(STATICDIR)
+	install -Dm644 api/graph/schema.graphqls $(SHAREDIR)/$(SERVICE).graphqls
+
+clean-bin:
+	rm -f $(BINARIES)
 
-api:
+clean-share:
+	rm -f static/main.min.css static/main.css
+
+.PHONY: all all-bin all-share
+.PHONY: install install-bin install-share
+.PHONY: clean clean-bin clean-share
+
+static/main.css: scss/main.scss
+	mkdir -p $(@D)
+	$(SASSC) $(SASSC_INCLUDE) $< $@
+
+static/main.min.css: static/main.css
+	minify -o $@ $<
+	cp $@ $(@D)/main.min.$$(sha256sum $@ | cut -c1-8).css
+
+api/loaders/*_gen.go &: api/loaders/generate.go api/loaders/gen go.sum
 	cd api && go generate ./loaders
+
+api/graph/api/generated.go: api/graph/schema.graphqls api/graph/generate.go go.sum api/loaders/*_gen.go
 	cd api && go generate ./graph
-	cd api && go build
 
-hgsrht-keys:
-	cd hgsrht-keys && go build
+$(SERVICE)-api: api/graph/api/generated.go api/loaders/*_gen.go
+	go build -o $@ ./api
 
-.PHONY: all api hgsrht-keys
+$(SERVICE)-keys:
+	cd keys && go build -o ../$@
+
+# Always rebuild
+.PHONY: $(BINARIES)

          
M api/graph/schema.resolvers.go +1 -1
@@ 515,7 515,7 @@ func (r *mutationResolver) DeleteUser(ct
 // Version is the resolver for the version field.
 func (r *queryResolver) Version(ctx context.Context) (*model.Version, error) {
 	conf := config.ForContext(ctx)
-	sshUser, _ := conf.Get("git.sr.ht::dispatch", "/usr/bin/hgsrht-keys")
+	sshUser, _ := conf.Get("git.sr.ht::dispatch", "/usr/bin/hg.sr.ht-keys")
 	sshUser = strings.Split(sshUser, ":")[0]
 
 	return &model.Version{

          
M config.example.ini +2 -2
@@ 99,7 99,7 @@ webhooks=redis://localhost:6379/1
 disable-publishing=false
 #
 # A post-update script which is installed in every mercurial repo.
-changegroup-script=/usr/bin/hgsrht-hook-changegroup
+changegroup-script=/usr/bin/hg.sr.ht-hook-changegroup
 #
 # hg.sr.ht's OAuth client ID and secret for meta.sr.ht
 # Register your client at meta.example.org/oauth

          
@@ 154,7 154,7 @@ internal-ipnet=127.0.0.0/8,::1/128,192.1
 # and is expected to emit an AuthorizedKeys file.
 #
 # Uncomment the relevant lines to enable the various sr.ht dispatchers.
-/usr/bin/hgsrht-keys=hg:hg
+/usr/bin/hg.sr.ht-keys=hg:hg
 
 [meta.sr.ht]
 origin=http://meta.sr.ht.local

          
M hgsrht-clonebundles => hg.sr.ht-clonebundles +0 -0

        
M hgsrht-hook-changegroup => hg.sr.ht-hook-changegroup +0 -0

        
M hgsrht-initdb => hg.sr.ht-initdb +0 -0

        
M hgsrht-install-ext => hg.sr.ht-install-ext +1 -1
@@ 14,7 14,7 @@ repos_path = cfg("hg.sr.ht", "repos")
 publishing_disabled = cfgb("hg.sr.ht", "disable-publishing", False)
 
 changegroup_script = cfg("hg.sr.ht", "changegroup-script",
-    "/usr/bin/hgsrht-hook-changegroup")
+    "/usr/bin/hg.sr.ht-hook-changegroup")
 
 def get_partial_hgrc_path(name):
     return f'/etc/sr.ht/hgrcs/{name}'

          
M hgsrht-migrate => hg.sr.ht-migrate +0 -0

        
M hgsrht-periodic => hg.sr.ht-periodic +0 -0

        
M hgsrht-shell => hg.sr.ht-shell +3 -3
@@ 18,7 18,7 @@ from sqlalchemy.dialects.postgresql.base
 log_to_console = bool(os.getenv('LOG2CONSOLE'))
 if not log_to_console:
     try:
-        _logf = open("/var/log/hgsrht-shell", "a")
+        _logf = open("/var/log/hg.sr.ht-shell", "a")
     except Exception as ex:
         sys.stderr.write("Unable to open log for writing\n")
         sys.stderr.write(str(ex) + "\n")

          
@@ 59,13 59,13 @@ def run_hg_serve(repo, allow_push):
             b'hooks',
             b'pretxnopen.hgsrht-shell',
             b'python:__main__.rejectpush',
-            b'hgsrht-shell',
+            b'hg.sr.ht-shell',
         )
         req.ui.setconfig(
             b'hooks',
             b'prepushkey.hgsrht-shell',
             b'python:__main__.rejectpush',
-            b'hgsrht-shell',
+            b'hg.sr.ht-shell',
         )
     dispatch.dispatch(req)
 

          
M hgsrht-upgraderepos => hg.sr.ht-upgraderepos +0 -0

        
M hgsrht/blueprints/internal.py +1 -1
@@ 1,5 1,5 @@ 
 """
-This blueprint is used internally by hgsrht-shell to speed up SSH access, by
+This blueprint is used internally by hg.sr.ht-shell to speed up SSH access, by
 taking advantage of the database connection already established by the web app.
 """
 import base64

          
M hgsrht/submit.py +1 -1
@@ 71,7 71,7 @@ class HgBuildSubmitter(BuildSubmitterBas
 
     def get_clone_url(self):
         origin = get_origin("hg.sr.ht", external=True)
-        hg_user = cfg("git.sr.ht::dispatch", "/usr/bin/hgsrht-keys", "hg:hg").split(":")[0]
+        hg_user = cfg("git.sr.ht::dispatch", "/usr/bin/hg.sr.ht-keys", "hg:hg").split(":")[0]
         owner_name = self.repo.owner.canonical_name
         repo_name = self.repo.name
         if self.repo.visibility == RepoVisibility.PRIVATE:

          
M hgsrht/urls.py +1 -1
@@ 2,7 2,7 @@ from srht.config import cfg
 from scmsrht.urls import get_clone_urls
 
 origin_url = cfg("hg.sr.ht", "origin")
-hg_user = cfg("git.sr.ht::dispatch", "/usr/bin/hgsrht-keys", "hg:hg").split(":")[0]
+hg_user = cfg("git.sr.ht::dispatch", "/usr/bin/hg.sr.ht-keys", "hg:hg").split(":")[0]
 ssh_url_root = f'ssh://{hg_user}@'
 
 def clone_urls(repo):

          
M keys/main.go +3 -3
@@ 11,13 11,13 @@ import (
 )
 
 func main() {
-	// hgsrht-keys is run by sshd to generate an authorized_key file on stdout.
+	// hg.sr.ht-keys is run by sshd to generate an authorized_key file on stdout.
 	// In order to facilitate this, we do one of two things:
 	// - Attempt to fetch the cached key info from Redis (preferred)
 	// - Fetch the key from meta.sr.ht and store it in SQL and Redis (slower)
 	service := "hg.sr.ht"
-	shellName := "hgsrht-shell"
-	logFile := "/var/log/hgsrht-keys"
+	shellName := "hg.sr.ht-shell"
+	logFile := "/var/log/hg.sr.ht-keys"
 
 	var (
 		config   ini.File

          
M pyproject.toml +8 -12
@@ 31,22 31,20 @@ packages = [
     "hgsrht.blueprints.api",
     "hgsrht.hgext",
     "hgsrht.hgrcs",
-    "hgsrht.static",
-    "hgsrht.static.icons",
     "hgsrht.templates",
     "hgsrht.templates.macros",
     "hgsrht.templates.partials",
     "hgsrht.types",
 ]
 script-files = [
-    "hgsrht-clonebundles",
-    "hgsrht-hook-changegroup",
-    "hgsrht-initdb",
-    "hgsrht-install-ext",
-    "hgsrht-migrate",
-    "hgsrht-periodic",
-    "hgsrht-shell",
-    "hgsrht-upgraderepos"
+    "hg.sr.ht-clonebundles",
+    "hg.sr.ht-hook-changegroup",
+    "hg.sr.ht-initdb",
+    "hg.sr.ht-install-ext",
+    "hg.sr.ht-migrate",
+    "hg.sr.ht-periodic",
+    "hg.sr.ht-shell",
+    "hg.sr.ht-upgraderepos"
 ]
 [tool.setuptools.package-data]
 "hgsrht" = ['default_query.graphql', 'schema.graphqls']

          
@@ 54,7 52,5 @@ script-files = [
 "hgsrht.templates" = ['*.html']
 "hgsrht.templates.macros" = ['*.html']
 "hgsrht.templates.partials" = ['*.html']
-"hgsrht.static" = ['*']
-"hgsrht.static.icons" = ['*']
 
 [tool.setuptools_scm]

          
M setup.py +0 -13
@@ 1,16 1,3 @@ 
-#!/usr/bin/env python3
 from setuptools import setup
-import subprocess
-import os
-import sys
-import importlib.resources
-
-with importlib.resources.path('srht', 'Makefile') as f:
-    srht_path = f.parent.as_posix()
-
-make = os.environ.get("MAKE", "make")
-subp = subprocess.run([make, "SRHT_PATH=" + srht_path])
-if subp.returncode != 0:
-    sys.exit(subp.returncode)
 
 setup()

          
R static =>  +0 -1
@@ 1,1 0,0 @@ 
-hgsrht/static/
  No newline at end of file