diff --git a/packages/Makefile b/packages/Makefile index 3c427e51b6..a2139dcd4f 100644 --- a/packages/Makefile +++ b/packages/Makefile @@ -1,24 +1,45 @@ -PACKAGE_PATH=$(shell cd $(name) && pwd) -SHA_SUM=$(shell sha256sum $(name)/zarf-package-$(name).tar.zst | cut -d " " -f1) -build-package: +# Figure out which Zarf binary we should use based on the operating system we are on +ZARF_BIN := zarf +UNAME_S := $(shell uname -s) +UNAME_P := $(shell uname -p) +ifneq ($(UNAME_S),Linux) + ifeq ($(UNAME_S),Darwin) + ZARF_BIN := $(addsuffix -mac,$(ZARF_BIN)) + endif + ifeq ($(UNAME_P),i386) + ZARF_BIN := $(addsuffix -intel,$(ZARF_BIN)) + endif + ifeq ($(UNAME_P),arm64) + ZARF_BIN := $(addsuffix -apple,$(ZARF_BIN)) + endif +endif + +PACKAGE_PATH := $(shell cd $(name) && pwd) + +.PHONY: default +default: help + +.PHONY: build-package +package: ifdef name - @cd $(name) && zarf package create --confirm - @echo "\nCreated $(name) add the sha and path to your zarf yaml components: " + @cd $(name) && $(ZARF_BIN) package create --confirm + @echo "\nCreated $(name) add the sha and path to your zarf yaml components: " @echo " - name: $(name)" - @echo " files:" - @echo " - source: \"$(PACKAGE_PATH)/zarf-package-$(name).tar.zst\"" - @echo " shasum: $(SHA_SUM)" - @echo " target: /usr/local/bin/zarf-package-$(name).tar.zst" - @echo " scripts:" - @echo " after:" + @echo " files:" + @echo " - source: \"$(PACKAGE_PATH)/zarf-package-$(name).tar.zst\"" + @echo " shasum: `cd $(PACKAGE_PATH) && sha256sum zarf-package-$(name).tar.zst | cut -d " " -f1`" + @echo " target: \"/usr/local/bin/zarf-package-$(name).tar.zst\"" + @echo " scripts:" + @echo " after:" @echo " - \"./zarf package deploy /usr/local/bin/zarf-package-$(name).tar.zst --confirm\"" else - @echo "Please provide a valid package name. ie: make build-package name=flux" + @echo "Please provide a valid package name. ie: make package name=flux" endif - +.PHONY: help help: @echo "\nAvailable commands: " - @echo "\n build-package Builds a tar.zst given the name of the component you wish to create." - @echo " example: make build-package name=flux" + @echo "\n package Builds a tar.zst given the name of the component you wish to create." + @echo " example: make build-package name=flux" + @echo "\n help shows this menu." @echo \ No newline at end of file diff --git a/packages/README.md b/packages/README.md index e56bfb2fc6..581187e74a 100644 --- a/packages/README.md +++ b/packages/README.md @@ -1,20 +1,20 @@ # Zarf Prebuilt Packages ## Prerequisites -- zarf binary in PATH as zarf or ```alias zarf="$HOME/path/to/zarf/cli``` -- sha256sum +- Add zarf binary to path `export PATH=path/to/zarf/binary:$PATH` +- Install `sha256sum` (on Mac it's `brew install coreutils`) ## Usage -executing the command `make build-package name=NAME_OF_PACKAGE` will build the zarf-package.tar.zst in the folder of the required package. It will also output the required yaml to add to your zarf.yaml components section. +executing the command `make package name=NAME_OF_PACKAGE` will build the zarf-package.tar.zst in the folder of the required package. It will also output the required yaml to add to your zarf.yaml components section. ### Building Composable Packages example: ```yaml -☁ packages ⚡ make build-package name=flux +☁ packages ⚡ make package name=flux Created flux add the sha and path to your zarf yaml components: - name: flux files: - source: "/home/ubuntu/github/zarf/packages/flux/zarf-package-flux.tar.zst" shasum: a8932720c6fe95e99be74c9dd1a6e8905b5c92b2b4672b3350e45739f3aad8be - target: /usr/local/bin/zarf-package-flux.tar.zst + target: "/usr/local/bin/zarf-package-flux.tar.zst" scripts: after: - "./zarf package deploy /usr/local/bin/zarf-package-flux.tar.zst --confirm" @@ -33,7 +33,7 @@ components: files: - source: "/home/ubuntu/github/zarf/packages/flux/zarf-package-flux.tar.zst" shasum: a8932720c6fe95e99be74c9dd1a6e8905b5c92b2b4672b3350e45739f3aad8be - target: /usr/local/bin/zarf-package-flux.tar.zst + target: "/usr/local/bin/zarf-package-flux.tar.zst" scripts: after: - "./zarf package deploy /usr/local/bin/zarf-package-flux.tar.zst --confirm"