Skip to content

Commit

Permalink
meson: Detect Linux distro and choose an appropriate init style, GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
rdmark committed Aug 2, 2024
1 parent dbc10f7 commit bd66215
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ jobs:
run: |
meson setup build \
-Dwith-appletalk=true \
-Dwith-init-style=openrc \
-Dwith-tests=true
- name: Build
run: meson compile -C build
Expand Down Expand Up @@ -162,7 +161,6 @@ jobs:
-Dwith-appletalk=true \
-Dwith-docbook-path=/usr/share/xml/docbook/xsl-stylesheets-1.79.2 \
-Dwith-init-hooks=false \
-Dwith-init-style=systemd \
-Dwith-tests=true
- name: Build
run: meson compile -C build
Expand Down Expand Up @@ -246,7 +244,6 @@ jobs:
meson setup build \
-Dwith-appletalk=true \
-Dwith-init-hooks=false \
-Dwith-init-style=systemd \
-Dwith-tests=true
- name: Build
run: meson compile -C build
Expand Down Expand Up @@ -303,7 +300,6 @@ jobs:
-Dwith-appletalk=true \
-Dwith-docbook-path=/usr/share/xml/docbook/stylesheet/nwalsh/1.79.2 \
-Dwith-init-hooks=false \
-Dwith-init-style=systemd \
-Dwith-tests=true
- name: Build
run: meson compile -C build
Expand Down
30 changes: 28 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,28 @@ cpu = host_machine.cpu_family()
host_os = host_machine.system()
target_os = target_machine.system()

linux_distro = ''

if host_os == 'linux' and fs.exists('/etc/os-release')
os_release = fs.read_file('/etc/os-release').strip()
if os_release.to_lower().contains('alpine')
linux_distro = 'alpine'
elif os_release.to_lower().contains('arch')
linux_distro = 'arch'
elif os_release.to_lower().contains('debian')
linux_distro = 'debian'
elif os_release.to_lower().contains('fedora')
linux_distro = 'fedora'
elif os_release.to_lower().contains('gentoo')
linux_distro = 'gentoo'
elif os_release.to_lower().contains('suse')
linux_distro = 'suse'
elif os_release.to_lower().contains('ubuntu')
linux_distro = 'ubuntu'
endif
message('Linux distro detected: '+ linux_distro)
endif

#########
# Paths #
#########
Expand Down Expand Up @@ -1955,8 +1977,12 @@ init_style = get_option('with-init-style')
init_dirs = []

if 'auto' in init_style
if uname_stdout.to_lower().contains('debian') or uname_stdout.to_lower().contains('ubuntu')
init_style = ['systemd']
if host_os == 'linux'
if linux_distro in ['debian', 'ubuntu', 'fedora', 'arch', 'suse']
init_style = ['systemd']
elif linux_distro in ['alpine', 'gentoo']
init_style = ['openrc']
endif
elif host_os == 'freebsd'
init_style = ['freebsd']
elif host_os == 'netbsd'
Expand Down

0 comments on commit bd66215

Please sign in to comment.