summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2025-05-29 05:53:26 -0300
committerEuAndreh <eu@euandre.org>2025-05-29 05:53:26 -0300
commit783845f84860968dd5e0f971fea42045c8b8e58c (patch)
tree756252dbf6965ab0504d0310d2e28e4f570e8a2d
parentmeta.capim: Add with :dependencies key (diff)
downloadhsts-main.tar.gz
hsts-main.tar.xz
Update to latest project skeleton: i18n and fine-grained fuzzingHEADmain
-rw-r--r--.gitignore5
-rw-r--r--Makefile75
-rw-r--r--deps.mk25
-rw-r--r--doc/hsts.en.0.adoc5
-rwxr-xr-xmkdeps.sh53
-rw-r--r--po/doc/de.po22
-rw-r--r--po/doc/doc.pot21
-rw-r--r--po/doc/eo.po22
-rw-r--r--po/doc/es.po22
-rw-r--r--po/doc/fr.po22
-rw-r--r--po/doc/note.txt5
-rw-r--r--po/doc/po4a.cfg5
-rw-r--r--po/doc/pt.po22
-rw-r--r--po/hsts/de.po10
-rw-r--r--po/hsts/eo.po10
-rw-r--r--po/hsts/es.po10
-rw-r--r--po/hsts/fr.po10
-rw-r--r--po/hsts/hsts.pot10
-rw-r--r--po/hsts/po4a.cfg3
-rw-r--r--po/hsts/pt.po10
-rw-r--r--src/hsts.go3
21 files changed, 321 insertions, 49 deletions
diff --git a/.gitignore b/.gitignore
index 094db69..d3c2f8f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,7 @@
-/src/version.go
+/doc/*
+!/doc/*.en.*.adoc
+/po/*/*.mo
+/src/meta.go
/*.bin
/src/*.a
/src/*.bin
diff --git a/Makefile b/Makefile
index 21caeb4..35366e1 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,6 @@ DATE = 1970-01-01
VERSION = 0.1.0
NAME = hsts
NAME_UC = $(NAME)
-LANGUAGES = en
## Installation prefix. Defaults to "/usr".
PREFIX = /usr
BINDIR = $(PREFIX)/bin
@@ -20,45 +19,58 @@ DESTDIR =
LDLIBS = --static
GOCFLAGS = -I $(GOLIBDIR)
GOLDFLAGS = -L $(GOLIBDIR)
+N = `nproc`
.SUFFIXES:
-.SUFFIXES: .go .a .bin .bin-check
+.SUFFIXES: .go .a .bin .bin-check .adoc .po .mo
.go.a:
go tool compile -I $(@D) $(GOCFLAGS) -o $@ -p $(*F) \
`find $< $$(if [ $(*F) != main ]; then \
- echo src/$(NAME).go src/version.go; fi) | uniq`
+ echo src/$(NAME).go src/meta.go; fi) | uniq`
.a.bin:
go tool link -L $(@D) $(GOLDFLAGS) -o $@ --extldflags '$(LDLIBS)' $<
+.adoc:
+ asciidoctor -b manpage -o $@ $<
+
+.po.mo:
+ msgfmt -cfv -o $@ $<
+
all:
include deps.mk
-libs.a = $(libs.go:.go=.a)
-mains.a = $(mains.go:.go=.a)
-mains.bin = $(mains.go:.go=.bin)
-functional-tests/lib.a = $(functional-tests/lib.go:.go=.a)
-fuzz-targets/lib.a = $(fuzz-targets/lib.go:.go=.a)
-benchmarks/lib.a = $(benchmarks/lib.go:.go=.a)
+libs.a = $(libs.go:.go=.a)
+mains.a = $(mains.go:.go=.a)
+mains.bin = $(mains.go:.go=.bin)
+functional/lib.a = $(functional/lib.go:.go=.a)
+fuzz/lib.a = $(fuzz/lib.go:.go=.a)
+benchmarks/lib.a = $(benchmarks/lib.go:.go=.a)
+manpages.N.adoc = $(manpages.en.N.adoc) $(manpages.XX.N.adoc)
+manpages.N = $(manpages.N.adoc:.adoc=)
+sources.mo = $(sources.po:.po=.mo)
sources = \
src/$(NAME).go \
- src/version.go \
+ src/meta.go \
src/main.go \
derived-assets = \
- src/version.go \
+ src/meta.go \
$(libs.a) \
$(mains.a) \
$(mains.bin) \
$(NAME).bin \
+ $(manpages.XX.N.adoc) \
+ $(manpages.N) \
+ $(sources.mo) \
side-assets = \
$(NAME).socket \
@@ -73,24 +85,30 @@ all: $(derived-assets)
$(libs.a): Makefile deps.mk
-$(libs.a): src/$(NAME).go src/version.go
+$(libs.a): src/$(NAME).go src/meta.go
-$(fuzz-targets/lib.a):
+$(fuzz/lib.a):
go tool compile $(GOCFLAGS) -o $@ -p $(NAME) -d=libfuzzer \
- $*.go src/$(NAME).go src/version.go
+ $*.go src/$(NAME).go src/meta.go
-src/version.go: Makefile
- echo 'package $(NAME); const Version = "$(VERSION)"' > $@
+src/meta.go: Makefile
+ echo 'package $(NAME)' > $@
+ echo 'const Version = "$(VERSION)"' >> $@
+ echo 'const Name = "$(NAME)"' >> $@
+ echo 'const LOCALEDIR = "$(LOCALEDIR)"' >> $@
$(NAME).bin: src/main.bin
ln -fs src/main.bin $@
+$(manpages.XX.N.adoc): po/doc/po4a.cfg
+ po4a --no-update --translate-only $@ po/doc/po4a.cfg
+
tests.bin-check = \
tests/main.bin-check \
- $(functional-tests/main.go:.go=.bin-check) \
+ $(functional/main.go:.go=.bin-check) \
$(tests.bin-check):
$(EXEC)$*.bin
@@ -119,12 +137,12 @@ check: check-unit check-integration
FUZZSEC=1
-fuzz-targets/main.bin-check = $(fuzz-targets/main.go:.go=.bin-check)
-$(fuzz-targets/main.bin-check):
- $(EXEC)$*.bin --test.fuzztime=$(FUZZSEC)s \
+fuzz/main.bin-check = $(fuzz/main.go:.go=.bin-check)
+$(fuzz/main.bin-check):
+ $(EXEC)$*.bin --test.fuzztime=$(FUZZSEC)s --test.parallel=$N \
--test.fuzz='.*' --test.fuzzcachedir=tests/fuzz/corpus
-fuzz: $(fuzz-targets/main.bin-check)
+fuzz: $(fuzz/main.bin-check)
@@ -138,6 +156,17 @@ bench: $(benchmarks/main.bin-check)
+i18n-doc:
+ po4a po/doc/po4a.cfg
+
+i18n-code:
+ gotext src/$(NAME).go > po/$(NAME)/$(NAME).pot
+ po4a po/$(NAME)/po4a.cfg
+
+i18n: i18n-doc i18n-code
+
+
+
## Remove *all* derived artifacts produced during the build.
## A dedicated test asserts that this is always true.
clean:
@@ -155,6 +184,8 @@ install: all
cp $(NAME).bin '$(DESTDIR)$(BINDIR)'/$(NAME)
cp src/$(NAME).a '$(DESTDIR)$(GOLIBDIR)'
cp $(sources) '$(DESTDIR)$(SRCDIR)'
+ instool '$(DESTDIR)$(MANDIR)' install man $(manpages.N)
+ instool '$(DESTDIR)$(LOCALEDIR)' install mo $(sources.mo)
## Uninstalls from $(DESTDIR)$(PREFIX). This is a perfect mirror
## of the "install" target, and removes *all* that was installed.
@@ -165,6 +196,8 @@ uninstall:
'$(DESTDIR)$(GOLIBDIR)'/$(NAME).a \
'$(DESTDIR)$(SRCDIR)' \
+ instool '$(DESTDIR)$(MANDIR)' uninstall man $(manpages.N)
+ instool '$(DESTDIR)$(LOCALEDIR)' uninstall mo $(sources.mo)
## Run it locally.
diff --git a/deps.mk b/deps.mk
index 5318d53..a049265 100644
--- a/deps.mk
+++ b/deps.mk
@@ -6,13 +6,30 @@ mains.go = \
src/main.go \
tests/main.go \
-functional-tests/lib.go = \
+manpages.en.N.adoc = \
+ doc/hsts.en.0.adoc \
-functional-tests/main.go = \
+manpages.XX.N.adoc = \
+ doc/hsts.de.0.adoc \
+ doc/hsts.eo.0.adoc \
+ doc/hsts.es.0.adoc \
+ doc/hsts.fr.0.adoc \
+ doc/hsts.pt.0.adoc \
-fuzz-targets/lib.go = \
+sources.po = \
+ po/hsts/de.po \
+ po/hsts/eo.po \
+ po/hsts/es.po \
+ po/hsts/fr.po \
+ po/hsts/pt.po \
-fuzz-targets/main.go = \
+functional/lib.go = \
+
+functional/main.go = \
+
+fuzz/lib.go = \
+
+fuzz/main.go = \
benchmarks/lib.go = \
diff --git a/doc/hsts.en.0.adoc b/doc/hsts.en.0.adoc
new file mode 100644
index 0000000..3ce6659
--- /dev/null
+++ b/doc/hsts.en.0.adoc
@@ -0,0 +1,5 @@
+= hsts(0)
+
+== NAME
+
+hsts - .
diff --git a/mkdeps.sh b/mkdeps.sh
index 3ce3e05..ae6fffc 100755
--- a/mkdeps.sh
+++ b/mkdeps.sh
@@ -4,37 +4,46 @@ set -eu
export LANG=POSIX.UTF-8
-no_main() {
- grep -v '/main\.go$'
+libs() {
+ find src tests -name '*.go' |
+ grep -Ev '/(main|meta)\.go$' |
+ grep -Ev '/_cgo_(import|gotypes)\.go$' |
+ grep -Ev '\.cgo1\.go$'
}
-only_main() {
- grep '/main\.go$'
+mains() {
+ find src tests -name '*.go' | grep '/main\.go$'
}
-sources() {
- find src tests -name '*.go' | grep -v '^src/version\.go$'
+docs() {
+ find doc/*.en.*.adoc
}
-libs() {
- sources | no_main
+xdocs() {
+ for l in `find po/doc/*.po | xargs -I% basename % .po`; do
+ docs | sed 's|/\(.*\)\.en\.\(.*\)$|/\1.'"$l"'.\2|'
+ done
}
-mains() {
- sources | only_main
+pos() {
+ find po/ -name '*.po' | grep -Ev '^po/(doc|tests)/'
}
+
libs | varlist 'libs.go'
mains | varlist 'mains.go'
-
-find tests/functional/*/*.go | no_main | varlist 'functional-tests/lib.go'
-find tests/functional/*/main.go | varlist 'functional-tests/main.go'
-find tests/fuzz/*/*.go | no_main | varlist 'fuzz-targets/lib.go'
-find tests/fuzz/*/main.go | varlist 'fuzz-targets/main.go'
-find tests/benchmarks/*/*.go | no_main | varlist 'benchmarks/lib.go'
-find tests/benchmarks/*/main.go | varlist 'benchmarks/main.go'
-
-sources | sort | sed 's/^\(.*\)\.go$/\1.a:\t\1.go/'
-mains | sort | sed 's/^\(.*\)\.go$/\1.bin:\t\1.a/'
-mains | sort | sed 's/^\(.*\)\.go$/\1.bin-check:\t\1.bin/'
-mains | sort | sed 's|^\(.*\)/main\.go$|\1/main.a:\t\1/$(NAME).a|'
+docs | varlist 'manpages.en.N.adoc'
+xdocs | varlist 'manpages.XX.N.adoc'
+pos | varlist 'sources.po'
+
+find tests/functional/*/*.go -not -name main.go | varlist 'functional/lib.go'
+find tests/functional/*/main.go | varlist 'functional/main.go'
+find tests/fuzz/*/*.go -not -name main.go | varlist 'fuzz/lib.go'
+find tests/fuzz/*/main.go | varlist 'fuzz/main.go'
+find tests/benchmarks/*/*.go -not -name main.go | varlist 'benchmarks/lib.go'
+find tests/benchmarks/*/main.go | varlist 'benchmarks/main.go'
+
+{ libs; mains; } | sort | sed 's/^\(.*\)\.go$/\1.a:\t\1.go/'
+mains | sort | sed 's/^\(.*\)\.go$/\1.bin:\t\1.a/'
+mains | sort | sed 's/^\(.*\)\.go$/\1.bin-check:\t\1.bin/'
+mains | sort | sed 's|^\(.*\)/main\.go$|\1/main.a:\t\1/$(NAME).a|'
diff --git a/po/doc/de.po b/po/doc/de.po
new file mode 100644
index 0000000..c5756bf
--- /dev/null
+++ b/po/doc/de.po
@@ -0,0 +1,22 @@
+msgid ""
+msgstr ""
+"Language: de\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#. type: Title =
+#: doc/hsts.en.0.adoc:1
+#, no-wrap
+msgid "hsts(0)"
+msgstr ""
+
+#. type: Title ==
+#: doc/hsts.en.0.adoc:3
+#, no-wrap
+msgid "NAME"
+msgstr ""
+
+#. type: Plain text
+#: doc/hsts.en.0.adoc:5
+msgid "hsts - ."
+msgstr ""
diff --git a/po/doc/doc.pot b/po/doc/doc.pot
new file mode 100644
index 0000000..72fbddc
--- /dev/null
+++ b/po/doc/doc.pot
@@ -0,0 +1,21 @@
+msgid ""
+msgstr ""
+"Language: \n"
+"Content-Type: text/plain; charset=UTF-8\n"
+
+#. type: Title =
+#: doc/hsts.en.0.adoc:1
+#, no-wrap
+msgid "hsts(0)"
+msgstr ""
+
+#. type: Title ==
+#: doc/hsts.en.0.adoc:3
+#, no-wrap
+msgid "NAME"
+msgstr ""
+
+#. type: Plain text
+#: doc/hsts.en.0.adoc:5
+msgid "hsts - ."
+msgstr ""
diff --git a/po/doc/eo.po b/po/doc/eo.po
new file mode 100644
index 0000000..2eeb863
--- /dev/null
+++ b/po/doc/eo.po
@@ -0,0 +1,22 @@
+msgid ""
+msgstr ""
+"Language: eo\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#. type: Title =
+#: doc/hsts.en.0.adoc:1
+#, no-wrap
+msgid "hsts(0)"
+msgstr ""
+
+#. type: Title ==
+#: doc/hsts.en.0.adoc:3
+#, no-wrap
+msgid "NAME"
+msgstr ""
+
+#. type: Plain text
+#: doc/hsts.en.0.adoc:5
+msgid "hsts - ."
+msgstr ""
diff --git a/po/doc/es.po b/po/doc/es.po
new file mode 100644
index 0000000..34d2363
--- /dev/null
+++ b/po/doc/es.po
@@ -0,0 +1,22 @@
+msgid ""
+msgstr ""
+"Language: es\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#. type: Title =
+#: doc/hsts.en.0.adoc:1
+#, no-wrap
+msgid "hsts(0)"
+msgstr ""
+
+#. type: Title ==
+#: doc/hsts.en.0.adoc:3
+#, no-wrap
+msgid "NAME"
+msgstr ""
+
+#. type: Plain text
+#: doc/hsts.en.0.adoc:5
+msgid "hsts - ."
+msgstr ""
diff --git a/po/doc/fr.po b/po/doc/fr.po
new file mode 100644
index 0000000..8827527
--- /dev/null
+++ b/po/doc/fr.po
@@ -0,0 +1,22 @@
+msgid ""
+msgstr ""
+"Language: fr\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+
+#. type: Title =
+#: doc/hsts.en.0.adoc:1
+#, no-wrap
+msgid "hsts(0)"
+msgstr ""
+
+#. type: Title ==
+#: doc/hsts.en.0.adoc:3
+#, no-wrap
+msgid "NAME"
+msgstr ""
+
+#. type: Plain text
+#: doc/hsts.en.0.adoc:5
+msgid "hsts - ."
+msgstr ""
diff --git a/po/doc/note.txt b/po/doc/note.txt
new file mode 100644
index 0000000..45279a4
--- /dev/null
+++ b/po/doc/note.txt
@@ -0,0 +1,5 @@
+PO4A-HEADER: mode=eof
+
+
+
+// Generated from po4a(1).
diff --git a/po/doc/po4a.cfg b/po/doc/po4a.cfg
new file mode 100644
index 0000000..7a9e570
--- /dev/null
+++ b/po/doc/po4a.cfg
@@ -0,0 +1,5 @@
+[options] --keep 0 --master-charset UTF-8 --localized-charset UTF-8 --addendum-charset UTF-8
+
+[po_directory] po/doc
+
+[type: asciidoc] doc/hsts.en.0.adoc $lang:doc/hsts.$lang.0.adoc
diff --git a/po/doc/pt.po b/po/doc/pt.po
new file mode 100644
index 0000000..2e1a6c9
--- /dev/null
+++ b/po/doc/pt.po
@@ -0,0 +1,22 @@
+msgid ""
+msgstr ""
+"Language: pt\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#. type: Title =
+#: doc/hsts.en.0.adoc:1
+#, no-wrap
+msgid "hsts(0)"
+msgstr ""
+
+#. type: Title ==
+#: doc/hsts.en.0.adoc:3
+#, no-wrap
+msgid "NAME"
+msgstr ""
+
+#. type: Plain text
+#: doc/hsts.en.0.adoc:5
+msgid "hsts - ."
+msgstr ""
diff --git a/po/hsts/de.po b/po/hsts/de.po
new file mode 100644
index 0000000..587838f
--- /dev/null
+++ b/po/hsts/de.po
@@ -0,0 +1,10 @@
+msgid ""
+msgstr ""
+"Language: de\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: src/hsts.go:56
+#, c-format
+msgid "Usage: %s LISTEN.socket\n"
+msgstr ""
diff --git a/po/hsts/eo.po b/po/hsts/eo.po
new file mode 100644
index 0000000..2058f10
--- /dev/null
+++ b/po/hsts/eo.po
@@ -0,0 +1,10 @@
+msgid ""
+msgstr ""
+"Language: eo\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: src/hsts.go:56
+#, c-format
+msgid "Usage: %s LISTEN.socket\n"
+msgstr ""
diff --git a/po/hsts/es.po b/po/hsts/es.po
new file mode 100644
index 0000000..331dad8
--- /dev/null
+++ b/po/hsts/es.po
@@ -0,0 +1,10 @@
+msgid ""
+msgstr ""
+"Language: es\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: src/hsts.go:56
+#, c-format
+msgid "Usage: %s LISTEN.socket\n"
+msgstr ""
diff --git a/po/hsts/fr.po b/po/hsts/fr.po
new file mode 100644
index 0000000..c041147
--- /dev/null
+++ b/po/hsts/fr.po
@@ -0,0 +1,10 @@
+msgid ""
+msgstr ""
+"Language: fr\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+
+#: src/hsts.go:56
+#, c-format
+msgid "Usage: %s LISTEN.socket\n"
+msgstr ""
diff --git a/po/hsts/hsts.pot b/po/hsts/hsts.pot
new file mode 100644
index 0000000..814b6c6
--- /dev/null
+++ b/po/hsts/hsts.pot
@@ -0,0 +1,10 @@
+msgid ""
+msgstr ""
+"Language: \n"
+"Content-Type: text/plain; charset=UTF-8\n"
+
+#: src/hsts.go:56
+#, c-format
+msgid "Usage: %s LISTEN.socket\n"
+msgstr ""
+
diff --git a/po/hsts/po4a.cfg b/po/hsts/po4a.cfg
new file mode 100644
index 0000000..ce7ced6
--- /dev/null
+++ b/po/hsts/po4a.cfg
@@ -0,0 +1,3 @@
+[options] --keep 0 --master-charset UTF-8 --localized-charset UTF-8 --addendum-charset UTF-8
+
+[po_directory] po/hsts
diff --git a/po/hsts/pt.po b/po/hsts/pt.po
new file mode 100644
index 0000000..aced5ca
--- /dev/null
+++ b/po/hsts/pt.po
@@ -0,0 +1,10 @@
+msgid ""
+msgstr ""
+"Language: pt\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: src/hsts.go:56
+#, c-format
+msgid "Usage: %s LISTEN.socket\n"
+msgstr ""
diff --git a/src/hsts.go b/src/hsts.go
index 5f3cee5..93f76ca 100644
--- a/src/hsts.go
+++ b/src/hsts.go
@@ -9,6 +9,7 @@ import (
"uuid"
g "gobang"
+ gt "gotext"
)
@@ -52,7 +53,7 @@ func Main() {
g.Init("program", "hsts")
if len(os.Args) != 2 {
- fmt.Fprintf(os.Stderr, "Usage: %s LISTEN.socket\n", os.Args[0])
+ fmt.Fprintf(os.Stderr, gt.Gettext("Usage: %s LISTEN.socket\n"), os.Args[0])
os.Exit(2)
}