osquery-1/cmake/CPackConfig.cmake.in
Stefano Bonicatti 57f9916473 Patch environment file path in initd and systemd scripts during DEB packaging (#5802)
Also add a check to systemd script to create and empty config file,
if this is missing.

Co-authored-by: seph <seph@directionless.org>
2019-09-12 18:02:23 -04:00

31 lines
1.4 KiB
CMake

# Copyright (c) 2014-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed in accordance with the terms specified in
# the LICENSE file found in the root directory of this source tree.
if("${CPACK_GENERATOR}" STREQUAL "")
message(FATAL_ERROR "No packaging system selected, cannot create a package. Please configure it through the PACKAGING_SYSTEM variable")
endif()
if("${CPACK_GENERATOR}" STREQUAL "DEB")
file(WRITE "@CMAKE_BINARY_DIR@/package/deb/conffiles"
"/etc/init.d/osqueryd\n"
"/etc/default/osqueryd\n")
# Patch the EnvironmentFile in the systemd unit
file(READ "@CMAKE_BINARY_DIR@/package/linux/osqueryd.service" osqueryd_service_file)
string(REPLACE "/etc/sysconfig/osqueryd" "/etc/default/osqueryd" osqueryd_service_file "${osqueryd_service_file}")
file(WRITE "@CMAKE_BINARY_DIR@/package/linux/osqueryd.service" "${osqueryd_service_file}")
# Patch /etc/sysconfig to /etc/default in the initd script
file(READ "@CMAKE_BINARY_DIR@/package/linux/osqueryd.initd" osqueryd_initd_file)
string(REPLACE "/etc/sysconfig" "/etc/default" osqueryd_initd_file "${osqueryd_initd_file}")
file(WRITE "@CMAKE_BINARY_DIR@/package/linux/osqueryd.initd" "${osqueryd_initd_file}")
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "@CMAKE_BINARY_DIR@/package/deb/conffiles;@CMAKE_BINARY_DIR@/package/deb/postinst")
elseif("${CPACK_GENERATOR}" STREQUAL "productbuild")
set(CPACK_SET_DESTDIR ON)
endif()