From: Sergey Matveev <stargrave@stargrave.org>
Date: Fri, 8 Mar 2024 16:58:49 +0000 (+0300)
Subject: Prepare for release
X-Git-Tag: v0.7.0^0
X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=93f0c7dfccc4277d61113115c7eb1aa7cb048413;p=meta4ra.git

Prepare for release
---

diff --git a/PUBKEY-SSH.pub b/PUBKEY-SSH.pub
new file mode 100644
index 0000000..49f6072
--- /dev/null
+++ b/PUBKEY-SSH.pub
@@ -0,0 +1 @@
+meta4ra@stargrave.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIUMcjpT5uw4pSYTic9SqFBrVWxwVl/50Yls0Hpm8Ql1
diff --git a/PUBKEY-SSH.pub.asc b/PUBKEY-SSH.pub.asc
new file mode 100644
index 0000000..fab5f07
--- /dev/null
+++ b/PUBKEY-SSH.pub.asc
@@ -0,0 +1,7 @@
+-----BEGIN PGP SIGNATURE-----
+
+iHUEABYKAB0WIQTbL/jtRAp+lJhvt3bSI36ECQhstwUCZetm/gAKCRDSI36ECQhs
+t31FAQD6t1/WffR40dHXm3hvb4UFAoZthv+lswJJOQdGgJ6ZfwD/Q5lXenxcEkHB
+E1/NtXT0tRuwi4b7MC0mDA9/TkCeRA0=
+=8ZfQ
+-----END PGP SIGNATURE-----
diff --git a/README b/README
index 15bc1a4..8f71194 100644
--- a/README
+++ b/README
@@ -13,3 +13,6 @@ algorithm on current system, whatever it is.
 
 meta4ra is copylefted free software: see the file COPYING for copying
 conditions. It should work on all POSIX-compatible systems.
+
+You can select desired fields by ordinary XML-related utulities:
+    xml sel -t -m "/_:metalink/_:file/_:url" -v . -nl data.meta4
diff --git a/bin/meta4ra-hashes-detect b/bin/meta4ra-hashes-detect
index 20d4815..1218ed6 100755
--- a/bin/meta4ra-hashes-detect
+++ b/bin/meta4ra-hashes-detect
@@ -1,4 +1,6 @@
 #!/bin/sh -e
+# Autodetect possible commandlines for various hashes. Example usage:
+# meta4ra-{create,check} -hashes "$(meta4ra-hashes-detect)" ...
 
 hw="hello world"
 hashes=""
diff --git a/build b/build
index 32381dd..9e81b1c 100755
--- a/build
+++ b/build
@@ -1,3 +1,4 @@
 #!/bin/sh -e
 
-exec go build -C cmd/meta4ra -ldflags=-s $@ -o ../../bin/meta4ra
+[ -d vendor ] && mod_vendor="-mod=vendor"
+exec go build -C cmd/meta4ra -ldflags=-s $mod_vendor $@ -o ../../bin/meta4ra
diff --git a/cmd/meta4ra/check.go b/cmd/meta4ra/check.go
index c030f8b..c53ccb9 100644
--- a/cmd/meta4ra/check.go
+++ b/cmd/meta4ra/check.go
@@ -50,6 +50,15 @@ and -extract-sig, then you can just specify an empty ("") FILE.
 	}
 	flag.Parse()
 
+	if *showVersion {
+		fmt.Println(meta4ra.Version())
+		return
+	}
+	if *showWarranty {
+		fmt.Println(meta4ra.Warranty)
+		return
+	}
+
 	data, err := os.ReadFile(*metaPath)
 	if err != nil {
 		log.Fatalln(err)
@@ -216,8 +225,10 @@ and -extract-sig, then you can just specify an empty ("") FILE.
 		}
 	}
 	if len(toCheck) != 0 {
-		fmt.Println("not all FILEs met")
-		bad = true
+		if _, ok := toCheck["."]; !(len(toCheck) == 1 && ok) {
+			fmt.Println("not all FILEs met")
+			bad = true
+		}
 	}
 	if bad {
 		os.Exit(1)
diff --git a/cmd/meta4ra/create.go b/cmd/meta4ra/create.go
index cfa7f4e..f7d17b0 100644
--- a/cmd/meta4ra/create.go
+++ b/cmd/meta4ra/create.go
@@ -46,11 +46,20 @@ func runCreate() {
 	torrent := flag.String("torrent", "", "Torrent URL")
 	flag.Usage = func() {
 		fmt.Fprintf(flag.CommandLine.Output(),
-			"Usage: %s [options] [URL ...] < DATA > XXX.meta4\n", os.Args[0])
+			"Usage: %s [options] [URL ...] < data > data.meta4\n", os.Args[0])
 		flag.PrintDefaults()
 	}
 	flag.Parse()
 
+	if *showVersion {
+		fmt.Println(meta4ra.Version())
+		return
+	}
+	if *showWarranty {
+		fmt.Println(meta4ra.Warranty)
+		return
+	}
+
 	if *fn == "" {
 		log.Fatalln("empty -fn")
 	}
diff --git a/cmd/meta4ra/hash.go b/cmd/meta4ra/hash.go
index 266aa61..3fb98f4 100644
--- a/cmd/meta4ra/hash.go
+++ b/cmd/meta4ra/hash.go
@@ -40,6 +40,15 @@ Only the first hash from -hashes will be used.
 	}
 	flag.Parse()
 
+	if *showVersion {
+		fmt.Println(meta4ra.Version())
+		return
+	}
+	if *showWarranty {
+		fmt.Println(meta4ra.Warranty)
+		return
+	}
+
 	hsh := *hashes
 	if i := strings.Index(hsh, ","); i != -1 {
 		hsh = hsh[:i]
diff --git a/cmd/meta4ra/main.go b/cmd/meta4ra/main.go
index 334ddc8..b0a5958 100644
--- a/cmd/meta4ra/main.go
+++ b/cmd/meta4ra/main.go
@@ -1,11 +1,17 @@
 package main
 
 import (
+	"flag"
 	"log"
 	"os"
 	"path"
 )
 
+var (
+	showVersion  = flag.Bool("version", false, "print version")
+	showWarranty = flag.Bool("warranty", false, "print warranty information")
+)
+
 func main() {
 	log.SetFlags(log.Lshortfile)
 	switch path.Base(os.Args[0]) {
diff --git a/internal/common.go b/internal/common.go
index 0418574..fc016d6 100644
--- a/internal/common.go
+++ b/internal/common.go
@@ -16,9 +16,31 @@
 // Metalink 4.0 utilities
 package internal
 
+import (
+	"runtime"
+)
+
 const (
 	Generator       = "meta4ra/0.7.0"
 	SigMediaTypePGP = "application/pgp-signature"
 	SigMediaTypeSSH = "application/ssh-signature"
 	BufLen          = 1 << 20
+
+	Warranty = `Copyright (C) 2021-2024 Sergey Matveev
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, version 3 of the License.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.`
 )
+
+func Version() string {
+	return Generator + " built with " + runtime.Version()
+}
diff --git a/makedist b/makedist
new file mode 100755
index 0000000..a4fc796
--- /dev/null
+++ b/makedist
@@ -0,0 +1,32 @@
+#!/bin/sh -ex
+
+cur=$(pwd)
+tmp=$(mktemp -d)
+release=$1
+[ -n "$release" ]
+
+git clone . $tmp/meta4ra-$release
+cd $tmp/meta4ra-$release
+git checkout v$release
+
+echo v$release > VERSION
+
+go mod vendor
+find . -name .gitignore -delete
+
+rm -rf .git makedist
+find . -type d -exec chmod 755 {} +
+find . -type f -exec chmod 644 {} +
+chmod +x bin/meta4ra-hashes-detect contrib/mk-meta4 build build-with-thirdparty
+
+cd ..
+tar cvf meta4ra-"$release".tar --uid=0 --gid=0 --numeric-owner meta4ra-"$release"
+zstd -19 -v meta4ra-"$release".tar
+tarball=meta4ra-"$release".tar.zst
+ssh-keygen -Y sign -f ~/.ssh/sign/meta4ra@stargrave.org -n file $tarball
+meta4ra-create -fn "$tarball" -mtime "$tarball" \
+    -sig-ssh "$tarball".sig \
+    http://www.meta4ra.stargrave.org/download/"$tarball" \
+    http://y.www.meta4ra.stargrave.org/download/"$tarball" < "$tarball" > "$tarball".meta4
+
+mv $tmp/$tarball $tarball.meta4 $cur/www/download