]> Cypherpunks repositories - prepro.git/commitdiff
Automatically determine module's name by go.mod
authorSergey Matveev <stargrave@stargrave.org>
Tue, 23 Jul 2024 07:36:54 +0000 (10:36 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Tue, 23 Jul 2024 07:42:04 +0000 (10:42 +0300)
USAGE
list-vers
mk-htmls
mk-mod-sig [new file with mode: 0755]
mk-mods

diff --git a/USAGE b/USAGE
index e51d88618e3d71a7a961944912345634591047616bede490849912e790022a0e..d2ce8d0b7b67390278775f6760974df00edd8080546c0c4ff570589931cc75f3 100644 (file)
--- a/USAGE
+++ b/USAGE
@@ -3,7 +3,7 @@ current directory:
     mk-mod VCS-URL VCS-PATH MODULE-NAME VERSION [SIGNKEY]
 Only Git VCS is supported. Git tag's name must be equal to VERSION.
 mk-mods iterates through all tags:
-    mk-mods VCS-URL VCS-PATH MODULE-BASE-NAME [SIGNKEY]
+    mk-mods VCS-URL VCS-PATH [SIGNKEY]
 SIGNKEY is optional path to OpenSSH signing key, that will sign the
 .ziphash file.
 
@@ -13,17 +13,17 @@ and creates corresponding "list" files.
 mk-html creates go-import-compatible static files:
     mk-html VCS-WEB-URL MODULE-NAME
 mk-htmls iterates through all tags:
-    mk-htmls VCS-WEB-URL VCS-PATH MODULE-BASE-NAME
+    mk-htmls VCS-WEB-URL VCS-PATH
 
 For example:
     mkdir proxy
     cd proxy
-    mk-mods https://git.cypherpunks.ru/balloon.git ~w/balloon go.cypherpunks.ru/balloon
-    mk-mods https://git.cypherpunks.ru/gotai64n.git ~w/gotai64n go.cypherpunks.ru/balloon/tai64n
+    mk-mods https://git.cypherpunks.ru/balloon.git ~w/balloon
+    mk-mods https://git.cypherpunks.ru/gotai64n.git ~w/gotai64n
     mk-list
     cd ..
 
     mkdir html
     cd html
-    mk-htmls "http://www.git.cypherpunks.ru/?p=balloon.git" ~w/balloon go.cypherpunks.ru/balloon
-    mk-htmls "http://www.git.cypherpunks.ru/?p=gotai64n.git" ~w/gotai64n go.cypherpunks.ru/balloon/tai64n
+    mk-htmls "http://www.git.cypherpunks.ru/?p=balloon.git" ~w/balloon
+    mk-htmls "http://www.git.cypherpunks.ru/?p=gotai64n.git" ~w/gotai64n
index e551e8ad075cf3098d663dde58f60741ed3e07b39b005cc94f5d8ce475d00998..b25f0c3ec4ee9d5f275d2383cbd318ca214ae6e9753a8b8a735c95f56d37b7a4 100755 (executable)
--- a/list-vers
+++ b/list-vers
@@ -2,13 +2,11 @@
 
 setopt ERR_EXIT
 vcs=$1
-mod=$2
 cd $vcs
 git tag | while read version ; do
     [[ $version =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]] || continue
     cols=(${(s:.:)version})
     v=${cols[1]}
-    modname=$mod
-    [[ $v == v0 || $v == v1 ]] || modname=${modname}/$v
+    modname=$(git archive $version | tar xfO - go.mod | sed -n "s/^module //p")
     print $modname $version
 done
index fd763aa56ee339332ee080d899953c1664e1f6ee235c75cb742dc65bfb5bd511..1ef40fa4936a632856e9b9580547cf38de15fd7f9cbdf1a9079045800ac4186c 100755 (executable)
--- a/mk-htmls
+++ b/mk-htmls
@@ -4,8 +4,7 @@ setopt ERR_EXIT
 root=$0:h:a
 vcsurl=$1
 vcspath=$2
-modbase=$3
 
-$root/list-vers $vcspath $modbase | while IFS=" " read modname version ; do
+$root/list-vers $vcspath | while IFS=" " read modname version ; do
     $root/mk-html $vcsurl $modname
 done
diff --git a/mk-mod-sig b/mk-mod-sig
new file mode 100755 (executable)
index 0000000..136e04b
--- /dev/null
@@ -0,0 +1,12 @@
+#!/usr/bin/env zsh
+
+setopt ERR_EXIT
+
+modname=$1
+version=$2
+signkey=$3
+
+cd $modname/@v
+[[ ! -s $version.ziphash.sig ]] || exit 0
+ssh-keygen -Y sign -f $signkey -n file $version.ziphash
+touch -r $version.ziphash $version.ziphash.sig
diff --git a/mk-mods b/mk-mods
index 23aaff2009d466da8e22cc20cc8abc4006b136cc8edee2c5e441f5e43ce6b3f7..f6cee53e8fc8832fe8ee66ec52f5f8c9d1a5a7b3d4fc15ab9fa6b9d725429043 100755 (executable)
--- a/mk-mods
+++ b/mk-mods
@@ -4,10 +4,9 @@ setopt ERR_EXIT
 root=$0:h:a
 vcsurl=$1
 vcspath=$2
-modbase=$3
-signkey=$4
+signkey=$3
 
-$root/list-vers $vcspath $modbase | while IFS=" " read modname version ; do
+$root/list-vers $vcspath | while IFS=" " read modname version ; do
     $root/mk-mod $vcsurl $vcspath $modname $version
     $root/mk-mod-sig $modname $version $signkey
 done