Skip to content

Commit

Permalink
support building arm 32 binary
Browse files Browse the repository at this point in the history
  • Loading branch information
gnmahanth committed Mar 19, 2024
1 parent b330f92 commit e2704fe
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 8 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ bootstrap: vendor
clean:
-rm package-scanner

.PHONY: clean-all
clean-all: clean
-rm -rf vendor
(cd tools/grype-bin && rm -rf grype*)
(cd tools/syft-bin && rm -rf syft*)

.PHONY: vendor
vendor:
go mod tidy -v
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ require (
github.com/olekukonko/tablewriter v0.0.5
github.com/sirupsen/logrus v1.9.3
google.golang.org/grpc v1.60.1
google.golang.org/protobuf v1.32.0
)

require (
Expand Down Expand Up @@ -91,5 +90,6 @@ require (
golang.org/x/tools v0.10.0 // indirect
google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
2 changes: 1 addition & 1 deletion tools/embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ var (
//go:embed syft-bin/syft.bin
SyftBin []byte

//go:embed grype-bin/grype
//go:embed grype-bin/grype.bin
GrypeBin []byte
)
15 changes: 11 additions & 4 deletions tools/grype-bin/get_grype.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,26 @@ set -eux
VERSION=0.73.1

HOST_OS=$(uname -s | tr '[:upper:]' '[:lower:]')
HOST_ARCH=$(uname -m)
HOST_ARCH="${GOARCH:=$(uname -m)}"

if [ "$HOST_ARCH" = "x86_64" ]; then
HOST_ARCH="amd64"
elif [ "$HOST_ARCH" = "aarch64" ]; then
HOST_ARCH="arm64"
elif [ "$HOST_ARCH" = "arm" ]; then
HOST_ARCH="arm"
fi

ARCHITECTURE="${TARGETPLATFORM:-$HOST_OS/$HOST_ARCH}"

IFS=/ read BUILD_OS BUILD_ARCH <<< $ARCHITECTURE

rm -rf grype_*.tar.gz grype
rm -rf grype*

curl -fsSLO https://github.com/anchore/grype/releases/download/v${VERSION}/grype_${VERSION}_${BUILD_OS}_${BUILD_ARCH}.tar.gz
tar -zxvf grype_${VERSION}_${BUILD_OS}_${BUILD_ARCH}.tar.gz grype
git clone https://github.com/anchore/grype.git --branch v$VERSION || true
(
cd grype/cmd/grype
export CGO_ENABLED=0
GOOS="$BUILD_OS" GOARCH="$BUILD_ARCH" go build -o grype.bin .
cp grype.bin ../../../
)
10 changes: 8 additions & 2 deletions tools/syft-bin/get_syft.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,26 @@

set -eux

RELEASE=optimise-resolver-2

HOST_OS=$(uname -s | tr '[:upper:]' '[:lower:]')
HOST_ARCH=$(uname -m)
HOST_ARCH="${GOARCH:=$(uname -m)}"

if [ "$HOST_ARCH" = "x86_64" ]; then
HOST_ARCH="amd64"
elif [ "$HOST_ARCH" = "aarch64" ]; then
HOST_ARCH="arm64"
elif [ "$HOST_ARCH" = "arm" ]; then
HOST_ARCH="arm"
fi

ARCHITECTURE="${TARGETPLATFORM:-$HOST_OS/$HOST_ARCH}"

IFS=/ read BUILD_OS BUILD_ARCH <<< $ARCHITECTURE

git clone https://github.com/deepfence/syft.git --branch optimise-resolver-2 || true
rm -rf syft*

git clone https://github.com/deepfence/syft.git --branch $RELEASE || true
(
cd syft/cmd/syft
export CGO_ENABLED=0
Expand Down

0 comments on commit e2704fe

Please sign in to comment.