diff --git a/HACKING.md b/HACKING.md index f5d770d0a..e7e53a753 100644 --- a/HACKING.md +++ b/HACKING.md @@ -32,14 +32,7 @@ locally (see [testing README](test/README.md)), you will need additional header files and other components. The following should work in a fresh Git clone: $ sudo dnf install dnf-utils python-srpm-macros - $ TEMPFILE=$(mktemp -u --suffix=.spec) && \ - ./tools/create-spec --version 1 -o "$TEMPFILE" tools/cockpit.spec.in && \ - sudo dnf builddep --spec "$TEMPFILE" && - rm "$TEMPFILE" - -Note that `tools/cockpit.spec.in` is a template filled in by -`tools/create-spec` when building RPMs, and cannot be directly parsed -by dnf. + $ sudo dnf builddep --spec tools/cockpit.spec For running the browser unit tests, the following dependencies are required: diff --git a/Makefile.am b/Makefile.am index 9d9e6ac37..060794bff 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,6 +28,7 @@ distdir: $(DISTFILES) mv .extra_dist.tmp '$(srcdir)/.extra_dist'; fi $(MAKE) $(AM_MAKEFLAGS) distdir-am EXTRA_FILES="$$(tr '\n' ' ' < $(srcdir)/.extra_dist) .extra_dist" test ! -x $(srcdir)/src/client/add-metainfo-releases || $(srcdir)/src/client/add-metainfo-releases --version '$(VERSION)' '$(distdir)'/src/client/*.metainfo.xml + sed -i "/^Version:/ s/0/$(VERSION)/" "$(distdir)/tools/cockpit.spec" $(srcdir)/tools/adjust-distdir-timestamps "$(distdir)" @echo ' DIST $(DIST_ARCHIVES)' @@ -46,10 +47,6 @@ dist-hook: $(distdir)/tools/arch/PKGBUILD $(distdir)/tools/arch/PKGBUILD: $(distdir)/tools/arch/PKGBUILD.in $(AM_V_GEN) sed "s/VERSION/$(VERSION)/" $< > $@ -dist-hook: $(distdir)/tools/cockpit.spec -$(distdir)/tools/cockpit.spec: $(distdir)/tools/cockpit.spec.in - $(AM_V_GEN) $(srcdir)/tools/create-spec --version "$(VERSION)" -o $@ $< - dist-hook: $(distdir)/tools/debian/changelog $(distdir)/tools/debian/changelog: $(distdir)/tools/debian/changelog.in $(AM_V_GEN) sed "s/VERSION/$(VERSION)/" $< > $@ diff --git a/autogen.sh b/autogen.sh index ae93241f5..36f2a99d0 100755 --- a/autogen.sh +++ b/autogen.sh @@ -15,10 +15,8 @@ srcdir="${0%/*}" case "${1:-}" in rpm) # configure with the same flags as when building an RPM - mkdir -p tmp/rpmbuild/SPECS - tools/create-spec -v 0 -o tmp/rpmbuild/SPECS/cockpit.spec tools/cockpit.spec.in exec rpmbuild -D '_topdir tmp/rpmbuild' -D 'make_build #' \ - --build-in-place -bc tmp/rpmbuild/SPECS/cockpit.spec ;; + --build-in-place -bc tools/cockpit.spec ;; *) exec "${srcdir}/configure" "$@" ;; diff --git a/packit.yaml b/packit.yaml index fa18b9c7d..33c1e64f7 100644 --- a/packit.yaml +++ b/packit.yaml @@ -1,8 +1,10 @@ upstream_project_url: https://github.com/cockpit-project/cockpit +# HACK: spec must be next to the generated tarball; https://github.com/packit/packit/issues/1621 +specfile_path: cockpit.spec actions: post-upstream-clone: - # packit will overwrite the version in its "fix spec file" stage - - tools/create-spec --version 0 -o cockpit.spec tools/cockpit.spec.in + # HACK: spec must be next to the generated tarball; https://github.com/packit/packit/issues/1621 + - cp tools/cockpit.spec . # 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' @@ -65,10 +67,10 @@ jobs: - centos-stream-9-x86_64 actions: post-upstream-clone: + # HACK: spec must be next to the generated tarball; https://github.com/packit/packit/issues/1621 + - cp tools/cockpit.spec . # 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 -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: diff --git a/tools/cockpit.spec.in b/tools/cockpit.spec similarity index 99% rename from tools/cockpit.spec.in rename to tools/cockpit.spec index 11f3cce2e..38abc2d2f 100644 --- a/tools/cockpit.spec.in +++ b/tools/cockpit.spec @@ -49,7 +49,7 @@ Summary: Web Console for Linux servers License: LGPLv2+ URL: https://cockpit-project.org/ -Version: @VERSION@ +Version: 0 Release: 1%{?dist} Source0: https://github.com/cockpit-project/cockpit/releases/download/%{version}/cockpit-%{version}.tar.xz diff --git a/tools/create-spec b/tools/create-spec deleted file mode 100755 index 113e0a0ee..000000000 --- a/tools/create-spec +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/python3 - -# This file is part of Cockpit. -# -# Copyright © 2022 Red Hat, Inc. -# -# Cockpit is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation; either version 2.1 of the License, or -# (at your option) any later version. -# -# Cockpit is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with Cockpit; If not, see . - -import argparse -import contextlib -import fileinput -import os.path -import re -import sys - - -BASE_DIR = os.path.realpath(f'{__file__}/../..') - - -def wip_version(args): - return 'g' in args.version - - -def substitute(match, args, package): - variable = match.group(1) - - if variable == 'VERSION': - return args.version - - else: - raise ValueError(f'Unsupported substitution @{variable}@') - - -def replace_fields(output, lines, args): - variable_re = re.compile(r'@([A-Z_]+)@') - package_re = re.compile(r'%package (-n cockpit-)?([a-z]*)') - package = None - - for line in lines: - if match := package_re.fullmatch(line.strip()): - package = match.group(2) - line = variable_re.sub(lambda m: substitute(m, args, package), line) - output.write(line) - - -@contextlib.contextmanager -def open_output(filename): - if filename: - fp = open(filename, 'w+') - yield fp - fp.close() - else: - yield sys.stdout - - -def main(): - parser = argparse.ArgumentParser() - parser.add_argument('--version', '-v', required=True, help='The version number') - 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() - - with open_output(args.output) as output: - replace_fields(output, fileinput.input(args.template), args) - - -if __name__ == '__main__': - main()