Skip to content

Commit

Permalink
common: add experimental install and package build
Browse files Browse the repository at this point in the history
Add conditional build of experimental features.
  • Loading branch information
tomaszkapela committed Apr 22, 2016
1 parent 4c141a9 commit d751756
Show file tree
Hide file tree
Showing 8 changed files with 213 additions and 33 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 $@
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
18 changes: 17 additions & 1 deletion doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand All @@ -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
22 changes: 21 additions & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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\
Expand Down Expand Up @@ -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)
Expand All @@ -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
3 changes: 3 additions & 0 deletions src/common.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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/ *\\$$//' \
Expand All @@ -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

Expand Down
92 changes: 79 additions & 13 deletions utils/build-dpkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,21 @@
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

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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit d751756

Please sign in to comment.