-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a "build_srpm" meson build option. When true, meson will attempt to build a SRPM using the current source root as the RPM source.
- Loading branch information
Showing
7 changed files
with
183 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
if get_option('build_srpm') | ||
subdir('srpm') | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
This directory includes files necessary to build an SRPM as part of the normal | ||
`meson compile` step. | ||
|
||
# Usage | ||
|
||
1. Set the `build_srpm` build option to `True` when setting up the project: | ||
`meson setup -Dbuild_srpm=True builddir` | ||
2. Compile the `srpm` target: `meson compile srpm -C builddir` | ||
|
||
An SRPM will be built and can be found in `builddir/dist/srpm`. This SRPM will | ||
need to be rebuilt into a binary in order to install it. To rebuild it using | ||
`mock` on Fedora, for example, run: | ||
|
||
``` | ||
mock --rebuild ./builddir/dist/srpm/*.src.rpm | ||
``` | ||
|
||
The RPM built by `mock` can be found (typically) in | ||
`/var/run/mock/<root-name>/results`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
git = find_program('git') | ||
rpmbuild = find_program('rpmbuild') | ||
tar = find_program('tar') | ||
bash = find_program('bash') | ||
|
||
commit = run_command(git, 'rev-parse', 'HEAD', capture: true, check: true).stdout().strip() | ||
|
||
if get_option('vendor') | ||
run_command([bash, files(meson.project_source_root() / 'build-aux' / 'vendor.sh')], check: true) | ||
endif | ||
|
||
build_root_basename = meson.project_build_root().split('/').get(-1) | ||
tarball = custom_target('tarball', | ||
command: [ | ||
tar, | ||
'--create', | ||
'--gzip', | ||
'--absolute-names', | ||
'--file', '@OUTPUT@', | ||
'--transform', 's+@0@+@1@-@2@+'.format(meson.project_source_root(), meson.project_name(), commit), | ||
'--exclude', build_root_basename, | ||
'--exclude', '.git', | ||
'--exclude', '.vscode', | ||
'--exclude', '.github', | ||
'--exclude', '.copr', | ||
meson.project_source_root() | ||
], | ||
output: '@0@-@[email protected]'.format(meson.project_name(), commit) | ||
) | ||
|
||
specfile = configure_file( | ||
input: 'yggdrasil.spec.in', | ||
output: '@BASENAME@', | ||
configuration: { | ||
'COMMIT': commit, | ||
'VERSION': meson.project_version(), | ||
} | ||
) | ||
|
||
run_target('srpm', | ||
command: [rpmbuild, '-bs', '--define', 'commit @0@'.format(commit), '--define', '_srcrpmdir @0@'.format(meson.current_build_dir()), '--define', '_sourcedir @0@'.format(meson.current_build_dir()), specfile], | ||
depends: [ | ||
tarball | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# This RPM spec file exists primarily to enable CI/CD pipelines and automatic | ||
# testing of built RPMs. This RPM can be used as a suitable baseline for a | ||
# proper distribution package, but changes should be made to suit the needs of | ||
# the package. | ||
# | ||
# See https://src.fedoraproject.org/rpms/yggdrasil/blob/rawhide/f/yggdrasil.spec | ||
# for a better example of a downstream distribution packaging example. | ||
|
||
%bcond_without check | ||
|
||
# https://github.com/redhatinsights/yggdrasil | ||
%global goipath github.com/redhatinsights/yggdrasil | ||
%global commit @COMMIT@ | ||
%global shortcommit %(c=%{commit}; echo ${c:0:7}) | ||
|
||
%if 0%{?fedora} | ||
%gometa -f | ||
%else | ||
%gometa | ||
%endif | ||
|
||
# Manually redefine %%dist to work around an issue in COPR where the build root | ||
# that creates the srpm does not define a value for %%dist. This should *NOT* be | ||
# carried in downstream; this is strictly an upstream/COPR/CI workaround. | ||
%if "%{dist}" == "" | ||
%global dist %{distprefix}.fc%{fedora} | ||
%endif | ||
|
||
%if 0%{?fedora} | ||
%global setup_flags -Dvendor=False -Dexamples=True | ||
%else | ||
%global setup_flags -Dvendor=True -Dexamples=True | ||
%endif | ||
|
||
%global common_description %{expand: | ||
yggdrasil is a system daemon that subscribes to topics on an MQTT broker and | ||
routes any data received on the topics to an appropriate child "worker" process, | ||
exchanging data with its worker processes through a D-Bus message broker.} | ||
|
||
%global golicenses LICENSE | ||
%global godocs CONTRIBUTING.md README.md | ||
|
||
Name: yggdrasil | ||
Version: @VERSION@ | ||
Release: 0%{?dist} | ||
Summary: Remote data transmission and processing client | ||
|
||
License: GPL-3.0-only | ||
URL: %{gourl} | ||
Source: %{gosource} | ||
|
||
BuildRequires: systemd-rpm-macros | ||
BuildRequires: meson | ||
BuildRequires: pkgconfig(dbus-1) | ||
BuildRequires: pkgconfig(systemd) | ||
BuildRequires: pkgconfig(bash-completion) | ||
|
||
%description %{common_description} | ||
|
||
%gopkg | ||
|
||
%prep | ||
%if 0%{?fedora} | ||
%goprep | ||
%else | ||
%goprep -k | ||
%endif | ||
|
||
%if 0%{?fedora} | ||
%generate_buildrequires | ||
%go_generate_buildrequires | ||
%endif | ||
|
||
%build | ||
%undefine _auto_set_build_flags | ||
export %gomodulesmode | ||
%{?gobuilddir:export GOPATH="%{gobuilddir}:${GOPATH:+${GOPATH}:}%{?gopath}"} | ||
%meson %setup_flags "-Dgobuildflags=[%(echo %{expand:%gocompilerflags} | sed -e s/"^"/"'"/ -e s/" "/"', '"/g -e s/"$"/"'"/), '-tags', '"rpm_crashtraceback\ ${BUILDTAGS:-}"', '-a', '-v', '-x']" -Dgoldflags='%{?currentgoldflags} -B 0x%(head -c20 /dev/urandom|od -An -tx1|tr -d " \n") -compressdwarf=false -linkmode=external -extldflags "%{build_ldflags} %{?__golang_extldflags}"' | ||
%meson_build | ||
|
||
%global gosupfiles ./ipc/com.redhat.Yggdrasil1.Dispatcher1.xml ./ipc/com.redhat.Yggdrasil1.Worker1.xml | ||
%install | ||
%meson_install | ||
%gopkginstall | ||
|
||
%if %{with check} | ||
%check | ||
%gocheck | ||
%endif | ||
|
||
%files | ||
%license LICENSE | ||
%doc CONTRIBUTING.md README.md | ||
%{_bindir}/* | ||
%{_libexecdir}/%{name}/* | ||
%config(noreplace) %{_sysconfdir}/%{name} | ||
%{_unitdir}/* | ||
%{_userunitdir}/* | ||
%{_datadir}/bash-completion/completions/* | ||
%{_datadir}/dbus-1/{interfaces,system-services,system.d}/* | ||
%{_datadir}/doc/%{name}/* | ||
%{_mandir}/man1/* | ||
|
||
%gopkgfiles | ||
|
||
%changelog | ||
%autochangelog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters