Skip to content
Snippets Groups Projects
Commit 390cddbb authored by Sergey Vorontsov's avatar Sergey Vorontsov Committed by Yaroslav Lobankov
Browse files

build: make packages with static binary inside


This patch adds facility to make DEB and RPM packages with a statically
compiled Tarantool binary inside. The build is performed in a Docker
container, using PackPack docker image (centos-7) and CPack.

The packpack/packpack:centos-7 image has all the necessary dependencies
for building Tarantool and quite old glibc 2.17 which theoretically
provides compatibility of the created packages with any distro where
glibc >= 2.17.

The build can be run with the command below:

    $ VERSION=3.0.0 ./static-build/make_packages.sh

In the `static_build` directory, there will be the following packages:

    tarantool_3.0.0-1_amd64.deb
    tarantool-dev_3.0.0-1_amd64.deb
    tarantool-3.0.0-1.x86_64.rpm
    tarantool-devel-3.0.0-1.x86_64.rpm

`tarantool_3.0.0-1_amd64.deb`, `tarantool-3.0.0-1.x86_64.rpm` are
packages with the Tarantool server binary inside.

`tarantool-dev_3.0.0-1_amd64.deb`, `tarantool-devel-3.0.0-1.x86_64.rpm`
are packages with the Tarantool server development files inside.

NO_DOC=build
NO_TEST=build

Co-authored-by: default avatarYaroslav Lobankov <y.lobankov@tarantool.org>
parent dc26e47e
No related branches found
No related tags found
No related merge requests found
## feature/build
* Added building static `deb` and `rpm` packages.
......@@ -10,3 +10,4 @@ project(tarantool-static C CXX)
include(cmake/AddDependencyProjects.cmake)
include(cmake/AddTarantoolProject.cmake)
include(cmake/AddTests.cmake)
include(cmake/MakePackages.cmake)
# CPack makes DEB and RPM packages. Creating RPM packages requires the rpm-build
# package installed. Creating DEB packages doesn't need any additional tools.
# CPack should have version 3.17 or greater (previous versions weren't tested).
# For building packages, it is recommended using OS with quite old glibc (for
# example, centos 7) for compatibility of the created packages with the various
# distros.
# Set architecture for packages (x86_64 or aarch64)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64" OR
CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "arm64")
set(CPACK_RPM_PACKAGE_ARCHITECTURE "aarch64")
else()
message(FATAL_ERROR "Unsupported architecture: ${CMAKE_SYSTEM_PROCESSOR}")
endif()
set(CPACK_COMPONENTS_GROUPING ONE_PER_GROUP)
set(CPACK_RPM_COMPONENT_INSTALL ON)
set(CPACK_DEB_COMPONENT_INSTALL ON)
install(DIRECTORY tarantool-prefix/include/ DESTINATION include
USE_SOURCE_PERMISSIONS
COMPONENT dev
EXCLUDE_FROM_ALL)
install(DIRECTORY tarantool-prefix/bin/ DESTINATION bin
USE_SOURCE_PERMISSIONS
COMPONENT server
EXCLUDE_FROM_ALL
FILES_MATCHING PATTERN "tarantool")
set(CPACK_GENERATOR "DEB;RPM")
set(CPACK_PACKAGE_NAME "tarantool")
set(CPACK_PACKAGE_CONTACT "admin@tarantool.org")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://tarantool.org")
set(CPACK_PACKAGE_VERSION "$ENV{VERSION}")
set(CPACK_PACKAGE_DIRECTORY "$ENV{OUTPUT_DIR}")
set(CPACK_RPM_PACKAGE_RELEASE "1")
set(CPACK_RPM_PACKAGE_LICENSE "BSD")
set(CPACK_DEBIAN_PACKAGE_RELEASE "1")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Tarantool Team <admin@tarantool.org>")
set(TARANTOOL_SERVER_DESCRIPTION
"Tarantool is a high performance in-memory database and Lua application server.
Tarantool supports replication, online backup and stored procedures in Lua.
The package provides Tarantool server binary.")
set(TARANTOOL_DEV_DESCRIPTION
"Tarantool is a high performance in-memory database and Lua application server.
Tarantool supports replication, online backup and stored procedures in Lua.
The package provides Tarantool server development files needed for pluggable
modules.")
set(CPACK_RPM_SERVER_PACKAGE_NAME "tarantool")
set(CPACK_RPM_SERVER_PACKAGE_GROUP "Applications/Databases")
set(CPACK_RPM_SERVER_PACKAGE_SUMMARY "In-memory database and Lua application server")
set(CPACK_RPM_SERVER_FILE_NAME
tarantool-${CPACK_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}.${CPACK_RPM_PACKAGE_ARCHITECTURE}.rpm)
set(CPACK_RPM_DEV_PACKAGE_NAME "tarantool-devel")
set(CPACK_RPM_DEV_PACKAGE_GROUP "Applications/Databases")
set(CPACK_RPM_DEV_PACKAGE_SUMMARY "Tarantool server development files")
set(CPACK_RPM_DEV_FILE_NAME
tarantool-devel-${CPACK_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}.${CPACK_RPM_PACKAGE_ARCHITECTURE}.rpm)
set(CPACK_DEBIAN_SERVER_PACKAGE_NAME "tarantool")
set(CPACK_DEBIAN_SERVER_PACKAGE_SECTION "database")
set(CPACK_DEBIAN_SERVER_FILE_NAME
tarantool_${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb)
set(CPACK_DEBIAN_DEV_PACKAGE_NAME "tarantool-dev")
set(CPACK_DEBIAN_DEV_PACKAGE_SECTION "libdevel")
set(CPACK_DEBIAN_DEV_FILE_NAME
tarantool-dev_${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb)
include(CPack)
cpack_add_component(dev
DISPLAY_NAME "Tarantool server development files"
DESCRIPTION ${TARANTOOL_DEV_DESCRIPTION}
GROUP dev)
cpack_add_component(server
DISPLAY_NAME "Tarantool server binary"
DESCRIPTION ${TARANTOOL_SERVER_DESCRIPTION}
GROUP server)
cpack_add_component_group(dev)
cpack_add_component_group(server)
#!/bin/sh -x
# This script makes DEB and RPM packages with a statically compiled Tarantool
# binary inside. The build is performed in a Docker container, using PackPack
# docker image (centos-7) and CPack. The packpack/packpack:centos-7 image has
# all the necessary dependencies for building Tarantool and quite old glibc 2.17
# which theoretically provides compatibility of the created packages with any
# distro where glibc >= 2.17.
# Usually the script should be run by a CI/CD system, but it is possible to do
# this manually set the following variables:
#
# CMAKE_TARANTOOL_ARGS - cmake args for the build
# VERSION - package version
# OUTPUT_DIR - output directory where to save packages
# Set default values for variables for successful run on the local machine.
CMAKE_TARANTOOL_ARGS="${CMAKE_TARANTOOL_ARGS:--DLUAJIT_ENABLE_GC64=ON;-DCMAKE_BUILD_TYPE=RelWithDebInfo}"
VERSION="${VERSION:-0.0.1}"
OUTPUT_DIR="${OUTPUT_DIR:-build}"
USER_ID=$(id -u)
echo "User ID: ${USER_ID}"
echo "CMake args: ${CMAKE_TARANTOOL_ARGS}"
echo "Package version: ${VERSION}"
echo "Output dir: ${OUTPUT_DIR}"
# Run building in a Docker container with the proper user to get artifacts
# with the correct permissions. If USER_ID is 0, then run as root. If USER_ID
# is not 0, then create the 'tarantool' user with the same user's ID as on the
# host machine. That helps avoid problems with permissions of artifacts.
if [ "${USER_ID}" = "0" ]; then
docker run --rm --pull=always \
--env VERSION=${VERSION} \
--env OUTPUT_DIR=${OUTPUT_DIR} \
--volume $(pwd):/tarantool \
--workdir /tarantool/static-build/ \
packpack/packpack:centos-7 sh -c "
cmake3 -DCMAKE_TARANTOOL_ARGS=\"${CMAKE_TARANTOOL_ARGS}\" &&
make -j $(nproc) &&
make package"
else
docker run --rm --pull=always \
--env VERSION=${VERSION} \
--env OUTPUT_DIR=${OUTPUT_DIR} \
--volume $(pwd):/tarantool \
--workdir /tarantool/static-build/ \
packpack/packpack:centos-7 sh -c "
useradd -u ${USER_ID} tarantool;
su -m tarantool sh -c '
cmake3 -DCMAKE_TARANTOOL_ARGS=\"${CMAKE_TARANTOOL_ARGS}\" &&
make -j $(nproc) &&
make package'"
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment