PUBKEY-SSH.pub | 1 + PUBKEY-SSH.pub.asc | 7 +++++++ README | 3 +++ bin/meta4ra-hashes-detect | 2 ++ build | 3 ++- cmd/meta4ra/check.go | 15 +++++++++++++-- cmd/meta4ra/create.go | 11 ++++++++++- cmd/meta4ra/hash.go | 9 +++++++++ cmd/meta4ra/main.go | 6 ++++++ internal/common.go | 22 ++++++++++++++++++++++ makedist | 32 ++++++++++++++++++++++++++++++++ diff --git a/PUBKEY-SSH.pub b/PUBKEY-SSH.pub new file mode 100644 index 0000000000000000000000000000000000000000..26dc8fc0ebbe5f4d806be046e89b1bffc6989dd144e86ff2828d156588f9409b --- /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 0000000000000000000000000000000000000000..16a2b13b7d5250c78b7466dd2fa0db04035863aaf9cf830e3d7440ae6a1d6608 --- /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 2768568dcd3a04d68bfc499b0f30b8766457bc95ce46fa301c76ed4abd94e6e1..39fcbff4e733e17cc5cc902f244a5b01023b8b56f153efb52e9d1f25a219ac87 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 a4e4a8c9c68698f8803a2943c5dc9febc6894825b143e58edb6b8a71514124a4..d60ac31fcc2b0821a9dbad3d44f7ab60284761a795c5d4f2c361ea50f9cb84aa 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 d98da18b71e103ad97f31542dd26b2b2f6601c28af59f411099fc920bf1b6adc..30cdb88f83baab840543758df5af2f203dd0af822ad7b69f7779e4d0e9a977cb 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 88d070707282bcaf44f31edc7f37027267697d672ece747997652818699ced3f..2f31bb88624f285840ae4ecf491105524da880ec7a78df9a26f39ab70c96d628 100644 --- a/cmd/meta4ra/check.go +++ b/cmd/meta4ra/check.go @@ -50,6 +50,15 @@ `) } 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 @@ } } } 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 8f2cb2eb3d2d1442e4714a72661d60253421283f0e2f217988317a8fda05afbe..0641d87af53978d3882ca1c6561adf94fe96a9ef0ca15ad7b383ecc1e79c5934 100644 --- a/cmd/meta4ra/create.go +++ b/cmd/meta4ra/create.go @@ -46,10 +46,19 @@ "Do not include Generator field") 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 72e6182f7be637677b9f777efd46be02ab917356336de984091c14e5df3f3a6c..d85ad67e923c69f8e3b9ac5a09a32d475f30808ba4355f3c88fd36d08b02af59 100644 --- a/cmd/meta4ra/hash.go +++ b/cmd/meta4ra/hash.go @@ -40,6 +40,15 @@ `) } 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 e5d74e531550fbdc37d031f7462b959caf4cd5f92b095be1335a2e2ce7a72d80..b131944e665f5041205ee2783ef10d8f6223b3f4c79046befc9101415c6d0fa2 100644 --- a/cmd/meta4ra/main.go +++ b/cmd/meta4ra/main.go @@ -1,9 +1,15 @@ 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() { diff --git a/internal/common.go b/internal/common.go index 21d3faca35dcbbd2299bf6186cd605e505366a4c16192cf2d936a8e15bd91098..825a7fb629ed583a7666df2541cdee2ccb43b5f5c99e9026df6d2d39812ecef7 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 .` ) + +func Version() string { + return Generator + " built with " + runtime.Version() +} diff --git a/makedist b/makedist new file mode 100755 index 0000000000000000000000000000000000000000..b45db5054d67ee3a7a37415498b35b3a1015869dbd12650d38bd61593311061f --- /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