Add statically linked Linux binaries

As discussed in https://github.com/coreos/butane/issues/87 this adds
additional Linux binaries to the package output that are statically
linked to improve compatibility with older Linux versions that do not
ship with glibc 2.32.
This commit is contained in:
Nikolas Grottendieck 2022-01-25 18:35:16 +01:00
parent 784997fa3f
commit 252df91d17

View File

@ -66,18 +66,18 @@ Provides: bundled(golang(gopkg.in/yaml.v3)) = 3.0.0-20191010095647.gitfc94e3f716
%description
%{common_description}
%package nonlinux
Summary: Butane for macOS and Windows
%package redistributable
Summary: Statically built Butane for Linux, macOS and Windows
License: ASL 2.0
BuildArch: noarch
%description nonlinux
%description redistributable
%{common_description}
This package contains macOS and Windows Butane binaries built through
cross-compilation. Do not install it. It is only used for building release
binaries to be signed by Fedora release engineering and uploaded to the
Butane GitHub releases page.
This package contains statically linked Linux, macOS and Windows Butane
binaries built through cross-compilation. Do not install it. It is only
used for building release binaries to be signed by Fedora release
engineering and uploaded to the Butane GitHub releases page.
%prep
%goprep -k
@ -92,6 +92,12 @@ echo "Building butane..."
%global gocrossbuild go build -ldflags "${LDFLAGS:-} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n')" -a -v -x
echo "Building Linux Butane with static linking..."
CGO_ENABLED=0 GOARCH=arm64 GOOS=linux %gocrossbuild -o butane-aarch64-unknown-linux-gnu-static internal/main.go
CGO_ENABLED=0 GOARCH=ppc64le GOOS=linux %gocrossbuild -o butane-ppc64le-unknown-linux-gnu-static internal/main.go
CGO_ENABLED=0 GOARCH=s390x GOOS=linux %gocrossbuild -o butane-s390x-unknown-linux-gnu-static internal/main.go
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux %gocrossbuild -o butane-x86_64-unknown-linux-gnu-static internal/main.go
echo "Building macOS Butane..."
GOARCH=amd64 GOOS=darwin %gocrossbuild -o butane-x86_64-apple-darwin internal/main.go
@ -103,8 +109,12 @@ install -d -p %{buildroot}%{_bindir}
install -p -m 0755 ./butane %{buildroot}%{_bindir}
ln -s butane %{buildroot}%{_bindir}/fcct
install -d -p %{buildroot}%{_datadir}/butane
install -p -m 0644 ./butane-aarch64-unknown-linux-gnu-static %{buildroot}%{_datadir}/butane
install -p -m 0644 ./butane-ppc64le-unknown-linux-gnu-static %{buildroot}%{_datadir}/butane
install -p -m 0644 ./butane-s390x-unknown-linux-gnu-static %{buildroot}%{_datadir}/butane
install -p -m 0644 ./butane-x86_64-apple-darwin %{buildroot}%{_datadir}/butane
install -p -m 0644 ./butane-x86_64-pc-windows-gnu.exe %{buildroot}%{_datadir}/butane
install -p -m 0644 ./butane-x86_64-unknown-linux-gnu-static %{buildroot}%{_datadir}/butane
%if %{with check}
%check
@ -117,11 +127,15 @@ install -p -m 0644 ./butane-x86_64-pc-windows-gnu.exe %{buildroot}%{_datadir}/bu
%{_bindir}/butane
%{_bindir}/fcct
%files nonlinux
%files redistributable
%license %{golicenses}
%dir %{_datadir}/butane
%{_datadir}/butane/butane-aarch64-unknown-linux-gnu-static
%{_datadir}/butane/butane-ppc64le-unknown-linux-gnu-static
%{_datadir}/butane/butane-s390x-unknown-linux-gnu-static
%{_datadir}/butane/butane-x86_64-apple-darwin
%{_datadir}/butane/butane-x86_64-pc-windows-gnu.exe
%{_datadir}/butane/butane-x86_64-unknown-linux-gnu-static
%changelog
* Wed Jan 19 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.13.1-2