Skip to content

Commit 37ccc27

Browse files
committed
Packit: easier to read distro conditionals
Distro conditionals have been rewritten in a cleaner and easier to read way. The prior `changelog` conditional didn't break any builds and wasn't noticeable as such. Just that the manual placeholder changelog would get used even when autochangelog support existed. Renamed: manual_changelog -> autochangelog, as `autochangelog` is used already in the default changelog macro and provides better consistency in `bcond_with[out]` conditions for changelog and go-rpm-macros. Also removed macros related to `import_path` as they are no longer necessary. Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>
1 parent caf8c55 commit 37ccc27

File tree

1 file changed

+15
-42
lines changed

1 file changed

+15
-42
lines changed

rpm/skopeo.spec

+15-42
Original file line numberDiff line numberDiff line change
@@ -7,57 +7,30 @@
77
%global debug_package %{nil}
88
%endif
99

10+
11+
%if %{defined rhel} && 0%{?rhel} == 8
1012
# RHEL 8's default %%gobuild macro doesn't account for the BUILDTAGS variable, so we
1113
# set it separately here and do not depend on RHEL 8's go-srpm-macros package.
12-
%if !0%{?fedora} && 0%{?rhel} <= 8
1314
%define gobuild(o:) go build -buildmode pie -compiler gc -tags="rpm_crashtraceback libtrust_openssl ${BUILDTAGS:-}" -ldflags "-linkmode=external -compressdwarf=false ${LDFLAGS:-} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '%__global_ldflags'" -a -v -x %{?**};
1415
%endif
1516

1617
%global gomodulesmode GO111MODULE=on
1718

18-
# NOTE: For conditionals %%bcond_with and %%bcond_without,
19-
# See: https://rpm-software-management.github.io/rpm/manual/conditionalbuilds.html
20-
21-
# copr_username is only set on copr environments, not on others like koji
22-
%if "%{?copr_username}" != "rhcontainerbot"
23-
%bcond_with copr
24-
%else
25-
%bcond_without copr
26-
%endif
27-
28-
%if 0%{?rhel}
29-
%bcond_with btrfs
30-
%else
31-
%bcond_without btrfs
32-
%endif
33-
34-
# go-rpm-macros package and autochangelog exists for fedora and rhel9
35-
%if 0%{?fedora} || 0%{?rhel} >= 9
36-
%bcond_without go_rpm_macros
37-
%bcond_without manual_changelog
38-
%else
39-
%bcond_with go_rpm_macros
40-
%bcond_without manual_changelog
19+
# No btrfs on RHEL
20+
%if %{defined fedora}
21+
%define build_with_btrfs 1
4122
%endif
4223

4324
# Only used in official koji builds
4425
# Copr builds set a separate epoch for all environments
45-
%if 0%{?fedora} && ! 0%{?rhel}
26+
%if %{defined fedora}
4627
%define conditional_epoch 1
4728
%else
4829
%define conditional_epoch 2
4930
%endif
5031

51-
%global provider github
52-
%global provider_tld com
53-
%global project containers
54-
%global repo skopeo
55-
# https://github.com/containers/skopeo
56-
%global import_path %{provider}.%{provider_tld}/%{project}/%{repo}
57-
%global git0 https://%{import_path}
58-
59-
Name: %{repo}
60-
%if %{with copr}
32+
Name: skopeo
33+
%if %{defined copr_username}
6134
Epoch: 102
6235
%else
6336
Epoch: %{conditional_epoch}
@@ -77,16 +50,16 @@ ExclusiveArch: %{golang_arches_future}
7750
ExclusiveArch: aarch64 ppc64le s390x x86_64
7851
%endif
7952
Summary: Inspect container images and repositories on registries
80-
URL: %{git0}
53+
URL: https://github.com/containers/%{name}
8154
# Tarball fetched from upstream
8255
Source0: %{url}/archive/v%{version}.tar.gz
8356
BuildRequires: go-md2man
84-
%if %{with btrfs}
57+
%if %{defined build_with_btrfs}
8558
BuildRequires: btrfs-progs-devel
8659
%endif
8760
BuildRequires: git-core
8861
BuildRequires: golang
89-
%if %{with go_rpm_macros}
62+
%if !%{defined gobuild}
9063
BuildRequires: go-rpm-macros
9164
%endif
9265
BuildRequires: gpgme-devel
@@ -146,7 +119,7 @@ export CGO_CFLAGS="$CGO_CFLAGS -m64 -mtune=generic -fcf-protection=full"
146119
%endif
147120

148121
BASEBUILDTAGS="$(hack/libdm_tag.sh) $(hack/libsubid_tag.sh)"
149-
%if %{with btrfs}
122+
%if %{defined build_with_btrfs}
150123
export BUILDTAGS="$BASEBUILDTAGS $(hack/btrfs_tag.sh) $(hack/btrfs_installed_tag.sh)"
151124
%else
152125
export BUILDTAGS="$BASEBUILDTAGS btrfs_noversion exclude_graphdriver_btrfs"
@@ -189,12 +162,12 @@ cp -pav systemtest/* %{buildroot}/%{_datadir}/%{name}/test/system/
189162
%{_datadir}/%{name}/test
190163

191164
%changelog
192-
%if %{with manual_changelog}
165+
%if %{defined autochangelog}
166+
%autochangelog
167+
%else
193168
# NOTE: This changelog will be visible on CentOS 8 Stream builds
194169
# Other envs are capable of handling autochangelog
195170
* Tue Jun 13 2023 RH Container Bot <rhcontainerbot@fedoraproject.org>
196171
- Placeholder changelog for envs that are not autochangelog-ready.
197172
- Contact upstream if you need to report an issue with the build.
198-
%else
199-
%autochangelog
200173
%endif

0 commit comments

Comments
 (0)