Unverified Commit bbc8d948 authored by Naxdy's avatar Naxdy
Browse files

linphonePackages: remove

Linphone is a SIP softphone application, which depends on many bespoke
and custom-patched libraries, collectively referred to as
`linphonePackages` in this commit.

The build process has been failing for a while on both stable and
unstable, but due to the way the packages are organized in nixpkgs,
updating them is quite cumbersome.

Therefore, in an effort to ensure future maintainability, we first
remove all existing packages from nixpkgs, to then be able to later add
them again within their own scope.
parent d8e887f7
Loading
Loading
Loading
Loading
+0 −144
Original line number Diff line number Diff line
{
  bctoolbox,
  belcard,
  belle-sip,
  belr,
  cmake,
  fetchFromGitLab,
  lib,
  liblinphone,
  mediastreamer,
  mediastreamer-openh264,
  minizip-ng,
  mkDerivation,
  qtgraphicaleffects,
  qtmultimedia,
  qtquickcontrols2,
  qttools,
}:

# How to update Linphone? (The Qt desktop app)
#
# Belledonne Communications (BC), the company making Linphone, has split the
# project into several sub-projects that they maintain, plus some third-party
# dependencies that they also extend with commits of their own, specific to
# Linphone and not (yet?) upstreamed.
#
# All of this is organised in a Software Development Kit (SDK) meta-repository
# with git submodules to pin all those repositories into a coherent whole.
#
# The Linphone Qt desktop app uses this SDK as submodule as well.
#
# So, in order to update the desktop app to a new release, one has to follow
# the submodule chain and update the corresponding derivations here, in nixpkgs,
# with the corresponding version number (or commit hash)

mkDerivation rec {
  pname = "linphone-desktop";
  version = "5.1.2";

  src = fetchFromGitLab {
    domain = "gitlab.linphone.org";
    owner = "public";
    group = "BC";
    repo = "linphone-desktop";
    rev = version;
    hash = "sha256-Pu2tGKe3C1uR4lzXkC5sJFu8iJBqF76UfWJXYjPwBkc=";
  };

  patches = [
    ./do-not-build-linphone-sdk.patch
    ./remove-bc_compute_full_version-usage.patch
    ./no-store-path-in-autostart.patch
    ./reset-output-dirs.patch
  ];

  # See: https://gitlab.linphone.org/BC/public/linphone-desktop/issues/21
  postPatch = ''
    echo "project(linphoneqt VERSION ${version})" >linphone-app/linphoneqt_version.cmake
    substituteInPlace linphone-app/src/app/AppController.cpp \
      --replace "APPLICATION_SEMVER" "\"${version}\""
    substituteInPlace CMakeLists.txt \
      --subst-var out
  '';

  # TODO: After linphone-desktop and liblinphone split into separate packages,
  # there might be some build inputs here that aren't needed for
  # linphone-desktop.
  buildInputs = [
    # Made by BC
    bctoolbox
    belcard
    belle-sip
    belr
    liblinphone
    mediastreamer
    mediastreamer-openh264

    minizip-ng
    qtgraphicaleffects
    qtmultimedia
    qtquickcontrols2
  ];

  nativeBuildInputs = [
    cmake
    qttools
  ];

  cmakeFlags = [
    "-DMINIZIP_INCLUDE_DIRS=${minizip-ng}/include"
    "-DMINIZIP_LIBRARIES=minizip"

    # RPATH of binary /nix/store/.../bin/... contains a forbidden reference to /build/
    "-DCMAKE_SKIP_BUILD_RPATH=ON"

    # Requires EQt5Keychain
    "-DENABLE_QT_KEYCHAIN=OFF"

    "-DCMAKE_INSTALL_BINDIR=bin"
    "-DCMAKE_INSTALL_INCLUDEDIR=include"
    "-DCMAKE_INSTALL_LIBDIR=lib"
  ];

  preInstall = ''
    mkdir -p $out/share/linphone
    mkdir -p $out/share/sounds/linphone
  '';

  # In order to find mediastreamer plugins, mediastreamer package was patched to
  # support an environment variable pointing to the plugin directory. Set that
  # environment variable by wrapping the Linphone executable.
  #
  # Also, some grammar files needed to be copied too from some dependencies. I
  # suppose if one define a dependency in such a way that its share directory is
  # found, then this copying would be unnecessary. These missing grammar files
  # were discovered when linphone crashed at startup and it was run with
  # --verbose flag. Instead of actually copying these files, create symlinks.
  #
  # It is quite likely that there are some other files still missing and
  # Linphone will randomly crash when it tries to access those files. Then,
  # those just need to be copied manually below.
  postInstall = ''
    mkdir -p $out/lib/mediastreamer/plugins
    ln -s ${mediastreamer-openh264}/lib/mediastreamer/plugins/* $out/lib/mediastreamer/plugins/
    ln -s ${mediastreamer}/lib/mediastreamer/plugins/* $out/lib/mediastreamer/plugins/

    mkdir -p $out/share/belr/grammars
    ln -s ${liblinphone}/share/belr/grammars/* $out/share/belr/grammars/
    ln -s ${liblinphone}/share/sounds/linphone/* $out/share/sounds/linphone/
    ln -s ${belle-sip}/share/belr/grammars/* $out/share/belr/grammars/

    wrapProgram $out/bin/linphone \
      --set MEDIASTREAMER_PLUGINS_DIR $out/lib/mediastreamer/plugins
  '';

  meta = with lib; {
    homepage = "https://www.linphone.org/";
    description = "Open source SIP phone for voice/video calls and instant messaging";
    mainProgram = "linphone";
    license = licenses.gpl3Plus;
    platforms = platforms.linux;
    maintainers = with maintainers; [ jluttine ];
  };
}
+0 −157
Original line number Diff line number Diff line
From e6a9992461f368d08d1ad63ffe454714ec0c59ce Mon Sep 17 00:00:00 2001
From: Lorenz Brun <lorenz@brun.one>
Date: Fri, 28 Jan 2022 02:36:01 +0100
Subject: [PATCH] Remove Linphone SDK build

---
 CMakeLists.txt                                | 100 +-----------------
 .../cmake_builder/additional_steps.cmake      |   9 --
 2 files changed, 5 insertions(+), 104 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b5a4ab5..3afcd88 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -194,7 +194,6 @@ list(APPEND APP_OPTIONS "-DQTKEYCHAIN_TARGET_NAME=${QTKEYCHAIN_TARGET_NAME}")
 
 list(APPEND APP_OPTIONS "-DENABLE_QT_GL=${ENABLE_VIDEO}")#Activate on video
 
-include(ExternalProject)
 set(PROJECT_BUILD_COMMAND "")
 if(CMAKE_BUILD_PARALLEL_LEVEL)
 	list(APPEND APP_OPTIONS "-DCMAKE_BUILD_PARALLEL_LEVEL=${CMAKE_BUILD_PARALLEL_LEVEL}")
@@ -237,41 +236,8 @@ if(ENABLE_BUILD_APP_PLUGINS)
 	endif()
 endif()
 
-if(NOT LINPHONE_QT_ONLY)
-#add_subdirectory(external/qtkeychain)
-	if(ENABLE_QT_KEYCHAIN)
-		ExternalProject_Add(app-qtkeychain PREFIX "${CMAKE_BINARY_DIR}/qtkeychain"
-			SOURCE_DIR "${CMAKE_SOURCE_DIR}/external/qtkeychain"
-			INSTALL_DIR "${QTKEYCHAIN_OUTPUT_DIR}"
-			BINARY_DIR "${SDK_BUILD_DIR}/qtkeychain"
-			BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --config $<CONFIG> ${PROJECT_BUILD_COMMAND}
-			LIST_SEPARATOR | # Use the alternate list separator
-			CMAKE_ARGS ${APP_OPTIONS} ${QTKEYCHAIN_OPTIONS} ${USER_ARGS} -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -DCMAKE_PREFIX_PATH=${PREFIX_PATH} -DCMAKE_OSX_ARCHITECTURES=${LINPHONESDK_MACOS_ARCHS}
-			BUILD_ALWAYS NO #${DO_BUILD}
-		)
-	endif()
-	ExternalProject_Add(sdk PREFIX "${CMAKE_BINARY_DIR}/sdk"
-		SOURCE_DIR "${CMAKE_SOURCE_DIR}/linphone-sdk"
-		INSTALL_DIR "${LINPHONE_OUTPUT_DIR}"
-		STAMP_DIR "${SDK_BUILD_DIR}/stamp"
-		BINARY_DIR "${SDK_BUILD_DIR}"
-		STEP_TARGETS build
-		BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --config $<CONFIG> ${PROJECT_BUILD_COMMAND}
-		INSTALL_COMMAND ${CMAKE_COMMAND} -E echo "Install step is already done at build time."
-		LIST_SEPARATOR | # Use the alternate list separator
-		CMAKE_ARGS ${APP_OPTIONS} ${USER_ARGS} -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -DCMAKE_PREFIX_PATH=${PREFIX_PATH} -DCMAKE_OSX_ARCHITECTURES=${LINPHONESDK_MACOS_ARCHS}
-		BUILD_ALWAYS NO #${DO_BUILD}
-	)
-	ExternalProject_Add_Step(sdk force_build
-		COMMENT "Forcing build for 'sdk'"
-		DEPENDEES configure
-		DEPENDERS build
-		ALWAYS 1
-	)
-endif()
 include(FindPkgConfig)
 
-set(APP_DEPENDS sdk)# Used if NOT LINPHONE_QT_ONLY
 if(ENABLE_QT_KEYCHAIN)
 	list(APPEND APP_DEPENDS app-qtkeychain)
 endif()
@@ -289,65 +255,9 @@ find_package(Mediastreamer2 CONFIG QUIET)
 find_package(ortp CONFIG QUIET)
 find_package(${QTKEYCHAIN_TARGET_NAME} CONFIG QUIET)
 
-if(NOT (LinphoneCxx_FOUND) OR NOT (Linphone_FOUND) OR NOT (bctoolbox_FOUND) OR NOT (belcard_FOUND) OR NOT (Mediastreamer2_FOUND) OR NOT (ortp_FOUND)
-	OR ( ENABLE_QT_KEYCHAIN AND NOT(${QTKEYCHAIN_TARGET_NAME}_FOUND) )
-	OR FORCE_APP_EXTERNAL_PROJECTS
-)
-	message("Projects are set as External projects. You can start building them by using for example : cmake --build . --target install")
-	ExternalProject_Add(linphone-qt PREFIX "${CMAKE_BINARY_DIR}/linphone-app"
-		SOURCE_DIR "${CMAKE_SOURCE_DIR}/linphone-app"
-		INSTALL_DIR "${APPLICATION_OUTPUT_DIR}"
-		BINARY_DIR "${CMAKE_BINARY_DIR}/linphone-app"
-		DEPENDS ${APP_DEPENDS}
-		BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --config $<CONFIG> ${PROJECT_BUILD_COMMAND}
-		INSTALL_COMMAND ${CMAKE_COMMAND} -E echo "Install step is already done at build time."
-		LIST_SEPARATOR | # Use the alternate list separator
-		CMAKE_ARGS ${APP_OPTIONS} ${USER_ARGS} -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -DCMAKE_PREFIX_PATH=${PREFIX_PATH} -DCMAKE_OSX_ARCHITECTURES=${LINPHONESDK_MACOS_ARCHS}
-	# ${APP_OPTIONS}
-		BUILD_ALWAYS ON
-	)
-	if( ENABLE_BUILD_APP_PLUGINS)
-		ExternalProject_Add(app-plugins PREFIX "${CMAKE_BINARY_DIR}/plugins-app"
-			SOURCE_DIR "${CMAKE_SOURCE_DIR}/plugins"
-			INSTALL_DIR "${APPLICATION_OUTPUT_DIR}"
-			BINARY_DIR "${CMAKE_BINARY_DIR}/plugins-app"
-			DEPENDS linphone-qt
-			BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --config $<CONFIG> ${PROJECT_BUILD_COMMAND}
-			INSTALL_COMMAND ${CMAKE_COMMAND} -E echo "Install step is already done at build time."
-			LIST_SEPARATOR | # Use the alternate list separator
-			CMAKE_ARGS ${APP_OPTIONS} ${USER_ARGS} -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -DCMAKE_PREFIX_PATH=${PREFIX_PATH} -DCMAKE_OSX_ARCHITECTURES=${LINPHONESDK_MACOS_ARCHS}
-		)
-	endif()
-	install(CODE "message(STATUS \"Running install\")")
-	set(AUTO_REGENERATION auto_regeneration)
-	if(	ENABLE_BUILD_APP_PLUGINS)
-		add_custom_target(${AUTO_REGENERATION} ALL
-			COMMAND ${CMAKE_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}
-			DEPENDS app-plugins)
-	else()
-		add_custom_target(${AUTO_REGENERATION} ALL
-			COMMAND ${CMAKE_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}
-			DEPENDS linphone-qt)
-	endif()
-else()
-	message("Adding Linphone Desktop in an IDE-friendly state")
-	set(CMAKE_INSTALL_PREFIX "${APPLICATION_OUTPUT_DIR}")
-	add_subdirectory(${CMAKE_SOURCE_DIR}/linphone-app)
-	if(NOT LINPHONE_QT_ONLY)
-		add_dependencies(app-library ${APP_DEPENDS})
-	endif()
-	if( ENABLE_BUILD_APP_PLUGINS)
-		add_subdirectory(${CMAKE_SOURCE_DIR}/plugins "plugins-app")
-	endif()
+message("Adding Linphone Desktop in an IDE-friendly state")
+set(CMAKE_INSTALL_PREFIX "${APPLICATION_OUTPUT_DIR}")
+add_subdirectory(${CMAKE_SOURCE_DIR}/linphone-app)
+if( ENABLE_BUILD_APP_PLUGINS)
+	add_subdirectory(${CMAKE_SOURCE_DIR}/plugins "plugins-app")
 endif()
-ExternalProject_Add(linphone-qt-only PREFIX "${CMAKE_BINARY_DIR}/linphone-app"
-    SOURCE_DIR "${CMAKE_SOURCE_DIR}/linphone-app"
-    INSTALL_DIR "${APPLICATION_OUTPUT_DIR}"
-    BINARY_DIR "${CMAKE_BINARY_DIR}/linphone-app"
-    BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --config $<CONFIG> ${PROJECT_BUILD_COMMAND}
-#    INSTALL_COMMAND ${CMAKE_COMMAND} -E echo "Install step is already done at build time."
-    LIST_SEPARATOR | # Use the alternate list separator
-    CMAKE_ARGS ${APP_OPTIONS} ${USER_ARGS} -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -DCMAKE_PREFIX_PATH=${PREFIX_PATH} -DCMAKE_OSX_ARCHITECTURES=${LINPHONESDK_MACOS_ARCHS}
-    EXCLUDE_FROM_ALL ON
-    #BUILD_ALWAYS ON
-)
diff --git a/linphone-app/cmake_builder/additional_steps.cmake b/linphone-app/cmake_builder/additional_steps.cmake
index 7f7fd57..a69a04e 100644
--- a/linphone-app/cmake_builder/additional_steps.cmake
+++ b/linphone-app/cmake_builder/additional_steps.cmake
@@ -54,14 +54,5 @@ if (ENABLE_PACKAGING)
     linphone_builder_apply_flags()
     linphone_builder_set_ep_directories(linphone_package)
     linphone_builder_expand_external_project_vars()
-    ExternalProject_Add(TARGET_linphone_package
-      DEPENDS TARGET_linphone_builder
-      TMP_DIR ${ep_tmp}
-      BINARY_DIR ${ep_build}
-      SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/linphone_package"
-      DOWNLOAD_COMMAND ""
-      CMAKE_GENERATOR ${CMAKE_GENERATOR}
-      CMAKE_ARGS ${LINPHONE_BUILDER_EP_ARGS} -DCMAKE_INSTALL_PREFIX=${LINPHONE_BUILDER_WORK_DIR}/PACKAGE -DTOOLS_DIR=${CMAKE_BINARY_DIR}/programs -DLINPHONE_OUTPUT_DIR=${CMAKE_INSTALL_PREFIX} -DLINPHONE_DESKTOP_DIR=${CMAKE_CURRENT_LIST_DIR}/.. -DLINPHONE_SOURCE_DIR=${EP_linphone_SOURCE_DIR} ${ENABLE_VARIABLES} -DLINPHONE_BUILDER_SIGNING_IDENTITY=${LINPHONE_BUILDER_SIGNING_IDENTITY}
-    )
   endif ()
 endif ()
-- 
2.39.3 (Apple Git-145)
+0 −27
Original line number Diff line number Diff line
From 6a26922e5e4363de36057d635a1bf889160b2533 Mon Sep 17 00:00:00 2001
From: Lorenz Brun <lorenz@brun.one>
Date: Fri, 28 Jan 2022 18:44:43 +0100
Subject: [PATCH] Do not use store path for autostart on Nix

---
 linphone-app/src/app/App.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/linphone-app/src/app/App.cpp b/linphone-app/src/app/App.cpp
index 868f8f44..2c61c648 100644
--- a/linphone-app/src/app/App.cpp
+++ b/linphone-app/src/app/App.cpp
@@ -858,6 +858,10 @@ void App::setAutoStart (bool enabled) {
 		exec = QProcessEnvironment::systemEnvironment().value(QStringLiteral("APPIMAGE"));
 		qDebug() << "exec path autostart set appimage=" << exec;
 	}
+	else if (binPath.startsWith("/nix/store")) { // Nix/NixOS
+		exec = QStringLiteral("linphone");
+		qDebug() << "exec path autostart set nix=" << exec;
+	}
 	else { //classic package
 		exec = binPath;
 		qDebug() << "exec path autostart set classic package=" << exec;
-- 
2.25.1
+0 −74
Original line number Diff line number Diff line
From 4849d5633b98e6d3514355436eab5ba537cbfd99 Mon Sep 17 00:00:00 2001
From: David P <megver83@parabola.nu>
Date: Fri, 23 Oct 2020 16:44:17 -0300
Subject: [PATCH] remove bc_compute_full_version usage

---
 linphone-app/CMakeLists.txt                           | 11 +----------
 linphone-app/build/CMakeLists.txt                     |  5 -----
 .../cmake_builder/linphone_package/CMakeLists.txt     | 10 +---------
 3 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/linphone-app/CMakeLists.txt b/linphone-app/CMakeLists.txt
index de7f917f..ee14ff78 100644
--- a/linphone-app/CMakeLists.txt
+++ b/linphone-app/CMakeLists.txt
@@ -21,17 +21,8 @@
 ################################################################################
 cmake_minimum_required(VERSION 3.1)
 
+include(linphoneqt_version.cmake)
 find_package(bctoolbox CONFIG)
-set(FULL_VERSION )
-bc_compute_full_version(FULL_VERSION)
-set(version_major )
-set(version_minor )
-set(version_patch )
-set(identifiers )
-set(metadata )
-bc_parse_full_version("${FULL_VERSION}" version_major version_minor version_patch identifiers metadata)
-
-project(linphoneqt VERSION "${version_major}.${version_minor}.${version_patch}")
 
 
 if(ENABLE_BUILD_VERBOSE)
diff --git a/linphone-app/build/CMakeLists.txt b/linphone-app/build/CMakeLists.txt
index 8ef03faa..97d94bd6 100644
--- a/linphone-app/build/CMakeLists.txt
+++ b/linphone-app/build/CMakeLists.txt
@@ -46,11 +46,6 @@ set(CPACK_SOURCE_IGNORE_FILES
   "libmng.spec"
 )
 
-bc_compute_full_version(PROJECT_VERSION_BUILD)
-if(PROJECT_VERSION_BUILD)
-  set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${PROJECT_VERSION_BUILD}")
-endif()
-
 message("-- Package file name is ${CPACK_PACKAGE_FILE_NAME}")
 
 set(CPACK_SOURCE_PACKAGE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME})
diff --git a/linphone-app/cmake_builder/linphone_package/CMakeLists.txt b/linphone-app/cmake_builder/linphone_package/CMakeLists.txt
index ac85c68a..e6af5a66 100644
--- a/linphone-app/cmake_builder/linphone_package/CMakeLists.txt
+++ b/linphone-app/cmake_builder/linphone_package/CMakeLists.txt
@@ -38,15 +38,7 @@ set(LINPHONE_QML_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../ui")
 # ==============================================================================
 # Build package version.
 # ==============================================================================
-bc_compute_full_version(APP_PROJECT_VERSION)
-if (GIT_EXECUTABLE AND NOT(APP_PROJECT_VERSION))
-  execute_process(
-    COMMAND ${GIT_EXECUTABLE} describe --always
-    OUTPUT_VARIABLE APP_PROJECT_VERSION
-    OUTPUT_STRIP_TRAILING_WHITESPACE
-    WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../.."
-  )
-elseif (NOT(APP_PROJECT_VERSION))
+if (NOT(APP_PROJECT_VERSION))
   set(APP_PROJECT_VERSION "0.0.0")
 endif ()
 string(REGEX REPLACE "([0-9.]+)-?.*" "\\1" LINPHONE_VERSION "${APP_PROJECT_VERSION}")
-- 
2.25.1
+0 −18
Original line number Diff line number Diff line
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b5a4ab5..b6b89c2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -59,10 +59,10 @@ set(CMAKE_CXX_STANDARD 11)
 
 # Prepare gobal CMAKE configuration specific to the current project
 set(SDK_BUILD_DIR "${CMAKE_BINARY_DIR}/WORK")       # SDK build in WORK. Keep all in it.
-set(LINPHONE_OUTPUT_DIR "${CMAKE_BINARY_DIR}/linphone-sdk/desktop")
-set(QTKEYCHAIN_OUTPUT_DIR "${CMAKE_BINARY_DIR}/qtkeychain")
+set(LINPHONE_OUTPUT_DIR "@out@")
+set(QTKEYCHAIN_OUTPUT_DIR "@out@")
 set(QTKEYCHAIN_TARGET_NAME "EQt5Keychain")
-set(APPLICATION_OUTPUT_DIR "${CMAKE_BINARY_DIR}/OUTPUT")
+set(APPLICATION_OUTPUT_DIR "@out@")
 
 set(CMAKE_PREFIX_PATH "${LINPHONE_OUTPUT_DIR};${APPLICATION_OUTPUT_DIR};${APPLICATION_OUTPUT_DIR}/include${PREFIX_PATH}")
 if(WIN32)
Loading