diff --git a/scripts/z-run b/scripts/z-run index 34d071a..e81c51c 100644 --- a/scripts/z-run +++ b/scripts/z-run @@ -129,7 +129,8 @@ exec -- "${ZRUN[@]}" ':: go / tool' \ build \ -v \ - -ldflags 'all=-s' \ + -tags 'netgo nobrotli' \ + -ldflags 'all=-s -extld=gcc -extldflags=-static' \ -gcflags 'all=-l=4' \ -o "${_outputs}/binaries/release/kawipiko-archiver" \ -- ./cmd/archiver.go \ diff --git a/sources/lib/archiver/compress-brotli-with.go b/sources/lib/archiver/compress-brotli-with.go new file mode 100644 index 0000000..f6be4c1 --- /dev/null +++ b/sources/lib/archiver/compress-brotli-with.go @@ -0,0 +1,31 @@ + +// +build !nobrotli + + +package archiver + + +import "bytes" + +import "github.com/google/brotli/go/cbrotli" + + + + +func CompressBrotli (_data []byte) ([]byte, string, error) { + + _buffer := & bytes.Buffer {} + + _encoder := cbrotli.NewWriter (_buffer, cbrotli.WriterOptions { Quality : 11, LGWin : 24}) + + if _, _error := _encoder.Write (_data); _error != nil { + return nil, "", _error + } + if _error := _encoder.Close (); _error != nil { + return nil, "", _error + } + + _data = _buffer.Bytes () + return _data, "br", nil +} + diff --git a/sources/lib/archiver/compress-brotli-without.go b/sources/lib/archiver/compress-brotli-without.go new file mode 100644 index 0000000..69f414c --- /dev/null +++ b/sources/lib/archiver/compress-brotli-without.go @@ -0,0 +1,17 @@ + +// +build nobrotli + + +package archiver + + +import "fmt" + + + + +func CompressBrotli (_data []byte) ([]byte, string, error) { + + return nil, "", fmt.Errorf ("[9252cf70] unsupported compression algorithm `%s`", "brotli") +} + diff --git a/sources/lib/archiver/compress.go b/sources/lib/archiver/compress.go index c0fb25c..d94cbe8 100644 --- a/sources/lib/archiver/compress.go +++ b/sources/lib/archiver/compress.go @@ -7,8 +7,6 @@ import "bytes" import "compress/gzip" import "fmt" -import "github.com/google/brotli/go/cbrotli" - @@ -50,21 +48,3 @@ func CompressGzip (_data []byte) ([]byte, string, error) { return _data, "gzip", nil } - -func CompressBrotli (_data []byte) ([]byte, string, error) { - - _buffer := & bytes.Buffer {} - - _encoder := cbrotli.NewWriter (_buffer, cbrotli.WriterOptions { Quality : 11, LGWin : 24}) - - if _, _error := _encoder.Write (_data); _error != nil { - return nil, "", _error - } - if _error := _encoder.Close (); _error != nil { - return nil, "", _error - } - - _data = _buffer.Bytes () - return _data, "br", nil -} -