diff --git a/packaging/rpm.cmake b/packaging/rpm.cmake index d5ebffadc..9e684552d 100644 --- a/packaging/rpm.cmake +++ b/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) diff --git a/packaging/rpm/rpm.changelog b/packaging/rpm/rpm.changelog new file mode 100644 index 000000000..9d1429ca0 --- /dev/null +++ b/packaging/rpm/rpm.changelog @@ -0,0 +1,2 @@ +* Mon Jun 22, 2020 ZeroTier, Inc. - 1.9.0-0 +- see https://github.com/zerotier/ZeroTierOne for release notes diff --git a/packaging/rpm/rpm.post b/packaging/rpm/rpm.post new file mode 100644 index 000000000..6b54239e0 --- /dev/null +++ b/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 diff --git a/packaging/rpm/rpm.postun b/packaging/rpm/rpm.postun new file mode 100644 index 000000000..714bad0a6 --- /dev/null +++ b/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 diff --git a/packaging/rpm/rpm.pre b/packaging/rpm/rpm.pre new file mode 100644 index 000000000..f1c474d7d --- /dev/null +++ b/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 diff --git a/packaging/rpm/rpm.preun b/packaging/rpm/rpm.preun new file mode 100644 index 000000000..ee4a5cda1 --- /dev/null +++ b/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