Add basic support for RPM packaging

Summary:
This is just the basic stuff needed to produce a RPM package of
Memgraph. Further work needs to be done in order for this to be up to
snuff.

Reviewers: mferencevic, buda

Reviewed By: mferencevic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D1318
This commit is contained in:
Teon Banek 2018-03-27 15:14:47 +02:00
parent ef71ae42fd
commit aaff656e27
4 changed files with 33 additions and 0 deletions

View File

@ -222,6 +222,7 @@ set(CPACK_PACKAGE_VERSION_MINOR ${memgraph_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${memgraph_VERSION_PATCH})
set(CPACK_PACKAGE_VERSION_TWEAK ${memgraph_VERSION_TWEAK})
set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${memgraph_VERSION}-${COMMIT_HASH}${CPACK_SYSTEM_NAME})
# DEB specific
# Instead of using "name <email>" format, we use "email (name)" to prevent
# errors due to full stop, '.' at the end of "Ltd". (See: RFC 822)
@ -240,6 +241,20 @@ set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}
Contains Memgraph, the graph database. It aims to deliver developers the
speed, simplicity and scale required to build the next generation of
applications driver by real-time connected data.")
# RPM specific
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION /var /var/lib /var/log /etc/logrotate.d /lib /lib/systemd /lib/systemd/system)
set(CPACK_RPM_PACKAGE_REQUIRES_PRE "shadow-utils,systemd")
# set(CPACK_RPM_USER_BINARY_SPECFILE "${CMAKE_SOURCE_DIR}/release/rpm/memgraph.spec.in")
set(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/release/rpm/preinst")
set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/release/rpm/postinst")
set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/release/rpm/prerm")
# Description formatting is important, no line must be greater than 80 characters.
set(CPACK_RPM_PACKAGE_DESCRIPTION "Contains Memgraph, the graph database.
: It aims to deliver developers the speed, simplicity and scale
: required to build the next generation of applications driver by
: real-time connected data.")
# All variables must be set before including.
include(CPack)
# ---- End Setup CPack ----

10
release/rpm/postinst Normal file
View File

@ -0,0 +1,10 @@
# Hackish way to get the sytemd unit at the right place
mv /lib/systemd/system/memgraph.service %{_unitdir}
# memgraph user and group must be set in preinst
chown memgraph:memgraph /var/lib/memgraph || exit 1
chmod 750 /var/lib/memgraph || exit 1
chown memgraph:adm /var/log/memgraph || exit 1
chmod 750 /var/log/memgraph || exit 1
# Make examples directory immutable (optional)
chattr +i -R /usr/share/memgraph/examples || true

6
release/rpm/preinst Normal file
View File

@ -0,0 +1,6 @@
# Add the 'memgraph' user and group
getent group memgraph >/dev/null || groupadd -r memgraph || exit 1
getent passwd memgraph >/dev/null || \
useradd -r -g memgraph -d /var/lib/memgraph -s /bin/bash memgraph || exit 1
echo "Don't forget to switch to the 'memgraph' user to use Memgraph" || exit 1

2
release/rpm/prerm Normal file
View File

@ -0,0 +1,2 @@
# Remove optional immutability from examples directory to allow removal
chattr -i -R /usr/share/memgraph/examples || true