Skip to content

Commit 0297033

Browse files
committed
Packit: easier to read distro conditionals
Distro conditionals have been rewritten in a cleaner and easier to read way. All `bcond` macros have been replaced with friendlier alternatives. Also removed macros related to `import_path` as they are no longer necessary. update-spec-provides.sh has been updated to account for possible build issues in downstream tasks which won't be noticed until a downstream release. Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>
1 parent 3fcadda commit 0297033

File tree

2 files changed

+16
-44
lines changed

2 files changed

+16
-44
lines changed

rpm/skopeo.spec

+14-42
Original file line numberDiff line numberDiff line change
@@ -9,55 +9,27 @@
99

1010
# RHEL 8's default %%gobuild macro doesn't account for the BUILDTAGS variable, so we
1111
# set it separately here and do not depend on RHEL 8's go-srpm-macros package.
12-
%if !0%{?fedora} && 0%{?rhel} <= 8
12+
%if %{defined rhel} && 0%{?rhel} == 8
1313
%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 %{?**};
1414
%endif
1515

1616
%global gomodulesmode GO111MODULE=on
1717

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
18+
# No btrfs on RHEL
19+
%if %{defined fedora}
20+
%define build_with_btrfs 1
4121
%endif
4222

4323
# Only used in official koji builds
4424
# Copr builds set a separate epoch for all environments
45-
%if 0%{?fedora} && ! 0%{?rhel}
25+
%if %{defined fedora}
4626
%define conditional_epoch 1
4727
%else
4828
%define conditional_epoch 2
4929
%endif
5030

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}
31+
Name: skopeo
32+
%if %{defined copr_username}
6133
Epoch: 102
6234
%else
6335
Epoch: %{conditional_epoch}
@@ -77,16 +49,16 @@ ExclusiveArch: %{golang_arches_future}
7749
ExclusiveArch: aarch64 ppc64le s390x x86_64
7850
%endif
7951
Summary: Inspect container images and repositories on registries
80-
URL: %{git0}
52+
URL: https://github.com/containers/%{name}
8153
# Tarball fetched from upstream
8254
Source0: %{url}/archive/v%{version}.tar.gz
8355
BuildRequires: go-md2man
84-
%if %{with btrfs}
56+
%if %{defined build_with_btrfs}
8557
BuildRequires: btrfs-progs-devel
8658
%endif
8759
BuildRequires: git-core
8860
BuildRequires: golang
89-
%if %{with go_rpm_macros}
61+
%if !%{defined gobuild}
9062
BuildRequires: go-rpm-macros
9163
%endif
9264
BuildRequires: gpgme-devel
@@ -146,7 +118,7 @@ export CGO_CFLAGS="$CGO_CFLAGS -m64 -mtune=generic -fcf-protection=full"
146118
%endif
147119

148120
BASEBUILDTAGS="$(hack/libdm_tag.sh) $(hack/libsubid_tag.sh)"
149-
%if %{with btrfs}
121+
%if %{defined build_with_btrfs}
150122
export BUILDTAGS="$BASEBUILDTAGS $(hack/btrfs_tag.sh) $(hack/btrfs_installed_tag.sh)"
151123
%else
152124
export BUILDTAGS="$BASEBUILDTAGS btrfs_noversion exclude_graphdriver_btrfs"
@@ -189,12 +161,12 @@ cp -pav systemtest/* %{buildroot}/%{_datadir}/%{name}/test/system/
189161
%{_datadir}/%{name}/test
190162

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

rpm/update-spec-provides.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
# packaging, via the `propose-downstream` packit action.
55
# The goimports don't need to be present upstream.
66

7-
set -e
7+
set -eo pipefail
88

9-
PACKAGE=$(basename $(git rev-parse --show-toplevel))
9+
PACKAGE=skopeo
1010
# script is run from git root directory
1111
SPEC_FILE=rpm/$PACKAGE.spec
1212

0 commit comments

Comments
 (0)