From c889c90c5b233b235250ff953c86cce1ca08640f Mon Sep 17 00:00:00 2001 From: Ciprian Dorin Craciun Date: Fri, 2 Sep 2022 15:27:11 +0300 Subject: [PATCH] [sources] Add support for `--sources-md5` and `--sources-cpio` flags. --- sources/cmd/archiver/archiver.go | 10 +++++++++- sources/cmd/server/server.go | 10 +++++++++- sources/cmd/version/version.go | 24 +++++++++++++++++++++--- sources/cmd/wrapper.go | 13 ++++++++++++- 4 files changed, 51 insertions(+), 6 deletions(-) diff --git a/sources/cmd/archiver/archiver.go b/sources/cmd/archiver/archiver.go index 62516f5..85ca202 100644 --- a/sources/cmd/archiver/archiver.go +++ b/sources/cmd/archiver/archiver.go @@ -1258,7 +1258,15 @@ func Main () () { switch os.Args[1] { case "version", "--version", "-v" : - version.Main ("kawipiko-archiver") + version.Main ("kawipiko-archiver", "version") + return + + case "--sources-md5" : + version.Main ("kawipiko-archiver", "sources.md5") + return + + case "--sources-cpio" : + version.Main ("kawipiko-archiver", "sources.cpio") return case "--help", "-h" : diff --git a/sources/cmd/server/server.go b/sources/cmd/server/server.go index 705dfe8..a59588b 100644 --- a/sources/cmd/server/server.go +++ b/sources/cmd/server/server.go @@ -700,7 +700,15 @@ func Main () () { switch os.Args[1] { case "version", "--version", "-v" : - version.Main ("kawipiko-server") + version.Main ("kawipiko-server", "version") + return + + case "--sources-md5" : + version.Main ("kawipiko-server", "sources.md5") + return + + case "--sources-cpio" : + version.Main ("kawipiko-server", "sources.cpio") return case "--help", "-h" : diff --git a/sources/cmd/version/version.go b/sources/cmd/version/version.go index ff28cc0..57394e7 100644 --- a/sources/cmd/version/version.go +++ b/sources/cmd/version/version.go @@ -51,9 +51,27 @@ func Version (_executableName string, _executable string, _stream io.Writer) (er -func Main (_executableName string) () { - if _error := Version (_executableName, "", os.Stdout); _error != nil { - AbortError (_error, "[74bfa815] unexpected error!") +func Main (_executableName string, _special string) () { + + switch _special { + + case "version" : + if _error := Version (_executableName, "", os.Stdout); _error != nil { + AbortError (_error, "[74bfa815] unexpected error!") + } + + case "sources.md5" : + if _, _error := os.Stdout.Write (StringToBytes (BuildSourcesMd5)); _error != nil { + AbortError (_error, "[c8f6b6c9] unexpected error!") + } + + case "sources.cpio" : + if _, _error := os.Stdout.Write (BuildSourcesCpioGz); _error != nil { + AbortError (_error, "[292d8865] unexpected error!") + } + + default : + panic ("[65a6f35f]") } } diff --git a/sources/cmd/wrapper.go b/sources/cmd/wrapper.go index 11c1f90..c2032ab 100644 --- a/sources/cmd/wrapper.go +++ b/sources/cmd/wrapper.go @@ -23,13 +23,24 @@ func main () () { switch _command { case "version", "--version", "-v" : - version.Main ("kawipiko-wrapper") + version.Main ("kawipiko-wrapper", "version") + return + + case "--sources-md5" : + version.Main ("kawipiko-wrapper", "sources.md5") + return + + case "--sources-cpio" : + version.Main ("kawipiko-wrapper", "sources.cpio") + return case "server" : server.Main () + return case "archiver" : archiver.Main () + return default : fmt.Fprintf (os.Stderr, "[!!] [44887671] unknown command: `%s`; aborting!\n", _command)