Skip to content

Commit

Permalink
feat: Added initial support for bulding RPMs using Packit
Browse files Browse the repository at this point in the history
* Card ID: CCT-231
* Added .packit.yml
* RPMs are build, when PR is created/updated
* RPMs are build for CentOS Strem 8/9, RHEL 8/9 and all Fedoras
* Added autochangelog and set source_date_epoch_from_changelog to 0.
  Use %autochangelog only for rhel9+ and fedora.
* Deleted .copr/Makefile
* Moved rhc.spec.in to ./
* Added rhc.spec target to Makefile and modified this file little bit
  • Loading branch information
jirihnidek authored and subpop committed Apr 10, 2024
1 parent 1175d1c commit 6f08033
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 54 deletions.
47 changes: 0 additions & 47 deletions .copr/Makefile

This file was deleted.

48 changes: 48 additions & 0 deletions .packit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
upstream_package_name: rhc
downstream_package_name: rhc
specfile_path: rhc.spec

srpm_build_deps:
- gawk
- git-core
- golang
- make
- 'pkgconfig(dbus-1)'
- 'pkgconfig(systemd)'
- rpm-build

actions:
post-upstream-clone:
- bash -c 'make rhc.spec dist'
get-current-version:
- awk '/^Version:/ {print $2;}' ./rhc.spec
create-archive:
- bash -c 'echo rhc-*.tar.*'
fix-spec-file:
- echo 'nothing to fix'

jobs:
- job: copr_build
trigger: pull_request
additional_repos:
- "copr://@yggdrasil/latest"
targets:
- centos-stream-8
- centos-stream-9
- fedora-all
- rhel-8
- rhel-9

- job: copr_build
trigger: commit
additional_repos:
- "copr://@yggdrasil/latest"
branch: main
owner: "@yggdrasil"
project: latest
targets:
- centos-stream-8
- centos-stream-9
- fedora-all
- rhel-8
- rhel-9
24 changes: 23 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,33 @@ dist:
--exclude=.vscode \
--exclude=.github \
--exclude=.gitignore \
--exclude=.copr \
--exclude=rhc-*.tar.gz \
--exclude=rhc \
--transform s/^\./$(PKGNAME)-$(VERSION)/ \
. && mv /tmp/$(PKGNAME)-$(VERSION).tar.gz .
rm -rf ./vendor

rhc.spec: rhc.spec.in
sed \
-e 's,[@]SHORTNAME[@],$(SHORTNAME),g' \
-e 's,[@]LONGNAME[@],$(LONGNAME),g' \
-e 's,[@]VERSION[@],$(VERSION),g' \
-e 's,[@]PKGNAME[@],$(PKGNAME),g' \
-e 's,[@]TOPICPREFIX[@],$(TOPICPREFIX),g' \
-e 's,[@]DATAHOST[@],$(DATAHOST),g' \
-e 's,[@]PROVIDER[@],$(PROVIDER),g' \
-e 's,[@]PREFIX[@],$(PREFIX),g' \
-e 's,[@]BINDIR[@],$(BINDIR),g' \
-e 's,[@]SBINDIR[@],$(SBINDIR),g' \
-e 's,[@]LIBEXECDIR[@],$(LIBEXECDIR),g' \
-e 's,[@]DATAROOTDIR[@],$(DATAROOTDIR),g' \
-e 's,[@]DATADIR[@],$(DATADIR),g' \
-e 's,[@]SYSCONFDIR[@],$(SYSCONFDIR),g' \
-e 's,[@]LOCALSTATEDIR[@],$(LOCALSTATEDIR),g' \
-e 's,[@]DOCDIR[@],$(DOCDIR),g' \
-e 's,[@]SERVICENAME[@],$(SERVICENAME),g' \
$^ > $@

.PHONY: clean
clean:
go mod tidy
Expand Down
15 changes: 9 additions & 6 deletions .copr/rhc.spec.in → rhc.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
# the package.

%define debug_package %{nil}

%define source_date_epoch_from_changelog 0

Name: @LONGNAME@
Version: @VERSION@
Release: @RELEASE@%{?dist}
Release: 0%{?dist}
Epoch: 1
Summary: Client for registering Red Hat Enterprise Linux systems
License: GPL-3.0-only
URL: https://github.com/redhatinsights/rhc

Source0: %{name}-%{version}-@RELEASE@.tar.gz
Source0: %{name}-%{version}.tar.gz

ExclusiveArch: %{go_arches}

Expand All @@ -39,7 +39,7 @@ MQTT client.


%build
cd %{name}-%{version}-@RELEASE@
cd %{name}-%{version}
make PREFIX=%{_prefix} \
SYSCONFDIR=%{_sysconfdir} \
LOCALSTATEDIR=%{_localstatedir} \
Expand All @@ -54,7 +54,7 @@ make PREFIX=%{_prefix} \


%install
cd %{name}-%{version}-@RELEASE@
cd %{name}-%{version}
make PREFIX=%{_prefix} \
SYSCONFDIR=%{_sysconfdir} \
LOCALSTATEDIR=%{_localstatedir} \
Expand All @@ -70,10 +70,13 @@ make PREFIX=%{_prefix} \
install

%files
%doc %{name}-%{version}-@RELEASE@/README.md
%doc %{name}-%{version}/README.md
%{_bindir}/@SHORTNAME@
%{_datadir}/bash-completion/completions/*
%{_mandir}/man1/*


%changelog
%if (0%{?fedora} || 0%{?rhel} >= 9)
%autochangelog
%endif

0 comments on commit 6f08033

Please sign in to comment.