From 908fa4a8d8b3cf3b1418111b66f9acdcb7191ed2f6f62df6031c5b7ccccd946b Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Tue, 23 Jul 2024 10:36:54 +0300 Subject: [PATCH] Automatically determine module's name by go.mod --- USAGE | 12 ++++++------ list-vers | 4 +--- mk-htmls | 3 +-- mk-mod-sig | 12 ++++++++++++ mk-mods | 5 ++--- 5 files changed, 22 insertions(+), 14 deletions(-) create mode 100755 mk-mod-sig diff --git a/USAGE b/USAGE index e51d886..d2ce8d0 100644 --- 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 diff --git a/list-vers b/list-vers index e551e8a..b25f0c3 100755 --- 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 diff --git a/mk-htmls b/mk-htmls index fd763aa..1ef40fa 100755 --- 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 index 0000000..136e04b --- /dev/null +++ b/mk-mod-sig @@ -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 23aaff2..f6cee53 100755 --- 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 -- 2.48.1