Skip to content

Commit

Permalink
tools: Drop create-spec
Browse files Browse the repository at this point in the history
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:
<packit/packit#1621>. Work around that by
copying the spec to the root directory, and pointing to it.
  • Loading branch information
martinpitt committed Jun 14, 2022
1 parent 3f771c2 commit 48d0a2f
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 99 deletions.
9 changes: 1 addition & 8 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
5 changes: 1 addition & 4 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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)'

Expand All @@ -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)/" $< > $@
Expand Down
4 changes: 1 addition & 3 deletions autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" "$@" ;;
Expand Down
10 changes: 6 additions & 4 deletions packit.yaml
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -62,10 +64,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:
Expand Down
2 changes: 1 addition & 1 deletion tools/cockpit.spec.in → tools/cockpit.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
79 changes: 0 additions & 79 deletions tools/create-spec

This file was deleted.

0 comments on commit 48d0a2f

Please sign in to comment.