Browse Source

finish up rpm generation

Grant Limberg 5 years ago
parent
commit
930bd91598

+ 24 - 0
packaging/rpm.cmake

@@ -4,6 +4,7 @@ set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
 set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
 set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
 set(CPACK_PACKAGE_VERSION_RELEASE ${PROJECT_VERSION_RELEASE})
+set(CPACK_RPM_PACKAGE_DESCRIPTION "ZeroTier network virtualization service ZeroTier One lets you join ZeroTier virtual networks and have them appear as tun/tap ports on your system. See https://www.zerotier.com/ for instructions and documentation.")
 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt")
 set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
 set(CPACK_GENERATOR "RPM")
@@ -14,7 +15,30 @@ set(CPACK_RPM_PACKAGE_AUTOREQ 1)
 set(CPACK_RPM_PACKAGE_REQUIRES "systemd, iproute, libstdc++")
 set(CPACK_RPM_PACKAGE_REQUIRES_PRE "/usr/sbin/useradd, /usr/bin/getent")
 set(CPACK_RPM_PACKAGE_OBSOLETES "zerotier-one")
+set(CPACK_PACKAGE_RELOCATABLE FALSE)
+
+set(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/packaging/rpm/rpm.pre")
+set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/packaging/rpm/rpm.post")
+set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/packaging/rpm/rpm.postun")
+set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/packaging/rpm/rpm.preun")
+set(CPACK_RPM_CHANGELOG_FILE" ${CMAKE_CURRENT_SOURCE_DIR}/packaging/rpm/rpm.changelog")
 
 install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/zerotier DESTINATION bin)
+if(IS_DIRECTORY /lib/systemd/system)
+    install(
+        FILES ${CMAKE_CURRENT_SOURCE_DIR}/packaging/debian/zerotier.service 
+        DESTINATION /lib/systemd/system
+    )
+elseif(IS_DIRECTORY /usr/lib/systemd/system)
+    install(
+        FILES ${CMAKE_CURRENT_SOURCE_DIR}/packaging/debian/zerotier.service 
+        DESTINATION /usr/lib/systemd/system
+    )
+else()
+    install(
+        FILES ${CMAKE_CURRENT_SOURCE_DIR}/packaging/debian/zerotier.init
+        DESTINATION /etc/init.d
+    )
+endif()
 
 include(CPack)

+ 2 - 0
packaging/rpm/rpm.changelog

@@ -0,0 +1,2 @@
+* Mon Jun 22, 2020 ZeroTier, Inc. <[email protected]> - 1.9.0-0
+- see https://github.com/zerotier/ZeroTierOne for release notes

+ 17 - 0
packaging/rpm/rpm.post

@@ -0,0 +1,17 @@
+%if 0%{?rhel} >= 7
+%systemd_post zerotier-one.service
+%endif
+%if 0%{?fedora} >= 21
+%systemd_post zerotier-one.service
+%endif
+%if 0%{?rhel} <= 6
+case "$1" in
+  1)
+    chkconfig --add zerotier-one
+  ;;
+  2)
+    chkconfig --del zerotier-one
+    chkconfig --add zerotier-one
+  ;;
+esac
+%endif

+ 6 - 0
packaging/rpm/rpm.postun

@@ -0,0 +1,6 @@
+%if 0%{?rhel} >= 7
+%systemd_postun_with_restart zerotier-one.service
+%endif
+%if 0%{?fedora} >= 21
+%systemd_postun_with_restart zerotier-one.service
+%endif

+ 6 - 0
packaging/rpm/rpm.pre

@@ -0,0 +1,6 @@
+%if 0%{?rhel} >= 7
+/usr/bin/getent passwd zerotier-one || /usr/sbin/useradd -r -d /var/lib/zerotier-one -s /sbin/nologin zerotier-one
+%endif
+%if 0%{?fedora} >= 21
+/usr/bin/getent passwd zerotier-one || /usr/sbin/useradd -r -d /var/lib/zerotier-one -s /sbin/nologin zerotier-one
+%endif

+ 18 - 0
packaging/rpm/rpm.preun

@@ -0,0 +1,18 @@
+%if 0%{?rhel} >= 7
+%systemd_preun zerotier-one.service
+%endif
+%if 0%{?fedora} >= 21
+%systemd_preun zerotier-one.service
+%endif
+%if 0%{?rhel} <= 6
+case "$1" in
+  0)
+    service zerotier-one stop
+    chkconfig --del zerotier-one
+  ;;
+  1)
+    # This is an upgrade.
+    :
+  ;;
+esac
+%endif