From 09638f8aedf5181aa782df9e3439e63016dcc69f Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Wed, 19 Jun 2024 13:25:59 +0530 Subject: [PATCH 1/3] Makefile: Add target for linux arm64 --- Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b0d0a38f..9decd9c8 100644 --- a/Makefile +++ b/Makefile @@ -40,6 +40,9 @@ $(BUILD_DIR)/macos-arm64/$(BINARY_NAME): $(BUILD_DIR)/linux-amd64/$(BINARY_NAME): CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="$(LDFLAGS)" -o $@ $(GO_BUILDFLAGS) ./cmd/admin-helper/ +$(BUILD_DIR)/linux-arm64/$(BINARY_NAME): + CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="$(LDFLAGS)" -o $@ $(GO_BUILDFLAGS) ./cmd/admin-helper/ + $(BUILD_DIR)/windows-amd64/$(BINARY_NAME).exe: CGO_ENABLED=0 GOARCH=amd64 GOOS=windows go build -ldflags="$(LDFLAGS)" -o $@ $(GO_BUILDFLAGS) ./cmd/admin-helper/ @@ -48,7 +51,7 @@ $(BUILD_DIR)/macos-universal/$(BINARY_NAME): $(BUILD_DIR)/macos-amd64/$(BINARY_N cd $(BUILD_DIR) && $(TOOLS_BINDIR)/makefat macos-universal/$(BINARY_NAME) macos-amd64/$(BINARY_NAME) macos-arm64/$(BINARY_NAME) .PHONY: cross ## Cross compiles all binaries -cross: $(BUILD_DIR)/macos-amd64/$(BINARY_NAME) $(BUILD_DIR)/macos-arm64/$(BINARY_NAME) $(BUILD_DIR)/linux-amd64/$(BINARY_NAME) $(BUILD_DIR)/windows-amd64/$(BINARY_NAME).exe +cross: $(BUILD_DIR)/macos-amd64/$(BINARY_NAME) $(BUILD_DIR)/macos-arm64/$(BINARY_NAME) $(BUILD_DIR)/linux-amd64/$(BINARY_NAME) $(BUILD_DIR)/linux-arm64/$(BINARY_NAME) $(BUILD_DIR)/windows-amd64/$(BINARY_NAME).exe .PHONY: macos-universal ## Creates macOS universal binary macos-universal: lint test $(BUILD_DIR)/macos-universal/$(BINARY_NAME) @@ -56,7 +59,8 @@ macos-universal: lint test $(BUILD_DIR)/macos-universal/$(BINARY_NAME) .PHONY: release release: clean lint test cross macos-universal mkdir $(RELEASE_DIR) - cp $(BUILD_DIR)/linux-amd64/$(BINARY_NAME) $(RELEASE_DIR)/$(BINARY_NAME)-linux + cp $(BUILD_DIR)/linux-amd64/$(BINARY_NAME) $(RELEASE_DIR)/$(BINARY_NAME)-linux-amd64 + cp $(BUILD_DIR)/linux-arm64/$(BINARY_NAME) $(RELEASE_DIR)/$(BINARY_NAME)-linux-arm64 cp $(BUILD_DIR)/macos-universal/$(BINARY_NAME) $(RELEASE_DIR)/$(BINARY_NAME)-darwin cp $(BUILD_DIR)/windows-amd64/$(BINARY_NAME).exe $(RELEASE_DIR)/$(BINARY_NAME)-windows.exe pushd $(RELEASE_DIR) && sha256sum * > sha256sum.txt && popd From 605c8ab030c63eddb48e0ee417b3232b05129807 Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Wed, 19 Jun 2024 13:33:46 +0530 Subject: [PATCH 2/3] Add support to generate aarch64 bits for Linux This pr adds linux arm64 target to makefile and also make change to spec file to generate right package for arm64. --- crc-admin-helper.spec.in | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/crc-admin-helper.spec.in b/crc-admin-helper.spec.in index ec8515c7..1a039553 100644 --- a/crc-admin-helper.spec.in +++ b/crc-admin-helper.spec.in @@ -18,6 +18,13 @@ CRC's helper with administrative privileges} %global golicenses LICENSE %global godocs *.md +%ifarch x86_64 +%global gohostarch amd64 +%endif +%ifarch aarch64 +%global gohostarch arm64 +%endif + Name: %{goname} Release: 1%{?dist} Summary: CRC's helper with administrative privileges @@ -52,10 +59,11 @@ make VERSION=%{version} GO_LDFLAGS="-B 0x$(head -c20 /dev/urandom|od -An -tx1|tr %install # with fedora macros: gopkginstall install -m 0755 -vd %{buildroot}%{_bindir} -install -m 0755 -vp %{gobuilddir}/src/%{goipath}/out/linux-amd64/crc-admin-helper %{buildroot}%{_bindir}/ +install -m 0755 -vp %{gobuilddir}/src/%{goipath}/out/linux-%{gohostarch}/crc-admin-helper %{buildroot}%{_bindir}/ install -d %{buildroot}%{_datadir}/%{name}-redistributable/{linux,macos,windows} -install -m 0755 -vp %{gobuilddir}/src/%{goipath}/out/linux-amd64/crc-admin-helper %{buildroot}%{_datadir}/%{name}-redistributable/linux/ +install -m 0755 -vp %{gobuilddir}/src/%{goipath}/out/linux-amd64/crc-admin-helper %{buildroot}%{_datadir}/%{name}-redistributable/linux/%{name}-amd64 +install -m 0755 -vp %{gobuilddir}/src/%{goipath}/out/linux-arm64/crc-admin-helper %{buildroot}%{_datadir}/%{name}-redistributable/linux/%{name}-arm64 install -m 0755 -vp %{gobuilddir}/src/%{goipath}/out/windows-amd64/crc-admin-helper.exe %{buildroot}%{_datadir}/%{name}-redistributable/windows/ install -m 0755 -vp %{gobuilddir}/src/%{goipath}/out/macos-universal/crc-admin-helper %{buildroot}%{_datadir}/%{name}-redistributable/macos/ From ab3d2b6d640fa74662cb23b06f0973093c5cd4fc Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Wed, 19 Jun 2024 13:48:08 +0530 Subject: [PATCH 3/3] Only build rpm for arm64 and amd64 We don't support all the arch so only build for supported one. - http://ftp.rpm.org/max-rpm/s1-rpm-multi-platform-dependent-tags.html --- crc-admin-helper.spec.in | 1 + 1 file changed, 1 insertion(+) diff --git a/crc-admin-helper.spec.in b/crc-admin-helper.spec.in index 1a039553..9d94a705 100644 --- a/crc-admin-helper.spec.in +++ b/crc-admin-helper.spec.in @@ -29,6 +29,7 @@ Name: %{goname} Release: 1%{?dist} Summary: CRC's helper with administrative privileges License: MIT +ExclusiveArch: x86_64 aarch64 URL: %{gourl} Source0: %{gosource}