From a55588ba0d9649b7028e3d9ff4c4a74d18ee8462 Mon Sep 17 00:00:00 2001 From: Krish Suchak Date: Wed, 25 Mar 2026 16:42:46 -0400 Subject: [PATCH] makefile and build scripts --- Makefile | 13 ++++++---- otdfctl/Makefile | 4 +-- otdfctl/scripts/verify-checksums.sh | 33 +++++++++++++++++++++++++ otdfctl/scripts/zip-builds.sh | 38 +++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+), 7 deletions(-) create mode 100755 otdfctl/scripts/verify-checksums.sh create mode 100755 otdfctl/scripts/zip-builds.sh diff --git a/Makefile b/Makefile index 035da1d35e..86933ff55c 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,10 @@ # make # To run all lint checks: `LINT_OPTIONS= make lint` -.PHONY: all build clean connect-wrapper-generate docker-build fix fmt go-lint license lint proto-generate proto-lint sdk/sdk test tidy toolcheck +.PHONY: all build clean connect-wrapper-generate docker-build fix fmt go-lint license lint proto-generate proto-lint sdk/sdk otdfctl/otdfctl test tidy toolcheck -MODS=protocol/go lib/ocrypto lib/fixtures lib/flattening lib/identifier sdk service examples -HAND_MODS=lib/ocrypto lib/fixtures lib/flattening lib/identifier sdk service examples +MODS=protocol/go lib/ocrypto lib/fixtures lib/flattening lib/identifier sdk service examples otdfctl +HAND_MODS=lib/ocrypto lib/fixtures lib/flattening lib/identifier sdk service examples otdfctl REQUIRED_BUF_VERSION=1.56.0 ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) @@ -111,9 +111,9 @@ bench: clean: for m in $(MODS); do (cd $$m && go clean) || exit 1; done - rm -f opentdf examples/examples + rm -f opentdf examples/examples otdfctl/otdfctl -build: proto-generate connect-wrapper-generate opentdf sdk/sdk examples/examples +build: proto-generate connect-wrapper-generate opentdf sdk/sdk examples/examples otdfctl/otdfctl opentdf: $(shell find service) go build -o opentdf -v service/main.go @@ -124,5 +124,8 @@ sdk/sdk: $(shell find sdk) examples/examples: $(shell find examples) (cd examples && go build -o examples .) +otdfctl/otdfctl: $(shell find otdfctl) + (cd otdfctl && go build -o otdfctl .) + docker-build: build docker build -t opentdf . diff --git a/otdfctl/Makefile b/otdfctl/Makefile index b9191ae912..c6fc513e4c 100644 --- a/otdfctl/Makefile +++ b/otdfctl/Makefile @@ -59,10 +59,10 @@ build-%: -o $(GO_BUILD_PREFIX)-$(word 1,$(subst -, ,$*))-$(word 2,$(subst -, ,$*))$(word 3,$(subst -, ,$*)) zip-builds: - ./.github/scripts/zip-builds.sh $(BINARY_NAME)-$(CURR_VERSION) $(TARGET_DIR) $(OUTPUT_DIR) + ./scripts/zip-builds.sh $(BINARY_NAME)-$(CURR_VERSION) $(TARGET_DIR) $(OUTPUT_DIR) verify-checksums: - ./.github/scripts/verify-checksums.sh $(OUTPUT_DIR) $(BINARY_NAME)-$(CURR_VERSION)_checksums.txt + ./scripts/verify-checksums.sh $(OUTPUT_DIR) $(BINARY_NAME)-$(CURR_VERSION)_checksums.txt # Target for running the project (adjust as necessary for your project) .PHONY: run diff --git a/otdfctl/scripts/verify-checksums.sh b/otdfctl/scripts/verify-checksums.sh new file mode 100755 index 0000000000..6ae3a89199 --- /dev/null +++ b/otdfctl/scripts/verify-checksums.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Check if the required arguments are provided +if [ $# -ne 2 ]; then + echo "Usage: $0 " + exit 1 +fi + +echo "Verifying checksums..." +# Location of the checksum file +checksumFile=$1/$2 +outputDir=$1 + +echo "Looking for checksum file: $checksumFile" +test -f "$checksumFile" || { echo "ERROR: Checksum file not found!"; exit 1; } + +# Iterate over each line in the checksum file +while read -r line; do + # Extract the expected checksum and filename from each line + read -ra ADDR <<< "$line" # Read the line into an array + expectedChecksum="${ADDR[0]}" + fileName="${ADDR[2]}" + + # Calculate the actual checksum of the file + actualChecksum=$(shasum -a 256 "$outputDir/$fileName" | awk '{print $1}') + + # Compare the expected checksum with the actual checksum + if [ "$expectedChecksum" == "$actualChecksum" ]; then + echo "SUCCESS: Checksum for $fileName is valid." + else + echo "ERROR: Checksum for $fileName does not match." + fi +done < "$checksumFile" diff --git a/otdfctl/scripts/zip-builds.sh b/otdfctl/scripts/zip-builds.sh new file mode 100755 index 0000000000..36eaa47d91 --- /dev/null +++ b/otdfctl/scripts/zip-builds.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# Check if the required arguments are provided +if [ $# -ne 3 ]; then + echo "Usage: $0 " + exit 1 +fi + +# Assign the arguments to variables +build_semver="$1" +binary_dir="$2" +output_dir="$3" + +# Create the output directory if it doesn't exist +mkdir -p "$output_dir" + +# Create a checksums file +checksums_file="$output_dir/${build_semver}_checksums.txt" +touch $checksums_file + +# Iterate over each binary file +for binary_file in "$binary_dir"/*; do + compressed="" + if [[ $binary_file == *.exe ]]; then + # If the file is a Windows binary, zip it + filename=$(basename "$binary_file") + compressed="${filename%.exe}.zip" + zip -j "$output_dir/$compressed" "$binary_file" + else + # For other binaries, tar and gzip them + filename=$(basename "$binary_file") + compressed="${filename}.tar.gz" + tar -czf "$output_dir/$compressed" "$binary_file" + fi + + # Append checksums to the file + echo "$(cat "$output_dir/$compressed" | shasum -a 256) $compressed" >> $checksums_file +done