From d751756819495f57062ca55c9fb2a88ae52b9ba2 Mon Sep 17 00:00:00 2001 From: Tomasz Kapela Date: Wed, 13 Apr 2016 10:40:41 +0200 Subject: [PATCH] common: add experimental install and package build Add conditional build of experimental features. --- Makefile | 4 +- README.md | 17 ++++++++ doc/Makefile | 18 +++++++- src/Makefile | 22 +++++++++- src/common.inc | 3 ++ utils/build-dpkg.sh | 92 ++++++++++++++++++++++++++++++++++------ utils/build-rpm.sh | 75 ++++++++++++++++++++++++-------- utils/make-pkg-config.sh | 15 +++++++ 8 files changed, 213 insertions(+), 33 deletions(-) diff --git a/Makefile b/Makefile index 16216278891..bc5d8a05644 100644 --- a/Makefile +++ b/Makefile @@ -66,6 +66,8 @@ export SRCVERSION = $(shell git describe 2>/dev/null ||\ RPM_BUILDDIR=rpmbuild DPKG_BUILDDIR=dpkgbuild +EXPERIMENTAL ?= n +BUILD_PACKAGE_CHECK ?= y rpm : override DESTDIR=$(CURDIR)/$(RPM_BUILDDIR) dpkg: override DESTDIR=$(CURDIR)/$(DPKG_BUILDDIR) rpm dpkg: override prefix=/usr @@ -114,7 +116,7 @@ pkg-clean: rpm dpkg: pkg-clean source +utils/build-$@.sh $(SRCVERSION) $(DESTDIR)/nvml $(DESTDIR) $(CURDIR)/$@\ - $(CURDIR)/src/test/testconfig.sh + ${EXPERIMENTAL} ${BUILD_PACKAGE_CHECK} $(CURDIR)/src/test/testconfig.sh install uninstall: $(MAKE) -C src $@ diff --git a/README.md b/README.md index 1bee6ae929b..e716e58fa6a 100644 --- a/README.md +++ b/README.md @@ -120,12 +120,22 @@ To build rpm packages on rpm-based distributions: ``` $ make rpm ``` + +If you want to build packages without running tests, run: +``` + $ make BUILD_PACKAGE_CHECK=n rpm +``` **DEPENDENCIES:** rpmbuild To build dpkg packages on Debian-based distributions: ``` $ make dpkg ``` + +If you want to build packages without running tests, run: +``` + $ make BUILD_PACKAGE_CHECK=n dpkg +``` **DEPENDENCIES:** devscripts (*) By default all code is built with -Werror flag which fails the whole build @@ -175,6 +185,13 @@ To test the libraries with AddressSanitizer and UndefinedBehaviorSanitizer, run: $ make EXTRA_CFLAGS="-fsanitize=address,undefined" EXTRA_LDFLAGS="-fsanitize=address,undefined" clobber all test check ``` +### Experimental Packages ### + +If you want to build/install experimental packages run: +``` + $ make EXPERIMENTAL=y [install,rpm,dpkg] +``` + ### Contacts ### For more information on this library, contact diff --git a/doc/Makefile b/doc/Makefile index aee500dd25a..a9b6d13f6cd 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -56,6 +56,9 @@ DOXYGEN_HTMLDIR=cpp_html MANPAGES_DESTDIR_1 = $(DESTDIR)$(man1dir) MANPAGES_DESTDIR_3 = $(DESTDIR)$(man3dir) +DOCS_DESTDIR = $(DESTDIR)$(docdir) +CPP_DOC_DIR ?= libpmemobj++-dev +CPP_DOCS_DESTDIR = $(DOCS_DESTDIR)/$(CPP_DOC_DIR) all: $(TXTFILES) @@ -80,6 +83,18 @@ clean: clobber: clean $(RM) -rf $(TXTFILES) $(HTMLFILES) $(GZFILES) $(DOXYGEN_HTMLDIR) +ifeq ($(EXPERIMENTAL),y) +install-cpp: doxygen_docs + $(call install_recursive,$(DOXYGEN_HTMLDIR),0644,$(CPP_DOCS_DESTDIR)) + +install: install-cpp + +uninstall-cpp: + $(RM) -rf $(CPP_DOCS_DESTDIR) + +uninstall: uninstall-cpp +endif + install: compress install -d $(MANPAGES_DESTDIR_1) install -p -m 0644 $(GZFILES_1) $(MANPAGES_DESTDIR_1) @@ -90,4 +105,5 @@ uninstall: $(foreach f, $(GZFILES_1), $(RM) $(MANPAGES_DESTDIR_1)/$(f)) $(foreach f, $(GZFILES_3), $(RM) $(MANPAGES_DESTDIR_3)/$(f)) -.PHONY: all html clean compress clobber cstyle install uninstall +.PHONY: all html clean compress clobber cstyle install uninstall install-cpp\ + uninstall-cpp doxygen_docs diff --git a/src/Makefile b/src/Makefile index 63e7cbe98ae..7ced15888cb 100644 --- a/src/Makefile +++ b/src/Makefile @@ -47,11 +47,18 @@ HEADERS_INSTALL = include/libpmem.h include/libvmem.h\ include/libpmemobj.h include/libpmemblk.h\ include/libpmemlog.h include/libvmmalloc.h +CPP_HEADERS_DESTDIR = $(DESTDIR)$(includedir)/libpmemobj +CPP_HEADERS_INSTALL = $(foreach d, include/libpmemobj, $(wildcard $(d)/*.hpp)) + MAKE_PKG_CONFIG = $(TOP)/utils/make-pkg-config.sh PKG_CONFIG_DESTDIR = $(DESTDIR)$(pkgconfigdir) PKG_CONFIG_FILES = libpmem.pc libvmem.pc libvmmalloc.pc\ libpmemobj.pc libpmemlog.pc libpmemblk.pc +ifeq ($(EXPERIMENTAL),y) + PKG_CONFIG_FILES += libpmemobj++.pc +endif + SCOPE_SRC_DIRS = $(TARGETS) include jemalloc/src SCOPE_HDR_DIRS = $(TARGETS) include jemalloc/src\ jemalloc/include/jemalloc\ @@ -130,6 +137,19 @@ ifeq ($(custom_build),) $(MAKE) -C jemalloc -f Makefile.nvml $@ DEBUG=1 endif +ifeq ($(EXPERIMENTAL),y) +install-cpp: + install -d $(CPP_HEADERS_DESTDIR) + install -p -m 0644 $(CPP_HEADERS_INSTALL) $(CPP_HEADERS_DESTDIR) + +install: install-cpp + +uninstall-cpp: + $(RM) -r $(CPP_HEADERS_DESTDIR) + +uninstall: uninstall-cpp +endif + install: all install -d $(HEADERS_DESTDIR) install -p -m 0644 $(HEADERS_INSTALL) $(HEADERS_DESTDIR) @@ -152,6 +172,6 @@ clean: .NOTPARALLEL: libvmem libvmmalloc -.PHONY: all install uninstall clean clobber cstyle test check pcheck\ +.PHONY: all install uninstall unistall-cpp install-cpp clean clobber cstyle test check pcheck\ jemalloc jemalloc-clean jemalloc-test jemalloc-check cscope $(ALL_TARGETS)\ pkg-config diff --git a/src/common.inc b/src/common.inc index b3900d67d06..9faaf68e648 100644 --- a/src/common.inc +++ b/src/common.inc @@ -64,6 +64,8 @@ check_Wconversion = $(shell echo "long int random(void); char test(void); char t check_librt = $(shell echo "int main() { struct timespec t; return clock_gettime(CLOCK_MONOTONIC, &t); }" |\ $(CC) $(CFLAGS) -x c -include time.h -o /dev/null - 2>/dev/null && echo y || echo n) +install_recursive = $(shell find $(1) -type f -exec install -m $(2) -D {} $(3)/{} \;) + define create-deps @cp $(objdir)/$*.d $(objdir)/.deps/$*.P; \ sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ @@ -76,6 +78,7 @@ export exec_prefix := $(prefix) export sysconfdir := $(prefix)/etc export datarootdir := $(prefix)/share export mandir := $(datarootdir)/man +export docdir := $(datarootdir)/doc export man1dir := $(mandir)/man1 export man3dir := $(mandir)/man3 diff --git a/utils/build-dpkg.sh b/utils/build-dpkg.sh index 5fdfc1145d4..b468e8a9465 100755 --- a/utils/build-dpkg.sh +++ b/utils/build-dpkg.sh @@ -37,10 +37,11 @@ SCRIPT_DIR=$(dirname $0) source $SCRIPT_DIR/pkg-common.sh -if [ $# -lt 4 -o $# -gt 5 ] +if [ $# -lt 6 -o $# -gt 7 ] then echo "Usage: $(basename $0) VERSION_TAG SOURCE_DIR WORKING_DIR"\ - "OUT_DIR [TEST_CONFIG_FILE]" + "OUT_DIR EXPERIMENTAL RUN_CHECK"\ + "[TEST_CONFIG_FILE] " exit 1 fi @@ -48,7 +49,9 @@ PACKAGE_VERSION_TAG=$1 SOURCE=$2 WORKING_DIR=$3 OUT_DIR=$4 -TEST_CONFIG_FILE=$5 +EXPERIMENTAL=$5 +BUILD_PACKAGE_CHECK=$6 +TEST_CONFIG_FILE=$7 function convert_changelog() { while read line @@ -70,6 +73,66 @@ function convert_changelog() { done < $1 } +function experimental_install_triggers_overrides() { +cat << EOF > debian/${OBJ_CPP_NAME}.install +usr/include/libpmemobj/*.hpp +usr/share/doc/${OBJ_CPP_DOC_DIR}/* +EOF + +cat << EOF > debian/${OBJ_CPP_NAME}.triggers +interest doc-base +EOF + +cat << EOF > debian/${OBJ_CPP_NAME}.lintian-overrides +$ITP_BUG_EXCUSE +new-package-should-close-itp-bug +# The following warnings are triggered by a bug in debhelper: +# http://bugs.debian.org/204975 +postinst-has-useless-call-to-ldconfig +postrm-has-useless-call-to-ldconfig +EOF + +cat << EOF > debian/${OBJ_CPP_NAME}.doc-base +Document: ${OBJ_CPP_NAME} +Title: NVML libpmemobj C++ bindings Manual +Author: NVML Developers +Abstract: This is the HTML docs for the C++ bindings for NVML's libpmemobj. +Section: Programming + +Format: HTML +Index: /usr/share/doc/${OBJ_CPP_DOC_DIR}/index.html +Files: /usr/share/doc/${OBJ_CPP_DOC_DIR}/* +EOF +} + +function append_experimental_control() { +cat << EOF >> $CONTROL_FILE + +Package: ${OBJ_CPP_NAME} +Section: libdevel +Architecture: any +Depends: libpmemobj-dev (=\${binary:Version}), \${shlibs:Depends}, \${misc:Depends} +Description: C++ bindings for libpmemobj (EXPERIMENTAL) + Headers-only C++ library for libpmemobj. +EOF +} + +CHECK_CMD=" +override_dh_auto_test: + dh_auto_test + if [ -f $TEST_CONFIG_FILE ]; then\ + cp $TEST_CONFIG_FILE src/test/testconfig.sh;\ + else\ + cp src/test/testconfig.sh.example src/test/testconfig.sh;\ + fi + make check +" + +if [ "${BUILD_PACKAGE_CHECK}" != "y" ] +then + CHECK_CMD="" +fi + check_tool debuild check_tool dch check_file $SCRIPT_DIR/pkg-config.sh @@ -82,6 +145,9 @@ PACKAGE_SOURCE=${PACKAGE_NAME}-${PACKAGE_VERSION} PACKAGE_TARBALL_ORIG=${PACKAGE_NAME}_${PACKAGE_VERSION}.orig.tar.gz MAGIC_INSTALL=utils/magic-install.sh MAGIC_UNINSTALL=utils/magic-uninstall.sh +CONTROL_FILE=debian/control +OBJ_CPP_NAME=libpmemobj++-dev +OBJ_CPP_DOC_DIR=${OBJ_CPP_NAME}-${PACKAGE_VERSION} [ -d $WORKING_DIR ] || mkdir $WORKING_DIR [ -d $OUT_DIR ] || mkdir $OUT_DIR @@ -105,7 +171,7 @@ cat << EOF > debian/compat EOF # Generate control file -cat << EOF > debian/control +cat << EOF > $CONTROL_FILE Source: $PACKAGE_NAME Maintainer: $PACKAGE_MAINTAINER Section: misc @@ -220,21 +286,14 @@ override_dh_strip: dh_strip --dbg-package=$PACKAGE_NAME-dbg override_dh_auto_install: - dh_auto_install -- prefix=/usr sysconfdir=/etc + dh_auto_install -- EXPERIMENTAL=${EXPERIMENTAL} CPP_DOC_DIR="${OBJ_CPP_DOC_DIR}" prefix=/usr sysconfdir=/etc override_dh_install: mkdir -p debian/tmp/usr/share/nvml/ cp utils/nvml.magic debian/tmp/usr/share/nvml/ dh_install -override_dh_auto_test: - dh_auto_test - if [ -f $TEST_CONFIG_FILE ]; then\ - cp $TEST_CONFIG_FILE src/test/testconfig.sh;\ - else\ - cp src/test/testconfig.sh.example src/test/testconfig.sh;\ - fi - make check +${CHECK_CMD} EOF chmod +x debian/rules @@ -488,6 +547,13 @@ $ITP_BUG_EXCUSE new-package-should-close-itp-bug EOF +# Experimental features +if [ "${EXPERIMENTAL}" = "y" ] +then + append_experimental_control; + experimental_install_triggers_overrides; +fi + # Convert ChangeLog to debian format CHANGELOG_TMP=changelog.tmp dch --create --empty --package $PACKAGE_NAME -v $PACKAGE_VERSION-$PACKAGE_RELEASE -M -c $CHANGELOG_TMP diff --git a/utils/build-rpm.sh b/utils/build-rpm.sh index dbb12aca874..e150c09014a 100755 --- a/utils/build-rpm.sh +++ b/utils/build-rpm.sh @@ -37,20 +37,25 @@ SCRIPT_DIR=$(dirname $0) source $SCRIPT_DIR/pkg-common.sh -if [ $# -lt 4 -o $# -gt 5 ] +if [ $# -lt 6 -o $# -gt 7 ] then - echo "Usage: $(basename $0) VERSION_TAG SOURCE_DIR WORKING_DIR"\ - "OUT_DIR [TEST_CONFIG_FILE]" - exit 1 + echo "Usage: $(basename $0) VERSION_TAG SOURCE_DIR WORKING_DIR"\ + "OUT_DIR EXPERIMENTAL RUN_CHECK"\ + "[TEST_CONFIG_FILE] " + exit 1 fi PACKAGE_VERSION_TAG=$1 SOURCE=$2 WORKING_DIR=$3 OUT_DIR=$4 -TEST_CONFIG_FILE=$5 +EXPERIMENTAL=$5 +BUILD_PACKAGE_CHECK=$6 +TEST_CONFIG_FILE=$7 -function convert_changelog() { +function create_changelog() { + echo + echo "%changelog" while read do if [[ $REPLY =~ $REGEX_DATE_AUTHOR ]] @@ -68,6 +73,24 @@ function convert_changelog() { done < $1 } +function add_experimental_packages() { +cat << EOF >> $RPM_SPEC_FILE + +%package -n ${OBJ_CPP_NAME} +Summary: C++ bindings for libpmemobj +Group: Development/Libraries +Requires: libpmemobj-devel = %{version} +%description -n ${OBJ_CPP_NAME} +Development files for NVML C++ libpmemobj bindings - EXPERIMENTAL + +%files -n ${OBJ_CPP_NAME} +%defattr(-,root,root,-) +%{_libdir}/pkgconfig/libpmemobj++.pc +%{_includedir}/libpmemobj/*.hpp +%{_docdir}/${OBJ_CPP_NAME}-%{version}/* +EOF +} + check_tool rpmbuild check_file $SCRIPT_DIR/pkg-config.sh @@ -86,6 +109,22 @@ then exit 1 fi +CHECK_CMD=" +%check +if [ -f $TEST_CONFIG_FILE ]; then + cp $TEST_CONFIG_FILE src/test/testconfig.sh +else + cp src/test/testconfig.sh.example src/test/testconfig.sh +fi + +make check +" + +if [ "${BUILD_PACKAGE_CHECK}" != "y" ] +then + CHECK_CMD="" +fi + PACKAGE_SOURCE=${PACKAGE_NAME}-${PACKAGE_VERSION} SOURCE=$PACKAGE_NAME PACKAGE_TARBALL=$PACKAGE_SOURCE.tar.gz @@ -94,6 +133,8 @@ CHANGELOG_FILE=$PACKAGE_SOURCE/ChangeLog MAGIC_INSTALL=$PACKAGE_SOURCE/utils/magic-install.sh MAGIC_UNINSTALL=$PACKAGE_SOURCE/utils/magic-uninstall.sh OLDPWD=$PWD +OBJ_CPP_NAME=libpmemobj++-devel +OBJ_CPP_DOC_DIR=${OBJ_CPP_NAME}-${PACKAGE_VERSION} [ -d $WORKING_DIR ] || mkdir -v $WORKING_DIR [ -d $OUT_DIR ] || mkdir $OUT_DIR @@ -337,18 +378,13 @@ make install DESTDIR=%{buildroot}\ includedir=%{_includedir}\ mandir=%{_mandir}\ bindir=%{_bindir}\ - sysconfdir=%{_sysconfdir} + sysconfdir=%{_sysconfdir}\ + EXPERIMENTAL=${EXPERIMENTAL}\ + CPP_DOC_DIR=${OBJ_CPP_DOC_DIR} mkdir -p %{buildroot}%{_datadir}/nvml cp utils/nvml.magic %{buildroot}%{_datadir}/nvml/ -%check -if [ -f $TEST_CONFIG_FILE ]; then - cp $TEST_CONFIG_FILE src/test/testconfig.sh -else - cp src/test/testconfig.sh.example src/test/testconfig.sh -fi - -make check +${CHECK_CMD} %clean make clobber @@ -357,10 +393,15 @@ make clobber %debug_package %endif -%changelog EOF -[ -f $CHANGELOG_FILE ] && convert_changelog $CHANGELOG_FILE >> $RPM_SPEC_FILE +# Experimental features +if [ "${EXPERIMENTAL}" = "y" ] +then + add_experimental_packages; +fi + +[ -f $CHANGELOG_FILE ] && create_changelog $CHANGELOG_FILE >> $RPM_SPEC_FILE tar zcf $PACKAGE_TARBALL $PACKAGE_SOURCE diff --git a/utils/make-pkg-config.sh b/utils/make-pkg-config.sh index d8d48304974..589ab7eef51 100755 --- a/utils/make-pkg-config.sh +++ b/utils/make-pkg-config.sh @@ -133,3 +133,18 @@ Requires: Libs: -L\${libdir} -lvmmalloc Cflags: -I\${includedir} EOF + +cat << EOF > libpmemobj++.pc +prefix=${prefix} +libdir=${libdir} +version=${version} +includedir=\${prefix}/include/libpmemobj + +Name: libpmemobj++ +Description: C++ bindings for the libpmemobj library from NVML project +Version: \${version} +URL: http://pmem.io/nvml +Requires.private: +Libs: -L\${libdir} -lpmemobj +Cflags: -I\${includedir} +EOF