mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2024-12-14 11:58:02 +00:00
Add build_rpm script and rpm spec (#1831)
Also, link stdlib++ and libgcc statically. Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
parent
684bf97ce6
commit
02fff36e3e
13 changed files with 149 additions and 20 deletions
14
.devcontainer/fedora/devcontainer.json
Normal file
14
.devcontainer/fedora/devcontainer.json
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"name": "helio",
|
||||||
|
"image": "ghcr.io/romange/fedora:30",
|
||||||
|
"customizations": {
|
||||||
|
"vscode": {
|
||||||
|
"extensions": [
|
||||||
|
"ms-vscode.cpptools",
|
||||||
|
"ms-vscode.cmake-tools",
|
||||||
|
"ms-vscode.cpptools-themes",
|
||||||
|
"twxs.cmake"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
2
.github/actions/regression-tests/action.yml
vendored
2
.github/actions/regression-tests/action.yml
vendored
|
@ -29,7 +29,7 @@ runs:
|
||||||
ls -l ${GITHUB_WORKSPACE}/
|
ls -l ${GITHUB_WORKSPACE}/
|
||||||
cd ${GITHUB_WORKSPACE}/tests
|
cd ${GITHUB_WORKSPACE}/tests
|
||||||
echo "Current commit is ${{github.sha}}"
|
echo "Current commit is ${{github.sha}}"
|
||||||
pip install -r dragonfly/requirements.txt
|
pip3 install -r dragonfly/requirements.txt
|
||||||
# used by PyTests
|
# used by PyTests
|
||||||
export DRAGONFLY_PATH="${GITHUB_WORKSPACE}/${{inputs.build-folder-name}}/${{inputs.dfly-executable}}"
|
export DRAGONFLY_PATH="${GITHUB_WORKSPACE}/${{inputs.build-folder-name}}/${{inputs.dfly-executable}}"
|
||||||
export UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 # to crash on errors
|
export UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 # to crash on errors
|
||||||
|
|
33
.github/workflows/release.yml
vendored
33
.github/workflows/release.yml
vendored
|
@ -54,13 +54,14 @@ jobs:
|
||||||
# Mount the artifacts directory as /artifacts in the container
|
# Mount the artifacts directory as /artifacts in the container
|
||||||
dockerRunArgs: |
|
dockerRunArgs: |
|
||||||
--volume "${{ github.workspace }}:/src"
|
--volume "${{ github.workspace }}:/src"
|
||||||
|
|
||||||
# The shell to run commands with in the container
|
# The shell to run commands with in the container
|
||||||
shell: /bin/bash
|
shell: /bin/bash
|
||||||
install: |
|
install: |
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
apt update && apt install -q -y autoconf-archive cmake curl git libssl-dev \
|
apt update && apt install -q -y autoconf-archive cmake curl git libssl-dev \
|
||||||
libunwind-dev ninja-build libtool gcc-9 g++-9 libboost-fiber-dev \
|
libunwind-dev ninja-build libtool gcc-9 g++-9 libboost-context-dev \
|
||||||
libxml2-dev zip libzstd-dev debhelper moreutils bison
|
zip libzstd-dev debhelper moreutils bison zlib1g-dev
|
||||||
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 40 \
|
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 40 \
|
||||||
--slave /usr/bin/g++ g++ /usr/bin/g++-9
|
--slave /usr/bin/g++ g++ /usr/bin/g++-9
|
||||||
run: |
|
run: |
|
||||||
|
@ -96,15 +97,25 @@ jobs:
|
||||||
build-native:
|
build-native:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: create-release
|
needs: create-release
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
# Build with these flags
|
||||||
|
- name: debian
|
||||||
|
container: ubuntu-dev:20
|
||||||
|
- name: rpm
|
||||||
|
container: fedora:30
|
||||||
container:
|
container:
|
||||||
image: ghcr.io/romange/ubuntu-dev:20
|
image: ghcr.io/romange/${{ matrix.container }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
- name: Configure
|
- name: Configure
|
||||||
run: |
|
run: |
|
||||||
apt update && apt install -y debhelper moreutils pip jq
|
if [ -f /etc/redhat-release ]; then
|
||||||
|
dnf install -y rpm-build libstdc++-static
|
||||||
|
fi
|
||||||
- name: Build artifacts
|
- name: Build artifacts
|
||||||
run: |
|
run: |
|
||||||
# Work around https://github.com/actions/checkout/issues/766
|
# Work around https://github.com/actions/checkout/issues/766
|
||||||
|
@ -112,8 +123,15 @@ jobs:
|
||||||
git describe --always --tags ${{ github.sha }}
|
git describe --always --tags ${{ github.sha }}
|
||||||
./tools/release.sh
|
./tools/release.sh
|
||||||
# once the build is over, we want to generate a Debian package
|
# once the build is over, we want to generate a Debian package
|
||||||
|
if [ -f /etc/debian_version ]; then
|
||||||
./tools/packaging/generate_debian_package.sh build-opt/dragonfly-x86_64
|
./tools/packaging/generate_debian_package.sh build-opt/dragonfly-x86_64
|
||||||
|
else
|
||||||
|
echo "TODO: build rpm"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Run regression tests
|
- name: Run regression tests
|
||||||
|
# Fedora 30 has older python packages, so this fails during requirements installation.
|
||||||
|
if : matrix.container != 'fedora:30'
|
||||||
uses: ./.github/actions/regression-tests
|
uses: ./.github/actions/regression-tests
|
||||||
with:
|
with:
|
||||||
dfly-executable: dragonfly-x86_64
|
dfly-executable: dragonfly-x86_64
|
||||||
|
@ -121,12 +139,19 @@ jobs:
|
||||||
run-only-on-ubuntu-latest: false
|
run-only-on-ubuntu-latest: false
|
||||||
build-folder-name: build-opt
|
build-folder-name: build-opt
|
||||||
- name: Save artifacts
|
- name: Save artifacts
|
||||||
|
if : matrix.container != 'fedora:30' # TODO
|
||||||
run: |
|
run: |
|
||||||
# place all artifacts at the same location
|
# place all artifacts at the same location
|
||||||
mkdir -p results-artifacts
|
mkdir -p results-artifacts
|
||||||
|
if [ -f /etc/debian_version ]; then
|
||||||
mv build-opt/dragonfly-*tar.gz results-artifacts
|
mv build-opt/dragonfly-*tar.gz results-artifacts
|
||||||
mv dragonfly_*.deb results-artifacts
|
mv dragonfly_*.deb results-artifacts
|
||||||
|
else
|
||||||
|
echo "TODO: upload rpm"
|
||||||
|
ls *.rpm
|
||||||
|
fi
|
||||||
- name: Upload
|
- name: Upload
|
||||||
|
if : matrix.container != 'fedora:30' # TODO
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: dragonfly-amd64
|
name: dragonfly-amd64
|
||||||
|
|
20
Makefile
20
Makefile
|
@ -2,18 +2,30 @@ BUILD_ARCH := $(shell uname -m)
|
||||||
RELEASE_NAME := "dragonfly-${BUILD_ARCH}"
|
RELEASE_NAME := "dragonfly-${BUILD_ARCH}"
|
||||||
|
|
||||||
HELIO_RELEASE := $(if $(HELIO_RELEASE),y,)
|
HELIO_RELEASE := $(if $(HELIO_RELEASE),y,)
|
||||||
HELIO_RELEASE_FLAGS = -DHELIO_RELEASE_FLAGS="-flto -g1 -gz"
|
|
||||||
|
HELIO_RELEASE_FLAGS = -DHELIO_RELEASE_FLAGS="-g1 -gz"
|
||||||
HELIO_USE_STATIC_LIBS = ON
|
HELIO_USE_STATIC_LIBS = ON
|
||||||
HELIO_OPENSSL_USE_STATIC_LIBS = ON
|
HELIO_OPENSSL_USE_STATIC_LIBS = ON
|
||||||
HELIO_ENABLE_GIT_VERSION = ON
|
HELIO_ENABLE_GIT_VERSION = ON
|
||||||
HELIO_WITH_UNWIND = OFF
|
HELIO_WITH_UNWIND = OFF
|
||||||
|
|
||||||
|
# Some distributions (old fedora) have incorrect dependencies for crypto
|
||||||
|
# so we add -lz for them.
|
||||||
|
LINKER_FLAGS=-lz
|
||||||
|
|
||||||
# equivalent to: if $(uname_m) == x86_64 || $(uname_m) == amd64
|
# equivalent to: if $(uname_m) == x86_64 || $(uname_m) == amd64
|
||||||
ifneq (, $(filter $(BUILD_ARCH),x86_64 amd64))
|
ifneq (, $(filter $(BUILD_ARCH),x86_64 amd64))
|
||||||
HELIO_MARCH_OPT := -march=core2 -msse4.1 -mpopcnt -mtune=skylake
|
HELIO_MARCH_OPT := -march=core2 -msse4.1 -mpopcnt -mtune=skylake
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# For release builds we link statically libstdc++ and libgcc. Currently,
|
||||||
|
# all the release builds are performed by gcc.
|
||||||
|
ifeq ($(HELIO_RELEASE),y)
|
||||||
|
LINKER_FLAGS += -static-libstdc++ -static-libgcc
|
||||||
|
endif
|
||||||
|
|
||||||
HELIO_FLAGS = $(if $(HELIO_RELEASE),-release $(HELIO_RELEASE_FLAGS),) \
|
HELIO_FLAGS = $(if $(HELIO_RELEASE),-release $(HELIO_RELEASE_FLAGS),) \
|
||||||
|
-DCMAKE_EXE_LINKER_FLAGS="$(LINKER_FLAGS)" \
|
||||||
-DBoost_USE_STATIC_LIBS=$(HELIO_USE_STATIC_LIBS) \
|
-DBoost_USE_STATIC_LIBS=$(HELIO_USE_STATIC_LIBS) \
|
||||||
-DOPENSSL_USE_STATIC_LIBS=$(HELIO_OPENSSL_USE_STATIC_LIBS) \
|
-DOPENSSL_USE_STATIC_LIBS=$(HELIO_OPENSSL_USE_STATIC_LIBS) \
|
||||||
-DENABLE_GIT_VERSION=$(HELIO_ENABLE_GIT_VERSION) \
|
-DENABLE_GIT_VERSION=$(HELIO_ENABLE_GIT_VERSION) \
|
||||||
|
@ -26,13 +38,11 @@ configure:
|
||||||
|
|
||||||
build:
|
build:
|
||||||
cd build-opt; \
|
cd build-opt; \
|
||||||
ninja dragonfly; \
|
ninja dragonfly && ldd dragonfly
|
||||||
ldd dragonfly
|
|
||||||
|
|
||||||
build-debug:
|
build-debug:
|
||||||
cd build-dbg; \
|
cd build-dbg; \
|
||||||
ninja dragonfly; \
|
ninja dragonfly && ldd dragonfly
|
||||||
ldd dragonfly
|
|
||||||
|
|
||||||
package:
|
package:
|
||||||
cd build-opt; \
|
cd build-opt; \
|
||||||
|
|
|
@ -38,7 +38,7 @@ source <virtual env name>/bin/activate
|
||||||
```
|
```
|
||||||
Then install all the required dependencies for the tests:
|
Then install all the required dependencies for the tests:
|
||||||
```
|
```
|
||||||
pip install -r dragonfly/requirements.txt
|
pip3 install -r dragonfly/requirements.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
### Running the tests
|
### Running the tests
|
||||||
|
|
|
@ -5,7 +5,7 @@ FROM alpine:3 as builder
|
||||||
|
|
||||||
# "openssl-libs-static" fixes "Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the"
|
# "openssl-libs-static" fixes "Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the"
|
||||||
RUN apk add autoconf-archive automake bash bison boost-dev cmake coreutils \
|
RUN apk add autoconf-archive automake bash bison boost-dev cmake coreutils \
|
||||||
curl ccache git gcc gdb g++ libunwind-dev libtool libxml2-dev make ninja \
|
curl ccache git gcc gdb g++ libunwind-dev libtool make ninja \
|
||||||
openssl-dev openssl-libs-static patch zip zstd-static
|
openssl-dev openssl-libs-static patch zip zstd-static
|
||||||
|
|
||||||
# This is required to make static linking work
|
# This is required to make static linking work
|
||||||
|
@ -30,7 +30,7 @@ COPY tools/docker/healthcheck.sh /usr/local/bin/healthcheck.sh
|
||||||
COPY --from=builder /build/build-opt/dragonfly /usr/local/bin/
|
COPY --from=builder /build/build-opt/dragonfly /usr/local/bin/
|
||||||
|
|
||||||
RUN apk --no-cache add libgcc libstdc++ \
|
RUN apk --no-cache add libgcc libstdc++ \
|
||||||
su-exec netcat-openbsd libxml2 icu boost-context && ldd /usr/local/bin/dragonfly
|
su-exec netcat-openbsd boost-context && ldd /usr/local/bin/dragonfly
|
||||||
|
|
||||||
RUN addgroup -S -g 1000 dfly && adduser -S -G dfly -u 999 dfly
|
RUN addgroup -S -g 1000 dfly && adduser -S -G dfly -u 999 dfly
|
||||||
RUN mkdir /data && chown dfly:dfly /data
|
RUN mkdir /data && chown dfly:dfly /data
|
||||||
|
|
|
@ -14,7 +14,7 @@ RUN ninja dragonfly
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
|
|
||||||
RUN addgroup -S -g 1000 dfly && adduser -S -G dfly -u 999 dfly
|
RUN addgroup -S -g 1000 dfly && adduser -S -G dfly -u 999 dfly
|
||||||
RUN apk --no-cache add libgcc libstdc++ libunwind boost1.77-fiber libxml2 \
|
RUN apk --no-cache add libgcc libstdc++ libunwind boost-context \
|
||||||
'su-exec>=0.2' netcat-openbsd openssl
|
'su-exec>=0.2' netcat-openbsd openssl
|
||||||
|
|
||||||
RUN mkdir /data && chown dfly:dfly /data
|
RUN mkdir /data && chown dfly:dfly /data
|
||||||
|
|
|
@ -11,8 +11,8 @@ RUN \
|
||||||
export DEBIAN_FRONTEND=noninteractive && \
|
export DEBIAN_FRONTEND=noninteractive && \
|
||||||
apt update && \
|
apt update && \
|
||||||
apt install -q -y autoconf-archive cmake curl git libssl-dev \
|
apt install -q -y autoconf-archive cmake curl git libssl-dev \
|
||||||
libunwind-dev ninja-build libtool gcc-9 g++-9 libboost-fiber-dev \
|
libunwind-dev ninja-build libtool gcc-9 g++-9 libboost-context-dev \
|
||||||
libxml2-dev zip libzstd-dev bison
|
zip libzstd-dev bison
|
||||||
|
|
||||||
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 40 \
|
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 40 \
|
||||||
--slave /usr/bin/g++ g++ /usr/bin/g++-9
|
--slave /usr/bin/g++ g++ /usr/bin/g++-9
|
||||||
|
|
|
@ -20,7 +20,7 @@ FROM ubuntu:20.04
|
||||||
ARG QEMU_CPU
|
ARG QEMU_CPU
|
||||||
ARG DEBIAN_FRONTEND=noninteractive
|
ARG DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
RUN apt clean && apt update && apt -y install netcat-openbsd ca-certificates redis-tools libxml2
|
RUN apt clean && apt update && apt -y install netcat-openbsd ca-certificates redis-tools
|
||||||
|
|
||||||
RUN groupadd -r -g 999 dfly && useradd -r -g dfly -u 999 dfly
|
RUN groupadd -r -g 999 dfly && useradd -r -g dfly -u 999 dfly
|
||||||
RUN mkdir /data && chown dfly:dfly /data
|
RUN mkdir /data && chown dfly:dfly /data
|
||||||
|
|
25
tools/packaging/rpm/build_rpm.sh
Executable file
25
tools/packaging/rpm/build_rpm.sh
Executable file
|
@ -0,0 +1,25 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Get the full path of the binary
|
||||||
|
ARCHIVE=$(realpath "$1")
|
||||||
|
VERSION="$2"
|
||||||
|
echo "Preparing $ARCHIVE"
|
||||||
|
|
||||||
|
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
|
||||||
|
|
||||||
|
# Setup RPM build environment in a unique subdirectory under /tmp
|
||||||
|
RPM_ROOT=$(mktemp -d /tmp/rpmbuild_XXXXXX)
|
||||||
|
echo "Working dir is $RPM_ROOT"
|
||||||
|
mkdir -p $RPM_ROOT/{BUILD,RPMS,SOURCES,SPECS}
|
||||||
|
|
||||||
|
# Put the archive and configuration files to the SOURCES directory
|
||||||
|
ln -s "$ARCHIVE" -t "$RPM_ROOT/SOURCES/"
|
||||||
|
cp $SCRIPT_DIR/dragonfly.service $RPM_ROOT/SOURCES/
|
||||||
|
cp $SCRIPT_DIR/dragonfly.conf $RPM_ROOT/SOURCES/
|
||||||
|
|
||||||
|
cp $SCRIPT_DIR/dragonfly.spec $RPM_ROOT/SPECS/
|
||||||
|
|
||||||
|
rpmbuild --define "_topdir $RPM_ROOT" --define "version $VERSION" -bb "$RPM_ROOT/SPECS/dragonfly.spec"
|
||||||
|
mv $RPM_ROOT/RPMS/*.rpm ./
|
1
tools/packaging/rpm/dragonfly.conf
Symbolic link
1
tools/packaging/rpm/dragonfly.conf
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../debian/dragonfly.conf
|
1
tools/packaging/rpm/dragonfly.service
Symbolic link
1
tools/packaging/rpm/dragonfly.service
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../debian/dragonfly.service
|
53
tools/packaging/rpm/dragonfly.spec
Normal file
53
tools/packaging/rpm/dragonfly.spec
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
%define pkg_name dragonfly
|
||||||
|
%define archive dragonfly-%{_arch}.tar.gz
|
||||||
|
|
||||||
|
# How the package name looks like
|
||||||
|
%define _build_name_fmt %%{NAME}.%%{ARCH}.rpm
|
||||||
|
|
||||||
|
Name: %{pkg_name}
|
||||||
|
Version: %{version}
|
||||||
|
Release: 1%{?dist}
|
||||||
|
Summary: DragonflyDB memory store
|
||||||
|
License: BUSL-1.1
|
||||||
|
URL: https://www.dragonflydb.io
|
||||||
|
Source0: %{archive}
|
||||||
|
Source1: dragonfly.service
|
||||||
|
Source2: dragonfly.conf
|
||||||
|
Group: Applications/System
|
||||||
|
Provides: user(dfly)
|
||||||
|
Provides: group(dfly)
|
||||||
|
|
||||||
|
%description
|
||||||
|
DragonflyDB is a vertically scalable and memory efficient in-memory store
|
||||||
|
that is compatible with Redis OSS and Memcached.
|
||||||
|
|
||||||
|
%pre
|
||||||
|
|
||||||
|
getent group dfly >/dev/null || groupadd -r dfly
|
||||||
|
getent passwd dfly >/dev/null || useradd -r -g dfly -M -s /sbin/nologin -c "User for DragonflyDB service" dfly
|
||||||
|
|
||||||
|
%prep
|
||||||
|
|
||||||
|
%build
|
||||||
|
tar xvfz %{SOURCE0}
|
||||||
|
mv ./dragonfly-%{_arch} ./dragonfly
|
||||||
|
|
||||||
|
%install
|
||||||
|
mkdir -p %{buildroot}/usr/local/bin
|
||||||
|
mkdir -p %{buildroot}/etc/dragonfly
|
||||||
|
|
||||||
|
install -m 755 ./dragonfly %{buildroot}/usr/local/bin/
|
||||||
|
mkdir -p %{buildroot}/usr/lib/systemd/system
|
||||||
|
cp %{SOURCE1} %{buildroot}/usr/lib/systemd/system/
|
||||||
|
cp %{SOURCE2} %{buildroot}/etc/dragonfly/
|
||||||
|
|
||||||
|
%clean
|
||||||
|
rm -rf %{buildroot}
|
||||||
|
rm -rf %{_builddir}/*
|
||||||
|
|
||||||
|
%files
|
||||||
|
%attr(-,dfly,dfly) /usr/local/bin/dragonfly
|
||||||
|
%attr(-,dfly,dfly) /usr/lib/systemd/system/dragonfly.service
|
||||||
|
%attr(-,dfly,dfly) /etc/dragonfly/dragonfly.conf
|
||||||
|
|
||||||
|
%changelog
|
Loading…
Reference in a new issue