butane/butane.spec
2022-06-21 11:39:18 +08:00

137 lines
6.3 KiB
RPMSpec

%bcond_with check
%define gobuild(o:) %{expand:
%global _dwz_low_mem_die_limit 0
%ifnarch ppc64
go build -buildmode pie -compiler gc -tags="rpm_crashtraceback ${BUILDTAGS:-}" -ldflags "${LDFLAGS:-}%{?currentgoldflags} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '-Wl,-z,relro -Wl,-z,now' -compressdwarf=false" -a -v -x %{?**};
%else
go build -compiler gc -tags="rpm_crashtraceback ${BUILDTAGS:-}" -ldflags "${LDFLAGS:-}%{?currentgoldflags} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '-Wl,-z,relro -Wl,-z,now' -compressdwarf=false" -a -v -x %{?**};
%endif
}
# https://github.com/coreos/butane
%global goipath github.com/coreos/butane
%global gomodulesmode GO111MODULE=on
%global common_description %{expand:
Butane translates human-readable Butane Configs into machine-readable Ignition
configs for provisioning operating systems that use Ignition.}
%global golicenses LICENSE
%global godocs docs README.md NEWS
Name: butane
Version: 0.14.0
Release: 1
Summary: Butane config transpiler
# Upstream license specification: Apache-2.0
License: ASL 2.0
URL: https://github.com/coreos/butane
Source0: butane-0.14.0.tar.gz
BuildRequires: golang
Provides: nestos-config-transpiler = %{version}-%{release}
Obsoletes: nestos-config-transpiler < 0.10.0-2
Provides: fcct = %{version}-%{release}
# Generated by go-mods-to-bundled-provides.py
Provides: bundled(golang(github.com/clarketm/json)) = 1.14.1
Provides: bundled(golang(github.com/coreos/go-semver/semver)) = 0.3.0
Provides: bundled(golang(github.com/coreos/go-systemd/unit)) = 0.0.0-20190321100706.git95778dfbb74e
Provides: bundled(golang(github.com/coreos/go-systemd/v22/unit)) = 0.0.0-20190321100706.git95778dfbb74e
Provides: bundled(golang(github.com/coreos/ignition/v2/config/merge)) = 2.13.0
Provides: bundled(golang(github.com/coreos/ignition/v2/config/shared/errors)) = 2.13.0
Provides: bundled(golang(github.com/coreos/ignition/v2/config/shared/validations)) = 2.13.0
Provides: bundled(golang(github.com/coreos/ignition/v2/config/util)) = 2.13.0
Provides: bundled(golang(github.com/coreos/ignition/v2/config/v3_0/types)) = 2.13.0
Provides: bundled(golang(github.com/coreos/ignition/v2/config/v3_1/types)) = 2.13.0
Provides: bundled(golang(github.com/coreos/ignition/v2/config/v3_2/types)) = 2.13.0
Provides: bundled(golang(github.com/coreos/ignition/v2/config/v3_3/types)) = 2.13.0
Provides: bundled(golang(github.com/coreos/ignition/v2/config/v3_4_experimental/types)) = 2.13.0
Provides: bundled(golang(github.com/coreos/ignition/v2/config/validate)) = 2.13.0
Provides: bundled(golang(github.com/coreos/vcontext/json)) = 0.0.0-20211021162308.gitf1dbbca7bef4
Provides: bundled(golang(github.com/coreos/vcontext/path)) = 0.0.0-20211021162308.gitf1dbbca7bef4
Provides: bundled(golang(github.com/coreos/vcontext/report)) = 0.0.0-20211021162308.gitf1dbbca7bef4
Provides: bundled(golang(github.com/coreos/vcontext/tree)) = 0.0.0-20211021162308.gitf1dbbca7bef4
Provides: bundled(golang(github.com/coreos/vcontext/validate)) = 0.0.0-20211021162308.gitf1dbbca7bef4
Provides: bundled(golang(github.com/coreos/vcontext/yaml)) = 0.0.0-20211021162308.gitf1dbbca7bef4
Provides: bundled(golang(github.com/davecgh/go-spew/spew)) = 1.1.1
Provides: bundled(golang(github.com/spf13/pflag)) = 1.0.6-0.20210604193023.gitd5e0c0615ace
Provides: bundled(golang(github.com/stretchr/testify/assert)) = 1.7.0
Provides: bundled(golang(github.com/vincent-petithory/dataurl)) = 1.0.0
Provides: bundled(golang(gopkg.in/yaml.v3)) = 3.0.0-20210107192922.git496545a6307b
%description
%{common_description}
%package redistributable
Summary: Statically built Butane for Linux, macOS and Windows
License: ASL 2.0
BuildArch: noarch
Obsoletes: butane-nonlinux < 0.13.1-3
%description redistributable
%{common_description}
This package contains statically linked Linux, macOS and Windows Butane
binaries built through cross-compilation.
%prep
%autosetup -p1 -n %{name}-%{version}
%build
export LDFLAGS="-X github.com/coreos/butane/internal/version.Raw=%{version} "
export GOFLAGS="-mod=vendor"
echo "Building butane..."
%gobuild -o ./butane internal/main.go
%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
echo "Building Windows Butane..."
GOARCH=amd64 GOOS=windows %gocrossbuild -o butane-x86_64-pc-windows-gnu.exe internal/main.go
%install
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
%gocheck
%endif
%files
%license %{golicenses}
%doc %{godocs}
%{_bindir}/butane
%{_bindir}/fcct
%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
* Mon Jun 20 2022 fushanqing <fushanqing@kylinos.cn> - 0.14.0-1
- Initial package