tools: Drop create-spec
Keep `Version: 0` in the spec file. This works fine with `autogen rpm`, `dnf builddep, and Packit. It was the last macro, so now it's a real working .spec. This avoids having to invoke this script all the time. This simplifies our packit config a bit and stops swimming against the stream. The only place where we want a real version is `make dist`, so that built RPMs have a correct version. Rework the rule to modify the file in-place in distdir. Unfortunately this uncovers another packit bug: If the .spec file is not in the same directory as the tarball, `packit srpm` gets upset: <https://github.com/packit/packit/issues/1621>. Work around that by copying the spec to the root directory, and pointing to it.
This commit is contained in:
parent
6fe66f053a
commit
ec81f06390
|
@ -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:
|
files and other components. The following should work in a fresh Git clone:
|
||||||
|
|
||||||
$ sudo dnf install dnf-utils python-srpm-macros
|
$ sudo dnf install dnf-utils python-srpm-macros
|
||||||
$ TEMPFILE=$(mktemp -u --suffix=.spec) && \
|
$ sudo dnf builddep --spec tools/cockpit.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.
|
|
||||||
|
|
||||||
For running the browser unit tests, the following dependencies are required:
|
For running the browser unit tests, the following dependencies are required:
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ distdir: $(DISTFILES)
|
||||||
mv .extra_dist.tmp '$(srcdir)/.extra_dist'; fi
|
mv .extra_dist.tmp '$(srcdir)/.extra_dist'; fi
|
||||||
$(MAKE) $(AM_MAKEFLAGS) distdir-am EXTRA_FILES="$$(tr '\n' ' ' < $(srcdir)/.extra_dist) .extra_dist"
|
$(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
|
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)"
|
$(srcdir)/tools/adjust-distdir-timestamps "$(distdir)"
|
||||||
@echo ' DIST $(DIST_ARCHIVES)'
|
@echo ' DIST $(DIST_ARCHIVES)'
|
||||||
|
|
||||||
|
@ -46,10 +47,6 @@ dist-hook: $(distdir)/tools/arch/PKGBUILD
|
||||||
$(distdir)/tools/arch/PKGBUILD: $(distdir)/tools/arch/PKGBUILD.in
|
$(distdir)/tools/arch/PKGBUILD: $(distdir)/tools/arch/PKGBUILD.in
|
||||||
$(AM_V_GEN) sed "s/VERSION/$(VERSION)/" $< > $@
|
$(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
|
dist-hook: $(distdir)/tools/debian/changelog
|
||||||
$(distdir)/tools/debian/changelog: $(distdir)/tools/debian/changelog.in
|
$(distdir)/tools/debian/changelog: $(distdir)/tools/debian/changelog.in
|
||||||
$(AM_V_GEN) sed "s/VERSION/$(VERSION)/" $< > $@
|
$(AM_V_GEN) sed "s/VERSION/$(VERSION)/" $< > $@
|
||||||
|
|
|
@ -15,10 +15,8 @@ srcdir="${0%/*}"
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
rpm)
|
rpm)
|
||||||
# configure with the same flags as when building an 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 #' \
|
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" "$@" ;;
|
exec "${srcdir}/configure" "$@" ;;
|
||||||
|
|
10
packit.yaml
10
packit.yaml
|
@ -1,8 +1,10 @@
|
||||||
upstream_project_url: https://github.com/cockpit-project/cockpit
|
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:
|
actions:
|
||||||
post-upstream-clone:
|
post-upstream-clone:
|
||||||
# packit will overwrite the version in its "fix spec file" stage
|
# HACK: spec must be next to the generated tarball; https://github.com/packit/packit/issues/1621
|
||||||
- tools/create-spec --version 0 -o cockpit.spec tools/cockpit.spec.in
|
- cp tools/cockpit.spec .
|
||||||
# HACK: until FMF uses tests from dist-git source tarball: https://github.com/teemtee/tmt/issues/585
|
# 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'
|
- 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
|
- centos-stream-9-x86_64
|
||||||
actions:
|
actions:
|
||||||
post-upstream-clone:
|
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
|
# HACK: https://github.com/packit/packit/issues/1560
|
||||||
- tools/node-modules checkout
|
- 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
|
# 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
|
# really should be the default, see https://github.com/packit/packit-service/issues/1505
|
||||||
create-archive:
|
create-archive:
|
||||||
|
|
|
@ -49,7 +49,7 @@ Summary: Web Console for Linux servers
|
||||||
License: LGPLv2+
|
License: LGPLv2+
|
||||||
URL: https://cockpit-project.org/
|
URL: https://cockpit-project.org/
|
||||||
|
|
||||||
Version: @VERSION@
|
Version: 0
|
||||||
Release: 1%{?dist}
|
Release: 1%{?dist}
|
||||||
Source0: https://github.com/cockpit-project/cockpit/releases/download/%{version}/cockpit-%{version}.tar.xz
|
Source0: https://github.com/cockpit-project/cockpit/releases/download/%{version}/cockpit-%{version}.tar.xz
|
||||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
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()
|
|
Loading…
Reference in New Issue