butane/butane.spec
2024-01-15 18:03:52 +08:00

149 lines
6.8 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
Name: butane
Version: 0.18.0
Release: 1
Summary: Butane config transpiler
License: Apache-2.0
URL: https://github.com/coreos/butane
Source0: %{url}/archive/refs/tags/v%{version}.tar.gz
Patch0: 0001-support-nestos-variant.patch
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.17.1
Provides: bundled(golang(github.com/coreos/go-semver/semver)) = 0.3.1
Provides: bundled(golang(github.com/coreos/go-systemd/v22/unit)) = 22.5.0
Provides: bundled(golang(github.com/coreos/ignition/v2/config/merge)) = 2.15.0
Provides: bundled(golang(github.com/coreos/ignition/v2/config/shared/errors)) = 2.15.0
Provides: bundled(golang(github.com/coreos/ignition/v2/config/shared/parse)) = 2.15.0
Provides: bundled(golang(github.com/coreos/ignition/v2/config/shared/validations)) = 2.15.0
Provides: bundled(golang(github.com/coreos/ignition/v2/config/util)) = 2.15.0
Provides: bundled(golang(github.com/coreos/ignition/v2/config/v3_0/types)) = 2.15.0
Provides: bundled(golang(github.com/coreos/ignition/v2/config/v3_1/types)) = 2.15.0
Provides: bundled(golang(github.com/coreos/ignition/v2/config/v3_2/types)) = 2.15.0
Provides: bundled(golang(github.com/coreos/ignition/v2/config/v3_3/types)) = 2.15.0
Provides: bundled(golang(github.com/coreos/ignition/v2/config/v3_4/types)) = 2.15.0
Provides: bundled(golang(github.com/coreos/ignition/v2/config/v3_5_experimental/types)) = 2.15.0
Provides: bundled(golang(github.com/coreos/ignition/v2/config/validate)) = 2.15.0
Provides: bundled(golang(github.com/coreos/vcontext/json)) = 0.0.0-20230201181013.gitd72178a18687
Provides: bundled(golang(github.com/coreos/vcontext/path)) = 0.0.0-20230201181013.gitd72178a18687
Provides: bundled(golang(github.com/coreos/vcontext/report)) = 0.0.0-20230201181013.gitd72178a18687
Provides: bundled(golang(github.com/coreos/vcontext/tree)) = 0.0.0-20230201181013.gitd72178a18687
Provides: bundled(golang(github.com/coreos/vcontext/validate)) = 0.0.0-20230201181013.gitd72178a18687
Provides: bundled(golang(github.com/coreos/vcontext/yaml)) = 0.0.0-20230201181013.gitd72178a18687
Provides: bundled(golang(github.com/spf13/pflag)) = 1.0.6-0.20210604193023.gitd5e0c0615ace
Provides: bundled(golang(github.com/stretchr/testify/assert)) = 1.8.2
Provides: bundled(golang(github.com/vincent-petithory/dataurl)) = 1.0.0
Provides: bundled(golang(gopkg.in/yaml.v3)) = 3.0.1
%description
%{common_description}
%package redistributable
Summary: Statically built Butane for Linux, macOS and Windows
License: Apache-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
GOARCH=arm64 GOOS=darwin %gocrossbuild -o butane-aarch64-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-apple-darwin %{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-apple-darwin
%{_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 Jan 15 2024 lijian <lijian2@kylinos.cn> - 0.18.0-1
- Upgrade to 0.18.0
* Fri Dec 01 2023 chendexi <chendexi@kylinos.cn> - 0.14.0-3
- Delete the compilation of ppc64 and s390 architecture
* Wed Oct 26 2022 fushanqing <fushanqing@kylinos.cn> - 0.14.0-2
- support nestos variant
* Mon Jun 20 2022 fushanqing <fushanqing@kylinos.cn> - 0.14.0-1
- Initial package