Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port the build system to meson #162

Merged
merged 3 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: ["1.18", "1.19", "1.20"]
go: ["1.18", "1.19", "1.20", "1.21", "1.22"]
steps:
- name: Updating ...
run: sudo apt-get -qq update
Expand All @@ -23,10 +23,10 @@ jobs:
go-version: ${{ matrix.go }}

- name: Go build (source)
run: make
run: go build ./...

- name: Go build (tests)
run: make tests
run: go test ./...

- name: Go vet
run: make vet
run: go vet ./...
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Install shellcheck
run: sudo apt install shellcheck
- name: Check shell bash scripts
run: shellcheck ./rhc.bash
run: shellcheck ./data/completion/rhc.bash
lint-language:
name: Lint language
runs-on: ubuntu-latest
Expand Down
26 changes: 16 additions & 10 deletions .packit.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
upstream_package_name: rhc
downstream_package_name: rhc
specfile_path: rhc.spec
specfile_path: builddir/dist/srpm/rhc.spec

srpm_build_deps:
- gawk
- git-core
- golang
- make
- 'pkgconfig(dbus-1)'
- 'pkgconfig(systemd)'
- meson
- "pkgconfig(bash-completion)"
- "pkgconfig(dbus-1)"
- "pkgconfig(systemd)"
- "rpm_macro(forgemeta)"
- rpm-build

actions:
post-upstream-clone:
- bash -c 'make rhc.spec dist'
- meson setup builddir -Dbuild_srpm=True -Dvendor=True --wipe
- meson compile tarball -C builddir
get-current-version:
- awk '/^Version:/ {print $2;}' ./rhc.spec
- awk '/^Version:/ {print $2;}' builddir/dist/srpm/rhc.spec
create-archive:
- bash -c 'echo rhc-*.tar.*'
- bash -c 'echo builddir/dist/srpm/rhc-*.tar.*'
fix-spec-file:
- echo 'nothing to fix'

Expand All @@ -29,7 +32,8 @@ jobs:
targets:
- centos-stream-9
- centos-stream-10
- fedora-all
- fedora-stable
- fedora-rawhide
- rhel-9

- job: copr_build
Expand All @@ -42,7 +46,8 @@ jobs:
targets:
- centos-stream-9
- centos-stream-10
- fedora-all
- fedora-stable
- fedora-rawhide
- rhel-9

- job: tests
Expand All @@ -63,7 +68,8 @@ jobs:
trigger: pull_request
identifier: "unit/fedora"
targets:
- fedora-all
- fedora-stable
- fedora-rawhide
labels:
- unit
tf_extra_params:
Expand Down
5 changes: 4 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ fully function.
It is possible to build `rhc` binary simply by running:

```
make
meson setup builddir
meson compile -C builddir
```

The resulting binary will be in the `builddir` directory.

If you want to install `rhc` into system, then it is recommended to create
RPM package and install rhc using package manager like dnf. You can
create RPM package using [packit](https://packit.dev/docs/cli) CLI too:
Expand Down
185 changes: 0 additions & 185 deletions Makefile

This file was deleted.

5 changes: 5 additions & 0 deletions data/completion/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
install_data(
'rhc.bash',
rename: 'rhc',
install_dir: bash_completion.get_variable(pkgconfig: 'completionsdir'),
)
File renamed without changes.
2 changes: 2 additions & 0 deletions data/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
subdir('completion')
subdir('systemd')
File renamed without changes.
6 changes: 6 additions & 0 deletions data/systemd/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
systemd_system_unit_dir = systemd.get_variable(pkgconfig: 'systemdsystemunitdir')
systemd_system_preset_dir = systemd.get_variable(pkgconfig: 'systemdsystempresetdir')

install_data('80-rhc.preset', install_dir: systemd_system_preset_dir)
install_data('rhc-canonical-facts.service', install_dir: systemd_system_unit_dir)
install_data('rhc-canonical-facts.timer', install_dir: systemd_system_unit_dir)
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions dist/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if get_option('build_srpm')
subdir('srpm')
endif
61 changes: 61 additions & 0 deletions dist/srpm/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
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()

systemd_sysusers_dir = systemd.get_variable(pkgconfig: 'sysusersdir')

if get_option('vendor')
run_command(
[bash, files(meson.project_source_root() / 'scripts' / '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(),
meson.project_version(),
),
'--exclude', build_root_basename,
'--exclude', '.git',
'--exclude', '.vscode',
'--exclude', '.github',
'--exclude', '.copr',
meson.project_source_root(),
],
output: '@0@-@1@.tar.gz'.format(meson.project_name(), meson.project_version()),
)

specfile = configure_file(
input: 'rhc.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],
)
Loading
Loading