File ansible-terraform-inventory.spec of Package test

# 软件包基本信息
Name:    ansible-terraform-inventory
Version: 0.10
Release: 1.1
Summary: Terraform inventory plugin for Ansible  # Ansible 的 Terraform 库存插件
License: MIT
Group:   Development/Tools
URL:     https://github.com/adammck/terraform-inventory

# 源代码文件
Source0: ansible-terraform-inventory-%{version}.tar.gz
Source1: vendor.tar.gz

# 构建依赖
BuildRequires: go
BuildRequires: rpm-build

%description
# 软件描述:Ansible 的 Terraform 库存插件
A Terraform inventory plugin for Ansible.

%prep
# 准备阶段:解压源代码
%setup -q -n ansible-terraform-inventory-%{version}
tar -xzf %{SOURCE1}  # 解压 vendor 包

%build
# 构建阶段:使用 Go 编译
export CGO_ENABLED=0  # 禁用 cgo
go build -mod=vendor '-ldflags=-X main.build_version=v%{version}' -o bin/terraform-inventory

%install
# 安装阶段:将二进制文件安装到系统目录
mkdir -p %{buildroot}/usr/bin
install -m 755 bin/terraform-inventory %{buildroot}/usr/bin/

%files
# 定义包中包含的文件
/usr/bin/terraform-inventory

%changelog
# 更新日志
* Sun Aug 10 2025 Your Name <your.email@example.com> - 0.10-1.1
- 初始软件包
- 移除 -buildmode=pie 以修复 cgo 构建错误
openSUSE Build Service is sponsored by