@@ -48,31 +48,47 @@ functional-tests-all:
4848 $(GO ) build -o functional-tests/sops go.mozilla.org/sops/v3/cmd/sops
4949 cd functional-tests && cargo test && cargo test -- --ignored
5050
51- deb-pkg : vendor
51+ # Creates variables during target re-definition. Basically this block allows the particular variables to be used in the final target
52+ build-deb-% : OS = $(word 1,$(subst -, ,$* ) )
53+ build-deb-% : ARCH = $(word 2,$(subst -, ,$* ) )
54+ build-deb-% : FPM_ARCH = $(word 3,$(subst -, ,$* ) )
55+ # Poor-mans function with parameters being split out from the variable part of it's name
56+ build-deb-% :
5257 rm -rf tmppkg
5358 mkdir -p tmppkg/usr/local/bin
54- GOOS=linux CGO_ENABLED=0 go build -mod vendor -o tmppkg/usr/local/bin/sops go.mozilla.org/sops/v3/cmd/sops
59+ GOOS=$( OS ) GOARCH= " $( ARCH ) " CGO_ENABLED=0 go build -mod vendor -o tmppkg/usr/local/bin/sops go.mozilla.org/sops/v3/cmd/sops
5560 fpm -C tmppkg -n sops --license MPL2.0 --vendor mozilla \
5661 --description " Sops is an editor of encrypted files that supports YAML, JSON and BINARY formats and encrypts with AWS KMS and PGP." \
5762 -m " AJ Bahnken <ajvb+sops@mozilla.com>" \
5863 --url https://go.mozilla.org/sops \
59- --architecture x86_64 \
64+ --architecture $( FPM_ARCH ) \
6065 -v " $$ (grep '^const Version' version/version.go |cut -d \" -f 2)" \
6166 -s dir -t deb .
6267
63- rpm-pkg : vendor
68+ # Create .deb packages for multiple architectures
69+ deb-pkg : vendor build-deb-linux-amd64-x86_64 build-deb-linux-arm64-arm64
70+
71+ # Creates variables during target re-definition. Basically this block allows the particular variables to be used in the final target
72+ build-rpm-% : OS = $(word 1,$(subst -, ,$* ) )
73+ build-rpm-% : ARCH = $(word 2,$(subst -, ,$* ) )
74+ build-rpm-% : FPM_ARCH = $(word 3,$(subst -, ,$* ) )
75+ # Poor-mans function with parameters being split out from the variable part of it's name
76+ build-rpm-% :
6477 rm -rf tmppkg
6578 mkdir -p tmppkg/usr/local/bin
66- GOOS=linux CGO_ENABLED=0 go build -mod vendor -o tmppkg/usr/local/bin/sops go.mozilla.org/sops/v3/cmd/sops
79+ GOOS=$( OS ) GOARCH= " $( ARCH ) " CGO_ENABLED=0 go build -mod vendor -o tmppkg/usr/local/bin/sops go.mozilla.org/sops/v3/cmd/sops
6780 fpm -C tmppkg -n sops --license MPL2.0 --vendor mozilla \
6881 --description " Sops is an editor of encrypted files that supports YAML, JSON and BINARY formats and encrypts with AWS KMS and PGP." \
6982 -m " AJ Bahnken <ajvb+sops@mozilla.com>" \
7083 --url https://go.mozilla.org/sops \
71- --architecture x86_64 \
72- --rpm-os linux \
84+ --architecture $( FPM_ARCH ) \
85+ --rpm-os $( OS ) \
7386 -v " $$ (grep '^const Version' version/version.go |cut -d \" -f 2)" \
7487 -s dir -t rpm .
7588
89+ # Create .rpm packages for multiple architectures
90+ rpm-pkg : vendor build-rpm-linux-amd64-x86_64 build-rpm-linux-arm64-arm64
91+
7692dmg-pkg : install
7793ifneq ($(OS ) ,darwin)
7894 echo 'you must be on MacOS and set OS=darwin on the make command line to build an OSX package'
0 commit comments