diff --git a/go.mod b/go.mod index bd7ce43..aeee0c9 100644 --- a/go.mod +++ b/go.mod @@ -3,11 +3,11 @@ module github.com/puellanivis/breton go 1.16 require ( - github.com/aws/aws-sdk-go v1.40.27 + github.com/aws/aws-sdk-go v1.44.240 github.com/pkg/errors v0.9.1 - github.com/pkg/sftp v1.13.2 - github.com/prometheus/client_golang v1.11.0 - golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 - golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d - golang.org/x/text v0.3.7 + github.com/pkg/sftp v1.13.5 + github.com/prometheus/client_golang v1.14.0 + golang.org/x/crypto v0.8.0 + golang.org/x/net v0.9.0 + golang.org/x/text v0.9.0 ) diff --git a/masher/mash.sh b/masher/mash.sh index ad9ef59..36982b0 100755 --- a/masher/mash.sh +++ b/masher/mash.sh @@ -1,5 +1,8 @@ #!/bin/bash +ARCH="amd64" +ARCH_DIR="x86_64" + while [[ $# -gt 0 ]]; do key="$1" val="${key#*=}" @@ -21,6 +24,10 @@ while [[ $# -gt 0 ]]; do export GOPRIVATE="$val" ;; + --arm64) + ARCH="arm64" + ARCH_DIR="arm64" + ;; --linux) LINUX="true" ;; @@ -210,42 +217,42 @@ if [[ -r ./.gitignore ]]; then fi if [[ $LINUX == "true" ]]; then - OUT="bin/linux.x86_64" + OUT="bin/linux.${ARCH_DIR}" echo "Compiling ${OUT}/${PROJECT}" [ -d "$OUT" ] || mkdir -p $OUT || exit 1 - GOOS=linux GOARCH=amd64 go build -o "${OUT}/${PROJECT}" "${LDFLAGS}" || exit 1 + GOOS=linux GOARCH=$ARCH go build -o "${OUT}/${PROJECT}" "${LDFLAGS}" || exit 1 [[ ( ${DEB} != "false" ) && ( -d debian ) ]] && DEB="true" fi if [[ $DARWIN == "true" ]]; then - OUT="bin/darwin.x86_64" + OUT="bin/darwin.${ARCH_DIR}" echo "Compiling ${OUT}/${PROJECT}" [ -d "$OUT" ] || mkdir -p $OUT || exit 1 - GOOS=darwin GOARCH=amd64 go build -o "${OUT}/${PROJECT}" "${LDFLAGS}" || exit 1 + GOOS=darwin GOARCH=$ARCH go build -o "${OUT}/${PROJECT}" "${LDFLAGS}" || exit 1 fi if [[ $OPENBSD == "true" ]]; then - OUT="bin/openbsd.x86_64" + OUT="bin/openbsd.${ARCH_DIR}" echo "Compiling ${OUT}/${PROJECT}" [ -d "$OUT" ] || mkdir -p $OUT || exit 1 - GOOS=openbsd GOARCH=amd64 go build -o "${OUT}/${PROJECT}" "${LDFLAGS}" || exit 1 + GOOS=openbsd GOARCH=$ARCH go build -o "${OUT}/${PROJECT}" "${LDFLAGS}" || exit 1 fi if [[ $WINDOWS == "true" ]]; then - OUT="bin/windows.x86_64" + OUT="bin/windows.${ARCH_DIR}" echo "Compiling ${OUT}/${PROJECT}.exe" [ -d "$OUT" ] || mkdir -p $OUT || exit 1 - GOOS=windows GOARCH=amd64 go build -o "${OUT}/${PROJECT}.exe" "${LDFLAGS}" || exit 1 + GOOS=windows GOARCH=$ARCH go build -o "${OUT}/${PROJECT}.exe" "${LDFLAGS}" || exit 1 fi -if [[ ( $DEB == "true" ) && ( -x bin/linux.x86_64/${PROJECT} ) ]]; then +if [[ ( $DEB == "true" ) && ( -x bin/linux.${ARCH_DIR}/${PROJECT} ) ]]; then [ -d debian ] || mkdir debian echo "Building debian package..." VERSION="${BUILDSTAMP}" - BIN_VERSION="$( ./bin/linux.x86_64/${PROJECT} --version )" + BIN_VERSION="$( ./bin/linux.${ARCH_DIR}/${PROJECT} --version )" [[ -n $BIN_VERSION ]] && echo "BIN_VERSION=\"$BIN_VERSION\"" case "${BIN_VERSION}" in *\ v*) @@ -254,7 +261,6 @@ if [[ ( $DEB == "true" ) && ( -x bin/linux.x86_64/${PROJECT} ) ]]; then ;; esac echo "VERSION=${VERSION}" - ARCH="amd64" # TODO(puellanivis): this shouldn’t be baked in, but it’s already baked in all over, already. if [[ -r ./.gitignore ]]; then grep -qFx -e "build" ./.gitignore || echo "build" >> ./.gitignore @@ -354,7 +360,7 @@ EOF # install binary install -d build/usr/bin - install -m755 "bin/linux.x86_64/${PROJECT}" "build/usr/bin/${PROJECT}" + install -m755 "bin/linux.${ARCH_DIR}/${PROJECT}" "build/usr/bin/${PROJECT}" if [[ ( -n ${DEB_PACKAGE} ) && ( -n ${VERSION} ) && ( -n ${ARCH} ) ]]; then DEB_FILE="${DEB_PACKAGE}_${VERSION}_${ARCH}.deb" diff --git a/masher/masher b/masher/masher index 4fdfebe..a5def04 100755 --- a/masher/masher +++ b/masher/masher @@ -32,6 +32,7 @@ DARWIN="" LINUX="" OPENBSD="" WINDOWS="" +ARM64="" if [[ -n ${MASHALL} ]]; then DARWIN="--darwin" LINUX="--linux" @@ -60,6 +61,13 @@ else esac fi +CPU="$( uname -m )" +case $CPU in +arm64) + ARM64="--arm64" +;; +esac + while [[ $# -gt 0 ]]; do key="$1" val="${key#*=}" @@ -72,6 +80,13 @@ while [[ $# -gt 0 ]]; do REGISTRY="$val" ;; + --arm64) + ARM64="--arm64" + ;; + --x86_64|--amd64) + ARM64="" + ;; + --darwin) DARWINFLAG="--darwin" ;; @@ -278,7 +293,7 @@ fi TIMESTAMP="$(date -u +"%Y%m%d.%H%M%S")" echo Using image: ${IMAGE} -echo /bin/mash.sh ${ESCAPE} ${DARWIN} ${LINUX} ${OPENBSD} ${WINDOWS} ${TEST} ${PROTO} ${BUILD} ${CACHE} ${PRIVATE} ${BUILD_VERSION} --timestamp=${TIMESTAMP} --id=${HASHID} $@ +echo /bin/mash.sh ${ESCAPE} ${ARM64} ${DARWIN} ${LINUX} ${OPENBSD} ${WINDOWS} ${TEST} ${PROTO} ${BUILD} ${CACHE} ${PRIVATE} ${BUILD_VERSION} --timestamp=${TIMESTAMP} --id=${HASHID} $@ DOCKER_VERSION="$(docker --version)" DOCKER_VERSION="${DOCKER_VERSION%%,*}" @@ -378,7 +393,7 @@ ${EXEC} docker run ${FLAGS} --rm \ $LIBS \ --workdir "${SRCROOT}/${PRJPATH}" \ ${IMAGE} \ - /bin/mash.sh ${ESCAPE} ${DARWIN} ${LINUX} ${OPENBSD} ${WINDOWS} ${TEST} ${PROTO} ${BUILD} ${CACHE} ${PRIVATE} ${BUILD_VERSION} --timestamp="${TIMESTAMP}" --id="${HASHID}" "$@" || exit 1 + /bin/mash.sh ${ESCAPE} ${ARM64} ${DARWIN} ${LINUX} ${OPENBSD} ${WINDOWS} ${TEST} ${PROTO} ${BUILD} ${CACHE} ${PRIVATE} ${BUILD_VERSION} --timestamp="${TIMESTAMP}" --id="${HASHID}" "$@" || exit 1 if [[ $PROD == "true" ]]; then make push || exit 1