pkg: devmapper: dynamically load dm_task_deferred_remove
dm_task_deferred_remove is not supported by all distributions, due to out-dated versions of devicemapper. However, in the case where the devicemapper library was updated without rebuilding Docker (which can happen in some distributions) then we should attempt to dynamically load the relevant object rather than try to link to it. This can only be done if Docker was built dynamically, for obvious reasons. In order to avoid having issues arise when dlsym(3) was unnecessary, gate the whole dlsym(3) logic behind a buildflag that we disable by default (libdm_dlsym_deferred_remove). Signed-off-by: Aleksa Sarai <asarai@suse.de> Upstream-commit: 98fe4bd8f1e35f8e498e268f653a43cbfa31e751 Component: engine
This commit is contained in:
@@ -103,6 +103,12 @@ if [ ! "$GOPATH" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Adds $1_$2 to DOCKER_BUILDTAGS unless it already
|
||||
# contains a word starting from $1_
|
||||
add_buildtag() {
|
||||
[[ " $DOCKER_BUILDTAGS" == *" $1_"* ]] || DOCKER_BUILDTAGS+=" $1_$2"
|
||||
}
|
||||
|
||||
if ${PKG_CONFIG} 'libsystemd >= 209' 2> /dev/null ; then
|
||||
DOCKER_BUILDTAGS+=" journald"
|
||||
elif ${PKG_CONFIG} 'libsystemd-journal' 2> /dev/null ; then
|
||||
@@ -118,12 +124,14 @@ if \
|
||||
fi
|
||||
|
||||
# test whether "libdevmapper.h" is new enough to support deferred remove
|
||||
# functionality.
|
||||
# functionality. We favour libdm_dlsym_deferred_remove over
|
||||
# libdm_no_deferred_remove in dynamic cases because the binary could be shipped
|
||||
# with a newer libdevmapper than the one it was built wih.
|
||||
if \
|
||||
command -v gcc &> /dev/null \
|
||||
&& ! ( echo -e '#include <libdevmapper.h>\nint main() { dm_task_deferred_remove(NULL); }'| gcc -xc - -o /dev/null $(pkg-config --libs devmapper) &> /dev/null ) \
|
||||
; then
|
||||
DOCKER_BUILDTAGS+=' libdm_no_deferred_remove'
|
||||
add_buildtag libdm dlsym_deferred_remove
|
||||
fi
|
||||
|
||||
# Use these flags when compiling the tests and final binary
|
||||
|
||||
Reference in New Issue
Block a user