diff --git a/CMakeLists.txt b/CMakeLists.txt index d6ae587..9ad636c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.10) -project(cgproxy VERSION 1.0) +project(cgproxy VERSION 3.4) add_executable(cgattach cgattach.cpp) install(TARGETS cgattach DESTINATION /usr/bin @@ -21,3 +21,28 @@ install(FILES cgproxy.conf DESTINATION /etc/) install(FILES cgroup-tproxy.sh DESTINATION /usr/share/cgproxy/scripts/) + + +## deb pack +set(CPACK_GENERATOR "DEB;RPM") +set(CPACK_PACKAGE_NAME "cgproxy") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "cgproxy will transparent proxy anything running in specific cgroup.It aslo supports global transparent proxy and gateway proxy") + +set(CPACK_DEBIAN_PACKAGE_NAME "cgproxy") +set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "x86_64") +set(CPACK_DEBIAN_PACKAGE_DEPENDS "systemd") +set(CPACK_DEBIAN_PACKAGE_SECTION "network") +set(CPACK_DEBIAN_PACKAGE_PRIORITY "Optional") +set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/springzfx/cgproxy") +set(CPACK_DEBIAN_PACKAGE_MAINTAINER "springzfx@gmail.com") +set(CONTROL_DIR ${CMAKE_SOURCE_DIR}/control) +set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CONTROL_DIR}/postinst;${CONTROL_DIR}/prerm") + +set(CPACK_RPM_PACKAGE_ARCHITECTURE, "x86_64") +set(CPACK_RPM_PACKAGE_REQUIRES "systemd") +set(CPACK_RPM_PACKAGE_GROUP "network") +set(CPACK_RPM_PACKAGE_URL "https://github.com/springzfx/cgproxy") +set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CONTROL_DIR}/postinst") +set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${CONTROL_DIR}/prerm") + +include(CPack) \ No newline at end of file diff --git a/control/postinst b/control/postinst new file mode 100644 index 0000000..e50402f --- /dev/null +++ b/control/postinst @@ -0,0 +1,2 @@ +#!/bin/sh +systemctl enable --now cgproxy.service diff --git a/control/prerm b/control/prerm new file mode 100644 index 0000000..4ac3201 --- /dev/null +++ b/control/prerm @@ -0,0 +1,2 @@ +#!/bin/sh +systemctl disable --now cgproxy.service