Skip to content

Commit

Permalink
[CI:BUILD] Packit: add jobs for downstream Fedora package builds
Browse files Browse the repository at this point in the history
Get rid of `podman.spec.rpkg` in favour of
`rpm/podman.spec` which gets synced with fedora dist-git on every
upstream release. The version in the new spec file is set to `0` by
default and gets updated by packit automatically on every packit task.

For local manual rpm builds using the spec, the helper script in the
`rpm/` subdir will update the Version field with the latest version
found in the upstream repo.

Packit will automatically create a PR on fedora dist-git on every new
upstream release. A sample PR will look like:
https://src.fedoraproject.org/rpms/container-selinux/pull-request/10#

A dry run for this can be triggered using:
`$ packit propose-downstream --local-content`

To run this command locally, you would need to have your packit
user-configuration-file set.
Ref: https://packit.dev/docs/configuration/#user-configuration-file

along with a fedora api key created at:
https://src.fedoraproject.org/settings#nav-api-tab with sufficient ACLs.

Also includes a revised `package` Makefile target which will build rpms
using `rpm/podman.spec`. Fixes: containers#18421.

[NO NEW TESTS NEEDED]

Signed-off-by: Lokesh Mandvekar <[email protected]>
(cherry picked from commit 6003dca)
Signed-off-by: Lokesh Mandvekar <[email protected]>
  • Loading branch information
lsm5 committed May 24, 2023
1 parent bcc68fc commit 6652633
Show file tree
Hide file tree
Showing 8 changed files with 497 additions and 272 deletions.
25 changes: 17 additions & 8 deletions .packit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,33 @@

set -eo pipefail

# Get Version from version/version.go in HEAD
VERSION=$(grep '^const RawVersion' version/rawversion/version.go | cut -d\" -f2 | sed -e 's/-/~/')
# Set path to rpm spec file
SPEC_FILE=rpm/podman.spec

# Get Version from HEAD
VERSION=$(grep '^const RawVersion' version/rawversion/version.go | cut -d\" -f2)

# RPM Version can't take "-"
RPM_VERSION=$(echo $VERSION | sed -e 's/-/~/')

# Generate source tarball from HEAD
git archive --prefix=podman-$VERSION/ -o podman-$VERSION.tar.gz HEAD

# rpmbuild expects source tarball in the same dir as spec file
mv podman-$VERSION.tar.gz rpm/

# RPM Spec modifications

# Use the Version from version/version.go in rpm spec
sed -i "s/^Version:.*/Version: $VERSION/" podman.spec
# Use the Version from HEAD in rpm spec
sed -i "s/^Version:.*/Version: $RPM_VERSION/" $SPEC_FILE

# Use Packit's supplied variable in the Release field in rpm spec.
# podman.spec is generated using `rpkg spec --outdir ./` as mentioned in the
# `post-upstream-clone` action in .packit.yaml.
sed -i "s/^Release:.*/Release: $PACKIT_RPMSPEC_RELEASE%{?dist}/" podman.spec
sed -i "s/^Release:.*/Release: $PACKIT_RPMSPEC_RELEASE%{?dist}/" $SPEC_FILE

# Use above generated tarball as Source in rpm spec
sed -i "s/^Source:.*.tar.gz/Source: podman-$VERSION.tar.gz/" podman.spec
sed -i "s/^Source0:.*.tar.gz/Source0: podman-$VERSION.tar.gz/" $SPEC_FILE

# Use the right build dir for autosetup stage in rpm spec
sed -i "s/^%setup.*/%autosetup -Sgit -n %{name}-$VERSION/" podman.spec
# Update setup macro to use the correct build dir
sed -i "s/^%autosetup.*/%autosetup -Sgit -n %{name}-$VERSION/" $SPEC_FILE
26 changes: 23 additions & 3 deletions .packit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
# Build targets can be found at:
# https://copr.fedorainfracloud.org/coprs/rhcontainerbot/packit-builds/

specfile_path: podman.spec
specfile_path: rpm/podman.spec
upstream_tag_template: v{version}

jobs:
- &copr
Expand All @@ -18,8 +19,6 @@ jobs:
- make
- rpkg
actions:
post-upstream-clone:
- "rpkg spec --outdir ./"
fix-spec-file:
- "bash .packit.sh"

Expand All @@ -30,3 +29,24 @@ jobs:
trigger: commit
branch: v4.5
project: qm

- job: propose_downstream
trigger: release
update_release: false
dist_git_branches:
- fedora-all
#TODO use the right action to update the goimports
# For whatever reason, none of the actions seem to work
#actions:
# create-patches:
# - "cd rpm && bash update-spec-provides.sh"

- job: koji_build
trigger: commit
dist_git_branches:
- fedora-all

- job: bodhi_update
trigger: commit
dist_git_branches:
- fedora-branched # rawhide updates are created automatically
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ win-gvproxy: test/version/version

.PHONY: package
package: ## Build rpm packages
rpkg local
$(MAKE) -C rpm

###
### Installation targets
Expand Down
260 changes: 0 additions & 260 deletions podman.spec.rpkg

This file was deleted.

10 changes: 10 additions & 0 deletions rpm/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
rpm:
$(shell /usr/bin/bash ./update-spec-version.sh)
spectool -g podman.spec
sudo dnf -y builddep podman.spec
rpmbuild -ba \
--define '_sourcedir $(shell pwd)' \
--define '_rpmdir %{_sourcedir}/RPMS' \
--define '_srcrpmdir %{_sourcedir}/SRPMS' \
--define '_builddir %{_sourcedir}/BUILD' \
podman.spec
Loading

0 comments on commit 6652633

Please sign in to comment.