tools: Eliminate BUILD_ALL spec template variable

This is part of the RHEL 8 package split, and will disappear at some
point. Drop this knowledge from packit.yaml, and change our spec to
build all packages by default. Localize the split logic in
image-prepare's build_install_rhel8() instead, from where it is easier
to remove in bulk.
This commit is contained in:
Martin Pitt 2022-06-14 11:44:16 +02:00 committed by Martin Pitt
parent 213a2d7e47
commit 6fe66f053a
4 changed files with 39 additions and 21 deletions

View File

@ -2,7 +2,7 @@ upstream_project_url: https://github.com/cockpit-project/cockpit
actions:
post-upstream-clone:
# packit will overwrite the version in its "fix spec file" stage
- tools/create-spec --version 0 --build-all -o cockpit.spec tools/cockpit.spec.in
- tools/create-spec --version 0 -o cockpit.spec tools/cockpit.spec.in
# HACK: until FMF uses tests from dist-git source tarball: https://github.com/teemtee/tmt/issues/585
- sh -exc 'mkdir -p tmp; curl --silent --fail https://src.fedoraproject.org/rpms/cockpit/raw/rawhide/f/plans/upstream.fmf | sed -r "/ref:/ s/[0-9.]+/$(git describe --abbrev=0)/" > tmp/upstream.fmf'
@ -68,7 +68,7 @@ jobs:
# HACK: https://github.com/packit/packit/issues/1560
- tools/node-modules checkout
# packit will overwrite the version in its "fix spec file" stage
- tools/create-spec --version 0 --build-all -o cockpit.spec tools/cockpit.spec.in
- tools/create-spec --version 0 -o cockpit.spec tools/cockpit.spec.in
# HACK: tarball for releases (copr_build, koji, etc.), copying spec's Source0; this
# really should be the default, see https://github.com/packit/packit-service/issues/1505
create-archive:

View File

@ -105,22 +105,43 @@ def build_install_coreos(dist_tar, image, verbose, quick):
return args
def build_install_rhel8(dist_tar, verbose):
def build_install_rhel8(dist_tar, image, verbose):
'''Special treatment of build/install on RHEL/CentOS 8
Here, cockpit is delivered as two mostly identical source packages: "cockpit" with
build_basic=1, and "cockpit-appstream" with build_optional=1. The spec has proper build_*
defaults depending on the Name:.
Basic is already built/installed in build_install_package() (except for distropkg); build the
cockpit-appstream variant here.
'''
vm_dist_tar = os.path.join("/var/tmp", os.path.basename(dist_tar))
return [
"--upload", f"{dist_tar}:{vm_dist_tar}",
args = ["--upload", f"{dist_tar}:{vm_dist_tar}"]
# in distropkg, keep basic OS packages, otherwise build/install cockpit
if 'distropkg' not in image:
args += [
# create cockpit.spec
"--run-command",
f"tar xf '{vm_dist_tar}' -O '*/tools/cockpit.spec' | sed '/%define build_all/d' > /var/tmp/cockpit.spec",
# create srpm
"--run-command",
"""su builder -c 'rpmbuild --define "_topdir /var/tmp/build" --define "_sourcedir /var/tmp" """
"""-bs /var/tmp/cockpit.spec' """,
# build rpms in mock
"--run-command",
"""su builder -c 'mock --no-clean --no-cleanup-after --disablerepo=* --offline --resultdir /var/tmp/build """
f"""--nocheck {"--verbose" if verbose else ""} --rebuild /var/tmp/build/SRPMS/*.src.rpm' """,
# install rpms
"--run-command",
"rpm -U --force --verbose $(find /var/tmp/build -name '*.rpm' -not -name '*.src.rpm')"]
# always build cockpit-appstream
args += [
# create cockpit-appstream.spec
"--run-command",
f"tar xf '{vm_dist_tar}' -O '*/tools/cockpit.spec' | sed '/^Name:/ s/$/-appstream/' > /var/tmp/cockpit-appstream.spec",
f"tar xf '{vm_dist_tar}' -O '*/tools/cockpit.spec' | sed '/^Name:/ s/$/-appstream/; /%define build_all/d' > /var/tmp/cockpit-appstream.spec",
# create srpm
"--run-command",
@ -136,6 +157,8 @@ def build_install_rhel8(dist_tar, verbose):
"--run-command",
"rpm -i --verbose $(find /var/tmp/appstream -name '*.rpm' -not -name '*.src.rpm')"]
return args
def validate_packages():
'''Post-install package checks'''
@ -190,12 +213,11 @@ def main():
if args.image == "fedora-coreos":
customize += build_install_coreos(dist_tar, args.image, args.verbose, args.quick)
elif "distropkg" not in args.image:
elif args.image.startswith("rhel-8") or args.image.startswith("centos-8"):
customize += build_install_rhel8(dist_tar, args.image, args.verbose)
else:
customize += build_install_package(dist_tar, args.image)
if args.image.startswith("rhel-8") or args.image.startswith("centos-8"):
customize += build_install_rhel8(dist_tar, args.verbose)
if args.containers:
customize += build_containers()

View File

@ -55,11 +55,11 @@ Source0: https://github.com/cockpit-project/cockpit/releases/download/%{v
# in RHEL 8 the source package is duplicated: cockpit (building basic packages like cockpit-{bridge,system})
# and cockpit-appstream (building optional packages like cockpit-{pcp})
# This split does not apply to EPEL/COPR.
# This split does not apply to EPEL/COPR nor packit c8s builds, only to our own
# image-prepare rhel-8-Y builds (which will disable build_all).
# In Fedora ELN/RHEL 9+ there is just one source package, which ships rpms in both BaseOS and AppStream
# We also provide an override mechanism if you want to build all packages.
%define build_all @BUILD_ALL@
%if 0%{?rhel} == 8 && 0%{?epel} == 0 && !%{build_all}
%define build_all 1
%if 0%{?rhel} == 8 && 0%{?epel} == 0 && !0%{?build_all}
%if "%{name}" == "cockpit"
%define build_basic 1

View File

@ -38,9 +38,6 @@ def substitute(match, args, package):
if variable == 'VERSION':
return args.version
elif variable == 'BUILD_ALL':
return '1' if args.build_all else '0'
else:
raise ValueError(f'Unsupported substitution @{variable}@')
@ -70,7 +67,6 @@ def open_output(filename):
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--version', '-v', required=True, help='The version number')
parser.add_argument('--build-all', action='store_true', help='Disable RHEL 8 hacks')
parser.add_argument('--output', '-o', help='The output file (or stdout)')
parser.add_argument('template', nargs='*', help='The template (or stdin)')
args = parser.parse_args()