Skip to content

Commit

Permalink
refactor: port the build system to meson
Browse files Browse the repository at this point in the history
- Remove the custom Makefile in favor of meson
- Move the systemd files and other data files into a data directory
- Move the srpm and spec file into a dist/srpm subdirectory
  • Loading branch information
subpop committed Nov 5, 2024
1 parent 4650008 commit 699a713
Show file tree
Hide file tree
Showing 19 changed files with 337 additions and 313 deletions.
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
16 changes: 9 additions & 7 deletions .packit.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
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-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 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@-@[email protected]'.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

0 comments on commit 699a713

Please sign in to comment.