From 05bac516402f396763da22c12f90fa25630a6494 Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Wed, 20 Dec 2017 11:26:55 +0900 Subject: [PATCH 01/16] Revert recovery update service Recovery partitions will be updated by PRE_UA. - Revert "Fix Architecture Dependency" - Revert "Introduce recovery-update.service" Change-Id: Ic15dda2e82ec1ab91d9c48121ec09486a8e88876 Signed-off-by: Sunmin Lee --- packaging/system-rw-update.spec | 9 +--- units/recovery-update.service | 12 ------ upgrade/recovery-update.sh | 91 ----------------------------------------- upgrade/update-init.sh | 18 -------- upgrade/update.sh | 18 ++++---- 5 files changed, 10 insertions(+), 138 deletions(-) delete mode 100755 units/recovery-update.service delete mode 100755 upgrade/recovery-update.sh diff --git a/packaging/system-rw-update.spec b/packaging/system-rw-update.spec index 84bad20..41a10fb 100644 --- a/packaging/system-rw-update.spec +++ b/packaging/system-rw-update.spec @@ -1,6 +1,6 @@ Name: system-rw-update Summary: System RW update management -Version: 1.1.0 +Version: 1.2.0 Release: 0 Group: Base/Startup License: Apache-2.0 @@ -49,11 +49,6 @@ ln -s ../offline-update.service %{buildroot}%{_unitdir}/system-update.target.wan ln -s ../getty.target %{buildroot}%{_unitdir}/system-update.target.wants ln -s ../cynara.socket %{buildroot}%{_unitdir}/system-update.target.wants -# recovery update service -mkdir -p %{buildroot}%{_unitdir}/multi-user.target.wants/ -install -m 0644 units/recovery-update.service %{buildroot}%{_unitdir}/recovery-update.service -ln -s ../recovery-update.service %{buildroot}%{_unitdir}/multi-user.target.wants/recovery-update.service - # SDB debugging install -m 644 units/udev-sdb-init.service %{buildroot}%{_unitdir} ln -s ../udev-sdb-init.service %{buildroot}%{_unitdir}/system-update.target.wants @@ -78,8 +73,6 @@ fi %{_datadir}/upgrade/* %{_unitdir}/offline-update.service %{_unitdir}/system-update.target.wants -%{_unitdir}/recovery-update.service -%{_unitdir}/multi-user.target.wants/recovery-update.service %{_unitdir}/udev-sdb-init.service %files ani diff --git a/units/recovery-update.service b/units/recovery-update.service deleted file mode 100755 index 478f99c..0000000 --- a/units/recovery-update.service +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=Recovery Update -Wants=local-fs.target -After=local-fs.target - -[Service] -Type=oneshot -SmackProcessLabel=System -ExecStart=/usr/share/upgrade/recovery-update.sh - -[Install] -WantedBy=multi-user.target diff --git a/upgrade/recovery-update.sh b/upgrade/recovery-update.sh deleted file mode 100755 index dc068a5..0000000 --- a/upgrade/recovery-update.sh +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/sh - -FULL_RECOVERY_P=ramdisk-recovery.img -TOTA_RECOVERY_P=RAMDISK2 -BLKDEV_RECOVERY= -POSTRESULT=post.result - -STATUS_DIR=/opt/data/recovery - -UPI_RECOVERY_PARTITION_COPY_ERROR=fa19 -UPI_RECOVERY_UPDATE_ERROR=fa1a - -#===================== -# funtions -#===================== - -#------------------------------------------------ -# print_log -#------------------------------------------------ -print_log() { - echo $@ - echo $@ >> ${PATCH_LOG_FILE} - /bin/sync -} - -#------------------------------------------------ -# get partition id -#------------------------------------------------ -get_partition_id() { - BLKID="/usr/sbin/blkid" - - PART_RECOVERY=$("$BLKID" --match-token PARTLABEL=ramdisk2 -o device || - "$BLKID" --match-token LABEL=ramdisk-recovery -o device) -} - -#===================== -# main routine start -#===================== - -get_partition_id - -BLKDEV_RECOVERY=${PART_RECOVERY} - -if [ ! -d ${STATUS_DIR} ]; then - echo "${STATUS_DIR} not exist" - exit 0 -fi - -if [ -f ${DST_DIR}/${TOTA_RECOVERY_P} ]; then - /bin/mv ${DST_DIR}/${TOTA_RECOVERY_P} ${DST_DIR}/${FULL_RECOVERY_P} -fi - -PATCH_LOG_FILE=${STATUS_DIR}/RW.LOG - -DST_DIR=/opt/usr/data/fota - -#------------------------------------------------ -# update recovery partition -#------------------------------------------------ -if [ -r ${DST_DIR}/${FULL_RECOVERY_P} ]; then - - #--- FULL_IMG case --- - TIMESTAMP=$(/bin/date +%H:%M:%S) - print_log "start recovery partition update : (${TIMESTAMP})" - - /bin/dd if=${DST_DIR}/${FULL_RECOVERY_P} of=${BLKDEV_RECOVERY} - if [ "$?" = "0" ]; then - /bin/rm -f ${DST_DIR}/${FULL_RECOVERY_P} - /bin/sync - print_log "update succeeded" - else - if [ -f /opt/data/recovery/result ]; then - fotaflag=`/bin/cat /opt/data/recovery/result` - if [ "$fotaflag" = "0" ]; then - echo ${UPI_RECOVERY_PARTITION_COPY_ERROR} > /opt/data/recovery/result - /usr/bin/chmod 644 /opt/data/recovery/result - print_log "Change result to ${UPI_RECOVERY_PARTITION_COPY_ERROR}" - fi - fi - print_log "update failed" - fi - - TIMESTAMP=$(/bin/date +%H:%M:%S) - print_log "end recovery partition update : (${TIMESTAMP})" -else - ULOG="skip recovery partition update" - /usr/bin/grep "${ULOG}" ${PATCH_LOG_FILE} > /dev/null 2>&1 - if [ "$?" != 0 ]; then - print_log "${ULOG}" - fi -fi diff --git a/upgrade/update-init.sh b/upgrade/update-init.sh index 5a02ac3..6825aeb 100755 --- a/upgrade/update-init.sh +++ b/upgrade/update-init.sh @@ -7,13 +7,6 @@ RW_MACRO=/usr/share/upgrade/rw-update-macro.inc RW_UPDATE=/usr/share/upgrade/update.sh DEBUG_MODE=/opt/usr/.upgdebug -DELTA_TAR=delta.tar -FULL_RECOVERY=ramdisk-recovery.img -TOTA_RECOVERY=RAMDISK2 -DST_DIR=/opt/usr/data/fota -STATUS_DIR=/opt/data/recovery -DELTA_PATH_FILE=${STATUS_DIR}/DELTA.PATH - if [ -f $RW_MACRO ]; then source $RW_MACRO get_version_info @@ -28,17 +21,6 @@ fi # Permission Update for shared directories /etc/gumd/useradd.d/91_user-dbspace-permissions.post owner -# Pre operations for recovery update -if [ -f ${DELTA_PATH_FILE} ]; then - if [ -f ${DST_DIR}/${TOTA_RECOVERY} ]; then - /bin/mv ${DST_DIR}/${TOTA_RECOVERY} ${DST_DIR}/${FULL_RECOVERY} - fi -fi - -if [ -f ${DELTA_DIR}/${DELTA_TAR} ]; then - /bin/rm -f ${DELTA_DIR}/${DELTA_TAR} -fi - sleep 10 if [ -f $DEBUG_MODE ]; then exit diff --git a/upgrade/update.sh b/upgrade/update.sh index ca15404..9129823 100755 --- a/upgrade/update.sh +++ b/upgrade/update.sh @@ -6,7 +6,7 @@ PATH=/bin:/usr/bin:/sbin:/usr/sbin TMP_DIR=/tmp/upgrade PATCH_DIR=/usr/share/upgrade/scripts -RW_LOG=/opt/data/recovery/RW.LOG +RESULT_FILE=/opt/data/recovery/rw_result SDB_RULE=/opt/data/recovery/99-sdb-switch.rules VERSION_FILE=/opt/etc/version RW_MACRO=/usr/share/upgrade/rw-update-macro.inc @@ -24,7 +24,7 @@ RW_ANI=/usr/bin/rw-update-ani Verity_Check() { if [ "z$1" = "z" ]; then - echo "Input Shell Script Null" >> ${RW_LOG} + echo "Input Shell Script Null" >> ${RESULT_FILE} return 1 fi @@ -39,18 +39,18 @@ Verity_Check() { md5list=`/usr/bin/grep ${SC_FILE} ${SC_LIST} | /usr/bin/awk -F' ' '{print $2}'` if [ "$md5result" = "$md5list" ]; then - echo "[PASS ] ${SC_FILE} verity check" >> ${RW_LOG} + echo "[PASS ] ${SC_FILE} verity check" >> ${RESULT_FILE} return 0 else - echo "[MISMATCH] ${SC_FILE} md5sum" >> ${RW_LOG} + echo "[MISMATCH] ${SC_FILE} md5sum" >> ${RESULT_FILE} return 2 fi else - echo "[No entry] ${SC_FILE} in ${SC_LIST}" >> ${RW_LOG} + echo "[No entry] ${SC_FILE} in ${SC_LIST}" >> ${RESULT_FILE} return 1 fi else - echo "No such file ${SC_LIST}" >> ${RW_LOG} + echo "No such file ${SC_LIST}" >> ${RESULT_FILE} return 1 fi } @@ -64,12 +64,12 @@ if [ -e ${RW_ANI} ]; then RW_GUI=1 fi -echo "System RW update: rw update started" > ${RW_LOG} +echo "System RW update: rw update started" > ${RESULT_FILE} # Execute update scripts if [ ! -d ${PATCH_DIR} ] then - echo "FAIL: Upgrade directory does not exist" >> ${RW_LOG} + echo "FAIL: Upgrade directory does not exist" >> ${RESULT_FILE} else if [ "${RW_GUI}" = "1" ]; then progress=0 @@ -97,7 +97,7 @@ else sync - echo "SUCCESS: Upgrade successfully finished" >> ${RW_LOG} + echo "SUCCESS: Upgrade successfully finished" >> ${RESULT_FILE} fi if [ -e ${SDB_RULE} ]; then -- 2.7.4 From 77fcd6c2340856d6e111a8a8c99fe7b482f65713 Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Mon, 18 Dec 2017 14:22:07 +0900 Subject: [PATCH 02/16] rw-update-macro: improve restore_backup_file helper This patch make rw-update-macro to consider the case of no smack rule, and handle the file path properly. In addition, the content of model-config was changed. This patch also covers it. Change-Id: Ief8d0e900fbcbb96df7ef1623f7b01b1a95b6098 Signed-off-by: Sunmin Lee --- upgrade/rw-update-macro.inc | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/upgrade/rw-update-macro.inc b/upgrade/rw-update-macro.inc index 3c670ab..7615e39 100755 --- a/upgrade/rw-update-macro.inc +++ b/upgrade/rw-update-macro.inc @@ -6,28 +6,29 @@ OLD_REL= NEW_REL= OLD_VER_INFO="/opt/etc/version" -write_version_info() { - OLD_VER=$(cat /etc/config/model-config.xml | grep platform.version \ - | sed -e 's/.*>\(.*\)<.*/\1/') - OLD_REL=$(cat /etc/info.ini | grep Date | sed -e 's/Date=//' -e 's/\_.*//') - echo "OLD_VER=$OLD_VER" > $OLD_VER_INFO - echo "OLD_REL=$OLD_REL" >> $OLD_VER_INFO -} - get_version_info() { if [ -f $OLD_VER_INFO ]; then source $OLD_VER_INFO fi - NEW_VER=$(cat /etc/config/model-config.xml | grep platform.version \ - | sed -e 's/.*>\(.*\)<.*/\1/') + NEW_VER=$(cat /etc/config/model-config.xml | grep platform.version\" \ + | sed -e 's/.*>\(.*\)<.*/\1/' | head -1) NEW_REL=$(cat /etc/info.ini | grep Date | sed -e 's/Date=//' -e 's/\_.*//') } +write_version_info() { + get_version_info + echo "OLD_VER=$NEW_VER" > $OLD_VER_INFO + echo "OLD_REL=$NEW_REL" >> $OLD_VER_INFO + + NEW_VER= + NEW_REL= +} + restore_backup_file() { BACKUP_ZIP="/usr/system/RestoreDir/opt.zip" REC=0 - DEST="/" + DEST= while [ "$1" != "" ]; do case $1 in @@ -50,22 +51,27 @@ restore_backup_file() { if [ "$REC" = "1" ]; then REC_FILES=$(unzip -l $BACKUP_ZIP | grep $MOD_PATH | awk '{print $4}') for REC_FILE in $REC_FILES; do - restore_backup_file $REC_FILE -d $DEST + if [ "z$DEST" = "z" ]; then + restore_backup_file $REC_FILE + else + restore_backup_file $REC_FILE -d $DEST + fi done return fi - unzip -nX $BACKUP_ZIP $MOD_PATH -d $DEST + unzip -nX $BACKUP_ZIP $MOD_PATH -d $DEST/ TMP=$(mktemp /tmp/smackinfo.XXXXXX) PATH_FOR_SMACK=$(echo $MOD_PATH | sed -e "s/\/$//") - if [ "z$DEST" = "z" ]; then - grep $PATH_FOR_SMACK'\ ' /usr/system/RestoreDir/smack_label.txt > $TMP + + FILE_PATH="$DEST/$PATH_FOR_SMACK" + SMACK_VAL=$(grep $PATH_FOR_SMACK'\ ' /usr/system/RestoreDir/smack_label.txt | \ + { read FILE SMACK; echo $SMACK; }) + if [ "z$SMACK_VAL" = "z" ]; then + echo "No smack label for $PATH_FOR_SMACK" else - FILE_PATH="$DEST/$PATH_FOR_SMACK" - SMACK_VAL=$(grep $PATH_FOR_SMACK'\ ' /usr/system/RestoreDir/smack_label.txt | \ - awk '{print $2 $3}') echo "$FILE_PATH $SMACK_VAL" > $TMP + rstsmack $TMP fi - rstsmack $TMP rm $TMP } -- 2.7.4 From 7126f56bcdbb6a9a5f95c2077fb8e8a506b99f1d Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Tue, 19 Dec 2017 16:03:12 +0900 Subject: [PATCH 03/16] Release 1.0.1 - Use the same path for update - Divide result into log and result file - rw-script-list: update hash values of scripts - rw-udpate-macro: improve restore_backup_file helper Change-Id: Ibf8c3b2683864d8579343ae10b2972471712e722 Signed-off-by: Sunmin Lee --- packaging/system-rw-update.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/system-rw-update.spec b/packaging/system-rw-update.spec index fda1f8e..7580630 100644 --- a/packaging/system-rw-update.spec +++ b/packaging/system-rw-update.spec @@ -1,6 +1,6 @@ Name: system-rw-update Summary: System RW update management -Version: 1.0.0 +Version: 1.0.1 Release: 0 Group: Base/Startup License: Apache-2.0 -- 2.7.4 From 6eb59c893235c1d22029ad21bd84dc28d1b5d6f2 Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Tue, 12 Dec 2017 17:58:34 +0900 Subject: [PATCH 04/16] rw-update-macro: patch for version info This patch means two changes: 1) Take REL away which is not used in platform 2) Apply four-digit to version info: for compatibility Change-Id: I77be4d796f324b4d1fe1603a369b408c16c3d8d0 Signed-off-by: Sunmin Lee --- upgrade/rw-update-macro.inc | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/upgrade/rw-update-macro.inc b/upgrade/rw-update-macro.inc index 7615e39..d3fe5a9 100755 --- a/upgrade/rw-update-macro.inc +++ b/upgrade/rw-update-macro.inc @@ -2,26 +2,32 @@ OLD_VER= NEW_VER= -OLD_REL= -NEW_REL= OLD_VER_INFO="/opt/etc/version" +# Convert version to 4 digits +convert_version() { + i=0 + VER=(0 0 0 0) + for ENT in $(echo "$1" | tr "." "\n"); do + VER[$i]=$ENT + ((i++)) + done + CVT_VER=${VER[0]}.${VER[1]}.${VER[2]}.${VER[3]} +} + get_version_info() { if [ -f $OLD_VER_INFO ]; then source $OLD_VER_INFO fi NEW_VER=$(cat /etc/config/model-config.xml | grep platform.version\" \ | sed -e 's/.*>\(.*\)<.*/\1/' | head -1) - NEW_REL=$(cat /etc/info.ini | grep Date | sed -e 's/Date=//' -e 's/\_.*//') + convert_version $NEW_VER + NEW_VER=$CVT_VER } write_version_info() { get_version_info echo "OLD_VER=$NEW_VER" > $OLD_VER_INFO - echo "OLD_REL=$NEW_REL" >> $OLD_VER_INFO - - NEW_VER= - NEW_REL= } restore_backup_file() { -- 2.7.4 From ae262b98483d5079a2ebfcd32f3687f062e08ed8 Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Wed, 27 Dec 2017 17:16:05 +0900 Subject: [PATCH 05/16] Update rw-update-macro.inc The options of restore_backup_file is changed to simplify the usage -r (deprecated): for now, always restore recursively if the target is directory -d (deprecated): for now, destination is always root(/) -f (new): the option for overwriting existing file Change-Id: I473182a8be5de46c65970eba11677b725a52a7de Signed-off-by: Sunmin Lee --- upgrade/rw-update-macro.inc | 107 +++++++++++++++++++++++++++++++------------- 1 file changed, 75 insertions(+), 32 deletions(-) mode change 100755 => 100644 upgrade/rw-update-macro.inc diff --git a/upgrade/rw-update-macro.inc b/upgrade/rw-update-macro.inc old mode 100755 new mode 100644 index d3fe5a9..31e1f1e --- a/upgrade/rw-update-macro.inc +++ b/upgrade/rw-update-macro.inc @@ -30,54 +30,97 @@ write_version_info() { echo "OLD_VER=$NEW_VER" > $OLD_VER_INFO } +BACKUP_ZIP="/usr/system/RestoreDir/opt.zip" + +restore_from_zip() { + + TARGET_FILE=$1 + TARGET_DIR=$(dirname /$TARGET_FILE) + + echo "restore_from_zip: $TARGET_FILE" + if [ ! -d $TARGET_DIR ]; then + mkdir -p $TARGET_DIR + fi + + # The attributes of directory can not be overwritten by unzip. + # Unzip the directory into temp path and copy it to original path. + if [ "z${TARGET_FILE: -1}" = "z/" ]; then + RESTORE_DIR_PATH="/tmp/restored_dir" + mkdir -p $RESTORE_DIR_PATH + unzip -oX $BACKUP_ZIP $TARGET_FILE -d $RESTORE_DIR_PATH > /dev/null + cp -af $RESTORE_DIR_PATH/$TARGET_FILE $TARGET_DIR + rm -rf $RESTORE_DIR_PATH + else + unzip -oX $BACKUP_ZIP $TARGET_FILE -d / > /dev/null + fi + + # Restore smack label + TMP=$(mktemp /tmp/smackinfo.XXXXXX) + PATH_FOR_SMACK=$(echo $TARGET_FILE | sed -e "s/\/$//") + SMACK_VAL=$(grep "$PATH_FOR_SMACK " /usr/system/RestoreDir/smack_label.txt | \ + { read FILE SMACK; echo $SMACK; }) + if [ "z$SMACK_VAL" = "z" ]; then + echo "No smack label for $PATH_FOR_SMACK" + else + echo "/$PATH_FOR_SMACK $SMACK_VAL" > $TMP + rstsmack $TMP + fi + rm $TMP +} + restore_backup_file() { - BACKUP_ZIP="/usr/system/RestoreDir/opt.zip" - REC=0 - DEST= + OVERWRITE= + RESTORE_PATH= - while [ "$1" != "" ]; do + while [ "z$1" != "z" ]; do case $1 in - -r ) - REC=1 - ;; - -d ) - shift - DEST=$1 + -f ) + OVERWRITE=$1 ;; - *) + * ) RESTORE_PATH=$1 ;; esac shift done - MOD_PATH=$(echo $RESTORE_PATH | sed -e "s/^\///") + if [ "z$RESTORE_PATH" = "z" ]; then + echo "There is no file to restore" + return + fi - if [ "$REC" = "1" ]; then - REC_FILES=$(unzip -l $BACKUP_ZIP | grep $MOD_PATH | awk '{print $4}') - for REC_FILE in $REC_FILES; do - if [ "z$DEST" = "z" ]; then - restore_backup_file $REC_FILE - else - restore_backup_file $REC_FILE -d $DEST - fi - done + if [ ! "z${RESTORE_PATH:0:1}" = "z/" ]; then + echo "Full path of file is required" return fi - unzip -nX $BACKUP_ZIP $MOD_PATH -d $DEST/ - TMP=$(mktemp /tmp/smackinfo.XXXXXX) - PATH_FOR_SMACK=$(echo $MOD_PATH | sed -e "s/\/$//") + if [ -e "$RESTORE_PATH" ]; then + if [ ! "z$OVERWRITE" = "z" ]; then + echo "Warning: $RESTORE_PATH already exists. It will be overwritten" + else + echo "Error: $RESTORE_PATH already exists" + return + fi + fi - FILE_PATH="$DEST/$PATH_FOR_SMACK" - SMACK_VAL=$(grep $PATH_FOR_SMACK'\ ' /usr/system/RestoreDir/smack_label.txt | \ - { read FILE SMACK; echo $SMACK; }) - if [ "z$SMACK_VAL" = "z" ]; then - echo "No smack label for $PATH_FOR_SMACK" + # Check if the target file is backed up + PATH_FOR_ZIP=$(echo $RESTORE_PATH | sed -e "s/^\///") + FOUND_FILES=$(unzip -l $BACKUP_ZIP | awk '{print $4}' | \ + grep "^$PATH_FOR_ZIP") + FOUND_FILE=$(echo "$FOUND_FILES" | \ + grep -E "$PATH_FOR_ZIP$|$PATH_FOR_ZIP/$") + if [ "z$FOUND_FILE" = "z" ]; then + echo "Error: $RESTORE_PATH was not backed up" + return + fi + + echo "restore_backup_file: $RESTORE_PATH" + if [ ! "z${FOUND_FILE: -1}" = "z/" ]; then + restore_from_zip $FOUND_FILE else - echo "$FILE_PATH $SMACK_VAL" > $TMP - rstsmack $TMP + for FILE in $FOUND_FILES; do + restore_from_zip $FILE + done fi - rm $TMP } -- 2.7.4 From 778f3ab7a785c2555832855a5d9889f7ce0ebda3 Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Wed, 3 Jan 2018 17:32:17 +0900 Subject: [PATCH 06/16] Introduce rstsmack for update RW update macro requires rstsmack which restores smack label of backed up file. Change-Id: I2babf6412b92f714c4cabebd92efd0e21cddbe46 Signed-off-by: Sunmin Lee --- CMakeLists.txt | 2 +- packaging/system-rw-update.spec | 7 +- rstsmack/CMakeLists.txt | 17 +++++ rstsmack/rstsmack.c | 154 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 178 insertions(+), 2 deletions(-) create mode 100755 rstsmack/CMakeLists.txt create mode 100644 rstsmack/rstsmack.c diff --git a/CMakeLists.txt b/CMakeLists.txt index bd272ca..f291c00 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,4 +3,4 @@ PROJECT(rw-updater C) #add sub directory ADD_SUBDIRECTORY(rw-update-ani) - +ADD_SUBDIRECTORY(rstsmack) diff --git a/packaging/system-rw-update.spec b/packaging/system-rw-update.spec index 7580630..99619f6 100644 --- a/packaging/system-rw-update.spec +++ b/packaging/system-rw-update.spec @@ -1,6 +1,6 @@ Name: system-rw-update Summary: System RW update management -Version: 1.0.1 +Version: 1.0.2 Release: 0 Group: Base/Startup License: Apache-2.0 @@ -23,6 +23,7 @@ BuildRequires: pkgconfig(cairo) BuildRequires: pkgconfig(libtbm) BuildRequires: pkgconfig(libtdm) BuildRequires: pkgconfig(vconf) +BuildRequires: pkgconfig(libsmack) %description ani UX for system RW update/upgrade @@ -66,6 +67,9 @@ else mkdir -p %{_libdir}/udev/rules.d ln -s /opt/data/update/99-sdb-switch.rules %{_libdir}/udev/rules.d fi +if [ ! -e %{_bindir}/rstsmack ]; then + ln -s %{_bindir}/rstsmack-for-update %{_bindir}/rstsmack +fi %files %manifest %{name}.manifest @@ -74,6 +78,7 @@ fi %{_unitdir}/offline-update.service %{_unitdir}/system-update.target.wants %{_unitdir}/udev-sdb-init.service +%{_bindir}/rstsmack-for-update %files ani %manifest %{name}-ani.manifest diff --git a/rstsmack/CMakeLists.txt b/rstsmack/CMakeLists.txt new file mode 100755 index 0000000..edfbb89 --- /dev/null +++ b/rstsmack/CMakeLists.txt @@ -0,0 +1,17 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(rstsmack-for-update C) + +SET(SRCS rstsmack.c) +INCLUDE(FindPkgConfig) +pkg_check_modules(pkgs REQUIRED libsmack) + +FOREACH(flag ${pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC") + +ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} -pie) + +INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME} DESTINATION bin) diff --git a/rstsmack/rstsmack.c b/rstsmack/rstsmack.c new file mode 100644 index 0000000..e17d696 --- /dev/null +++ b/rstsmack/rstsmack.c @@ -0,0 +1,154 @@ +/* + * rstsmack - Restore smack attributes on files + * + * Copyright (c) 2000 - 2017 Samsung Electronics Co., Ltd. + * + * Contact: MyoungJune Park + * Created by Wonil Choi + * + * 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. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef DEBUG +# define LOGINFO(fmt, arg...) printf(fmt, ##arg) +#else +# define LOGINFO(fmt, arg...) +#endif + +void print_help(const char *cmd) +{ + printf("Usage: %s \n", cmd); + printf(" INPUT FILE should be same format as generated by" + " chsmack.\n\n"); + printf(" Ex) # chsmack /usr/bin/* > /tmp/rstsmack_input.txt\n"); +} + +static inline int abandonqm(char *label) +{ + int ret = 0; + /* ignore last character which must be a quotation mark */ + ret = (int) strlen(label); + ret--; + if (ret > SMACK_LABEL_LEN || ret <= 0) + return -1; + label[ret] = '\0'; + return 0; +} + +static void set_label(const char *pathname, char *label, int type) +{ + int ret = -1; + + if (abandonqm(label) == 0) { + ret = smack_lsetlabel(pathname, label, type); + if (ret < 0) + perror(pathname); + } else + fprintf(stderr, "The input file has wrong format, %s\n", + pathname); +} + +static int parse_and_set(const char *srcfile) +{ + /* We assume the text format of input file is same as chsmack output */ + FILE *fp; + int ret = 0; + char linebuf[PATH_MAX + 5 * SMACK_LABEL_LEN], pathname[PATH_MAX]; + char label[SMACK_LABEL_LEN + 1]; + char *plabel; /* pointer of beginning smack label */ + fp = fopen(srcfile, "r"); + if (fp == NULL) + return -1; + + while (fgets(linebuf, sizeof(linebuf), fp)) { + plabel = strstr(linebuf, " access="); + + if (plabel && strlen(plabel) >= SMACK_LABEL_LEN) { // handling "The maximum input length is not specified" + fclose(fp); + return -1; + } + if (plabel && linebuf != plabel) { + *plabel = '\0'; + strncpy(pathname, linebuf, sizeof(pathname)); + pathname[sizeof(pathname) - 1] = '\0'; + plabel++; + } else { + linebuf[strlen(linebuf) - 1] = '\0'; + LOGINFO("no label, set label: %s, access=\"_\"(floor)\n", linebuf); + strncpy(label, "_\"", SMACK_LABEL_LEN); + set_label(linebuf, label, SMACK_LABEL_ACCESS); + /* TODO: If file name contains " access=" then it would + * not be processed */ + continue; + } + + LOGINFO("set label: %s,", pathname); + + ret = sscanf(plabel, "access=\"%s", label); + if (ret > 0) { + LOGINFO(" access: \"%s", label); + set_label(pathname, label, SMACK_LABEL_ACCESS); + plabel = plabel + sizeof(" access=\"") + strlen(label); + } + + ret = sscanf(plabel, "execute=\"%s", label); + if (ret > 0) { + LOGINFO(", exec: \"%s", label); + set_label(pathname, label, SMACK_LABEL_EXEC); + plabel = plabel + sizeof(" execute=\"") + strlen(label); + } + + ret = sscanf(plabel, "mmap=\"%s", label); + if (ret > 0) { + LOGINFO(", mmap: \"%s", label); + set_label(pathname, label, SMACK_LABEL_MMAP); + plabel = plabel + sizeof(" mmap=\"") + strlen(label); + } + + ret = sscanf(plabel, "transmute=\"%s", label); + if (ret > 0) { + LOGINFO(", transmute: \"%s", label); + strncpy(label, "1\"", SMACK_LABEL_LEN); + set_label(pathname, label, SMACK_LABEL_TRANSMUTE); + } + LOGINFO("\n"); + + } + + fclose(fp); + return 0; +} + +int main(int argc, char *argv[]) +{ + if (argc < 2) { + print_help(argv[0]); + return -1; + } + if (parse_and_set(argv[1]) < 0) { + print_help(argv[0]); + return -1; + } + return 0; +} -- 2.7.4 From 814f70c0c4dd4a766cbbdfe49e82fbef62621b6c Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Fri, 5 Jan 2018 09:36:48 +0900 Subject: [PATCH 07/16] Apply changes of rw-update-macro According to recent patch, update-init.sh is required to be changed a little. Change-Id: I7b2a5ab1b6afc5ee3c1e9e41fba827090e9e7f92 Signed-off-by: Sunmin Lee --- upgrade/update-init.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/upgrade/update-init.sh b/upgrade/update-init.sh index 6825aeb..c57f52f 100755 --- a/upgrade/update-init.sh +++ b/upgrade/update-init.sh @@ -12,10 +12,10 @@ if [ -f $RW_MACRO ]; then get_version_info fi -if [ "$NEW_VER" = "4.0" ]; then +if [ ! "$OLD_VER" = "$NEW_VER" ]; then # Restore rpm db rm -rf /var/lib/rpm/* - restore_backup_file -r /opt/var/lib/rpm + restore_backup_file -f /opt/var/lib/rpm fi # Permission Update for shared directories -- 2.7.4 From f45055895ea16e0c36bbae3c9f990b8ffabf1b1e Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Fri, 19 Jan 2018 15:40:23 +0900 Subject: [PATCH 08/16] rw-update-macro: support -r option for compatibility The -r option of restore_backup_file was removed and it has restored directory recursively as default. However, this option is still required to consider compatibility. Change-Id: I2d49628a107f11739c641e19033404c7d325c55d Signed-off-by: Sunmin Lee --- upgrade/rw-update-macro.inc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/upgrade/rw-update-macro.inc b/upgrade/rw-update-macro.inc index 31e1f1e..ef7797b 100644 --- a/upgrade/rw-update-macro.inc +++ b/upgrade/rw-update-macro.inc @@ -78,6 +78,8 @@ restore_backup_file() { -f ) OVERWRITE=$1 ;; + -r ) + ;; * ) RESTORE_PATH=$1 ;; -- 2.7.4 From 8f0baa4366b2e4c594c992e3fccd1afef32a40eb Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Thu, 26 Jul 2018 13:54:33 +0900 Subject: [PATCH 09/16] Apply update path config The new platform config path TZ_SYS_UPGRADE is introduced. Apply it to each file. Change-Id: I7a9642e8ab9743d52e8e731970054f44b64b93c0 Signed-off-by: Sunmin Lee --- CMakeLists.txt | 7 +++++++ packaging/system-rw-update.spec | 23 ++++++++++++++++------ ...ne-update.service => offline-update.service.in} | 2 +- ...v-sdb-init.service => udev-sdb-init.service.in} | 2 +- ...{install-sdb-rule.sh => install-sdb-rule.sh.in} | 4 ++-- .../{record-version.sh => record-version.sh.in} | 2 +- upgrade/{update-init.sh => update-init.sh.in} | 4 ++-- upgrade/{update.sh => update.sh.in} | 15 +++++++------- 8 files changed, 39 insertions(+), 20 deletions(-) rename units/{offline-update.service => offline-update.service.in} (80%) rename units/{udev-sdb-init.service => udev-sdb-init.service.in} (76%) rename upgrade/{install-sdb-rule.sh => install-sdb-rule.sh.in} (59%) rename upgrade/{record-version.sh => record-version.sh.in} (63%) rename upgrade/{update-init.sh => update-init.sh.in} (84%) rename upgrade/{update.sh => update.sh.in} (88%) diff --git a/CMakeLists.txt b/CMakeLists.txt index f291c00..4559f6b 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,13 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(rw-updater C) +CONFIGURE_FILE(upgrade/install-sdb-rule.sh.in upgrade/install-sdb-rule.sh @ONLY) +CONFIGURE_FILE(upgrade/update-init.sh.in upgrade/update-init.sh @ONLY) +CONFIGURE_FILE(upgrade/update.sh.in upgrade/update.sh @ONLY) +CONFIGURE_FILE(upgrade/record-version.sh.in upgrade/record-version.sh @ONLY) +CONFIGURE_FILE(units/udev-sdb-init.service.in units/udev-sdb-init.service @ONLY) +CONFIGURE_FILE(units/offline-update.service.in units/offline-update.service @ONLY) + #add sub directory ADD_SUBDIRECTORY(rw-update-ani) ADD_SUBDIRECTORY(rstsmack) diff --git a/packaging/system-rw-update.spec b/packaging/system-rw-update.spec index f9f70b7..7145b3f 100644 --- a/packaging/system-rw-update.spec +++ b/packaging/system-rw-update.spec @@ -1,6 +1,6 @@ Name: system-rw-update Summary: System RW update management -Version: 1.2.1 +Version: 1.2.2 Release: 0 Group: Base/Startup License: Apache-2.0 @@ -9,6 +9,7 @@ Source1001: %{name}.manifest Source1002: %{name}-ani.manifest BuildRequires: cmake +BuildRequires: pkgconfig(libtzplatform-config) %description This package provides files for RW update @@ -36,14 +37,24 @@ cp %{SOURCE1001} . cp %{SOURCE1002} . export LDFLAGS+="-Wl,--rpath=%{_prefix}/lib -Wl,--as-needed" -LDFLAGS="$LDFLAGS" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} +LDFLAGS="$LDFLAGS" +cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \ + -DTZ_SYS_UPGRADE=%TZ_SYS_UPGRADE \ + -DTZ_SYS_UPGRADE_SCRIPTS=%TZ_SYS_UPGRADE_SCRIPTS \ + -DTZ_SYS_UPGRADE_DATA=%TZ_SYS_UPGRADE_DATA %__make %{?_smp_mflags} %install %make_install -mkdir -p %{buildroot}%{_datadir} -cp -r upgrade %{buildroot}%{_datadir} +%define upgrade_dir %TZ_SYS_UPGRADE +mkdir -p %{buildroot}%{upgrade_dir} +cp upgrade/99-sdb-switch.rules %{buildroot}%{upgrade_dir} +cp upgrade/install-sdb-rule.sh %{buildroot}%{upgrade_dir} +cp upgrade/record-version.sh %{buildroot}%{upgrade_dir} +cp upgrade/rw-update-macro.inc %{buildroot}%{upgrade_dir} +cp upgrade/update-init.sh %{buildroot}%{upgrade_dir} +cp upgrade/update.sh %{buildroot}%{upgrade_dir} mkdir -p %{buildroot}%{_unitdir}/system-update.target.wants install -m 644 units/offline-update.service %{buildroot}%{_unitdir} ln -s ../offline-update.service %{buildroot}%{_unitdir}/system-update.target.wants/offline-update.service @@ -65,7 +76,7 @@ if [ -e %{_libdir}/udev/rules.d/99-sdb-switch.rules ]; then echo "Exist 99-sdb-switch.rules, Skip!" else mkdir -p %{_libdir}/udev/rules.d - ln -s /opt/data/update/99-sdb-switch.rules %{_libdir}/udev/rules.d + ln -s %TZ_SYS_UPGRADE_DATA/99-sdb-switch.rules %{_libdir}/udev/rules.d fi if [ ! -e %{_bindir}/rstsmack ]; then ln -s %{_bindir}/rstsmack-for-update %{_bindir}/rstsmack @@ -74,7 +85,7 @@ fi %files %manifest %{name}.manifest %license LICENSE.Apache-2.0 -%{_datadir}/upgrade/* +%TZ_SYS_UPGRADE/* %{_unitdir}/offline-update.service %{_unitdir}/system-update.target.wants %{_unitdir}/udev-sdb-init.service diff --git a/units/offline-update.service b/units/offline-update.service.in similarity index 80% rename from units/offline-update.service rename to units/offline-update.service.in index cb81600..5fb87e2 100644 --- a/units/offline-update.service +++ b/units/offline-update.service.in @@ -7,4 +7,4 @@ After=sysinit.target [Service] Type=oneshot SmackProcessLabel=System::Privileged -ExecStart=/usr/share/upgrade/update-init.sh +ExecStart=@TZ_SYS_UPGRADE@/update-init.sh diff --git a/units/udev-sdb-init.service b/units/udev-sdb-init.service.in similarity index 76% rename from units/udev-sdb-init.service rename to units/udev-sdb-init.service.in index 893a1fb..812610f 100644 --- a/units/udev-sdb-init.service +++ b/units/udev-sdb-init.service.in @@ -6,4 +6,4 @@ Before=sysinit.target systemd-udevd.service [Service] SmackProcessLabel=System Type=oneshot -ExecStart=/usr/share/upgrade/install-sdb-rule.sh +ExecStart=@TZ_SYS_UPGRADE@/install-sdb-rule.sh diff --git a/upgrade/install-sdb-rule.sh b/upgrade/install-sdb-rule.sh.in similarity index 59% rename from upgrade/install-sdb-rule.sh rename to upgrade/install-sdb-rule.sh.in index 6bff17c..4adfaae 100755 --- a/upgrade/install-sdb-rule.sh +++ b/upgrade/install-sdb-rule.sh.in @@ -1,9 +1,9 @@ #!/bin/bash SDB_RULE="99-sdb-switch.rules" -DEST=/opt/data/update +DEST=@TZ_SYS_UPGRADE_DATA@ if [ ! -e ${DEST}/${SDB_RULE} ]; then /bin/mkdir -p ${DEST} - /bin/cp /usr/share/upgrade/${SDB_RULE} ${DEST} + /bin/cp @TZ_SYS_UPGRADE@/${SDB_RULE} ${DEST} fi diff --git a/upgrade/record-version.sh b/upgrade/record-version.sh.in similarity index 63% rename from upgrade/record-version.sh rename to upgrade/record-version.sh.in index 9f74a06..4ce57d2 100755 --- a/upgrade/record-version.sh +++ b/upgrade/record-version.sh.in @@ -1,5 +1,5 @@ #!/bin/sh -RW_MACRO=/usr/share/upgrade/rw-update-macro.inc +RW_MACRO=@TZ_SYS_UPGRADE@/rw-update-macro.inc if [ -e ${RW_MACRO} ]; then source ${RW_MACRO} diff --git a/upgrade/update-init.sh b/upgrade/update-init.sh.in similarity index 84% rename from upgrade/update-init.sh rename to upgrade/update-init.sh.in index c57f52f..db05a1b 100755 --- a/upgrade/update-init.sh +++ b/upgrade/update-init.sh.in @@ -3,8 +3,8 @@ # RW update initialize script # PATH=/bin:/usr/bin:/sbin:/usr/sbin -RW_MACRO=/usr/share/upgrade/rw-update-macro.inc -RW_UPDATE=/usr/share/upgrade/update.sh +RW_MACRO=@TZ_SYS_UPGRADE@/rw-update-macro.inc +RW_UPDATE=@TZ_SYS_UPGRADE@/update.sh DEBUG_MODE=/opt/usr/.upgdebug if [ -f $RW_MACRO ]; then diff --git a/upgrade/update.sh b/upgrade/update.sh.in similarity index 88% rename from upgrade/update.sh rename to upgrade/update.sh.in index 8ead592..999a71b 100755 --- a/upgrade/update.sh +++ b/upgrade/update.sh.in @@ -7,13 +7,14 @@ PATH=/bin:/usr/bin:/sbin:/usr/sbin UPI_RW_UPDATE_ERROR=fa1a TMP_DIR=/tmp/upgrade -PATCH_DIR=/usr/share/upgrade/scripts -UPDATE_DIR=/opt/data/update -LOG_FILE=${UPDATE_DIR}/rw_update.log -RESULT_FILE=${UPDATE_DIR}/result -SDB_RULE=${UPDATE_DIR}/99-sdb-switch.rules +UPDATE_DIR=@TZ_SYS_UPGRADE@ +PATCH_DIR=@TZ_SYS_UPGRADE_SCRIPTS@ +UPDATE_DATA_DIR=@TZ_SYS_UPGRADE_DATA@ +LOG_FILE=${UPDATE_DATA_DIR}/rw_update.log +RESULT_FILE=${UPDATE_DATA_DIR}/result +SDB_RULE=${UPDATE_DATA_DIR}/99-sdb-switch.rules VERSION_FILE=/opt/etc/version -RW_MACRO=/usr/share/upgrade/rw-update-macro.inc +RW_MACRO=${UPDATE_DIR}/rw-update-macro.inc RUN=/bin/sh RW_GUI= @@ -33,7 +34,7 @@ Verity_Check() { fi SC_FILE=`/usr/bin/basename $1` - SC_LIST=/usr/share/upgrade/rw-script.list + SC_LIST=${UPDATE_DIR}/rw-script.list if [ -f ${SC_LIST} ]; then grep ${SC_FILE} ${SC_LIST} > /dev/null 2>&1 if [ "$?" = "0" ]; then -- 2.7.4 From e7f411997911eba1b0f016a5b265afd7e72c6723 Mon Sep 17 00:00:00 2001 From: Kichan Kwon Date: Thu, 18 Apr 2019 17:51:10 +0900 Subject: [PATCH 10/16] Define PATH environment variable Change-Id: I0fb2b1258b1a209b115af55be1b0091b35d72a00 Signed-off-by: Kichan Kwon --- upgrade/install-sdb-rule.sh.in | 2 ++ upgrade/record-version.sh.in | 2 ++ 2 files changed, 4 insertions(+) diff --git a/upgrade/install-sdb-rule.sh.in b/upgrade/install-sdb-rule.sh.in index 4adfaae..6b0e067 100755 --- a/upgrade/install-sdb-rule.sh.in +++ b/upgrade/install-sdb-rule.sh.in @@ -1,5 +1,7 @@ #!/bin/bash +PATH="/usr/bin:/bin:/usr/sbin:/sbin" + SDB_RULE="99-sdb-switch.rules" DEST=@TZ_SYS_UPGRADE_DATA@ diff --git a/upgrade/record-version.sh.in b/upgrade/record-version.sh.in index 4ce57d2..a7830dc 100755 --- a/upgrade/record-version.sh.in +++ b/upgrade/record-version.sh.in @@ -1,4 +1,6 @@ #!/bin/sh +PATH="/usr/bin:/bin:/usr/sbin:/sbin" + RW_MACRO=@TZ_SYS_UPGRADE@/rw-update-macro.inc if [ -e ${RW_MACRO} ]; then -- 2.7.4 From 935e4d5867f45cc1d9f482dc1d49f8766b2ecb6c Mon Sep 17 00:00:00 2001 From: Jeon Sang-Heon Date: Tue, 16 Jul 2019 12:20:37 +0900 Subject: [PATCH 11/16] Modify memory leak issue Change-Id: I890bee6d8857eceda7d877d2f64448ffe67667c4 Signed-off-by: Jeon Sang-Heon --- rw-update-ani/rw-update-ani_new.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rw-update-ani/rw-update-ani_new.c b/rw-update-ani/rw-update-ani_new.c index e7c061a..5b62384 100755 --- a/rw-update-ani/rw-update-ani_new.c +++ b/rw-update-ani/rw-update-ani_new.c @@ -78,7 +78,7 @@ static void update_lang(void) setenv("LC_MESSAGES", lang, 1); r = setlocale(LC_ALL, ""); if (r == NULL) { - r = setlocale(LC_ALL, vconf_get_str(VCONFKEY_LANGSET)); + r = setlocale(LC_ALL, lang); if (r) _DEBUG_LOG("***** setlocale=%s\n", r); } -- 2.7.4 From ce564395abbd80a1a06de2d01477740b31533d5c Mon Sep 17 00:00:00 2001 From: Kichan Kwon Date: Tue, 16 Jul 2019 15:53:48 +0900 Subject: [PATCH 12/16] rw-update-ani : apply HWC(HardWard Composer) - Wearable targets use HWC windows since Tizen 5.5 - Commit via HWC if backend has HWC capability Change-Id: Ie2ffd2746b8fc92aef7c4306d47b3f6af9e8c63a Signed-off-by: Kichan Kwon --- packaging/system-rw-update.spec | 2 +- rw-update-ani/rw-update_new_common_display.h | 3 + rw-update-ani/rw-update_new_tdm_display.c | 120 ++++++++++++++++++--------- 3 files changed, 86 insertions(+), 39 deletions(-) diff --git a/packaging/system-rw-update.spec b/packaging/system-rw-update.spec index 7145b3f..45b9a1a 100644 --- a/packaging/system-rw-update.spec +++ b/packaging/system-rw-update.spec @@ -1,6 +1,6 @@ Name: system-rw-update Summary: System RW update management -Version: 1.2.2 +Version: 1.2.3 Release: 0 Group: Base/Startup License: Apache-2.0 diff --git a/rw-update-ani/rw-update_new_common_display.h b/rw-update-ani/rw-update_new_common_display.h index d3073f3..456e184 100755 --- a/rw-update-ani/rw-update_new_common_display.h +++ b/rw-update-ani/rw-update_new_common_display.h @@ -55,6 +55,9 @@ typedef struct chg_common_disp { int stride; int current_buf_id; int degree; + + bool use_tdm_hwc; + tdm_hwc *hwc; } common_disp; typedef enum { diff --git a/rw-update-ani/rw-update_new_tdm_display.c b/rw-update-ani/rw-update_new_tdm_display.c index ecf8ec5..a8ff0f7 100755 --- a/rw-update-ani/rw-update_new_tdm_display.c +++ b/rw-update-ani/rw-update_new_tdm_display.c @@ -114,6 +114,12 @@ int chg_common_display_init(common_disp *st_disp) goto exit; } + err = tdm_output_set_mode(output, &output_mode[0]); + if (err != TDM_ERROR_NONE) { + _DEBUG_EXCEPTION("failed to set mode. error num = %d\n", err); + goto exit; + } + /* GET MODE INFO */ st_disp->output = output; st_disp->width = output_mode->hdisplay; @@ -197,41 +203,57 @@ int chg_common_display_init(common_disp *st_disp) } #endif - /* SET LAYER */ - tdm_layer_capability layer_caps; - tdm_layer *tmp_layer = NULL; + /* CHECK HWC USAGE */ + tdm_output_capability output_caps; + tdm_output_get_capabilities(st_disp->output, &output_caps); + if (output_caps & TDM_OUTPUT_CAPABILITY_HWC) + st_disp->use_tdm_hwc = true; + else + st_disp->use_tdm_hwc = false; - for (i = 0; i < output_count; i++) { - tmp_layer = tdm_output_get_layer(st_disp->output, output_count, &err); - tdm_layer_get_capabilities(tmp_layer, &layer_caps); - if (layer_caps & TDM_LAYER_CAPABILITY_PRIMARY) - break; - } + /* SET LAYER */ + if (st_disp->use_tdm_hwc) { + st_disp->hwc = tdm_output_get_hwc(st_disp->output, &err); + if (!st_disp->hwc) { + _DEBUG_EXCEPTION("failed to get hwc. error num = %d\n", err); + goto exit; + } + } else { + tdm_layer_capability layer_caps; + tdm_layer *tmp_layer = NULL; + + for (i = 0; i < output_count; i++) { + tmp_layer = tdm_output_get_layer(st_disp->output, output_count, &err); + tdm_layer_get_capabilities(tmp_layer, &layer_caps); + if (layer_caps & TDM_LAYER_CAPABILITY_PRIMARY) + break; + } - if (!tmp_layer) { - _DEBUG_EXCEPTION("failed to get output layer. error num = %d\n", err); - goto exit; - } + if (!tmp_layer) { + _DEBUG_EXCEPTION("failed to get output layer. error num = %d\n", err); + goto exit; + } - st_disp->layer = tmp_layer; - - layer_info.src_config.size.h = st_disp->width; - layer_info.src_config.size.v = st_disp->height; - layer_info.src_config.pos.x = 0; - layer_info.src_config.pos.y = 0; - layer_info.src_config.pos.w = st_disp->width; - layer_info.src_config.pos.h = st_disp->height; - layer_info.src_config.format = TBM_FORMAT_ARGB8888; - layer_info.dst_pos.x = 0; - layer_info.dst_pos.y = 0; - layer_info.dst_pos.w = st_disp->width; - layer_info.dst_pos.h = st_disp->height; - layer_info.transform = TDM_TRANSFORM_NORMAL; - - err = tdm_layer_set_info(st_disp->layer, &layer_info); - if (err != TDM_ERROR_NONE) { - _DEBUG_EXCEPTION("failed to get output layer. error num = %d\n", err); - goto exit; + st_disp->layer = tmp_layer; + + layer_info.src_config.size.h = st_disp->width; + layer_info.src_config.size.v = st_disp->height; + layer_info.src_config.pos.x = 0; + layer_info.src_config.pos.y = 0; + layer_info.src_config.pos.w = st_disp->width; + layer_info.src_config.pos.h = st_disp->height; + layer_info.src_config.format = TBM_FORMAT_ARGB8888; + layer_info.dst_pos.x = 0; + layer_info.dst_pos.y = 0; + layer_info.dst_pos.w = st_disp->width; + layer_info.dst_pos.h = st_disp->height; + layer_info.transform = TDM_TRANSFORM_NORMAL; + + err = tdm_layer_set_info(st_disp->layer, &layer_info); + if (err != TDM_ERROR_NONE) { + _DEBUG_EXCEPTION("failed to get output layer. error num = %d\n", err); + goto exit; + } } /* SETUP PP */ @@ -366,10 +388,21 @@ void chg_common_display_rotate(common_disp *st_disp) return; } - tdm_layer_set_buffer(st_disp->layer, st_disp->pp_surf[buf_cnt]); + if (st_disp->use_tdm_hwc) { + uint32_t num_types; + tdm_region damage; + memset(&damage, 0, sizeof(damage)); + + tdm_hwc_set_client_target_buffer(st_disp->hwc, st_disp->surf[buf_cnt], damage); + tdm_hwc_validate(st_disp->hwc, NULL, 0, &num_types); + tdm_hwc_accept_validation(st_disp->hwc); + tdm_hwc_commit(st_disp->hwc, 1, chg_common_display_commit_handler_cb, st_disp); + } else { + tdm_layer_set_buffer(st_disp->layer, st_disp->pp_surf[buf_cnt]); - // TODO: sync or async?? - tdm_output_commit(st_disp->output, 1, chg_common_display_commit_handler_cb, st_disp); + // TODO: sync or async?? + tdm_output_commit(st_disp->output, 1, chg_common_display_commit_handler_cb, st_disp); + } } #endif @@ -382,10 +415,21 @@ void chg_common_display_update(common_disp *st_disp) buf_cnt = st_disp->current_buf_id; //st_disp->current_buf_id = (++st_disp->current_buf_id)%MAX_BUF; - tdm_layer_set_buffer(st_disp->layer, st_disp->surf[buf_cnt]); + if (st_disp->use_tdm_hwc) { + uint32_t num_types; + tdm_region damage; + memset(&damage, 0, sizeof(damage)); + + tdm_hwc_set_client_target_buffer(st_disp->hwc, st_disp->surf[buf_cnt], damage); + tdm_hwc_validate(st_disp->hwc, NULL, 0, &num_types); + tdm_hwc_accept_validation(st_disp->hwc); + tdm_hwc_commit(st_disp->hwc, 1, chg_common_display_commit_handler_cb, st_disp); + } else { + tdm_layer_set_buffer(st_disp->layer, st_disp->surf[buf_cnt]); - // TODO: sync or async?? - tdm_output_commit(st_disp->output, 1, chg_common_display_commit_handler_cb, st_disp); + // TODO: sync or async?? + tdm_output_commit(st_disp->output, 1, chg_common_display_commit_handler_cb, st_disp); + } return; } -- 2.7.4 From 1c2b4639fa98a0de7f13674c6e83bd3b398b61c6 Mon Sep 17 00:00:00 2001 From: Kichan Kwon Date: Fri, 19 Jul 2019 16:34:26 +0900 Subject: [PATCH 13/16] Revert TZ_SYS_UPGRADE_DATA Change-Id: Ic5198e24f2922abbd69a421158aeb2bec74d592a Signed-off-by: Kichan Kwon --- packaging/system-rw-update.spec | 5 ++--- upgrade/install-sdb-rule.sh.in | 2 +- upgrade/update.sh.in | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packaging/system-rw-update.spec b/packaging/system-rw-update.spec index 45b9a1a..0a7a980 100644 --- a/packaging/system-rw-update.spec +++ b/packaging/system-rw-update.spec @@ -40,8 +40,7 @@ export LDFLAGS+="-Wl,--rpath=%{_prefix}/lib -Wl,--as-needed" LDFLAGS="$LDFLAGS" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \ -DTZ_SYS_UPGRADE=%TZ_SYS_UPGRADE \ - -DTZ_SYS_UPGRADE_SCRIPTS=%TZ_SYS_UPGRADE_SCRIPTS \ - -DTZ_SYS_UPGRADE_DATA=%TZ_SYS_UPGRADE_DATA + -DTZ_SYS_UPGRADE_SCRIPTS=%TZ_SYS_UPGRADE_SCRIPTS %__make %{?_smp_mflags} %install @@ -76,7 +75,7 @@ if [ -e %{_libdir}/udev/rules.d/99-sdb-switch.rules ]; then echo "Exist 99-sdb-switch.rules, Skip!" else mkdir -p %{_libdir}/udev/rules.d - ln -s %TZ_SYS_UPGRADE_DATA/99-sdb-switch.rules %{_libdir}/udev/rules.d + ln -s /opt/data/update/99-sdb-switch.rules %{_libdir}/udev/rules.d fi if [ ! -e %{_bindir}/rstsmack ]; then ln -s %{_bindir}/rstsmack-for-update %{_bindir}/rstsmack diff --git a/upgrade/install-sdb-rule.sh.in b/upgrade/install-sdb-rule.sh.in index 6b0e067..186d409 100755 --- a/upgrade/install-sdb-rule.sh.in +++ b/upgrade/install-sdb-rule.sh.in @@ -3,7 +3,7 @@ PATH="/usr/bin:/bin:/usr/sbin:/sbin" SDB_RULE="99-sdb-switch.rules" -DEST=@TZ_SYS_UPGRADE_DATA@ +DEST=/opt/data/update if [ ! -e ${DEST}/${SDB_RULE} ]; then /bin/mkdir -p ${DEST} diff --git a/upgrade/update.sh.in b/upgrade/update.sh.in index 999a71b..ef11319 100755 --- a/upgrade/update.sh.in +++ b/upgrade/update.sh.in @@ -9,7 +9,7 @@ UPI_RW_UPDATE_ERROR=fa1a TMP_DIR=/tmp/upgrade UPDATE_DIR=@TZ_SYS_UPGRADE@ PATCH_DIR=@TZ_SYS_UPGRADE_SCRIPTS@ -UPDATE_DATA_DIR=@TZ_SYS_UPGRADE_DATA@ +UPDATE_DATA_DIR=/opt/data/update LOG_FILE=${UPDATE_DATA_DIR}/rw_update.log RESULT_FILE=${UPDATE_DATA_DIR}/result SDB_RULE=${UPDATE_DATA_DIR}/99-sdb-switch.rules -- 2.7.4 From d8d68cc44641cfd1023d1828fdb354be8bed78cf Mon Sep 17 00:00:00 2001 From: Kichan Kwon Date: Fri, 19 Jul 2019 15:47:47 +0900 Subject: [PATCH 14/16] Create the result file even if update is successful Change-Id: Ie9db0b5d1fb35287269aec71849abf2a5c885797 Signed-off-by: Kichan Kwon --- packaging/system-rw-update.spec | 2 +- upgrade/update.sh.in | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packaging/system-rw-update.spec b/packaging/system-rw-update.spec index 0a7a980..41a0371 100644 --- a/packaging/system-rw-update.spec +++ b/packaging/system-rw-update.spec @@ -1,6 +1,6 @@ Name: system-rw-update Summary: System RW update management -Version: 1.2.3 +Version: 1.2.4 Release: 0 Group: Base/Startup License: Apache-2.0 diff --git a/upgrade/update.sh.in b/upgrade/update.sh.in index ef11319..c081ce6 100755 --- a/upgrade/update.sh.in +++ b/upgrade/update.sh.in @@ -4,6 +4,7 @@ # PATH=/bin:/usr/bin:/sbin:/usr/sbin +RW_UPDATE_ERROR_NONE=00 UPI_RW_UPDATE_ERROR=fa1a TMP_DIR=/tmp/upgrade @@ -106,6 +107,7 @@ else sync echo "SUCCESS: Upgrade successfully finished" >> ${LOG_FILE} + echo "${RW_UPDATE_ERROR_NONE}" > ${RESULT_FILE} fi if [ -e ${SDB_RULE} ]; then -- 2.7.4 From 3f9a1ece3ba0c0cd8aa99dcaa4f2c692341a2aff Mon Sep 17 00:00:00 2001 From: Kichan Kwon Date: Thu, 8 Aug 2019 19:45:42 +0900 Subject: [PATCH 15/16] rw-script-list: add efl-misc script Change-Id: Iae4a315daf94f695f5c15e90eb229c809868a266 Signed-off-by: Kichan Kwon --- rw-script-list/rw-script.list | 1 + 1 file changed, 1 insertion(+) diff --git a/rw-script-list/rw-script.list b/rw-script-list/rw-script.list index 1df0cf5..de2ea4f 100755 --- a/rw-script-list/rw-script.list +++ b/rw-script-list/rw-script.list @@ -8,6 +8,7 @@ 500.context-service.sh 323908008385576f5b261f7d5811d8ae 500.crash-manager-upgrade.sh 9f11ad44cde7a8b27d4e69f0a5fa3f74 500.dnet_db_upgrade_30_40.sh 2718a6306157b4eba917c9c940a7f590 +500.efl-misc.sh a74f47437c226f3723c02e5759de2ea0 500.fontconfig.sh dafd6efdcd6b343623f9085606b594aa 500.mcc_mnc_oper_list_upgrade_30_40.sh 83823fa7036779564758a640fc5da58a 500.screen-reader.sh 75f0b2dd6d398d0ef7ab67ed72587d68 -- 2.7.4 From 3096c4778118dd741d036f47ffd8dabb8ad2a75e Mon Sep 17 00:00:00 2001 From: Kichan Kwon Date: Mon, 2 Sep 2019 10:22:26 +0900 Subject: [PATCH 16/16] Run all upgrade scripts without verification result - For each script developer's convenience Change-Id: I665aea2d6b118d4f034bda3c9d1b13caff59d9f5 Signed-off-by: Kichan Kwon --- upgrade/update.sh.in | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/upgrade/update.sh.in b/upgrade/update.sh.in index c081ce6..b2ac574 100755 --- a/upgrade/update.sh.in +++ b/upgrade/update.sh.in @@ -98,10 +98,8 @@ else echo ${progress} > ${TMP_DIR}/progress fi Verity_Check ${PATCH_DIR}/${PATCH} - # Skip in case of 'No entry' only - if [ "$?" != "1" ]; then - ${RUN} ${PATCH_DIR}/${PATCH} - fi + # Without verification result, run all scripts + ${RUN} ${PATCH_DIR}/${PATCH} done sync -- 2.7.4