Merge pull request #329691 from jnsgruk/multipass-1.14.0

This commit is contained in:
Jon Seager 2024-07-24 22:27:08 +01:00 committed by GitHub
commit 786858a02e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 163 additions and 59 deletions

View File

@ -1,22 +1,3 @@
diff --git a/3rd-party/CMakeLists.txt b/3rd-party/CMakeLists.txt
index 188ebfc6..4a34a922 100644
--- a/3rd-party/CMakeLists.txt
+++ b/3rd-party/CMakeLists.txt
@@ -2,12 +2,8 @@ include(FetchContent)
set(FETCHCONTENT_QUIET FALSE)
FetchContent_Declare(gRPC
- GIT_REPOSITORY https://github.com/CanonicalLtd/grpc.git
- GIT_TAG e3acf245
- GIT_SHALLOW TRUE
- GIT_SUBMODULES "third_party/abseil-cpp third_party/cares/cares third_party/protobuf third_party/re2 third_party/zlib"
- GIT_SUBMODULES_RECURSE false
- GIT_PROGRESS TRUE
+ DOWNLOAD_COMMAND true
+ SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/grpc
)
set(gRPC_SSL_PROVIDER "package" CACHE STRING "Provider of ssl library")
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 52bd407f..a1100112 100644
--- a/tests/CMakeLists.txt

View File

@ -1,31 +1,34 @@
{ cmake
, dnsmasq
, fetchFromGitHub
, git
, gtest
, iproute2
, iptables
, lib
, libapparmor
, libvirt
, libxml2
, nixosTests
, openssl
, OVMF
, pkg-config
, qemu
, qemu-utils
, qtbase
, qtwayland
, wrapQtAppsHook
, slang
, stdenv
, xterm
{
cmake,
dnsmasq,
fetchFromGitHub,
git,
gtest,
iproute2,
iptables,
lib,
libapparmor,
libvirt,
libxml2,
nixosTests,
openssl,
OVMF,
pkg-config,
qemu,
poco,
protobuf,
qemu-utils,
qtbase,
qtwayland,
wrapQtAppsHook,
slang,
stdenv,
xterm,
}:
let
pname = "multipass";
version = "1.13.1";
version = "1.14.0";
# This is done here because a CMakeLists.txt from one of it's submodules tries
# to modify a file, so we grab the source for the submodule here, copy it into
@ -38,15 +41,14 @@ let
fetchSubmodules = true;
};
in
stdenv.mkDerivation
{
stdenv.mkDerivation {
inherit pname version;
src = fetchFromGitHub {
owner = "canonical";
repo = "multipass";
rev = "refs/tags/v${version}";
hash = "sha256-QttgWSuhxcuOyMNF9Ve1w0ftT41+hNz3WW5Vag/88X4=";
hash = "sha256-1g5Og4LkNujjT4KCXHmXaiTK58Bgb2KyYLKwTFFVEHE=";
fetchSubmodules = true;
leaveDotGit = true;
postFetch = ''
@ -57,21 +59,40 @@ stdenv.mkDerivation
};
patches = [
# Multipass is usually only delivered as a snap package on Linux, and it expects that
# the LXD backend will also be delivered via a snap - in which cases the LXD socket
# is available at '/var/snap/lxd/...'. Here we patch to ensure that Multipass uses the
# LXD socket location on NixOS in '/var/lib/...'
./lxd_socket_path.patch
# The upstream cmake file attempts to fetch googletest using FetchContent, which fails
# in the Nix build environment. This patch disables the fetch in favour of providing
# the googletest library from nixpkgs.
./cmake_no_fetch.patch
# Ensures '-Wno-ignored-attributes' is supported by the compiler before attempting to build.
./cmake_warning.patch
# As of Multipass 1.14.0, the upstream started using vcpkg for grabbing C++ dependencies,
# which doesn't work in the nix build environment. This patch reverts that change, in favour
# of providing those dependencies manually in this derivation.
./vcpkg_no_install.patch
# The compiler flags used in nixpkgs surface an error in the test suite where an
# unreachable path was not annotated as such - this patch adds the annotation to ensure
# that the test suite passes in the nix build process.
./test_unreachable_call.patch
];
postPatch = ''
# Make sure the version is reported correctly in the compiled binary.
substituteInPlace ./CMakeLists.txt \
--replace "determine_version(MULTIPASS_VERSION)" "" \
--replace 'set(MULTIPASS_VERSION ''${MULTIPASS_VERSION})' 'set(MULTIPASS_VERSION "v${version}")'
--replace-fail "determine_version(MULTIPASS_VERSION)" "" \
--replace-fail 'set(MULTIPASS_VERSION ''${MULTIPASS_VERSION})' 'set(MULTIPASS_VERSION "v${version}")'
# Don't build/use vcpkg
rm -rf 3rd-party/vcpkg
# Patch the patch of the OVMF binaries to use paths from the nix store.
substituteInPlace ./src/platform/backends/qemu/linux/qemu_platform_detail_linux.cpp \
--replace "OVMF.fd" "${OVMF.fd}/FV/OVMF.fd" \
--replace "QEMU_EFI.fd" "${OVMF.fd}/FV/QEMU_EFI.fd"
--replace-fail "OVMF.fd" "${OVMF.fd}/FV/OVMF.fd" \
--replace-fail "QEMU_EFI.fd" "${OVMF.fd}/FV/QEMU_EFI.fd"
# Copy the grpc submodule we fetched into the source code.
cp -r --no-preserve=mode ${grpc_src} 3rd-party/grpc
@ -97,6 +118,9 @@ stdenv.mkDerivation
EOF
'';
# We'll build the flutter application seperately using buildFlutterApplication
cmakeFlags = [ "-DMULTIPASS_ENABLE_FLUTTER_GUI=false" ];
buildInputs = [
gtest
libapparmor
@ -105,6 +129,8 @@ stdenv.mkDerivation
openssl
qtbase
qtwayland
poco.dev
protobuf
];
nativeBuildInputs = [
@ -118,15 +144,17 @@ stdenv.mkDerivation
nativeCheckInputs = [ gtest ];
postInstall = ''
wrapProgram $out/bin/multipassd --prefix PATH : ${lib.makeBinPath [
dnsmasq
iproute2
iptables
OVMF.fd
qemu
qemu-utils
xterm
]}
wrapProgram $out/bin/multipassd --prefix PATH : ${
lib.makeBinPath [
dnsmasq
iproute2
iptables
OVMF.fd
qemu
qemu-utils
xterm
]
}
'';
passthru.tests = {

View File

@ -0,0 +1,12 @@
diff --git a/tests/test_common_callbacks.cpp b/tests/test_common_callbacks.cpp
index ccae78e0..f9ab4423 100644
--- a/tests/test_common_callbacks.cpp
+++ b/tests/test_common_callbacks.cpp
@@ -73,6 +73,7 @@ struct TestLoggingSpinnerCallbacks : public TestSpinnerCallbacks, public WithPar
default:
assert(false && "shouldn't be here");
}
+ __builtin_unreachable();
}
};

View File

@ -0,0 +1,83 @@
diff --git a/3rd-party/CMakeLists.txt b/3rd-party/CMakeLists.txt
index 73291f6c..c1a38198 100644
--- a/3rd-party/CMakeLists.txt
+++ b/3rd-party/CMakeLists.txt
@@ -4,6 +4,24 @@ if (MSVC)
add_compile_options(-wd5045) #Disable warning about Spectre mitigation
endif()
+include(FetchContent)
+set(FETCHCONTENT_QUIET FALSE)
+
+FetchContent_Declare(gRPC
+ DOWNLOAD_COMMAND true
+ SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/grpc
+)
+
+set(gRPC_SSL_PROVIDER "package" CACHE STRING "Provider of ssl library")
+
+FetchContent_MakeAvailable(gRPC)
+
+# Workaround for zlib placing its generated zconf.h file in the build dir,
+# and protobuf not knowing so finding the system version instead
+include_directories(${grpc_SOURCE_DIR}/third_party/zlib)
+
+set_property(DIRECTORY ${grpc_SOURCE_DIR} PROPERTY EXCLUDE_FROM_ALL YES)
+
# Generates gRPC and protobuf C++ sources and headers from the given .proto files
#
# generate_grpc_cpp (<SRCS> <DEST> [<ARGN>...])
@@ -34,9 +52,9 @@ function(generate_grpc_cpp SRCS DEST)
"${DEST}/${FIL_WE}.grpc.pb.h"
"${DEST}/${FIL_WE}.pb.cc"
"${DEST}/${FIL_WE}.pb.h"
- COMMAND $<TARGET_FILE:protobuf::protoc>
- ARGS --grpc_out=${DEST} --cpp_out=${DEST} --proto_path=${FIL_DIR} --proto_path=${grpc_SOURCE_DIR}/third_party/protobuf/src --plugin=protoc-gen-grpc=$<TARGET_FILE:gRPC::grpc_cpp_plugin> ${ABS_FIL}
- DEPENDS ${ABS_FIL}
+ COMMAND $<TARGET_FILE:protoc>
+ ARGS --grpc_out=${DEST} --cpp_out=${DEST} --proto_path=${FIL_DIR} --proto_path=${grpc_SOURCE_DIR}/third_party/protobuf/src --plugin=protoc-gen-grpc=$<TARGET_FILE:grpc_cpp_plugin> ${ABS_FIL}
+ DEPENDS ${ABS_FIL} protoc grpc_cpp_plugin
COMMENT "Running gRPC C++ protocol buffer compiler on ${FIL}"
VERBATIM)
endforeach ()
@@ -47,9 +65,14 @@ endfunction()
add_library(gRPC INTERFACE)
+target_include_directories(gRPC INTERFACE
+ ${CMAKE_CURRENT_SOURCE_DIR}/grpc/include
+ ${CMAKE_CURRENT_SOURCE_DIR}/grpc/third_party/protobuf/src)
+
target_link_libraries(gRPC INTERFACE
- gRPC::grpc++
- protobuf::libprotobuf)
+ grpc++
+ libprotobuf
+ zlibstatic)
if (NOT MSVC)
target_compile_options(gRPC INTERFACE "-Wno-unused-parameter" "-Wno-non-virtual-dtor" "-Wno-pedantic")
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 18e47b74..d5bf5dea 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -49,9 +49,6 @@ if(NOT DEFINED VCPKG_BUILD_DEFAULT)
set(VCPKG_TARGET_TRIPLET "${VCPKG_HOST_ARCH}-${VCPKG_HOST_OS}-release")
endif()
-set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/3rd-party/vcpkg/scripts/buildsystems/vcpkg.cmake"
- CACHE STRING "Vcpkg toolchain file")
-
project(Multipass)
option(MULTIPASS_ENABLE_TESTS "Build tests" ON)
@@ -125,9 +122,6 @@ endif()
# OpenSSL config
find_package(OpenSSL REQUIRED)
-# gRPC config
-find_package(gRPC CONFIG REQUIRED)
-
# Needs to be here before we set further compilation options
add_subdirectory(3rd-party)