Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions rpm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Building the rpm locally

The revised spec file uses [`go-vendor-tools`]
(https://fedora.gitlab.io/sigs/go/go-vendor-tools/scenarios/#generate-specfile-with-go2rpm)
which enable vendoring for Go
language packages in Fedora.

Follow these steps to build an rpm locally using Fedora packager tools.
These steps assume a Fedora machine.

1. Install packager tools. See [Installing Packager Tools](https://docs.fedoraproject.org/en-US/package-maintainers/Installing_Packager_Tools/).

1. Install go-vendor-tools:

``` bash
sudo dnf install go-vendor-tools*
```

1. Copy `podman-bootc.spec` and `go-vendor-tools.toml` into a directory.

1. Change into the directory.

1. Change version in spec file if needed.

1. Download tar file:

``` bash
spectool -g -s 0 podman-bootc.spec
```

1. Generate archive:

```bash
go_vendor_archive create --config go-vendor-tools.toml podman-bootc.spec
```

1. Build rpm locally:

```bash
fedpkg --release rawhide mockbuild --srpm-mock
```

1. Check output in the `results_podman-bootc` subdirectory
18 changes: 18 additions & 0 deletions rpm/go-vendor-tools.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[archive]

[licensing]
detector = "askalono"
[[licensing.licenses]]
path = "vendor/github.com/fsouza/go-dockerclient/DOCKER-LICENSE"
sha256sum = "04649aa5a97550d0bb083955b37586eb0ed6c6caa6e8a32f9cc840bbb3274254"
expression = "Apache-2.0"

[[licensing.licenses]]
path = "vendor/github.com/shirou/gopsutil/v3/LICENSE"
sha256sum = "ad1e64b82c04fb2ee6bfe521bff01266971ffaa70500024d4ac767c6033aafb9"
expression = "BSD-3-Clause"

[[licensing.licenses]]
path = "vendor/gopkg.in/yaml.v3/LICENSE"
sha256sum = "d18f6323b71b0b768bb5e9616e36da390fbd39369a81807cca352de4e4e6aa0b"
expression = "MIT"
Comment on lines +1 to +18
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry I forgot to ask why this file is required? (I'm not familiar with the go-vendor tool)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the go-vendor-tools macros process the license files during the rpm build process. The toml file provides configuration to that process. E.G. specify alternate license detector, set licenses for modules where the detector cannot find a license, exclude directories or files from license detection.

The toml file can also replace a module with a different version if needed. For example to resolve an urgent CVE.

See https://fedora.gitlab.io/sigs/go/go-vendor-tools/config/ for options.

95 changes: 63 additions & 32 deletions rpm/podman-bootc.spec
Original file line number Diff line number Diff line change
@@ -1,61 +1,92 @@
# Generated by go2rpm 1.16.0.post0
%bcond check 1

# https://github.com/containers/podman-bootc
%global goipath github.com/containers/podman-bootc
Version: 0.1.1
Version: 0.1.2

%gometa -L -f

%global golicenses LICENSE
%global godocs README.md
%global common_description %{expand:
A scriptable CLI that offers an efficient and ergonomic "edit-compile-debug"
cycle for bootable containers.}

Name: podman-bootc
Release: %autorelease
Summary: Streamlining podman + bootc interactions

License: Apache-2.0
# Generated by go-vendor-tools
License: Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND ISC AND MIT AND MPL-2.0 AND Unlicense
URL: %{gourl}
Source0: %{gosource}
Source1: vendor.tar.gz # Vendor file place holder

BuildRequires: gcc
BuildRequires: golang
BuildRequires: make
BuildRequires: libvirt-devel
# Generated by go-vendor-tools
Source1: %{archivename}-vendor.tar.bz2
Source2: go-vendor-tools.toml

Requires: podman-machine
Requires: xorriso
Requires: podman
Requires: qemu
Requires: libvirt
BuildRequires: go-vendor-tools
# make needed for man generation but not available in release
# BuildRequires: make
BuildRequires: gcc
BuildRequires: libvirt-devel
BuildRequires: go-md2man

%description
%{summary}.
Requires: podman-machine
Requires: xorriso
Requires: podman
Requires: qemu
Requires: libvirt

%gopkg
%description %{common_description}

%prep
%goprep -Ak # k: keep vendor directory
%setup -T -D -a 1
%goprep -A
%setup -q -T -D -a1 %{forgesetupargs}
%autopatch -p1

%generate_buildrequires
%go_vendor_license_buildrequires -c %{S:2}

%build
export BUILDTAGS="exclude_graphdriver_btrfs btrfs_noversion exclude_graphdriver_devicemapper containers_image_openpgp remote"
%gobuild -o %{gobuilddir}/bin/%%{name} %{goipath}
%{__make} docs
# explicitly turn on module support for gotest and gobuild
%global gomodulesmode GO111MODULE=on

# define global for use in gobuild and gotest
%global buildtags exclude_graphdriver_btrfs btrfs_noversion exclude_graphdriver_devicemapper containers_image_openpgp remote
export GO_BUILDTAGS="%{buildtags}"

%gobuild -o %{gobuilddir}/bin/podman-bootc %{goipath}

# docs directory not included in current source tar file
# build man files
# %%make_build docs

%install
%gopkginstall
%go_vendor_license_install -c %{S:2}
install -m 0755 -vd %{buildroot}%{_bindir}
install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/
install -m 0755 -vd %{buildroot}%{_mandir}/man1
install -m 0755 -vp docs/*.1 %{buildroot}%{_mandir}/man1/
# docs directory not included in current source tar file
# install -m 0755 -vd %%{buildroot}%%{_mandir}/man1
# install -m 0755 -vp docs/*.1 %%{buildroot}%%{_mandir}/man1/

%files
%license LICENSE
%doc README.md
%{_bindir}/*
%{_mandir}/man1/*.1*
%check
%go_vendor_license_check -c %{S:2}

%if %{with check}

# redefine gotestflags to include needed buildtags
%define gotestflags %{gocompilerflags} '-tags=%{buildtags}'

%gopkgfiles
# skip ./pkg/vms - cannot run vm tests in build
# skip ./test - end-to-end integration tests that cannot run in build
%gotest $(go list ./... | awk '!/(vm|test)/ {print $1}')
%endif

%files -f %{go_vendor_license_filelist}
%license vendor/modules.txt
%doc README.md
%{_bindir}/podman-bootc
# docs directory not included in current source tar file
# %%{_mandir}/man1/*.1*

%changelog
%autochangelog