diff --git a/peirates.go b/peirates.go index 023e8b1..d808329 100644 --- a/peirates.go +++ b/peirates.go @@ -27,7 +27,7 @@ var UseAuthCanI bool = true // Main starts Peirates[] func Main() { // Peirates version string - var version = "1.1.22a" + var version = "1.1.22b" var err error diff --git a/scripts/build.sh b/scripts/build.sh index 6b3be22..343991f 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -5,7 +5,10 @@ # v0.2 - 08 May 2023 - Minor tweaks echo "Building for Linux on AMD64..." -GOOS=linux GOARCH=amd64 go build -v -ldflags="-s -w" $(realpath ../cmd/peirates) +# For static build, uncomment the below line and comment the one below it. +GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" $(realpath ../cmd/peirates) +#GOOS=linux GOARCH=amd64 go build -tags netgo,osusergo -a --ldflags '-extldflags "-static"' $(realpath ../cmd/peirates) + exit_code=$? if [ $exit_code -eq 0 ] ; then diff --git a/scripts/dist.sh b/scripts/dist.sh index 0e403da..f28d43d 100755 --- a/scripts/dist.sh +++ b/scripts/dist.sh @@ -22,6 +22,7 @@ function usage() { echo "-r Build for arm64" echo "-t Build for 386" echo "-x Build all architectures" + echo "-s Build statically-linked" } function compress() { @@ -30,21 +31,15 @@ function compress() { rmdir peirates-${OS}-${ARCH} } -function build-dynamic() { +function build() { echo "Building for arch: ${ARCH}" - GOOS=${OS} GOARCH=${ARCH} go build -ldflags="-s -w" $(realpath ../cmd/peirates) - if [ ! -d peirates-${OS}-${ARCH} ] ; then - mkdir peirates-${OS}-${ARCH} - fi - mv peirates peirates-${OS}-${ARCH} - if [ $COMPRESS == "yes" ] ; then - compress ${ARCH} + + if [ $STATIC == "static" ] ; then + GOOS=${OS} GOARCH=${ARCH} go build -tags netgo,osusergo --ldflags '-extldflags "-static"' $(realpath ../cmd/peirates) + else + GOOS=${OS} GOARCH=${ARCH} go build -ldflags="-s -w" $(realpath ../cmd/peirates) fi -} -function build() { - echo "Building for arch: ${ARCH}" - GOOS=${OS} GOARCH=${ARCH} go build -ldflags="-s -w" $(realpath ../cmd/peirates) if [ ! -d peirates-${OS}-${ARCH} ] ; then mkdir peirates-${OS}-${ARCH} fi @@ -63,11 +58,14 @@ function main() { for xx in ${ARCHITECTURES[@]}; do ARCH="${xx}" + #build-dynamic ${ARCH} build ${ARCH} done } -while getopts "haCmrtx" option; do +STATIC="dynamic" + +while getopts "haCmrstx" option; do case $option in h) usage @@ -85,6 +83,9 @@ while getopts "haCmrtx" option; do r) ARCHITECTURES=( "arm64" ) ;; + s) + STATIC="static" + ;; t) ARCHITECTURES=( "386" ) ;;