aerc: fix build when GOFLAGS contains spaces
Due to multiple levels of nested quoting, it is not possible to escape
spaces and/or quotes from GOFLAGS and pass the value to go build
-ldflags to set a compile time variable.
Encode main.Flags in base64 and decode it when reading it.
Fixes: d7e6dc3649
("aerc: add build info to version string")
Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
This commit is contained in:
parent
3ba8a3b750
commit
8f8dee8303
2 changed files with 5 additions and 2 deletions
3
Makefile
3
Makefile
|
@ -11,10 +11,11 @@ MANDIR?=$(PREFIX)/share/man
|
||||||
GO?=go
|
GO?=go
|
||||||
GOFLAGS?=
|
GOFLAGS?=
|
||||||
BUILD_OPTS?=-trimpath
|
BUILD_OPTS?=-trimpath
|
||||||
|
flags!=echo -- $(GOFLAGS) | base64 | tr -d '\n'
|
||||||
# ignore environment variable
|
# ignore environment variable
|
||||||
GO_LDFLAGS:=
|
GO_LDFLAGS:=
|
||||||
GO_LDFLAGS+=-X main.Version=$(VERSION)
|
GO_LDFLAGS+=-X main.Version=$(VERSION)
|
||||||
GO_LDFLAGS+=-X main.Flags=$(GOFLAGS)
|
GO_LDFLAGS+=-X main.Flags=$(flags)
|
||||||
GO_LDFLAGS+=-X git.sr.ht/~rjarry/aerc/config.shareDir=$(SHAREDIR)
|
GO_LDFLAGS+=-X git.sr.ht/~rjarry/aerc/config.shareDir=$(SHAREDIR)
|
||||||
GO_LDFLAGS+=$(GO_EXTRA_LDFLAGS)
|
GO_LDFLAGS+=$(GO_EXTRA_LDFLAGS)
|
||||||
|
|
||||||
|
|
4
aerc.go
4
aerc.go
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"encoding/base64"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
@ -95,7 +96,8 @@ var Flags string
|
||||||
|
|
||||||
func buildInfo() string {
|
func buildInfo() string {
|
||||||
info := Version
|
info := Version
|
||||||
if strings.Contains(Flags, "notmuch") {
|
flags, _ := base64.StdEncoding.DecodeString(Flags)
|
||||||
|
if strings.Contains(string(flags), "notmuch") {
|
||||||
info += " +notmuch"
|
info += " +notmuch"
|
||||||
}
|
}
|
||||||
info += fmt.Sprintf(" (%s %s %s)",
|
info += fmt.Sprintf(" (%s %s %s)",
|
||||||
|
|
Loading…
Reference in a new issue