Compare commits

...

2 Commits

Author SHA1 Message Date
Teon Banek
aaff656e27 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
2018-03-27 16:50:32 +02:00
Teon Banek
ef71ae42fd Statically link libgcc and libstdc++
Summary:
This should allow us to distributed Memgraph executables on machines
which have different versions of libstdc++.

Reviewers: mferencevic, buda

Reviewed By: buda

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D1307
2018-03-26 16:09:53 +02:00
4 changed files with 41 additions and 0 deletions

View File

@@ -72,6 +72,14 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z -Wall -Werror=switch -Werror=
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO set(CMAKE_CXX_FLAGS_RELWITHDEBINFO
"${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fno-omit-frame-pointer") "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fno-omit-frame-pointer")
# Statically link libgcc and libstdc++, the GCC allows this according to:
# https://www.gnu.org/licenses/gcc-exception-faq.html
# Last checked for gcc-7.3, we are using gcc-6.3 on build machines (license is
# valid there also).
# ** If we change versions, recheck this! **
# ** Static linking is allowed only for executables! **
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
# Use gold linker to speedup build # Use gold linker to speedup build
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
@@ -214,6 +222,7 @@ set(CPACK_PACKAGE_VERSION_MINOR ${memgraph_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${memgraph_VERSION_PATCH}) set(CPACK_PACKAGE_VERSION_PATCH ${memgraph_VERSION_PATCH})
set(CPACK_PACKAGE_VERSION_TWEAK ${memgraph_VERSION_TWEAK}) set(CPACK_PACKAGE_VERSION_TWEAK ${memgraph_VERSION_TWEAK})
set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${memgraph_VERSION}-${COMMIT_HASH}${CPACK_SYSTEM_NAME}) set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${memgraph_VERSION}-${COMMIT_HASH}${CPACK_SYSTEM_NAME})
# DEB specific # DEB specific
# Instead of using "name <email>" format, we use "email (name)" to prevent # 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) # errors due to full stop, '.' at the end of "Ltd". (See: RFC 822)
@@ -232,6 +241,20 @@ set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}
Contains Memgraph, the graph database. It aims to deliver developers the Contains Memgraph, the graph database. It aims to deliver developers the
speed, simplicity and scale required to build the next generation of speed, simplicity and scale required to build the next generation of
applications driver by real-time connected data.") 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. # All variables must be set before including.
include(CPack) include(CPack)
# ---- End Setup 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