From 9cc4965ed89fa1d70cfc3739df2582b7fc53bb08 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Tue, 13 Aug 2024 21:46:14 -0400 Subject: [PATCH] Bump: github.com/rwinkhart/libmutton PRE-TAG => v0.2.1; add script for generating release binaries --- README.md | 6 +++--- go.mod | 4 ++-- go.sum | 8 ++++---- packaging/main.sh | 8 ++++++-- packaging/{ => resources}/pkgbuild-git-stable.sh | 2 +- packaging/resources/release-binaries.sh | 11 +++++++++++ src/cli/1globals.go | 3 ++- src/cli/add.go | 2 +- src/cli/init.go | 8 ++++---- src/cli/utilitiesMisc.go | 2 +- 10 files changed, 35 insertions(+), 19 deletions(-) rename packaging/{ => resources}/pkgbuild-git-stable.sh (97%) create mode 100644 packaging/resources/release-binaries.sh diff --git a/README.md b/README.md index 9a286c1..5055d33 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,9 @@ After installing, please review the [usage guide](https://github.com/rwinkhart/M # Roadmap #### Release v0.2.1 -- [ ] libmutton v0.2.1 - - [ ] Only run getSSHClient once to prevent being asked for keyfile password multiple times - - [ ] Ensure all config files and entry files are created with 0600 permissions +- [x] libmutton v0.2.1 + - [x] Only run getSSHClient once to prevent being asked for keyfile password multiple times + - [x] Ensure all config files and entry files are created with 0600 permissions - [x] Add fail-specific error codes - [x] Document in man page - [x] Split into separate repos diff --git a/go.mod b/go.mod index 89d26d6..418483b 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.22.6 require ( github.com/charmbracelet/glamour v0.7.0 - github.com/rwinkhart/libmutton v0.0.0-20240808213918-f5e5cd31bb85 + github.com/rwinkhart/libmutton v0.2.1 golang.org/x/term v0.23.0 ) @@ -32,6 +32,6 @@ require ( github.com/yuin/goldmark-emoji v1.0.3 // indirect golang.org/x/crypto v0.26.0 // indirect golang.org/x/net v0.28.0 // indirect - golang.org/x/sys v0.23.0 // indirect + golang.org/x/sys v0.24.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect ) diff --git a/go.sum b/go.sum index c857fdd..2964f7a 100644 --- a/go.sum +++ b/go.sum @@ -52,8 +52,8 @@ github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= -github.com/rwinkhart/libmutton v0.0.0-20240808213918-f5e5cd31bb85 h1:j3Xj6ZVJGwqCM6UHhCiX0WlnoSlDMjM9ZbAylhko65g= -github.com/rwinkhart/libmutton v0.0.0-20240808213918-f5e5cd31bb85/go.mod h1:treJ/J2D6+LuDQQ435Jg3fsXRHlBnoKlMYExo3VzUKc= +github.com/rwinkhart/libmutton v0.2.1 h1:J6tRCOJ22D3r0At7c1PnU5eHQkxxtrtue5b5lu/90Qw= +github.com/rwinkhart/libmutton v0.2.1/go.mod h1:W4xYquN2Hz5rNyaaIUZCMTLvTNcAx804f1Y4vaUBmiw= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= @@ -88,8 +88,8 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= -golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= +golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= diff --git a/packaging/main.sh b/packaging/main.sh index 7358485..789c5da 100755 --- a/packaging/main.sh +++ b/packaging/main.sh @@ -18,11 +18,15 @@ fi mkdir -p ./1output case "$1" in + release-binaries) + . ./resources/release-binaries.sh + create_release_binaries + ;; pkgbuild-git-stable) - . ./pkgbuild-git-stable.sh + . ./resources/pkgbuild-git-stable.sh create_pkgbuild_git_stable ;; *) - printf '\nusage: package.sh [target] \n\ntargets: pkgbuild-git-stable\n\n' + printf '\nusage: package.sh [target] \n\ntargets: release-binaries pkgbuild-git-stable\n\n' ;; esac diff --git a/packaging/pkgbuild-git-stable.sh b/packaging/resources/pkgbuild-git-stable.sh similarity index 97% rename from packaging/pkgbuild-git-stable.sh rename to packaging/resources/pkgbuild-git-stable.sh index 619f884..ad5d5ec 100644 --- a/packaging/pkgbuild-git-stable.sh +++ b/packaging/resources/pkgbuild-git-stable.sh @@ -1,7 +1,7 @@ #!/bin/sh create_pkgbuild_git_stable() { - printf '\ngenerating PKGBUILD...\n' + printf '\nGenerating PKGBUILD...\n' local source="git+https://github.com/rwinkhart/MUTN.git#tag=v\${pkgver}" printf "# Maintainer: Randall Winkhart pkgname=mutn diff --git a/packaging/resources/release-binaries.sh b/packaging/resources/release-binaries.sh new file mode 100644 index 0000000..50ae49a --- /dev/null +++ b/packaging/resources/release-binaries.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +create_release_binaries() { + printf '\nGenerating release binaries...\n' + cd .. + GOOS=linux CGO_ENABLED=0 GOAMD64=v1 go build -o ./packaging/1output/mutn-linux-x86_64_v1 -ldflags="-s -w" -trimpath ./mutn.go + GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -o ./packaging/1output/mutn-linux-aarch64 -ldflags="-s -w" -trimpath ./mutn.go + GOOS=windows CGO_ENABLED=0 GOAMD64=v1 go build -o ./packaging/1output/mutn-windows-x86_64_v1.exe -ldflags="-s -w" -trimpath ./mutn.go + GOOS=windows GOARCH=arm64 CGO_ENABLED=0 go build -o ./packaging/1output/mutn-windows-aarch64.exe -ldflags="-s -w" -trimpath ./mutn.go + cd ./packaging +} diff --git a/src/cli/1globals.go b/src/cli/1globals.go index c5625da..c1883d8 100644 --- a/src/cli/1globals.go +++ b/src/cli/1globals.go @@ -11,7 +11,8 @@ var ( ) const ( + MUTNVersion = "0.2.B" // untagged releases feature a letter suffix corresponding to the eventual release version, e.g "0.2.A" -> "0.2.0", "0.2.B" -> "0.2.1" + AnsiBold = "\033[1m" ansiBlackOnWhite = "\033[38;5;0;48;5;15m" - MUTNVersion = "0.2.B" // untagged releases feature a letter suffix corresponding to the eventual release version, e.g "0.2.A" -> "0.2.0", "0.2.B" -> "0.2.1" ) diff --git a/src/cli/add.go b/src/cli/add.go index 88b8d99..72baa8f 100644 --- a/src/cli/add.go +++ b/src/cli/add.go @@ -15,7 +15,7 @@ func AddEntry(targetLocation string, hideSecrets bool, entryType uint8) { _, isAccessible := core.TargetIsFile(targetLocation, false, 0) if isAccessible { fmt.Println(core.AnsiError + "Target location already exists" + core.AnsiReset) - os.Exit(106) + os.Exit(core.ErrorTargetExists) } // ensure target containing directory exists and is a directory (not a file) diff --git a/src/cli/init.go b/src/cli/init.go index 7d8f996..446d850 100644 --- a/src/cli/init.go +++ b/src/cli/init.go @@ -22,7 +22,7 @@ func TempInitCli() { gpgIDInt := inputMenuGen("Select GPG key:", uidSlice) if gpgIDInt == 0 { fmt.Println(core.AnsiError + "No GPG keys found - please generate one" + core.AnsiReset) - os.Exit(105) + os.Exit(core.ErrorTargetNotFound) } gpgID = uidSlice[gpgIDInt-1] } @@ -54,13 +54,13 @@ func TempInitCli() { sshKeyProtected := inputBinary("Is the identity file password-protected?") // initialize libmutton directories - core.DirInit(false) + oldDeviceID := core.DirInit(false) // write config file (temporarily assigns sshEntryRoot and sshIsWindows to null to pass initial device ID registration) - core.WriteConfig([][3]string{{"MUTN", "textEditor", textEditor}, {"LIBMUTTON", "gpgID", gpgID}, {"LIBMUTTON", "sshUser", sshUser}, {"LIBMUTTON", "sshIP", sshIP}, {"LIBMUTTON", "sshPort", sshPort}, {"LIBMUTTON", "sshKey", sshKey}, {"LIBMUTTON", "sshKeyProtected", strconv.FormatBool(sshKeyProtected)}, {"LIBMUTTON", "sshEntryRoot", "null"}, {"LIBMUTTON", "sshIsWindows", "null"}}, false) + core.WriteConfig([][3]string{{"MUTN", "textEditor", textEditor}, {"LIBMUTTON", "gpgID", gpgID}, {"LIBMUTTON", "sshUser", sshUser}, {"LIBMUTTON", "sshIP", sshIP}, {"LIBMUTTON", "sshPort", sshPort}, {"LIBMUTTON", "sshKey", sshKey}, {"LIBMUTTON", "sshKeyProtected", strconv.FormatBool(sshKeyProtected)}, {"LIBMUTTON", "sshEntryRoot", "null"}, {"LIBMUTTON", "sshIsWindows", "false"}}, false) // generate and register device ID - sshEntryRoot, sshIsWindows := sync.DeviceIDGen() + sshEntryRoot, sshIsWindows := sync.DeviceIDGen(oldDeviceID) // update config file with sshEntryRoot and sshIsWindows core.WriteConfig([][3]string{{"LIBMUTTON", "sshEntryRoot", sshEntryRoot}, {"LIBMUTTON", "sshIsWindows", sshIsWindows}}, true) diff --git a/src/cli/utilitiesMisc.go b/src/cli/utilitiesMisc.go index b11cd31..e6bd278 100644 --- a/src/cli/utilitiesMisc.go +++ b/src/cli/utilitiesMisc.go @@ -74,7 +74,7 @@ func writeEntryCLI(targetLocation string, unencryptedEntry []string, hideSecrets EntryReader(unencryptedEntry, hideSecrets, true) } else { fmt.Println(core.AnsiError + "No data supplied for entry" + core.AnsiReset) - os.Exit(105) + os.Exit(core.ErrorTargetNotFound) } }