From c4fde49a5c0198890078e4c5f7566b387884fe0f Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Tue, 1 Aug 2017 17:29:29 -0700 Subject: [PATCH] Dockerfile*: bump devmapper library version Let's use latest lvm2 sources to compile the libdevmapper library. Initial reason for compiling devmapper lib from sources was a need to have the static version of the library at hand, in order to build the static dockerd, but note that the same headers/solib are used for dynamic build (dynbinary) as well. The reason for this patch is to enable the deferral removal feature. The supplied devmapper library (and headers) are too old, lacking the needed functions, so the daemon is built with 'libdm_no_deferred_remove' build tag (see the check in hack/make.sh). Because of this, even if the kernel dm driver is perfectly able to support the feature, it can not be used. For more details and background story, see [1]. Surely, one can't just change the version number. While at it: - improve the comments; - remove obsoleted URLs; - remove s390 and ppc configure updates that are no longer needed; - use pkg-config instead of hardcoding the flags (newer lib added some more dependencies); [1] https://github.com/moby/moby/issues/34298 Signed-off-by: Kir Kolyshkin --- Dockerfile | 14 ++++++------- Dockerfile.aarch64 | 20 ++++++------------- Dockerfile.armhf | 14 ++++++------- Dockerfile.ppc64le | 20 ++++++------------- Dockerfile.s390x | 20 ++++++------------- hack/make.sh | 2 +- pkg/devicemapper/devmapper_wrapper.go | 1 - .../devmapper_wrapper_deferred_remove.go | 5 +---- pkg/devicemapper/devmapper_wrapper_dynamic.go | 6 ++++++ pkg/devicemapper/devmapper_wrapper_static.go | 6 ++++++ 10 files changed, 46 insertions(+), 62 deletions(-) create mode 100644 pkg/devicemapper/devmapper_wrapper_dynamic.go create mode 100644 pkg/devicemapper/devmapper_wrapper_static.go diff --git a/Dockerfile b/Dockerfile index 33e88dce26..8fd83c9f62 100644 --- a/Dockerfile +++ b/Dockerfile @@ -72,21 +72,21 @@ RUN apt-get update && apt-get install -y \ zip \ --no-install-recommends \ && pip install awscli==1.10.15 -# Get lvm2 source for compiling statically -ENV LVM2_VERSION 2.02.103 + +# Get lvm2 sources to build statically linked devmapper library +ENV LVM2_VERSION 2.02.173 RUN mkdir -p /usr/local/lvm2 \ && curl -fsSL "https://mirrors.kernel.org/sourceware/lvm2/LVM2.${LVM2_VERSION}.tgz" \ | tar -xzC /usr/local/lvm2 --strip-components=1 -# See https://git.fedorahosted.org/cgit/lvm2.git/refs/tags for release tags -# Compile and install lvm2 +# Compile and install (only the needed library) RUN cd /usr/local/lvm2 \ && ./configure \ --build="$(gcc -print-multiarch)" \ --enable-static_link \ - && make device-mapper \ - && make install_device-mapper -# See https://git.fedorahosted.org/cgit/lvm2.git/tree/INSTALL + --enable-pkgconfig \ + && make -C include \ + && make -C libdm install_device-mapper # Install seccomp: the version shipped upstream is too old ENV SECCOMP_VERSION 2.3.2 diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index cabcda28bd..c17d698bfe 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -54,28 +54,20 @@ RUN apt-get update && apt-get install -y \ vim-common \ --no-install-recommends -# Get lvm2 source for compiling statically -ENV LVM2_VERSION 2.02.103 +# Get lvm2 sources to build statically linked devmapper library +ENV LVM2_VERSION 2.02.173 RUN mkdir -p /usr/local/lvm2 \ && curl -fsSL "https://mirrors.kernel.org/sourceware/lvm2/LVM2.${LVM2_VERSION}.tgz" \ | tar -xzC /usr/local/lvm2 --strip-components=1 -# See https://git.fedorahosted.org/cgit/lvm2.git/refs/tags for release tags -# Fix platform enablement in lvm2 to support aarch64 properly -RUN set -e \ - && for f in config.guess config.sub; do \ - curl -fsSL -o "/usr/local/lvm2/autoconf/$f" "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=$f;hb=HEAD"; \ - done -# "arch.c:78:2: error: #error the arch code needs to know about your machine type" - -# Compile and install lvm2 +# Compile and install (only the needed library) RUN cd /usr/local/lvm2 \ && ./configure \ --build="$(gcc -print-multiarch)" \ --enable-static_link \ - && make device-mapper \ - && make install_device-mapper -# See https://git.fedorahosted.org/cgit/lvm2.git/tree/INSTALL + --enable-pkgconfig \ + && make -C include \ + && make -C libdm install_device-mapper # Install seccomp: the version shipped upstream is too old ENV SECCOMP_VERSION 2.3.2 diff --git a/Dockerfile.armhf b/Dockerfile.armhf index dd1f536191..8685ff8f67 100644 --- a/Dockerfile.armhf +++ b/Dockerfile.armhf @@ -53,21 +53,21 @@ RUN apt-get update && apt-get install -y \ --no-install-recommends \ && pip install awscli==1.10.15 -# Get lvm2 source for compiling statically -ENV LVM2_VERSION 2.02.103 +# Get lvm2 sources to build statically linked devmapper library +ENV LVM2_VERSION 2.02.173 RUN mkdir -p /usr/local/lvm2 \ && curl -fsSL "https://mirrors.kernel.org/sourceware/lvm2/LVM2.${LVM2_VERSION}.tgz" \ | tar -xzC /usr/local/lvm2 --strip-components=1 -# See https://git.fedorahosted.org/cgit/lvm2.git/refs/tags for release tags -# Compile and install lvm2 +# Compile and install (only the needed library) RUN cd /usr/local/lvm2 \ && ./configure \ --build="$(gcc -print-multiarch)" \ --enable-static_link \ - && make device-mapper \ - && make install_device-mapper -# See https://git.fedorahosted.org/cgit/lvm2.git/tree/INSTALL + --enable-pkgconfig \ + && make -C include \ + && make -C libdm install_device-mapper + # Install Go # IMPORTANT: When updating this please note that stdlib archive/tar pkg is vendored diff --git a/Dockerfile.ppc64le b/Dockerfile.ppc64le index 43b84e4501..3441f3d30d 100644 --- a/Dockerfile.ppc64le +++ b/Dockerfile.ppc64le @@ -53,28 +53,20 @@ RUN apt-get update && apt-get install -y \ vim-common \ --no-install-recommends -# Get lvm2 source for compiling statically -ENV LVM2_VERSION 2.02.103 +# Get lvm2 sources to build statically linked devmapper library +ENV LVM2_VERSION 2.02.173 RUN mkdir -p /usr/local/lvm2 \ && curl -fsSL "https://mirrors.kernel.org/sourceware/lvm2/LVM2.${LVM2_VERSION}.tgz" \ | tar -xzC /usr/local/lvm2 --strip-components=1 -# See https://git.fedorahosted.org/cgit/lvm2.git/refs/tags for release tags -# Fix platform enablement in lvm2 to support ppc64le properly -RUN set -e \ - && for f in config.guess config.sub; do \ - curl -fsSL -o "/usr/local/lvm2/autoconf/$f" "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=$f;hb=HEAD"; \ - done -# "arch.c:78:2: error: #error the arch code needs to know about your machine type" - -# Compile and install lvm2 +# Compile and install (only the needed library) RUN cd /usr/local/lvm2 \ && ./configure \ --build="$(gcc -print-multiarch)" \ --enable-static_link \ - && make device-mapper \ - && make install_device-mapper -# See https://git.fedorahosted.org/cgit/lvm2.git/tree/INSTALL + --enable-pkgconfig \ + && make -C include \ + && make -C libdm install_device-mapper # Install seccomp: the version shipped upstream is too old ENV SECCOMP_VERSION 2.3.2 diff --git a/Dockerfile.s390x b/Dockerfile.s390x index 35ec683739..e43783f2d2 100644 --- a/Dockerfile.s390x +++ b/Dockerfile.s390x @@ -64,28 +64,20 @@ RUN set -x \ ) \ && rm -rf "$SECCOMP_PATH" -# Get lvm2 source for compiling statically -ENV LVM2_VERSION 2.02.103 +# Get lvm2 sources to build statically linked devmapper library +ENV LVM2_VERSION 2.02.173 RUN mkdir -p /usr/local/lvm2 \ && curl -fsSL "https://mirrors.kernel.org/sourceware/lvm2/LVM2.${LVM2_VERSION}.tgz" \ | tar -xzC /usr/local/lvm2 --strip-components=1 -# See https://git.fedorahosted.org/cgit/lvm2.git/refs/tags for release tags -# Fix platform enablement in lvm2 to support s390x properly -RUN set -e \ - && for f in config.guess config.sub; do \ - curl -fsSL -o "/usr/local/lvm2/autoconf/$f" "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=$f;hb=HEAD"; \ - done -# "arch.c:78:2: error: #error the arch code needs to know about your machine type" - -# Compile and install lvm2 +# Compile and install (only the needed library) RUN cd /usr/local/lvm2 \ && ./configure \ --build="$(gcc -print-multiarch)" \ --enable-static_link \ - && make device-mapper \ - && make install_device-mapper -# See https://git.fedorahosted.org/cgit/lvm2.git/tree/INSTALL + --enable-pkgconfig \ + && make -C include \ + && make -C libdm install_device-mapper # IMPORTANT: When updating this please note that stdlib archive/tar pkg is vendored ENV GO_VERSION 1.8.3 diff --git a/hack/make.sh b/hack/make.sh index e625b863de..07c26ebcf5 100755 --- a/hack/make.sh +++ b/hack/make.sh @@ -130,7 +130,7 @@ fi # functionality. if \ command -v gcc &> /dev/null \ - && ! ( echo -e '#include \nint main() { dm_task_deferred_remove(NULL); }'| gcc -xc - -o /dev/null -ldevmapper &> /dev/null ) \ + && ! ( echo -e '#include \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' fi diff --git a/pkg/devicemapper/devmapper_wrapper.go b/pkg/devicemapper/devmapper_wrapper.go index da3b43f796..64e82dfd04 100644 --- a/pkg/devicemapper/devmapper_wrapper.go +++ b/pkg/devicemapper/devmapper_wrapper.go @@ -3,7 +3,6 @@ package devicemapper /* -#cgo LDFLAGS: -L. -ldevmapper #define _GNU_SOURCE #include #include // FIXME: present only for BLKGETSIZE64, maybe we can remove it? diff --git a/pkg/devicemapper/devmapper_wrapper_deferred_remove.go b/pkg/devicemapper/devmapper_wrapper_deferred_remove.go index 7e231ddcb8..7f793c2708 100644 --- a/pkg/devicemapper/devmapper_wrapper_deferred_remove.go +++ b/pkg/devicemapper/devmapper_wrapper_deferred_remove.go @@ -2,10 +2,7 @@ package devicemapper -/* -#cgo LDFLAGS: -L. -ldevmapper -#include -*/ +// #include import "C" // LibraryDeferredRemovalSupport tells if the feature is enabled in the build diff --git a/pkg/devicemapper/devmapper_wrapper_dynamic.go b/pkg/devicemapper/devmapper_wrapper_dynamic.go new file mode 100644 index 0000000000..7d84508982 --- /dev/null +++ b/pkg/devicemapper/devmapper_wrapper_dynamic.go @@ -0,0 +1,6 @@ +// +build linux,cgo,!static_build + +package devicemapper + +// #cgo pkg-config: devmapper +import "C" diff --git a/pkg/devicemapper/devmapper_wrapper_static.go b/pkg/devicemapper/devmapper_wrapper_static.go new file mode 100644 index 0000000000..cf7f26a4c6 --- /dev/null +++ b/pkg/devicemapper/devmapper_wrapper_static.go @@ -0,0 +1,6 @@ +// +build linux,cgo,static_build + +package devicemapper + +// #cgo pkg-config: --static devmapper +import "C"