2019-10-03 08:33:31 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
SCRIPT_DIR="$(dirname "$BASH_SOURCE")"
|
|
|
|
SCRIPT_DIR="$(realpath "$SCRIPT_DIR")"
|
|
|
|
|
2020-03-27 02:14:52 +00:00
|
|
|
num_vcpus=$(nproc)
|
2019-10-03 08:33:31 +00:00
|
|
|
NUM_WORKERS=${NUM_WORKERS:-$num_vcpus}
|
|
|
|
|
|
|
|
DEPS_DIR="${DEPS_DIR:-$SCRIPT_DIR/build.deps}"
|
|
|
|
depsSrcDir="$DEPS_DIR/src"
|
|
|
|
depsToolsetDir="$DEPS_DIR/mingw"
|
|
|
|
|
|
|
|
lz4SrcDir="${depsSrcDir}/lz4"
|
|
|
|
lz4Dir="${depsToolsetDir}/lz4"
|
|
|
|
lz4Tag="v1.9.2"
|
2020-04-02 07:40:38 +00:00
|
|
|
sslTag="OpenSSL_1_1_1c"
|
2019-10-03 08:33:31 +00:00
|
|
|
sslDir="${depsToolsetDir}/openssl"
|
2020-04-02 07:40:38 +00:00
|
|
|
sslSrcDir="${depsSrcDir}/openssl"
|
2019-10-03 08:33:31 +00:00
|
|
|
|
|
|
|
curlTag="curl-7_66_0"
|
|
|
|
curlSrcDir="${depsSrcDir}/curl"
|
|
|
|
curlDir="${depsToolsetDir}/curl"
|
|
|
|
|
|
|
|
# For now, we'll keep the version number within the file path when not using git.
|
|
|
|
boostUrl="https://dl.bintray.com/boostorg/release/1.70.0/source/boost_1_70_0.tar.gz"
|
|
|
|
boostSrcDir="${depsSrcDir}/boost_1_70_0"
|
|
|
|
boostDir="${depsToolsetDir}/boost"
|
|
|
|
zlibDir="${depsToolsetDir}/zlib"
|
|
|
|
zlibSrcDir="${depsSrcDir}/zlib"
|
2020-03-24 02:16:28 +00:00
|
|
|
backtraceDir="${depsToolsetDir}/libbacktrace"
|
|
|
|
backtraceSrcDir="${depsSrcDir}/libbacktrace"
|
2019-10-03 08:33:31 +00:00
|
|
|
snappySrcDir="${depsSrcDir}/snappy"
|
|
|
|
snappyDir="${depsToolsetDir}/snappy"
|
|
|
|
snappyTag="1.1.7"
|
|
|
|
# Additional Windows libraries, which aren't provided by Mingw
|
|
|
|
winLibDir="${depsToolsetDir}/windows/lib"
|
|
|
|
|
rbd: allow mounting images on Windows
This change will allow mapping rbd images on Windows, leveraging the
WNBD[1] Virtual Storport Miniport driver [2].
The behavior and CLI is similar to the Linux rbd-nbd, with a few
notable differences:
* device paths cannot be requested. The disk number and path will
be picked by Windows. If a device path is provided by the user
when mapping an image, it will be used as an identifier, which
can also be used when unmapping the image.
* the "show" command was added, which describes a specific mapping.
This can be used for retrieving the disk path.
* the "service" command was added, allowing rbd-wnbd to run as a
Windows service. All mappings are currently perisistent, being
recreated when the service stops, unless explicitly unmapped.
The service disconnects the mappings when being stopped.
* the "list" command also includes a "status" column.
The purpose of the "service" mode is to ensure that mappings survive
reboots and that the Windows service start order can be adjusted so
that rbd images can be mapped before starting services that may depend
on it, such as VMMS.
The mapped images can either be consumed by the host directly or exposed
to Hyper-V VMs.
While at it, we'll skip building rbd-mirror as it's quite unlikely that
this daemon is going to be used on Windows for now.
[1] https://github.com/cloudbase/wnbd
[2] https://docs.microsoft.com/en-us/windows-hardware/drivers/storage/overview-of-storage-virtual-miniport-drivers
Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
2020-07-30 11:40:31 +00:00
|
|
|
wnbdUrl="https://github.com/cloudbase/wnbd"
|
|
|
|
wnbdTag="master"
|
|
|
|
wnbdSrcDir="${depsSrcDir}/wnbd"
|
|
|
|
wnbdLibDir="${depsToolsetDir}/wnbd/lib"
|
2019-10-03 08:33:31 +00:00
|
|
|
|
2020-03-27 02:43:22 +00:00
|
|
|
# Allow for OS specific customizations through the OS flag (normally
|
|
|
|
# passed through from win32_build).
|
|
|
|
# Valid options are currently "ubuntu" and "suse".
|
|
|
|
OS=${OS:-"ubuntu"}
|
|
|
|
|
2019-10-03 08:33:31 +00:00
|
|
|
function _make() {
|
|
|
|
make -j $NUM_WORKERS $@
|
|
|
|
}
|
|
|
|
|
2020-05-27 10:23:45 +00:00
|
|
|
if [[ -d $DEPS_DIR ]]; then
|
|
|
|
echo "Cleaning up dependency build dir: $DEPS_DIR"
|
|
|
|
rm -rf $DEPS_DIR
|
|
|
|
fi
|
|
|
|
|
2019-10-03 08:33:31 +00:00
|
|
|
mkdir -p $DEPS_DIR
|
|
|
|
mkdir -p $depsToolsetDir
|
|
|
|
mkdir -p $depsSrcDir
|
|
|
|
|
2020-03-27 02:43:22 +00:00
|
|
|
case "$OS" in
|
|
|
|
ubuntu)
|
|
|
|
sudo apt-get update
|
|
|
|
sudo apt-get -y install mingw-w64 cmake pkg-config python3-dev python3-pip \
|
2020-08-07 12:11:02 +00:00
|
|
|
autoconf libtool ninja-build zip
|
2020-03-27 02:43:22 +00:00
|
|
|
sudo python3 -m pip install cython
|
|
|
|
;;
|
|
|
|
suse)
|
|
|
|
for PKG in mingw64-cross-gcc-c++ mingw64-libgcc_s_seh1 mingw64-libstdc++6 \
|
|
|
|
cmake pkgconf python3-devel autoconf libtool ninja zip \
|
|
|
|
python3-Cython gcc patch wget git; do
|
|
|
|
rpm -q $PKG >/dev/null || zypper -n install $PKG
|
|
|
|
done
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
MINGW_CMAKE_FILE="$DEPS_DIR/mingw.cmake"
|
|
|
|
source "$SCRIPT_DIR/mingw_conf.sh"
|
2019-10-03 08:33:31 +00:00
|
|
|
|
|
|
|
cd $depsSrcDir
|
2020-03-24 02:16:28 +00:00
|
|
|
if [[ ! -d $zlibSrcDir ]]; then
|
2019-10-03 08:33:31 +00:00
|
|
|
git clone https://github.com/madler/zlib
|
|
|
|
fi
|
2020-03-24 02:16:28 +00:00
|
|
|
cd $zlibSrcDir
|
2019-10-03 08:33:31 +00:00
|
|
|
# Apparently the configure script is broken...
|
2020-03-27 02:43:22 +00:00
|
|
|
sed -e s/"PREFIX = *$"/"PREFIX = ${MINGW_PREFIX}"/ -i win32/Makefile.gcc
|
2019-10-03 08:33:31 +00:00
|
|
|
_make -f win32/Makefile.gcc
|
|
|
|
_make BINARY_PATH=$zlibDir \
|
|
|
|
INCLUDE_PATH=$zlibDir/include \
|
|
|
|
LIBRARY_PATH=$zlibDir/lib \
|
|
|
|
SHARED_MODE=1 \
|
|
|
|
-f win32/Makefile.gcc install
|
|
|
|
|
|
|
|
cd $depsToolsetDir
|
|
|
|
if [[ ! -d $lz4Dir ]]; then
|
|
|
|
git clone https://github.com/lz4/lz4
|
2020-03-24 02:16:28 +00:00
|
|
|
cd $lz4Dir; git checkout $lz4Tag
|
2019-10-03 08:33:31 +00:00
|
|
|
fi
|
2020-03-24 02:16:28 +00:00
|
|
|
cd $lz4Dir
|
2020-03-27 02:43:22 +00:00
|
|
|
_make BUILD_STATIC=no CC=${MINGW_CC%-posix*} \
|
|
|
|
DLLTOOL=${MINGW_DLLTOOL} \
|
|
|
|
WINDRES=${MINGW_WINDRES} \
|
2020-03-23 13:34:37 +00:00
|
|
|
TARGET_OS=Windows_NT
|
2019-10-03 08:33:31 +00:00
|
|
|
|
|
|
|
cd $depsSrcDir
|
|
|
|
if [[ ! -d $sslSrcDir ]]; then
|
2020-04-02 07:40:38 +00:00
|
|
|
git clone https://github.com/openssl/openssl
|
|
|
|
cd $sslSrcDir; git checkout $sslTag
|
2019-10-03 08:33:31 +00:00
|
|
|
fi
|
|
|
|
cd $sslSrcDir
|
|
|
|
mkdir -p $sslDir
|
2020-03-27 02:43:22 +00:00
|
|
|
CROSS_COMPILE="${MINGW_PREFIX}" ./Configure \
|
2019-10-03 08:33:31 +00:00
|
|
|
mingw64 shared --prefix=$sslDir
|
|
|
|
_make depend
|
|
|
|
_make
|
|
|
|
_make install
|
|
|
|
|
|
|
|
cd $depsSrcDir
|
|
|
|
if [[ ! -d $curlSrcDir ]]; then
|
|
|
|
git clone https://github.com/curl/curl
|
2020-03-24 02:16:28 +00:00
|
|
|
cd $curlSrcDir && git checkout $curlTag
|
2019-10-03 08:33:31 +00:00
|
|
|
fi
|
|
|
|
cd $curlSrcDir
|
|
|
|
./buildconf
|
|
|
|
./configure --prefix=$curlDir --with-ssl=$sslDir --with-zlib=$zlibDir \
|
2020-03-27 02:43:22 +00:00
|
|
|
--host=${MINGW_BASE}
|
2019-10-03 08:33:31 +00:00
|
|
|
_make
|
|
|
|
_make install
|
|
|
|
|
|
|
|
|
|
|
|
cd $depsSrcDir
|
|
|
|
if [[ ! -d $boostSrcDir ]]; then
|
|
|
|
wget -qO- $boostUrl | tar xz
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd $boostSrcDir
|
2020-03-27 02:43:22 +00:00
|
|
|
echo "using gcc : mingw32 : ${MINGW_CXX} ;" > user-config.jam
|
2019-10-03 08:33:31 +00:00
|
|
|
|
|
|
|
# Workaround for https://github.com/boostorg/thread/issues/156
|
|
|
|
# Older versions of mingw provided a different pthread lib.
|
|
|
|
sed -i 's/lib$(libname)GC2.a/lib$(libname).a/g' ./libs/thread/build/Jamfile.v2
|
|
|
|
sed -i 's/mthreads/pthreads/g' ./tools/build/src/tools/gcc.py
|
|
|
|
sed -i 's/mthreads/pthreads/g' ./tools/build/src/tools/gcc.jam
|
|
|
|
|
|
|
|
sed -i 's/pthreads/mthreads/g' ./tools/build/src/tools/gcc.py
|
|
|
|
sed -i 's/pthreads/mthreads/g' ./tools/build/src/tools/gcc.jam
|
|
|
|
|
2020-03-27 02:43:22 +00:00
|
|
|
export PTW32_INCLUDE=${PTW32Include}
|
|
|
|
export PTW32_LIB=${PTW32Lib}
|
2019-10-03 08:33:31 +00:00
|
|
|
|
|
|
|
# Fix getting Windows page size
|
|
|
|
# TODO: send this upstream and maybe use a fork until it merges.
|
|
|
|
# Meanwhile, we might consider moving those to ceph/cmake/modules/BuildBoost.cmake.
|
|
|
|
# This cmake module will first have to be updated to support Mingw though.
|
2020-03-06 11:05:18 +00:00
|
|
|
patch -N boost/thread/pthread/thread_data.hpp <<EOL
|
2019-10-03 08:33:31 +00:00
|
|
|
--- boost/thread/pthread/thread_data.hpp 2019-10-11 15:26:15.678703586 +0300
|
|
|
|
+++ boost/thread/pthread/thread_data.hpp.new 2019-10-11 15:26:07.321463698 +0300
|
|
|
|
@@ -32,6 +32,10 @@
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
+#if defined(_WIN32)
|
|
|
|
+#include <windows.h>
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
@@ -54,6 +58,10 @@
|
|
|
|
if (size==0) return;
|
|
|
|
#ifdef BOOST_THREAD_USES_GETPAGESIZE
|
|
|
|
std::size_t page_size = getpagesize();
|
|
|
|
+#elif _WIN32
|
|
|
|
+ SYSTEM_INFO system_info;
|
|
|
|
+ ::GetSystemInfo (&system_info);
|
|
|
|
+ std::size_t page_size = system_info.dwPageSize;
|
|
|
|
#else
|
|
|
|
std::size_t page_size = ::sysconf( _SC_PAGESIZE);
|
|
|
|
#endif
|
|
|
|
EOL
|
|
|
|
|
|
|
|
# Use pthread if requested
|
2020-03-06 11:05:18 +00:00
|
|
|
patch -N boost/asio/detail/thread.hpp <<EOL
|
2019-10-03 08:33:31 +00:00
|
|
|
--- boost/asio/detail/thread.hpp 2019-10-11 16:26:11.191094656 +0300
|
|
|
|
+++ boost/asio/detail/thread.hpp.new 2019-10-11 16:26:03.310542438 +0300
|
|
|
|
@@ -19,6 +19,8 @@
|
|
|
|
|
|
|
|
#if !defined(BOOST_ASIO_HAS_THREADS)
|
|
|
|
# include <boost/asio/detail/null_thread.hpp>
|
|
|
|
+#elif defined(BOOST_ASIO_HAS_PTHREADS)
|
|
|
|
+# include <boost/asio/detail/posix_thread.hpp>
|
|
|
|
#elif defined(BOOST_ASIO_WINDOWS)
|
|
|
|
# if defined(UNDER_CE)
|
|
|
|
# include <boost/asio/detail/wince_thread.hpp>
|
|
|
|
@@ -27,8 +29,6 @@
|
|
|
|
# else
|
|
|
|
# include <boost/asio/detail/win_thread.hpp>
|
|
|
|
# endif
|
|
|
|
-#elif defined(BOOST_ASIO_HAS_PTHREADS)
|
|
|
|
-# include <boost/asio/detail/posix_thread.hpp>
|
|
|
|
#elif defined(BOOST_ASIO_HAS_STD_THREAD)
|
|
|
|
# include <boost/asio/detail/std_thread.hpp>
|
|
|
|
#else
|
|
|
|
@@ -41,6 +41,8 @@
|
|
|
|
|
|
|
|
#if !defined(BOOST_ASIO_HAS_THREADS)
|
|
|
|
typedef null_thread thread;
|
|
|
|
+#elif defined(BOOST_ASIO_HAS_PTHREADS)
|
|
|
|
+typedef posix_thread thread;
|
|
|
|
#elif defined(BOOST_ASIO_WINDOWS)
|
|
|
|
# if defined(UNDER_CE)
|
|
|
|
typedef wince_thread thread;
|
|
|
|
@@ -49,8 +51,6 @@
|
|
|
|
# else
|
|
|
|
typedef win_thread thread;
|
|
|
|
# endif
|
|
|
|
-#elif defined(BOOST_ASIO_HAS_PTHREADS)
|
|
|
|
-typedef posix_thread thread;
|
|
|
|
#elif defined(BOOST_ASIO_HAS_STD_THREAD)
|
|
|
|
typedef std_thread thread;
|
|
|
|
#endif
|
|
|
|
EOL
|
|
|
|
|
|
|
|
# Unix socket support for Windows is currently disabled by Boost.
|
|
|
|
# https://github.com/huangqinjin/asio/commit/d27a8ad1870
|
2020-03-06 11:05:18 +00:00
|
|
|
patch -N boost/asio/detail/socket_types.hpp <<EOL
|
2019-10-03 08:33:31 +00:00
|
|
|
--- boost/asio/detail/socket_types.hpp 2019-11-29 16:50:58.647125797 +0000
|
|
|
|
+++ boost/asio/detail/socket_types.hpp.new 2020-01-13 11:45:05.015104678 +0000
|
|
|
|
@@ -200,6 +200,8 @@
|
|
|
|
typedef ipv6_mreq in6_mreq_type;
|
|
|
|
typedef sockaddr_in6 sockaddr_in6_type;
|
|
|
|
typedef sockaddr_storage sockaddr_storage_type;
|
|
|
|
+struct sockaddr_un_type { u_short sun_family;
|
|
|
|
+ char sun_path[108]; }; /* copy from afunix.h */
|
|
|
|
typedef addrinfo addrinfo_type;
|
|
|
|
# endif
|
|
|
|
typedef ::linger linger_type;
|
|
|
|
EOL
|
2020-03-06 11:05:18 +00:00
|
|
|
patch -N boost/asio/detail/config.hpp <<EOL
|
2019-10-03 08:33:31 +00:00
|
|
|
--- boost/asio/detail/config.hpp 2019-11-29 16:50:58.691126211 +0000
|
|
|
|
+++ boost/asio/detail/config.hpp.new 2020-01-13 13:09:17.966771750 +0000
|
|
|
|
@@ -1142,13 +1142,9 @@
|
|
|
|
// UNIX domain sockets.
|
|
|
|
#if !defined(BOOST_ASIO_HAS_LOCAL_SOCKETS)
|
|
|
|
# if !defined(BOOST_ASIO_DISABLE_LOCAL_SOCKETS)
|
|
|
|
-# if !defined(BOOST_ASIO_WINDOWS) \\
|
|
|
|
- && !defined(BOOST_ASIO_WINDOWS_RUNTIME) \\
|
|
|
|
- && !defined(__CYGWIN__)
|
|
|
|
+# if !defined(BOOST_ASIO_WINDOWS_RUNTIME)
|
|
|
|
# define BOOST_ASIO_HAS_LOCAL_SOCKETS 1
|
|
|
|
-# endif // !defined(BOOST_ASIO_WINDOWS)
|
|
|
|
- // && !defined(BOOST_ASIO_WINDOWS_RUNTIME)
|
|
|
|
- // && !defined(__CYGWIN__)
|
|
|
|
+# endif // !defined(BOOST_ASIO_WINDOWS_RUNTIME)
|
|
|
|
# endif // !defined(BOOST_ASIO_DISABLE_LOCAL_SOCKETS)
|
|
|
|
#endif // !defined(BOOST_ASIO_HAS_LOCAL_SOCKETS)
|
|
|
|
EOL
|
|
|
|
|
|
|
|
./bootstrap.sh
|
|
|
|
|
|
|
|
./b2 install --user-config=user-config.jam toolset=gcc-mingw32 \
|
|
|
|
target-os=windows release \
|
|
|
|
threadapi=pthread --prefix=$boostDir \
|
|
|
|
address-model=64 architecture=x86 \
|
|
|
|
binary-format=pe abi=ms -j $NUM_WORKERS \
|
|
|
|
-sZLIB_INCLUDE=$zlibDir/include -sZLIB_LIBRARY_PATH=$zlibDir/lib \
|
|
|
|
--without-python --without-mpi
|
|
|
|
|
|
|
|
cd $depsSrcDir
|
|
|
|
if [[ ! -d $backtraceSrcDir ]]; then
|
|
|
|
git clone https://github.com/ianlancetaylor/libbacktrace
|
|
|
|
fi
|
2020-03-24 02:16:28 +00:00
|
|
|
mkdir -p $backtraceSrcDir/build
|
|
|
|
cd $backtraceSrcDir/build
|
2019-10-03 08:33:31 +00:00
|
|
|
../configure --prefix=$backtraceDir --exec-prefix=$backtraceDir \
|
2020-03-27 02:43:22 +00:00
|
|
|
--host ${MINGW_BASE} --enable-host-shared
|
2019-10-03 08:33:31 +00:00
|
|
|
_make LDFLAGS="-no-undefined"
|
|
|
|
_make install
|
|
|
|
cp $backtraceDir/lib/libbacktrace.a $backtraceDir/lib/libbacktrace.dll.a
|
|
|
|
|
|
|
|
cd $depsSrcDir
|
|
|
|
if [[ ! -d $snappySrcDir ]]; then
|
|
|
|
git clone https://github.com/google/snappy
|
2020-03-24 02:16:28 +00:00
|
|
|
cd $snappySrcDir && git checkout $snappyTag
|
2019-10-03 08:33:31 +00:00
|
|
|
fi
|
2020-03-24 02:16:28 +00:00
|
|
|
mkdir -p $snappySrcDir/build
|
|
|
|
cd $snappySrcDir/build
|
2019-10-03 08:33:31 +00:00
|
|
|
|
|
|
|
cmake -DCMAKE_INSTALL_PREFIX=$snappyDir \
|
|
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
|
|
-DBUILD_SHARED_LIBS=ON \
|
|
|
|
-DSNAPPY_BUILD_TESTS=OFF \
|
|
|
|
-DCMAKE_TOOLCHAIN_FILE=$MINGW_CMAKE_FILE \
|
|
|
|
../
|
|
|
|
_make
|
|
|
|
_make install
|
|
|
|
|
|
|
|
cmake -DCMAKE_INSTALL_PREFIX=$snappyDir \
|
|
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
|
|
-DBUILD_SHARED_LIBS=OFF \
|
|
|
|
-DSNAPPY_BUILD_TESTS=OFF \
|
|
|
|
-DCMAKE_TOOLCHAIN_FILE=$MINGW_CMAKE_FILE \
|
|
|
|
../
|
|
|
|
_make
|
|
|
|
_make install
|
|
|
|
|
|
|
|
# mswsock.lib is not provided by mingw, so we'll have to generate
|
|
|
|
# it.
|
|
|
|
mkdir -p $winLibDir
|
|
|
|
cat > $winLibDir/mswsock.def <<EOF
|
|
|
|
LIBRARY MSWSOCK.DLL
|
|
|
|
EXPORTS
|
|
|
|
AcceptEx@32
|
|
|
|
EnumProtocolsA@12
|
|
|
|
EnumProtocolsW@12
|
|
|
|
GetAcceptExSockaddrs@32
|
|
|
|
GetAddressByNameA@40
|
|
|
|
GetAddressByNameW@40
|
|
|
|
GetNameByTypeA@12
|
|
|
|
GetNameByTypeW@12
|
|
|
|
GetServiceA@28
|
|
|
|
GetServiceW@28
|
|
|
|
GetTypeByNameA@8
|
|
|
|
GetTypeByNameW@8
|
|
|
|
MigrateWinsockConfiguration@12
|
|
|
|
NPLoadNameSpaces@12
|
|
|
|
SetServiceA@24
|
|
|
|
SetServiceW@24
|
|
|
|
TransmitFile@28
|
|
|
|
WSARecvEx@16
|
|
|
|
dn_expand@20
|
|
|
|
getnetbyname@4
|
|
|
|
inet_network@4
|
|
|
|
rcmd@24
|
|
|
|
rexec@24rresvport@4
|
|
|
|
s_perror@8sethostname@8
|
|
|
|
EOF
|
|
|
|
|
2020-03-27 02:43:22 +00:00
|
|
|
$MINGW_DLLTOOL -d $winLibDir/mswsock.def \
|
|
|
|
-l $winLibDir/libmswsock.a
|
2020-03-24 03:13:36 +00:00
|
|
|
|
|
|
|
touch $depsToolsetDir/completed
|