Skip to content

Commit

Permalink
meson: Automatic detection of init style, GitHub #1124
Browse files Browse the repository at this point in the history
  • Loading branch information
rdmark committed Jul 21, 2024
1 parent c332293 commit 75ce025
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 33 deletions.
16 changes: 4 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ jobs:
meson setup build \
-Dwith-tests=true \
-Dwith-init-hooks=false \
-Dwith-init-style=debian-systemd \
-Dwith-pkgconfdir-path=/etc/netatalk
- name: Meson - Build
run: meson compile -C build
Expand Down Expand Up @@ -469,8 +468,7 @@ jobs:
meson setup build \
-Dwith-tests=true \
-Dwith-manual=true \
-Dwith-init-hooks=false \
-Dwith-init-style=debian-systemd
-Dwith-init-hooks=false
- name: Meson - Build and generate manual pages
run: meson compile -C build
- name: Meson - Run tests
Expand Down Expand Up @@ -592,8 +590,7 @@ jobs:
gmake uninstall
echo "Building with Meson"
meson setup build \
-Dpkg_config_path=/usr/local/libdata/pkgconfig \
-Dwith-init-style=freebsd
-Dpkg_config_path=/usr/local/libdata/pkgconfig
meson compile -C build
meson install -C build
/etc/rc.d/netatalk start
Expand Down Expand Up @@ -658,8 +655,7 @@ jobs:
echo "Building with Meson"
meson setup build \
-Dpkg_config_path=/usr/pkg/lib/pkgconfig \
-Dwith-dtrace=false \
-Dwith-init-style=netbsd
-Dwith-dtrace=false
meson compile -C build
meson install -C build
service netatalk onestart
Expand Down Expand Up @@ -717,8 +713,7 @@ jobs:
gmake -j $(nproc)
echo "Building with Meson"
meson setup build \
-Dpkg_config_path=/usr/local/lib/pkgconfig \
-Dwith-init-style=openbsd
-Dpkg_config_path=/usr/local/lib/pkgconfig
meson compile -C build
meson install -C build
rcctl -d start netatalk
Expand Down Expand Up @@ -764,7 +759,6 @@ jobs:
- name: Meson - Configure
run: |
meson setup build \
-Dwith-init-style=macos-launchd \
-Dwith-tests=true
- name: Meson - Build
run: meson compile -C build
Expand Down Expand Up @@ -830,7 +824,6 @@ jobs:
echo "Building with Meson"
meson setup build \
-Dpkg_config_path=/opt/local/lib/pkgconfig \
-Dwith-init-style=solaris \
-Dwith-ldap-path=/opt/local \
-Dwith-pgp-uam=true
meson compile -C build
Expand Down Expand Up @@ -901,7 +894,6 @@ jobs:
echo "Building with Meson"
meson setup build \
-Dpkg_config_path=/usr/lib/amd64/pkgconfig \
-Dwith-init-style=solaris \
-Dwith-pgp-uam=true
meson compile -C build
meson install -C build
Expand Down
35 changes: 17 additions & 18 deletions distrib/initscripts/meson.build
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
if get_option('with-init-style') == 'none'
init_dir = 'none'
init_dirs += init_dir
if init_style == 'none'
init_dirs += 'none'
endif

if (
get_option('with-init-style') == 'debian'
or get_option('with-init-style') == 'debian-systemd'
or get_option('with-init-style') == 'gentoo-systemd'
or get_option('with-init-style') == 'redhat-systemd'
or get_option('with-init-style') == 'suse-systemd'
or get_option('with-init-style') == 'systemd'
init_style == 'debian'
or init_style == 'debian-systemd'
or init_style == 'gentoo-systemd'
or init_style == 'redhat-systemd'
or init_style == 'suse-systemd'
or init_style == 'systemd'
)
init_dir = '/usr/lib/systemd/system'
init_dirs += init_dir
Expand All @@ -28,8 +27,8 @@ if (
endif

if (
get_option('with-init-style') == 'debian'
or get_option('with-init-style') == 'debian-sysv'
init_style == 'debian'
or init_style == 'debian-sysv'
)
init_dir = '/etc/init.d'
init_dirs += init_dir
Expand All @@ -54,7 +53,7 @@ if (
endif
endif

if get_option('with-init-style') == 'freebsd'
if init_style == 'freebsd'
init_dir = '/etc/rc.d'
init_dirs += init_dir
custom_target(
Expand All @@ -76,7 +75,7 @@ if get_option('with-init-style') == 'freebsd'
endif
endif

if get_option('with-init-style') == 'netbsd'
if init_style == 'netbsd'
init_dir = '/etc/rc.d'
init_dirs += init_dir
custom_target(
Expand All @@ -91,7 +90,7 @@ if get_option('with-init-style') == 'netbsd'
)
endif

if get_option('with-init-style') == 'openbsd'
if init_style == 'openbsd'
init_dir = '/etc/rc.d'
init_dirs += init_dir
custom_target(
Expand All @@ -113,7 +112,7 @@ if get_option('with-init-style') == 'openbsd'
endif
endif

if get_option('with-init-style') == 'solaris'
if init_style == 'solaris'
init_dir = '/lib/svc/manifest/network'
init_dirs += init_dir
custom_target(
Expand All @@ -135,8 +134,8 @@ if get_option('with-init-style') == 'solaris'
endif

if (
get_option('with-init-style') == 'openrc'
or get_option('with-init-style') == 'gentoo-openrc'
init_style == 'openrc'
or init_style == 'gentoo-openrc'
)
init_dir = '/etc/init.d'
init_dirs += init_dir
Expand All @@ -160,7 +159,7 @@ if (
endif
endif

if get_option('with-init-style') == 'macos-launchd'
if init_style == 'macos-launchd'
init_dir = '/Library/LaunchDaemons'
init_dirs += init_dir
custom_target(
Expand Down
29 changes: 27 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,31 @@ else
bison = find_program('bison', required: false)
endif

##############
# Init Style #
##############

uname_stdout = run_command(uname, '-a', check: false).stdout().strip()
init_style = get_option('with-init-style')

if init_style == 'auto'
if uname_stdout.to_lower().contains('debian') or uname_stdout.to_lower().contains('ubuntu')
init_style = 'debian-systemd'
elif host_os == 'freebsd'
init_style = 'freebsd'
elif host_os == 'netbsd'
init_style = 'netbsd'
elif host_os == 'openbsd'
init_style = 'openbsd'
elif host_os == 'darwin'
init_style = 'macos-launchd'
elif host_os == 'sunos'
init_style = 'solaris'
else
init_style = 'none'
endif
endif

#############
# Libraries #
#############
Expand All @@ -150,7 +175,7 @@ if host_os == 'netbsd'
libsearch_dirs += '/usr/pkg/lib'
endif

if uname.found() and run_command(uname, '-n', check: false).stdout().strip().contains('omnios')
if uname.found() and uname_stdout.to_lower().contains('omnios')
libsearch_dirs += '/opt/local/lib'
endif

Expand Down Expand Up @@ -2083,7 +2108,7 @@ uams_using_options = '(' + uams_options + ')'

summary({'Netatalk version': netatalk_version}, section: 'Configuration Summary:')
summary_info = {
' Initscript style': get_option('with-init-style'),
' Initscript style': init_style,
}
summary(summary_info, bool_yn: true, section: ' Init Style:')

Expand Down
3 changes: 2 additions & 1 deletion meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ option(
type: 'combo',
choices: [
'none',
'auto',
'debian',
'debian-systemd',
'debian-sysv',
Expand All @@ -320,7 +321,7 @@ option(
'suse-systemd',
'systemd',
],
value: 'none',
value: 'auto',
description: 'Use OS specific init config',
)
option(
Expand Down

0 comments on commit 75ce025

Please sign in to comment.