Skip to content

Commit

Permalink
arm64 and ppc64le builds
Browse files Browse the repository at this point in the history
Signed-off-by: Prabhu Subramanian <[email protected]>

ppc64 build script

Signed-off-by: Prabhu Subramanian <[email protected]>
  • Loading branch information
prabhu committed Aug 30, 2023
1 parent fed0a0f commit b6ff5d0
Show file tree
Hide file tree
Showing 23 changed files with 237 additions and 17 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
node-version: 20.x
registry-url: https://registry.npmjs.org/
- uses: actions/setup-go@v3
with:
Expand All @@ -42,6 +42,18 @@ jobs:
npm publish --access=public --@cyclonedx:registry='https://npm.pkg.github.com'
echo "cyclonedx:registry=https://registry.npmjs.org" > ~/.npmrc
npm publish --access=public --@cyclonedx:registry='https://registry.npmjs.org'
pushd packages/arm64
echo "cyclonedx:registry=https://npm.pkg.github.com" > ~/.npmrc
npm publish --access=public --@cyclonedx:registry='https://npm.pkg.github.com'
echo "cyclonedx:registry=https://registry.npmjs.org" > ~/.npmrc
npm publish --access=public --@cyclonedx:registry='https://registry.npmjs.org'
popd
pushd packages/ppc64
echo "cyclonedx:registry=https://npm.pkg.github.com" > ~/.npmrc
npm publish --access=public --@cyclonedx:registry='https://npm.pkg.github.com'
echo "cyclonedx:registry=https://registry.npmjs.org" > ~/.npmrc
npm publish --access=public --@cyclonedx:registry='https://registry.npmjs.org'
popd
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPMJS_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
node-version: 20.x
registry-url: https://registry.npmjs.org/
- uses: actions/setup-go@v3
with:
Expand All @@ -40,4 +40,10 @@ jobs:
pip3 install blint
blint -i plugins -o /tmp/reports
npm publish --dry-run
pushd packages/arm64
npm publish --dry-run
popd
pushd packages/ppc64
npm publish --dry-run
popd
continue-on-error: true
28 changes: 28 additions & 0 deletions build-ppc64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

rm -rf plugins/goversion
rm -rf plugins/trivy
rm -rf plugins/cargo-auditable
rm -rf plugins/osquery
mkdir -p plugins/osquery

for plug in goversion trivy cargo-auditable
do
mkdir -p plugins/$plug
pushd thirdparty/$plug
make build/linux_ppc64le
chmod +x build/*
cp -rf build/* ../../plugins/$plug/
rm -rf build
popd
done

./plugins/goversion/goversion-linux-ppc64le
./plugins/trivy/trivy-cdxgen-linux-ppc64le -v
./plugins/cargo-auditable/cargo-auditable-cdxgen-linux-ppc64le

chmod +x packages/ppc64/build-ppc64.sh
pushd packages/ppc64
./build-ppc64.sh
popd

8 changes: 8 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ copy build\* ..\..\plugins\cargo-auditable\
Remove-Item build -Recurse -Force
cd ..\..

New-Item -ItemType Directory -Path plugins\trivy -Force
cd thirdparty\trivy
go build -ldflags "-H=windowsgui -s -w" -o build\trivy-windows-amd64.exe
..\..\upx-4.1.0-win64\upx.exe -9 --lzma build\trivy-windows-amd64.exe
copy build\* ..\..\plugins\trivy\
Remove-Item build -Recurse -Force
cd ..\..

Remove-Item osquery-5.9.1.windows_x86_64 -Recurse -Force
Remove-Item osquery-5.9.1.windows_x86_64.zip -Recurse -Force
Remove-Item upx-4.1.0-win64 -Recurse -Force
Expand Down
9 changes: 9 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash

rm -rf plugins/goversion
rm -rf plugins/trivy
rm -rf plugins/cargo-auditable
Expand Down Expand Up @@ -36,3 +37,11 @@ done
./plugins/goversion/goversion-linux-amd64
./plugins/trivy/trivy-cdxgen-linux-amd64 -v
./plugins/cargo-auditable/cargo-auditable-cdxgen-linux-amd64

chmod +x packages/arm64/build-arm64.sh
pushd packages/arm64
./build-arm64.sh
popd
pushd packages/ppc64
./build-ppc64.sh
popd
3 changes: 1 addition & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Debug mode flag
const DEBUG_MODE =
process.env.SCAN_DEBUG_MODE === "debug" ||
process.env.SHIFTLEFT_LOGGING_LEVEL === "debug" ||
process.env.CDXGEN_DEBUG_MODE === "debug" ||
process.env.NODE_ENV === "development";

if (DEBUG_MODE) {
Expand Down
9 changes: 6 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cyclonedx/cdxgen-plugins-bin",
"version": "1.3.0",
"version": "1.4.0",
"description": "Binary plugins to supercharge @cyclonedx/cdxgen npm package",
"main": "index.js",
"repository": {
Expand All @@ -24,5 +24,8 @@
"files": [
"*.js",
"plugins/"
],
"cpu": [
"x64"
]
}
28 changes: 28 additions & 0 deletions packages/arm64/build-arm64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

rm -rf plugins/goversion
rm -rf plugins/trivy
rm -rf plugins/cargo-auditable
rm -rf plugins/osquery
mkdir -p plugins/osquery

wget https://github.com/osquery/osquery/releases/download/5.9.1/osquery-5.9.1.windows_arm64.zip
unzip osquery-5.9.1.windows_arm64.zip
cp "osquery-5.9.1.windows_arm64/Program Files/osquery/osqueryi.exe" plugins/osquery/osqueryi-windows-arm64.exe
sha256sum plugins/osquery/osqueryi-windows-arm64.exe > plugins/osquery/osqueryi-windows-arm64.exe.sha256
rm -rf osquery-5.9.1.windows_arm64
rm osquery-5.9.1.windows_arm64.zip

wget https://github.com/osquery/osquery/releases/download/5.9.1/osquery-5.9.1_1.linux_aarch64.tar.gz
tar -xvf osquery-5.9.1_1.linux_aarch64.tar.gz
cp opt/osquery/bin/osqueryd plugins/osquery/osqueryi-linux-arm64
upx -9 --lzma plugins/osquery/osqueryi-linux-arm64
sha256sum plugins/osquery/osqueryi-linux-arm64 > plugins/osquery/osqueryi-linux-arm64.sha256
rm -rf etc usr var opt
rm osquery-5.9.1_1.linux_aarch64.tar.gz

for plug in goversion trivy cargo-auditable
do
mkdir -p plugins/$plug
mv ../../plugins/$plug/*arm64* plugins/$plug/
done
8 changes: 8 additions & 0 deletions packages/arm64/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Debug mode flag
const DEBUG_MODE =
process.env.CDXGEN_DEBUG_MODE === "debug" ||
process.env.NODE_ENV === "development";

if (DEBUG_MODE) {
console.log("cdxgen plugins check");
}
31 changes: 31 additions & 0 deletions packages/arm64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "@cyclonedx/cdxgen-plugins-bin-arm64",
"version": "1.4.0",
"description": "Arm64 binary plugins to supercharge @cyclonedx/cdxgen npm package",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/cyclonedx/cdxgen-plugins-bin.git"
},
"keywords": [
"cdxgen",
"sbom",
"bom",
"plugins",
"dependency",
"appsec"
],
"author": "Prabhu Subramanian <[email protected]>",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/cyclonedx/cdxgen-plugins-bin/issues"
},
"homepage": "https://github.com/cyclonedx/cdxgen-plugins-bin#readme",
"files": [
"*.js",
"plugins/"
],
"cpu": [
"arm64"
]
}
4 changes: 4 additions & 0 deletions packages/arm64/plugins/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
goversion/
trivy/
cargo-auditable/
osquery/
Empty file added packages/arm64/plugins/.gitkeep
Empty file.
Empty file.
11 changes: 11 additions & 0 deletions packages/ppc64/build-ppc64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

rm -rf plugins/goversion
rm -rf plugins/trivy
rm -rf plugins/cargo-auditable

for plug in goversion trivy cargo-auditable
do
mkdir -p plugins/$plug
mv ../../plugins/$plug/*ppc64* plugins/$plug/
done
8 changes: 8 additions & 0 deletions packages/ppc64/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Debug mode flag
const DEBUG_MODE =
process.env.CDXGEN_DEBUG_MODE === "debug" ||
process.env.NODE_ENV === "development";

if (DEBUG_MODE) {
console.log("cdxgen plugins check");
}
34 changes: 34 additions & 0 deletions packages/ppc64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "@cyclonedx/cdxgen-plugins-bin-ppc64",
"version": "1.4.0",
"description": "ppc64 binary plugins to supercharge @cyclonedx/cdxgen npm package",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/cyclonedx/cdxgen-plugins-bin.git"
},
"keywords": [
"cdxgen",
"sbom",
"bom",
"plugins",
"dependency",
"appsec"
],
"author": "Prabhu Subramanian <[email protected]>",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/cyclonedx/cdxgen-plugins-bin/issues"
},
"homepage": "https://github.com/cyclonedx/cdxgen-plugins-bin#readme",
"files": [
"*.js",
"plugins/"
],
"os": [
"linux"
],
"cpu": [
"ppc64"
]
}
4 changes: 4 additions & 0 deletions packages/ppc64/plugins/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
goversion/
trivy/
cargo-auditable/
osquery/
Empty file added packages/ppc64/plugins/.gitkeep
Empty file.
Empty file.
14 changes: 11 additions & 3 deletions thirdparty/cargo-auditable/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PATH := $(PATH):/usr/local/go/bin:$HOME/go/bin:
appname := cargo-auditable-cdxgen
sources := main.go

build = CGO_ENABLED=0 GOOS=$(1) GOARCH=$(2) go build -ldflags "-s -w -extldflags=-Wl,-z,now,-z,relro" -o build/$(appname)-$(1)-$(2)$(3) && upx -9 --lzma build/$(appname)-$(1)-$(2)$(3)
build = CGO_ENABLED=0 GOOS=$(1) GOARCH=$(2) go build -ldflags "-s -w -extldflags=-Wl,-z,now,-z,relro" -o build/$(appname)-$(1)-$(2)$(3) && upx -9 --lzma build/$(appname)-$(1)-$(2)$(3) || true
sha = cd build && sha256sum $(appname)-$(1)-$(2)$(3) > $(appname)-$(1)-$(2)$(3).sha256

.PHONY: all windows darwin linux clean
Expand All @@ -12,7 +12,7 @@ all: windows darwin linux
clean: rm -rf build/

##### LINUX BUILDS #####
linux: build/linux_amd64
linux: build/linux_amd64 build/linux_arm64 build/linux_ppc64le

build/linux_386: $(sources)
$(call build,linux,386,)
Expand All @@ -30,6 +30,10 @@ build/linux_arm64: $(sources)
$(call build,linux,arm64,)
$(call sha,linux,arm64,)

build/linux_ppc64le: $(sources)
$(call build,linux,ppc64le,)
$(call sha,linux,ppc64le,)

##### DARWIN (MAC) BUILDS #####
darwin: build/darwin_amd64 build/darwin_arm64

Expand All @@ -42,7 +46,7 @@ build/darwin_arm64: $(sources)
$(call sha,darwin,arm64,)

##### WINDOWS BUILDS #####
windows: build/windows_amd64
windows: build/windows_amd64 build/windows_arm64

build/windows_386: $(sources)
$(call build,windows,386,.exe)
Expand All @@ -51,3 +55,7 @@ build/windows_386: $(sources)
build/windows_amd64: $(sources)
$(call build,windows,amd64,.exe)
$(call sha,windows,amd64,.exe)

build/windows_arm64: $(sources)
$(call build,windows,arm64,.exe)
$(call sha,windows,arm64,.exe)
14 changes: 11 additions & 3 deletions thirdparty/goversion/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PATH := $(PATH):/usr/local/go/bin:$HOME/go/bin:
appname := goversion
sources := version.go exe.go xcoff.go file.go

build = CGO_ENABLED=0 GOOS=$(1) GOARCH=$(2) go build -ldflags "-s -w -extldflags=-Wl,-z,now,-z,relro" -o build/$(appname)-$(1)-$(2)$(3) && upx -9 --lzma build/$(appname)-$(1)-$(2)$(3)
build = CGO_ENABLED=0 GOOS=$(1) GOARCH=$(2) go build -ldflags "-s -w -extldflags=-Wl,-z,now,-z,relro" -o build/$(appname)-$(1)-$(2)$(3) && upx -9 --lzma build/$(appname)-$(1)-$(2)$(3) || true
sha = cd build && sha256sum $(appname)-$(1)-$(2)$(3) > $(appname)-$(1)-$(2)$(3).sha256

.PHONY: all windows darwin linux clean
Expand All @@ -12,7 +12,7 @@ all: windows darwin linux
clean: rm -rf build/

##### LINUX BUILDS #####
linux: build/linux_amd64
linux: build/linux_amd64 build/linux_arm64 build/linux_ppc64le

build/linux_386: $(sources)
$(call build,linux,386,)
Expand All @@ -30,6 +30,10 @@ build/linux_arm64: $(sources)
$(call build,linux,arm64,)
$(call sha,linux,arm64,)

build/linux_ppc64le: $(sources)
$(call build,linux,ppc64le,)
$(call sha,linux,ppc64le,)

##### DARWIN (MAC) BUILDS #####
darwin: build/darwin_amd64 build/darwin_arm64

Expand All @@ -42,7 +46,7 @@ build/darwin_arm64: $(sources)
$(call sha,darwin,arm64,)

##### WINDOWS BUILDS #####
windows: build/windows_amd64
windows: build/windows_amd64 build/windows_arm64

build/windows_386: $(sources)
$(call build,windows,386,.exe)
Expand All @@ -51,3 +55,7 @@ build/windows_386: $(sources)
build/windows_amd64: $(sources)
$(call build,windows,amd64,.exe)
$(call sha,windows,amd64,.exe)

build/windows_arm64: $(sources)
$(call build,windows,arm64,.exe)
$(call sha,windows,arm64,.exe)
Loading

0 comments on commit b6ff5d0

Please sign in to comment.