From 34ee674f371c0588f1c47bb0ce6fdda517e2ace0 Mon Sep 17 00:00:00 2001 From: Mateusz Piesta Date: Wed, 8 Mar 2023 11:31:51 +0100 Subject: [PATCH] [MOS-939] Apply target update scripts * Removed old UDM-related update scripts that are no longer needed. * Applied target update script * Removed unneeded data folder from user partition * Removed dummy personalization.json --- cmake/modules/AddScripts.cmake | 2 +- image/system_a/data/personalization.json | 10 -- products/PurePhone/CMakeLists.txt | 2 +- scripts/lua/install.sh | 6 - scripts/lua/update_udm.lua | 159 ----------------------- 5 files changed, 2 insertions(+), 177 deletions(-) delete mode 100644 image/system_a/data/personalization.json delete mode 100644 scripts/lua/update_udm.lua diff --git a/cmake/modules/AddScripts.cmake b/cmake/modules/AddScripts.cmake index 4ba288dcf3dbf48f64e083e868260a6670fe0586..ac8567399ab284a5a58ac62f9f1178a6604d3f76 100644 --- a/cmake/modules/AddScripts.cmake +++ b/cmake/modules/AddScripts.cmake @@ -11,7 +11,7 @@ function(add_scripts_target) ${_ARG_TARGET} DEPENDS ${_ARG_DEPENDS} - COMMAND ${PROJECT_SOURCE_DIR}/scripts/lua/install.sh ${_ARG_PRODUCT} ${_ARG_DEST_DIR} udm + COMMAND ${PROJECT_SOURCE_DIR}/scripts/lua/install.sh ${_ARG_PRODUCT} ${_ARG_DEST_DIR} COMMENT "Installing scripts for ${_ARG_PRODUCT} to ${_ARG_DEST_DIR} directory" ) diff --git a/image/system_a/data/personalization.json b/image/system_a/data/personalization.json deleted file mode 100644 index a3c706f499ab4459e44966db37ae1484555faf70..0000000000000000000000000000000000000000 --- a/image/system_a/data/personalization.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "serial" : "00000000000000", - "model" : "1.00", - "case_colour" : "nocase", - "pcb_mb_version" : "0v0", - "pcb_um_version" : "0v0", - "pcb_lm_version" : "0v0", - "pcb_am_version" : "0v0", - "battery_revision" : "0v0" -} diff --git a/products/PurePhone/CMakeLists.txt b/products/PurePhone/CMakeLists.txt index 405877d380c94cb9c8065112cb649400559d08bc..454f88cb6016d2f34f9fdae2d95d7d832e3ddcb0 100644 --- a/products/PurePhone/CMakeLists.txt +++ b/products/PurePhone/CMakeLists.txt @@ -110,7 +110,7 @@ add_directories( TARGET create_user_directories PREFIX ${SYSROOT_PATH}/user DEPENDS system_directories_common - DIRECTORIES data temp media/app/music_player + DIRECTORIES temp media/app/music_player ) if (${PROJECT_TARGET} STREQUAL "TARGET_RT1051") diff --git a/scripts/lua/install.sh b/scripts/lua/install.sh index 0817f7d3258c594b7b2dfb517da2c96df4631982..602243174effec310ace18b7069b38d5c8568825 100755 --- a/scripts/lua/install.sh +++ b/scripts/lua/install.sh @@ -32,12 +32,6 @@ if validate_product_selection; then cp -r share ${DESTINATION}/share cp -r migration/migration.lua ${DESTINATION}/share cp *.lua ${DESTINATION} - - if [ -n "$3" ]; then - echo "Generating UDM update package" - cp update_udm.lua ${DESTINATION}/update.lua - cp products/${PRODUCT}/update_product.lua ${DESTINATION} - fi rm ${DESTINATION}/update_udm.lua cd - fi \ No newline at end of file diff --git a/scripts/lua/update_udm.lua b/scripts/lua/update_udm.lua deleted file mode 100644 index 1636be3fd9c6a8863f9e5b806576e9bc469a2ca3..0000000000000000000000000000000000000000 --- a/scripts/lua/update_udm.lua +++ /dev/null @@ -1,159 +0,0 @@ -local update = {} -local lfs = require('lfs') -local json = require('lunajson') -local paths = require('paths') -local consts = require('consts') -local helpers = require('helpers') -local recovery = require('recovery') -local migration = require('migration') -local update_product = require('update_product') - -update.script_name = "update.lua" -update.img_in_progress = "assets/gui_image_update_in_progress.bin" -update.img_success = "assets/gui_image_update_success.bin" -update.img_failure = "assets/gui_image_update_failed.bin" - --- Match only files with '.db' extensions and omit such files inside subdirectories -local match_db_files = '^[^%/]*%.db$' - -local function build_db_set(file) - local contents = helpers.read_whole_file(file) - local root = json.decode(contents) - local set = {} - for _, entry in pairs(root.databases) do - set[entry.name] = tonumber(entry.version) - end - return set -end - -local function purge_target_slot() - local target_dir = recovery.sys.target_slot() - print(string.format("Removing target slot content, '%s'", target_dir)) - helpers.rmdir_content(target_dir) -end - -local function copy_update_package() - local target_dir = recovery.sys.target_slot() - print(string.format("Copying content of the update package '%s' to '%s'", paths.update_dir, target_dir)) - helpers.copy_dir(paths.update_dir, target_dir) -end - -local function copy_databases() - local from = recovery.sys.user() - local to = paths.target.db_dir - print(string.format("Copying databases from '%s' to '%s'", from, to)) - helpers.copy_dir_filtered(from, to, match_db_files) -end - -local function create_directories() - print("Creating 'log', 'crash_dumps' and 'sys' directories") - - local target_dir = recovery.sys.target_slot() - lfs.mkdir(target_dir .. "/log") - lfs.mkdir(target_dir .. "/crash_dumps") - lfs.mkdir(target_dir .. "/var") -end - -local function migrate_db() - local target_dir = recovery.sys.target_slot() - local version_file = paths.update_dir .. "/" .. consts.version_file - local db_path = target_dir .. "/db" - local migration_dir = db_path .. "/migration" - - print("Performing database migration") - local dbset = build_db_set(version_file) - local result = migration.migrate(db_path, migration_dir, dbset) - assert(result == migration.retcode.OK, string.format("Database migration process failed with %d", result)) -end - -local function enter() - -- Mark the current slot as successful - recovery.bootctrl.mark_as_successful() - -- Mark the target slot as unbootable - recovery.bootctrl.mark_as_unbootable(recovery.bootctrl.get_next_active()) -end - -local function exit() - print("Finishing update process") - helpers.rmdir(paths.update_dir) - os.remove(paths.update_file) - - -- Update the working directory to the newly updated scripts directory - lfs.chdir(recovery.sys.target_slot() .. "/scripts") - - -- Mark the old 'MUDITAOS' partition as unbootable&unsuccessful - recovery.bootctrl.mark_as_unbootable(recovery.bootctrl.get_current_slot()) - -- Mark the 'system_b' as bootable and active - recovery.bootctrl.mark_as_bootable(recovery.bootctrl.get_next_active()) - recovery.bootctrl.mark_as_active(recovery.bootctrl.get_next_active()) - recovery.sys.set_os_boot_status(false) -end - -local function repartition_filesystem() - print("Repartitioning 'MUDITAOS' and 'BACKUP' partitions and changing theirs labels") - - -- Repartitioning filesystem remounts all available disks. During this process, working directory - -- will be set to the default one hence we need to recreate it. - local wdir = lfs.currentdir() - recovery.sys.repartition_fs() - lfs.chdir(wdir) -end - -local function user_remove_directories() - print("->Removing backup, crash_dumps, data, db, logs, tmp directories") - if helpers.exists(recovery.sys.user() .. "/backup") then - helpers.rmdir(recovery.sys.user() .. "/backup") - end - if helpers.exists(recovery.sys.user() .. "/crash_dumps") then - helpers.rmdir(recovery.sys.user() .. "/crash_dumps") - end - if helpers.exists(recovery.sys.user() .. "/data") then - helpers.rmdir(recovery.sys.user() .. "/data") - end - if helpers.exists(recovery.sys.user() .. "/db") then - helpers.rmdir(recovery.sys.user() .. "/db") - end - if helpers.exists(recovery.sys.user() .. "/logs") then - helpers.rmdir(recovery.sys.user() .. "/logs") - end - if helpers.exists(recovery.sys.user() .. "/tmp") then - helpers.rmdir(recovery.sys.user() .. "/tmp") - end -end - -local function user_remove_files() - print("->Removing files") - helpers.rm_files_from_dir(recovery.sys.user()) -end - -local function user_create_directories() - print("->Creating media directory") - lfs.mkdir(recovery.sys.user() .. "/media") -end - -local function user_product_specific() - print("->Executing product specific steps") - update_product.execute() -end - -local function adjust_user_partition_layout() - print("Adjusting user partition layout...") - user_remove_directories() - user_create_directories() - user_product_specific() - user_remove_files() -end - -function update.execute() - enter() - repartition_filesystem() - purge_target_slot() - copy_update_package() - copy_databases() - create_directories() - migrate_db() - adjust_user_partition_layout() - exit() -end - -return update