From f79b02f8d78ed0e5a7cd5aeeda6dbfbc98236aae Mon Sep 17 00:00:00 2001 From: Mateusz Moscicki Date: Tue, 18 Jan 2022 15:07:20 +0100 Subject: [PATCH] Enable static linking to libtota delta.ua is provided in the delta.tar file to perform the system upgrade. When linked dynamically it calls functions from libtota that are on the old system, while we would like to use the new version. Change-Id: Ifaf889ac498886eab3310edbf250d99c22cb8bd1 --- CMakeLists.txt | 15 +++++++++++++-- packaging/tota-ua.spec | 2 ++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d669ab8..18a1142 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,19 +53,27 @@ MESSAGE("Build type: ${CMAKE_BUILD_TYPE}") INCLUDE(FindPkgConfig) pkg_check_modules(pkgs REQUIRED - tota openssl1.1 blkid + liblzma-tool ) pkg_check_modules(blkid_pkgs REQUIRED blkid ) +FIND_LIBRARY(libtota_path REQUIRED NAMES libtota.a) +FIND_LIBRARY(libbrotlidec_path REQUIRED NAMES libbrotlidec-static.a) +FIND_LIBRARY(libbrotlicommon_path REQUIRED NAMES libbrotlicommon-static.a) + FOREACH(flag ${pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) +ADD_LIBRARY(tota STATIC IMPORTED) +ADD_LIBRARY(brotlienc STATIC IMPORTED) +ADD_LIBRARY(brotlicommon STATIC IMPORTED) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -fPIE") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") SET(CMAKE_C_FLAGS_RELEASE "-O2") @@ -90,7 +98,10 @@ CONFIGURE_FILE(${TOTA_UA_SCRIPTS_DIR}/40-tota-ua.list.in SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed -pie") ADD_EXECUTABLE(${EXECNAME} ${SRCS}) -TARGET_LINK_LIBRARIES(${EXECNAME} ${pkgs_LDFLAGS}) +SET_TARGET_PROPERTIES(tota PROPERTIES IMPORTED_LOCATION ${libtota_path}) +SET_TARGET_PROPERTIES(brotlienc PROPERTIES IMPORTED_LOCATION ${libbrotlidec_path}) +SET_TARGET_PROPERTIES(brotlicommon PROPERTIES IMPORTED_LOCATION ${libbrotlicommon_path}) +TARGET_LINK_LIBRARIES(${EXECNAME} tota brotlienc brotlicommon ${pkgs_LDFLAGS}) INSTALL(TARGETS ${EXECNAME} DESTINATION ${BINDIR}) diff --git a/packaging/tota-ua.spec b/packaging/tota-ua.spec index f7982f0..dcc4885 100755 --- a/packaging/tota-ua.spec +++ b/packaging/tota-ua.spec @@ -9,6 +9,8 @@ Source0: %{name}-%{version}.tar.gz BuildRequires: cmake BuildRequires: ca-certificates-devel BuildRequires: pkgconfig(tota) +BuildRequires: pkgconfig(liblzma-tool) +BuildRequires: libbrotli-devel BuildRequires: pkgconfig(openssl1.1) BuildRequires: pkgconfig(libtzplatform-config) BuildRequires: pkgconfig(dlog) -- 2.7.4