ClickHouse/debian/rules

172 lines
6.8 KiB
Plaintext
Raw Normal View History

2016-02-07 20:02:44 +00:00
#!/usr/bin/make -f
# -*- makefile -*-
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
ifndef THREADS_COUNT
2017-01-10 18:28:24 +00:00
THREADS_COUNT=`nproc || grep -c ^processor /proc/cpuinfo`
2016-02-07 20:02:44 +00:00
endif
BUILD_TARGETS=clickhouse $(DAEMONS)
2017-01-10 18:28:24 +00:00
DEB_GCC_VERSION ?= -6
DEB_BUILD_GNU_TYPE := $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_HOST_GNU_TYPE := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
CC := gcc$(DEB_GCC_VERSION)
CXX := g++$(DEB_GCC_VERSION)
else
CC := $(DEB_HOST_GNU_TYPE)-gcc$(DEB_GCC_VERSION)
CXX := $(DEB_HOST_GNU_TYPE)-g++$(DEB_GCC_VERSION)
endif
CMAKE_FLAGS ?= -DCMAKE_CXX_COMPILER=`which $(CXX)` -DCMAKE_C_COMPILER=`which $(CC)`
ifdef CMAKE_BUILD_TYPE
CMAKE_FLAGS += -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE)
endif
ifdef USE_STATIC_LIBRARIES
CMAKE_FLAGS += -DUSE_STATIC_LIBRARIES=$(USE_STATIC_LIBRARIES)
endif
2016-02-07 20:02:44 +00:00
configure-stamp:
dh_testdir
rm -rf build
make clean 1> /dev/null 2>&1 || echo "Nothing to clean"
rm -f CMakeCache.txt
mkdir -p build
touch configure-stamp
build: build-stamp
build-stamp: configure-stamp
dh_testdir
# если не задан тип сборки запускаем cmake без указания типа, если задан - передаём его
2017-01-10 18:28:24 +00:00
# for building Debug run: debuild -e CMAKE_BUILD_TYPE=Debug
# for building with shared libs run: debuild -e USE_STATIC_LIBRARIES=0
cd build && pwd && cmake .. $(CMAKE_FLAGS)
2016-02-07 20:02:44 +00:00
# TODO: возможно надо исправить
2016-05-27 18:42:08 +00:00
# последовательно запускаем make для каждой из целей.
2016-02-07 20:02:44 +00:00
# т.к. при параллельном запуске (make target1 target2) несколько раз одновременно создаются бинарники
# и возникает raise с custom_command, использующие эти бинарники
for target in ${BUILD_TARGETS}; do $(MAKE) -j$(THREADS_COUNT) -C build $$target; done
2016-02-07 20:02:44 +00:00
touch $@
clean:
dh_testdir
dh_testroot
rm -f configure-stamp build-stamp
2016-02-07 20:02:44 +00:00
rm -rf build
# Удалим созданные для dh_installinit файлы
find ./debian/ -name "*.init" -type l -delete
# Удалим созданные для dh_installcron файлы
find ./debian/ -name "*.cron.d" -type f -delete
2016-06-16 16:14:50 +00:00
# Удалим созданные ссылки на файлы документации
find ./debian/ -name "*.docs" -type l -delete
rm -f ./debian/copyright
2016-02-07 20:02:44 +00:00
# Удалим созданные *.install файлы
for DAEMON_PKG in ${DAEMONS}; do AUTO=`grep "# automatically created" debian/$$DAEMON_PKG.install`; if [ "x$$AUTO" != "x" ]; then rm -f debian/$$DAEMON_PKG.install; fi; done
2016-02-07 20:02:44 +00:00
dh_clean
install: build
dh_testdir
dh_testroot
dh_prep
cd build && \
for target in ${BUILD_TARGETS}; do DESTDIR=../debian/tmp cmake -DCOMPONENT=$$target -P cmake_install.cmake; done
2016-02-07 20:02:44 +00:00
# Создаём нужные файлы для dh_installinit, т.к. он их понимает только внутри debian/
for I in debian/tmp/etc/init.d/*; do echo $$I; ln -s tmp/etc/init.d/`basename $$I` debian/`basename $$I`.init; done
# Хотим, чтобы для пакета clickhouse-server-base init file назывался clickhouse-server
if [ -e debian/tmp/etc/init.d/clickhouse-server ]; then ln -s tmp/etc/init.d/clickhouse-server debian/clickhouse-server-base.clickhouse-server.init; fi
# создаем дефолтный cron, если нет крон-файла созданного пользователем
# cron_name имеет вид daemonname
2016-02-07 20:02:44 +00:00
# Для ClickHouse не должно быть лишних зависимостей.
# Making necessary *.install files
2016-02-07 20:02:44 +00:00
for DAEMON_PKG in ${DAEMONS}; do \
if [ ! -e "debian/$$DAEMON_PKG.install" ]; then \
echo "# automatically created" > debian/$$DAEMON_PKG.install; \
echo "/etc/$$DAEMON_PKG/config.xml" >> debian/$$DAEMON_PKG.install; \
echo "/usr/bin/$$DAEMON_PKG" >> debian/$$DAEMON_PKG.install; \
echo "/etc/cron.d/$$DAEMON_PKG" >> debian/$$DAEMON_PKG.install; \
2016-02-07 20:02:44 +00:00
if [ -e "debian/tmp/etc/monrun/conf.d/$$DAEMON_PKG.conf" ]; then \
echo "/etc/monrun/conf.d/$$DAEMON_PKG.conf" >> debian/$$DAEMON_PKG.install; \
2016-02-07 20:02:44 +00:00
fi;\
fi; \
done
# Making necessary *.postinst files
2016-02-07 20:02:44 +00:00
for DAEMON_PKG in ${DAEMONS}; do \
if [ ! -e "debian/$$DAEMON_PKG.postinst" ]; then \
echo "# automatically created" > debian/$$DAEMON_PKG.postinst; \
echo "mkdir -p /etc/$$DAEMON_PKG/conf.d" >> debian/$$DAEMON_PKG.postinst; \
echo "chown -R clickhouse: /etc/$$DAEMON_PKG" >> debian/$$DAEMON_PKG.postinst; \
if [ -e "debian/tmp/etc/init.d/$$DAEMON_PKG" ]; then \
2016-02-07 20:02:44 +00:00
if echo $$DAEMON_PKG | grep server > /dev/null; then\
echo "update-rc.d $$DAEMON_PKG defaults > /dev/null || exit \$$?" >> debian/$$DAEMON_PKG.postinst; \
2016-02-07 20:02:44 +00:00
else\
echo "update-rc.d $$DAEMON_PKG start 30 2 3 4 5 . stop 70 0 1 6 . > /dev/null || exit \$$?" >> debian/$$DAEMON_PKG.postinst; \
2016-02-07 20:02:44 +00:00
fi\
fi\
\
else \
echo >> debian/$$DAEMON_PKG.postinst; \
echo "mkdir -p /etc/$$DAEMON_PKG/conf.d; chown -R clickhouse: /etc/$$DAEMON_PKG" >> debian/$$DAEMON_PKG.postinst; \
2016-02-07 20:02:44 +00:00
fi; \
done
# In case building clickhouse-server, adding to package binary of clang, ld and header files - for dynamic compilation.
mkdir -p debian/tmp/usr/share/clickhouse/bin debian/tmp/usr/share/clickhouse/headers
debian/copy_clang_binaries.sh debian/tmp/usr/share/clickhouse/bin/
./copy_headers.sh . debian/tmp/usr/share/clickhouse/headers
2016-02-07 20:02:44 +00:00
# Making docs
cp LICENSE debian/copyright
for DAEMON_PKG in ${DAEMONS}; do \
2016-06-10 15:00:57 +00:00
echo "LICENSE" > debian/$$DAEMON_PKG.docs; \
echo "AUTHORS" >> debian/$$DAEMON_PKG.docs; \
echo "README.md" >> debian/$$DAEMON_PKG.docs; \
done
ln -s clickhouse-server.docs debian/clickhouse-server-base.docs
ln -s clickhouse-server.docs debian/clickhouse-server-common.docs
ln -s clickhouse-server.docs debian/clickhouse-server-metrika.docs
mkdir -p debian/tmp/etc/security/limits.d
cp tools/etc/security/limits.d/clickhouse.conf debian/tmp/etc/security/limits.d
mkdir -p debian/tmp/etc/init.d
cp tools/etc/init.d/clickhouse-server debian/tmp/etc/init.d
mkdir -p debian/tmp/etc/cron.d
cp tools/etc/cron.d/clickhouse-server debian/tmp/etc/cron.d
2016-02-07 20:02:44 +00:00
# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.
# Build architecture-dependent files here.
binary-arch: build install
dh_testdir
dh_testroot
dh_installdocs
dh_installinit --no-start --no-package=clickhouse-server-base
dh_installinit --no-start --package=clickhouse-server-base --name=clickhouse-server
dh_installcron
dh_installdirs
dh_installchangelogs
dh_install --sourcedir=debian/tmp
dh_link
dh_compress
dh_fixperms
dh_installdeb
2016-06-10 13:14:32 +00:00
dh_shlibdeps --exclude=clang --exclude=stdc --exclude=ld
2016-02-07 20:02:44 +00:00
dh_gencontrol
dh_md5sums
dh_builddeb -- -Zgzip -z3
2016-02-07 20:02:44 +00:00
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install