upgrade-apply-deltafs: Add possibility to build this binary on host by adding a cmake... 20/282620/7
authorAntoni Adaszkiewicz <a.adaszkiewi@samsung.com>
Thu, 6 Oct 2022 12:35:50 +0000 (14:35 +0200)
committerAntoni Adaszkiewicz <a.adaszkiewi@samsung.com>
Mon, 7 Nov 2022 10:02:48 +0000 (11:02 +0100)
Change-Id: If634e2c3f8c171ac0f3a07a8d61f0e3723fc7ddf

CMakeLists.host-build [new file with mode: 0644]
CMakeLists.target-build [new file with mode: 0644]
CMakeLists.txt
src/upgrade-apply-deltafs/ua.c

diff --git a/CMakeLists.host-build b/CMakeLists.host-build
new file mode 100644 (file)
index 0000000..aacd73c
--- /dev/null
@@ -0,0 +1,56 @@
+#
+# upgrade-engine
+#
+# Copyright (c) 2022 Samsung Electronics Co., Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+
+ADD_DEFINITIONS("-DFEATURE_SUPPORT_CAPABILITY")
+ADD_DEFINITIONS("-D_FILE_OFFSET_BITS=64")
+ADD_DEFINITIONS("-DHOST_BUILD")
+
+SET(SRCS
+       src/upgrade-apply-deltafs/fota_util.c
+       src/upgrade-apply-deltafs/ua.c
+       src/upgrade-apply-deltafs/engine/SS_Common.c
+       src/upgrade-apply-deltafs/engine/SS_UPI.c
+       src/upgrade-apply-deltafs/engine/SS_FSUpdate.c
+       src/upgrade-apply-deltafs/engine/SS_ApplyPatch.c
+       src/upgrade-apply-deltafs/engine/SS_PatchDelta.c
+       src/upgrade-apply-deltafs/engine/fota_log.c
+       src/upgrade-apply-deltafs/engine/fota_tar.c
+       src/upgrade-apply-deltafs/engine/ss_bspatch_common.c
+       src/upgrade-apply/sha1/sha1.c
+)
+
+INCLUDE_DIRECTORIES(src/upgrade-apply/sha1)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${PROJECT_NAME}_pkgs REQUIRED liblzma-tool libbrotlienc zlib)
+
+FOREACH(flag ${${PROJECT_NAME}_pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -I./include")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+SET(EXECNAME "upgrade-apply-deltafs")
+SET(BINDIR "/usr/bin")
+ADD_EXECUTABLE(${EXECNAME} ${SRCS})
+
+TARGET_LINK_LIBRARIES(${EXECNAME} PRIVATE ${${PROJECT_NAME}_pkgs_LDFLAGS} "-g" "-pthread")
+TARGET_LINK_LIBRARIES(${EXECNAME} PRIVATE libtar.a)
+INSTALL(TARGETS ${EXECNAME} DESTINATION ${BINDIR})
\ No newline at end of file
diff --git a/CMakeLists.target-build b/CMakeLists.target-build
new file mode 100644 (file)
index 0000000..7802192
--- /dev/null
@@ -0,0 +1,26 @@
+#
+# upgrade-engine
+#
+# Copyright (c) 2022 Samsung Electronics Co., Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+
+ADD_SUBDIRECTORY(src/dmverity)
+ADD_SUBDIRECTORY(src/img-verifier)
+ADD_SUBDIRECTORY(src/upgrade-apply)
+ADD_SUBDIRECTORY(src/upgrade-apply-deltafs)
+ADD_SUBDIRECTORY(src/blkid-print)
+ADD_SUBDIRECTORY(data)
+ADD_SUBDIRECTORY(scripts/rw-upgrade)
index 310f4c5..453d410 100644 (file)
@@ -1,7 +1,7 @@
 #
 # upgrade-engine
 #
-# Copyright (c) 2021 Samsung Electronics Co., Ltd.
+# Copyright (c) 2022 Samsung Electronics Co., Ltd.
 #
 # Licensed under the Apache License, Version 2.0 (the License);
 # you may not use this file except in compliance with the License.
@@ -14,7 +14,6 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-#
 
 CMAKE_MINIMUM_REQUIRED(VERSION 2.82)
 PROJECT(upgrade C)
@@ -40,10 +39,10 @@ ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
 
 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed -pie")
 
-ADD_SUBDIRECTORY(src/dmverity)
-ADD_SUBDIRECTORY(src/img-verifier)
-ADD_SUBDIRECTORY(src/upgrade-apply)
-ADD_SUBDIRECTORY(src/upgrade-apply-deltafs)
-ADD_SUBDIRECTORY(src/blkid-print)
-ADD_SUBDIRECTORY(data)
-ADD_SUBDIRECTORY(scripts/rw-upgrade)
+# set this to ON if you want to build on host
+OPTION(DEFINE_HOST_BUILD OFF)
+IF(DEFINE_HOST_BUILD)
+       INCLUDE(CMakeLists.host-build)
+ELSE()
+       INCLUDE(CMakeLists.target-build)
+ENDIF()
\ No newline at end of file
index 726199c..dd231bd 100755 (executable)
@@ -33,7 +33,9 @@
 #include <string.h>
 #include <getopt.h>
 
+#ifndef HOST_BUILD
 #include <hal/device/hal-board.h>
+#endif
 
 #include "ua.h"
 #include "fota_util.h"
@@ -200,10 +202,13 @@ update_progress:
 static void set_upgrade_progress(int percent)
 {
        int relative_precent = HAL_PROGRESS_MIN + ((HAL_PROGRESS_MAX - HAL_PROGRESS_MIN) * percent)/100;
+
+#ifndef HOST_BUILD
        if (hal_device_board_set_upgrade_status(relative_precent) < 0) {
                LOG("set_upgrade_status failed: %d\n", relative_precent);
                return;
        }
+#endif
 
        LOG("set_upgrade_status success: %d\n", relative_precent);
 }