1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-11-22 17:39:53 +03:00

Fix wrapper script generation

This commit is contained in:
Ron Isaacson 2020-06-29 23:04:35 -04:00
parent 853b4a57bc
commit 6fe678fe84
5 changed files with 21 additions and 12 deletions

View File

@ -1,17 +1,26 @@
if(UNIX) if(UNIX)
# Creates wrapper scripts and installs them in the user's binaries directory, which is usually "/usr/local/bin". # Creates wrapper scripts and installs them in the user's binaries directory, which is usually "/usr/local/bin".
# This is required because symlinks use the folder they are in as working directory. # This is required because symlinks use the folder they are in as working directory.
macro(install_wrapper_script component target) #
get_filename_component(file_name ${target} NAME) # The actual wrapper script needs to be generated at install time, not build time, because it depends on the
# installation prefix. This is especially important when generating packages (rpm/deb) where the prefix is
# changed from /usr to /usr/local for the install step.
#
# The placeholder is needed to satisfy the "install" dependency scanner which runs early.
#
macro(install_wrapper_script component)
file(GENERATE OUTPUT ${BUILD_DIRECTORY}/${component}.sh
CONTENT "# placeholder\n"
)
file(WRITE ${TOP_DIRECTORY}/tmp/script/${file_name} "#!/bin/sh\n") install(CODE "file(WRITE ${BUILD_DIRECTORY}/${component}.sh \"#!/bin/sh\nexec \${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBEXECDIR}/softether/${component}/${component} \\\"$@\\\"\n\")"
file(APPEND ${TOP_DIRECTORY}/tmp/script/${file_name} "${target} \"$@\"\n") COMPONENT ${component}
file(APPEND ${TOP_DIRECTORY}/tmp/script/${file_name} "exit $?\n") )
install(FILES ${TOP_DIRECTORY}/tmp/script/${file_name} install(PROGRAMS ${BUILD_DIRECTORY}/${component}.sh
COMPONENT ${component} COMPONENT ${component}
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} DESTINATION bin
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE RENAME ${component}
) )
endmacro(install_wrapper_script) endmacro(install_wrapper_script)
endif() endif()

View File

@ -39,7 +39,7 @@ if(UNIX)
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
) )
install_wrapper_script("vpnbridge" "${CMAKE_INSTALL_FULL_LIBEXECDIR}/softether/vpnbridge/vpnbridge") install_wrapper_script("vpnbridge")
if(NOT "${CMAKE_INSTALL_SYSTEMD_UNITDIR}" STREQUAL "") if(NOT "${CMAKE_INSTALL_SYSTEMD_UNITDIR}" STREQUAL "")
configure_file(${TOP_DIRECTORY}/systemd/softether-vpnbridge.service ${CMAKE_BINARY_DIR}/systemd/softether-vpnbridge.service) configure_file(${TOP_DIRECTORY}/systemd/softether-vpnbridge.service ${CMAKE_BINARY_DIR}/systemd/softether-vpnbridge.service)
install(FILES ${CMAKE_BINARY_DIR}/systemd/softether-vpnbridge.service install(FILES ${CMAKE_BINARY_DIR}/systemd/softether-vpnbridge.service

View File

@ -39,7 +39,7 @@ if(UNIX)
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
) )
install_wrapper_script("vpnclient" "${CMAKE_INSTALL_FULL_LIBEXECDIR}/softether/vpnclient/vpnclient") install_wrapper_script("vpnclient")
if(NOT "${CMAKE_INSTALL_SYSTEMD_UNITDIR}" STREQUAL "") if(NOT "${CMAKE_INSTALL_SYSTEMD_UNITDIR}" STREQUAL "")
configure_file(${TOP_DIRECTORY}/systemd/softether-vpnclient.service ${CMAKE_BINARY_DIR}/systemd/softether-vpnclient.service) configure_file(${TOP_DIRECTORY}/systemd/softether-vpnclient.service ${CMAKE_BINARY_DIR}/systemd/softether-vpnclient.service)
install(FILES ${CMAKE_BINARY_DIR}/systemd/softether-vpnclient.service install(FILES ${CMAKE_BINARY_DIR}/systemd/softether-vpnclient.service

View File

@ -39,5 +39,5 @@ if(UNIX)
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
) )
install_wrapper_script("vpncmd" "${CMAKE_INSTALL_FULL_LIBEXECDIR}/softether/vpncmd/vpncmd") install_wrapper_script("vpncmd")
endif() endif()

View File

@ -39,7 +39,7 @@ if(UNIX)
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
) )
install_wrapper_script("vpnserver" "${CMAKE_INSTALL_FULL_LIBEXECDIR}/softether/vpnserver/vpnserver") install_wrapper_script("vpnserver")
if(NOT "${CMAKE_INSTALL_SYSTEMD_UNITDIR}" STREQUAL "") if(NOT "${CMAKE_INSTALL_SYSTEMD_UNITDIR}" STREQUAL "")
configure_file(${TOP_DIRECTORY}/systemd/softether-vpnserver.service ${CMAKE_BINARY_DIR}/systemd/softether-vpnserver.service) configure_file(${TOP_DIRECTORY}/systemd/softether-vpnserver.service ${CMAKE_BINARY_DIR}/systemd/softether-vpnserver.service)
install(FILES ${CMAKE_BINARY_DIR}/systemd/softether-vpnserver.service install(FILES ${CMAKE_BINARY_DIR}/systemd/softether-vpnserver.service