From ca5bf7bf4bee088119e3012069e2ca98a48373cd Mon Sep 17 00:00:00 2001 From: jcorporation Date: Sun, 30 Jul 2023 17:51:21 +0200 Subject: [PATCH] Feat: add cmake option to skip installing startup script #1080 --- CMakeLists.txt | 1 + cmake/CopyConfig.cmake.in | 46 +++++++++++++++------------- docs/installation/compiling/cmake.md | 1 + 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6be8bf3c0..c186c980b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,6 +59,7 @@ option(MYMPD_ENABLE_LUA "Enables lua support, default ON" "ON") option(MYMPD_MANPAGES "Creates and installs manpages" "ON") option(MYMPD_MINIMAL "Enables minimal myMPD build, disables all MYMPD_ENABLE_* flags" "OFF") option(MYMPD_STRIP_BINARY "Enables stripping the binaries for Release, default ON" "ON") +option(MYMPD_STARTUP_SCRIPT "Installs the startup script, default ON" "ON") if(MYMPD_MINIMAL) set(MYMPD_ENABLE_FLAC "OFF") diff --git a/cmake/CopyConfig.cmake.in b/cmake/CopyConfig.cmake.in index 616848ddf..affef7384 100644 --- a/cmake/CopyConfig.cmake.in +++ b/cmake/CopyConfig.cmake.in @@ -2,28 +2,30 @@ # myMPD (c) 2018-2023 Juergen Mang # https://github.com/jcorporation/mympd -# Install startup script -if(EXISTS "/lib/systemd/system" OR EXISTS "/usr/lib/systemd/system") - #Install systemd unit - file(INSTALL "@CMAKE_CURRENT_BINARY_DIR@/contrib/initscripts/mympd.service" - DESTINATION "/usr/lib/systemd/system" - FILE_PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) -elseif(EXISTS "/sbin/openrc-run") - #Install openrc script - file(RENAME "@CMAKE_CURRENT_BINARY_DIR@/contrib/initscripts/mympd.openrc" - "@CMAKE_CURRENT_BINARY_DIR@/contrib/initscripts/mympd") - file(INSTALL "@CMAKE_CURRENT_BINARY_DIR@/contrib/initscripts/mympd" - DESTINATION "/etc/init.d" - FILE_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) -elseif(EXISTS "/etc/init.d") - #Install sysVinit script - file(RENAME "@CMAKE_CURRENT_BINARY_DIR@/contrib/initscripts/mympd.sysVinit" - "@CMAKE_CURRENT_BINARY_DIR@/contrib/initscripts/mympd") - file(INSTALL "@CMAKE_CURRENT_BINARY_DIR@/contrib/initscripts/mympd" - DESTINATION "/etc/init.d" - FILE_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) -else() - message("No supported init system found, no startup script was installed") +if("@MYMPD_STARTUP_SCRIPT@" STREQUAL "ON") + # Install startup script + if(EXISTS "/lib/systemd/system" OR EXISTS "/usr/lib/systemd/system") + #Install systemd unit + file(INSTALL "@CMAKE_CURRENT_BINARY_DIR@/contrib/initscripts/mympd.service" + DESTINATION "/usr/lib/systemd/system" + FILE_PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) + elseif(EXISTS "/sbin/openrc-run") + #Install openrc script + file(RENAME "@CMAKE_CURRENT_BINARY_DIR@/contrib/initscripts/mympd.openrc" + "@CMAKE_CURRENT_BINARY_DIR@/contrib/initscripts/mympd") + file(INSTALL "@CMAKE_CURRENT_BINARY_DIR@/contrib/initscripts/mympd" + DESTINATION "/etc/init.d" + FILE_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) + elseif(EXISTS "/etc/init.d") + #Install sysVinit script + file(RENAME "@CMAKE_CURRENT_BINARY_DIR@/contrib/initscripts/mympd.sysVinit" + "@CMAKE_CURRENT_BINARY_DIR@/contrib/initscripts/mympd") + file(INSTALL "@CMAKE_CURRENT_BINARY_DIR@/contrib/initscripts/mympd" + DESTINATION "/etc/init.d" + FILE_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) + else() + message("No supported init system found, no startup script was installed") + endif() endif() # Install and compress manpages diff --git a/docs/installation/compiling/cmake.md b/docs/installation/compiling/cmake.md index 233677675..4f049e05e 100644 --- a/docs/installation/compiling/cmake.md +++ b/docs/installation/compiling/cmake.md @@ -32,6 +32,7 @@ sudo make -C build install | MYMPD_MANPAGES | ON | Creates and installs manpages | | MYMPD_MINIMAL | OFF | Enables minimal myMPD build, disables all MYMPD_ENABLE_* flags | | MYMPD_STRIP_BINARY | ON | Enables stripping the binaries for Release | +| MYMPD_STARTUP_SCRIPT | ON | Installs the startup script | {: .table .table-sm} ## cmake build types