File terraform-provider-libvirt.spec of Package terraform-provider-libvirt

#
# spec file for package terraform-provider-libvirt
#
# Copyright (c) 2025 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


Name:           terraform-provider-libvirt
Version:        0.8.3+git.1741083459.5d70006
Release:        0
Summary:        Terraform provider for KVM hypervisors via libvirt
License:        MPL-2.0
Group:          System/Management
URL:            https://github.com/dmacvicar/terraform-provider-libvirt/
Source:         %{name}-%{version}.tar.xz
Patch0:         ipv6.patch
Source99:       %{name}-rpmlintrc


%if 0%{?ubuntu_version}
BuildRequires:  debhelper
BuildRequires:  dh-golang
BuildRequires:  golang-go
BuildRequires:  libvirt-dev
BuildRequires:  pkgconfig
BuildRequires:  xz-utils
%else
BuildRequires:  golang
BuildRequires:  libvirt-devel
BuildRequires:  xz
%if 0%{?suse_version}
Requires:       mkisofs
%else
Requires:       genisoimage
%endif
Requires:       (terraform >= 1.6.0 or opentofu >= 1.10.7)
%if 0%{?fedora} || 0%{?rhel_version} || 0%{?centos_version}
BuildRequires:  golang
%endif
%endif

%description
This is a terraform provider that lets you provision servers on a libvirt host
via Terraform.

%prep
%autosetup -p1 -n %{name}-%{version}

%build
export GO111MODULE=on
export GOPROXY=off
# Optional: disable cgo for static build (if libvirt C bindings are not needed)
# export CGO_ENABLED=0

# Build stripped binary with version info
go build -ldflags "-s -w -X main.version=%{version}" -o terraform-provider-libvirt

%install
mkdir -p %{buildroot}%{_bindir}
install -m 0755 terraform-provider-libvirt %{buildroot}%{_bindir}/terraform-provider-libvirt

# Terraform plugin registry layout
VERSION=$(echo "%{version}" | cut -d '+' -f 1)
PROVIDER_OS_PATH="$(go env GOOS)_$(go env GOARCH)"

mkdir -p %{buildroot}%{_datadir}/terraform/plugins/registry.terraform.io/dmacvicar/libvirt/${VERSION}/${PROVIDER_OS_PATH}
ln -s %{_bindir}/terraform-provider-libvirt %{buildroot}%{_datadir}/terraform/plugins/registry.terraform.io/dmacvicar/libvirt/${VERSION}/${PROVIDER_OS_PATH}/terraform-provider-libvirt

mkdir -p %{buildroot}%{_datadir}/terraform/plugins/registry.opentofu.org/dmacvicar/libvirt/${VERSION}/${PROVIDER_OS_PATH}
ln -s %{_bindir}/terraform-provider-libvirt %{buildroot}%{_datadir}/terraform/plugins/registry.opentofu.org/dmacvicar/libvirt/${VERSION}/${PROVIDER_OS_PATH}/terraform-provider-libvirt

# Optional: package the binary tarball
curr=$PWD
if [ -d %{_topdir}/OTHER ]; then
    cd %{buildroot}%{_bindir}
    tar zcf %{_topdir}/OTHER/%{name}-%{version}.%{_repository}.%{_arch}.tar.gz terraform-provider-libvirt
fi
cd $curr

%files
%license LICENSE
%doc README.md
%{_datadir}/terraform
%{_bindir}/terraform-provider-libvirt

%changelog
openSUSE Build Service is sponsored by