Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable linux arm builds for admin-helper #59

Merged
merged 3 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/

Expand All @@ -48,15 +51,16 @@ $(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)

.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
Expand Down
13 changes: 11 additions & 2 deletions crc-admin-helper.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,18 @@ 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
License: MIT
ExclusiveArch: x86_64 aarch64
URL: %{gourl}
Source0: %{gosource}

Expand Down Expand Up @@ -52,10 +60,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/

Expand Down