From 60992a2600cd9a21389b59653a433cdc815915f6 Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Tue, 12 Sep 2017 13:14:06 +0900 Subject: [PATCH 01/16] Introduce recovery-update.service The recovery partition used to be updated separately in the first boot after update other partitions. This service implements recovery partition update in normal boot mode. Change-Id: Ie6e5966e5a6760daad87d304eb556aa8ad15ad02 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, 138 insertions(+), 10 deletions(-) create mode 100755 units/recovery-update.service create mode 100755 upgrade/recovery-update.sh diff --git a/packaging/system-rw-update.spec b/packaging/system-rw-update.spec index 954ec3b..df736d0 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.1.0 Release: 0 Group: Base/Startup License: Apache-2.0 @@ -49,6 +49,11 @@ 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}%{_libdir}/systemd/system/multi-user.target.wants/ +install -m 0644 units/recovery-update.service %{buildroot}%{_libdir}/systemd/system/recovery-update.service +ln -s ../recovery-update.service %{buildroot}%{_libdir}/systemd/system/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 @@ -73,6 +78,8 @@ 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 new file mode 100755 index 0000000..478f99c --- /dev/null +++ b/units/recovery-update.service @@ -0,0 +1,12 @@ +[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 new file mode 100755 index 0000000..dc068a5 --- /dev/null +++ b/upgrade/recovery-update.sh @@ -0,0 +1,91 @@ +#!/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 6825aeb..5a02ac3 100755 --- a/upgrade/update-init.sh +++ b/upgrade/update-init.sh @@ -7,6 +7,13 @@ 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 @@ -21,6 +28,17 @@ 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 9129823..ca15404 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 -RESULT_FILE=/opt/data/recovery/rw_result +RW_LOG=/opt/data/recovery/RW.LOG 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" >> ${RESULT_FILE} + echo "Input Shell Script Null" >> ${RW_LOG} 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" >> ${RESULT_FILE} + echo "[PASS ] ${SC_FILE} verity check" >> ${RW_LOG} return 0 else - echo "[MISMATCH] ${SC_FILE} md5sum" >> ${RESULT_FILE} + echo "[MISMATCH] ${SC_FILE} md5sum" >> ${RW_LOG} return 2 fi else - echo "[No entry] ${SC_FILE} in ${SC_LIST}" >> ${RESULT_FILE} + echo "[No entry] ${SC_FILE} in ${SC_LIST}" >> ${RW_LOG} return 1 fi else - echo "No such file ${SC_LIST}" >> ${RESULT_FILE} + echo "No such file ${SC_LIST}" >> ${RW_LOG} return 1 fi } @@ -64,12 +64,12 @@ if [ -e ${RW_ANI} ]; then RW_GUI=1 fi -echo "System RW update: rw update started" > ${RESULT_FILE} +echo "System RW update: rw update started" > ${RW_LOG} # Execute update scripts if [ ! -d ${PATCH_DIR} ] then - echo "FAIL: Upgrade directory does not exist" >> ${RESULT_FILE} + echo "FAIL: Upgrade directory does not exist" >> ${RW_LOG} else if [ "${RW_GUI}" = "1" ]; then progress=0 @@ -97,7 +97,7 @@ else sync - echo "SUCCESS: Upgrade successfully finished" >> ${RESULT_FILE} + echo "SUCCESS: Upgrade successfully finished" >> ${RW_LOG} fi if [ -e ${SDB_RULE} ]; then -- 2.7.4 From a2b7648d86272d0b21cfd2fd2e707e8ef4dd501c Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Fri, 27 Oct 2017 18:56:14 +0900 Subject: [PATCH 02/16] Fix Architecture Dependency Change-Id: I56a8954d8336eb1e471373fb96a895e222563035 Signed-off-by: Sunmin Lee --- packaging/system-rw-update.spec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packaging/system-rw-update.spec b/packaging/system-rw-update.spec index df736d0..84bad20 100644 --- a/packaging/system-rw-update.spec +++ b/packaging/system-rw-update.spec @@ -50,9 +50,9 @@ 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}%{_libdir}/systemd/system/multi-user.target.wants/ -install -m 0644 units/recovery-update.service %{buildroot}%{_libdir}/systemd/system/recovery-update.service -ln -s ../recovery-update.service %{buildroot}%{_libdir}/systemd/system/multi-user.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} -- 2.7.4 From b6a4e080d1fbc5561a16a2463d360853f46ae347 Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Thu, 2 Nov 2017 19:45:20 +0900 Subject: [PATCH 03/16] Remove unused script Change-Id: Ic9ac75bad457020f40439610d33c4e3bf9d9f97a Signed-off-by: Sunmin Lee --- make_upgrade_image.sh | 90 --------------------------------------------------- 1 file changed, 90 deletions(-) delete mode 100755 make_upgrade_image.sh diff --git a/make_upgrade_image.sh b/make_upgrade_image.sh deleted file mode 100755 index c57e978..0000000 --- a/make_upgrade_image.sh +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/sh -# -# make_upgrade_image.sh -# -# Convert Tizen platform image to upgrade image - -# For sdb debugging - -sdb_debugging=1 - -# Back up data -backup () { - if [ $# -lt 2 ]; then - echo "No backup data" - return 0 - fi - - echo "Back up file at $2" - cat $2 - - # Push data for pre-patch (works in initrd) - local backup_path="/usr/share/upgrade/prepatch/data" - local backup_files="$(cat $2)" - local tmp_path=$1 - - umount ${tmp_path} - e2fsck -f rootfs.img - resize2fs rootfs.img 1G - mount rootfs.img ${tmp_path} - - mount system-data.img ${tmp_path}/opt - mount user.img ${tmp_path}/opt/usr - - mkdir -p ${tmp_path}/$backup_path - for file in $backup_files; do - cp -afv ${tmp_path}/$file ${tmp_path}/$backup_path - done - - sync - - umount -l ${tmp_path}/opt/usr - umount -l ${tmp_path}/opt - - umount ${tmp_path} - e2fsck -f rootfs.img - resize2fs -M rootfs.img - mount rootfs.img ${tmp_path} -} - -if [ `id -u` -ne 0 ] -then - echo "make_upgrade_image.sh should be executed as root" - exit -fi - -if [ ! $1 ] -then - echo "usage: $0 [tizen-image-update(tar.gz)]" - exit -fi - -echo "Decompressing $1" -imgs=`tar zxvf $1` - -tmp_root=`mktemp -d system.XXX` -echo "Mount rootfs.img" -mount rootfs.img ${tmp_root} - -cwd=`pwd` -backup ${cwd}/${tmp_root} $2 - -sync -umount ${tmp_root} - -upgrade_img=`echo $1 | sed -e 's/\.tar\.gz//'`-upgrade.tar.gz -echo "Compressing upgrade image ${upgrade_img}" - -ro_imgs= -for img in ${imgs}; do - if [ "${img}" != "system-data.img" ] && [ "${img}" != "user.img" ]; then - ro_imgs="${ro_imgs} ${img}" - fi -done - -tar zcf ${upgrade_img} ${ro_imgs} - -echo "Remove dummies" -rm -rf ${imgs} ${tmp_root} - -echo "Done" -- 2.7.4 From a639738cc13b4ddc4369969862702e82820d6308 Mon Sep 17 00:00:00 2001 From: Kichan Kwon Date: Fri, 1 Dec 2017 11:51:54 +0900 Subject: [PATCH 04/16] Make recovery directory before updating - It is made by initrd-fota, but we can use it without initrd-fota Change-Id: I27eaf314b5d2c826699697fa2778888a77ab988d Signed-off-by: Kichan Kwon --- upgrade/update.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/upgrade/update.sh b/upgrade/update.sh index 9129823..2ad1c0d 100755 --- a/upgrade/update.sh +++ b/upgrade/update.sh @@ -6,8 +6,9 @@ PATH=/bin:/usr/bin:/sbin:/usr/sbin TMP_DIR=/tmp/upgrade PATCH_DIR=/usr/share/upgrade/scripts -RESULT_FILE=/opt/data/recovery/rw_result -SDB_RULE=/opt/data/recovery/99-sdb-switch.rules +RECOVERY_DIR=/opt/data/recovery +RESULT_FILE=${RECOVERY_DIR}/rw_result +SDB_RULE=${RECOVERY_DIR}/99-sdb-switch.rules VERSION_FILE=/opt/etc/version RW_MACRO=/usr/share/upgrade/rw-update-macro.inc RUN=/bin/sh @@ -64,6 +65,8 @@ if [ -e ${RW_ANI} ]; then RW_GUI=1 fi +mkdir -p ${RECOVERY_DIR} + echo "System RW update: rw update started" > ${RESULT_FILE} # Execute update scripts -- 2.7.4 From b791951988c1aac4ebd5c93618af1efaedf11468 Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Mon, 18 Dec 2017 10:10:35 +0900 Subject: [PATCH 05/16] Use the same path for update Change-Id: I0668efafa71b6b56ec7c1136641cc2b8a9d297b8 Signed-off-by: Sunmin Lee --- packaging/system-rw-update.spec | 2 +- upgrade/install-sdb-rule.sh | 2 +- upgrade/update.sh | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packaging/system-rw-update.spec b/packaging/system-rw-update.spec index 954ec3b..fda1f8e 100644 --- a/packaging/system-rw-update.spec +++ b/packaging/system-rw-update.spec @@ -64,7 +64,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/recovery/99-sdb-switch.rules %{_libdir}/udev/rules.d + ln -s /opt/data/update/99-sdb-switch.rules %{_libdir}/udev/rules.d fi %files diff --git a/upgrade/install-sdb-rule.sh b/upgrade/install-sdb-rule.sh index 3fac92f..6bff17c 100755 --- a/upgrade/install-sdb-rule.sh +++ b/upgrade/install-sdb-rule.sh @@ -1,7 +1,7 @@ #!/bin/bash SDB_RULE="99-sdb-switch.rules" -DEST=/opt/data/recovery +DEST=/opt/data/update if [ ! -e ${DEST}/${SDB_RULE} ]; then /bin/mkdir -p ${DEST} diff --git a/upgrade/update.sh b/upgrade/update.sh index 2ad1c0d..e3bb54a 100755 --- a/upgrade/update.sh +++ b/upgrade/update.sh @@ -6,9 +6,9 @@ PATH=/bin:/usr/bin:/sbin:/usr/sbin TMP_DIR=/tmp/upgrade PATCH_DIR=/usr/share/upgrade/scripts -RECOVERY_DIR=/opt/data/recovery -RESULT_FILE=${RECOVERY_DIR}/rw_result -SDB_RULE=${RECOVERY_DIR}/99-sdb-switch.rules +UPDATE_DIR=/opt/data/update +RESULT_FILE=${UPDATE_DIR}/rw_result +SDB_RULE=${UPDATE_DIR}/99-sdb-switch.rules VERSION_FILE=/opt/etc/version RW_MACRO=/usr/share/upgrade/rw-update-macro.inc RUN=/bin/sh -- 2.7.4 From c142ab96426f3ccd162a78bbac7ea65a42984f4d Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Mon, 18 Dec 2017 10:16:59 +0900 Subject: [PATCH 06/16] Divide result into log and result file Change-Id: I1b1659f102f6f4b88a68365d65fcd7714e2b574f Signed-off-by: Sunmin Lee --- upgrade/update.sh | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/upgrade/update.sh b/upgrade/update.sh index e3bb54a..8ead592 100755 --- a/upgrade/update.sh +++ b/upgrade/update.sh @@ -4,10 +4,13 @@ # 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 -RESULT_FILE=${UPDATE_DIR}/rw_result +LOG_FILE=${UPDATE_DIR}/rw_update.log +RESULT_FILE=${UPDATE_DIR}/result SDB_RULE=${UPDATE_DIR}/99-sdb-switch.rules VERSION_FILE=/opt/etc/version RW_MACRO=/usr/share/upgrade/rw-update-macro.inc @@ -25,7 +28,7 @@ RW_ANI=/usr/bin/rw-update-ani Verity_Check() { if [ "z$1" = "z" ]; then - echo "Input Shell Script Null" >> ${RESULT_FILE} + echo "Input Shell Script Null" >> ${LOG_FILE} return 1 fi @@ -40,18 +43,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" >> ${RESULT_FILE} + echo "[PASS ] ${SC_FILE} verity check" >> ${LOG_FILE} return 0 else - echo "[MISMATCH] ${SC_FILE} md5sum" >> ${RESULT_FILE} + echo "[MISMATCH] ${SC_FILE} md5sum" >> ${LOG_FILE} return 2 fi else - echo "[No entry] ${SC_FILE} in ${SC_LIST}" >> ${RESULT_FILE} + echo "[No entry] ${SC_FILE} in ${SC_LIST}" >> ${LOG_FILE} return 1 fi else - echo "No such file ${SC_LIST}" >> ${RESULT_FILE} + echo "No such file ${SC_LIST}" >> ${LOG_FILE} return 1 fi } @@ -67,12 +70,13 @@ fi mkdir -p ${RECOVERY_DIR} -echo "System RW update: rw update started" > ${RESULT_FILE} +echo "System RW update: rw update started" > ${LOG_FILE} # Execute update scripts if [ ! -d ${PATCH_DIR} ] then - echo "FAIL: Upgrade directory does not exist" >> ${RESULT_FILE} + echo "FAIL: Upgrade directory does not exist" >> ${LOG_FILE} + echo "${UPI_RW_UPDATE_ERROR}" > ${RESULT_FILE} else if [ "${RW_GUI}" = "1" ]; then progress=0 @@ -100,7 +104,7 @@ else sync - echo "SUCCESS: Upgrade successfully finished" >> ${RESULT_FILE} + echo "SUCCESS: Upgrade successfully finished" >> ${LOG_FILE} fi if [ -e ${SDB_RULE} ]; then -- 2.7.4 From 9e6fd807b86e90321c3e63fb26b91e3137ea81cd Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Mon, 18 Dec 2017 10:43:05 +0900 Subject: [PATCH 07/16] rw-script-list: update hash values of scripts Change-Id: I4d496522c9ee63c18088aa3fb290277029453bbe Signed-off-by: Sunmin Lee --- rw-script-list/image_info.txt | 2 +- rw-script-list/rw-script.list | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rw-script-list/image_info.txt b/rw-script-list/image_info.txt index 17a70d7..2aa1b26 100644 --- a/rw-script-list/image_info.txt +++ b/rw-script-list/image_info.txt @@ -1,2 +1,2 @@ Base image of RW script list: -tizen-4.0-unified_20171013.5_wearable-wayland-armv7l-tw1 +tizen-4.0-unified_20171215.1_wearable-wayland-armv7l-tw1 diff --git a/rw-script-list/rw-script.list b/rw-script-list/rw-script.list index ae392d0..1df0cf5 100755 --- a/rw-script-list/rw-script.list +++ b/rw-script-list/rw-script.list @@ -1,21 +1,21 @@ 200.filesystem-pre.patch.sh 79b54c435348043a5573cb0611f960a3 -201.security_upgrade.sh 27e9f83367475c42915e1f9dd0b9c763 +201.security_upgrade.sh 5c8b8ea34b3484ae409de1798b6fd14f 210.dlog_upgrade.sh 28fc518a34b338fb83fa8830abd5d50a -299.buxton2_upgrade.sh eb2e5dded9581768e66d093e56c322a5 +299.buxton2_upgrade.sh 978cfae060a388b8ffeaf4ae3efa7215 500.account-manager.sh 5d8b0bbf15b1aecd7b5d146e8dce6d3d -500.bluez_upgrade.sh cfe2be967a740854f004c181c5f7bfa5 +500.bluez_upgrade.sh 09824b61cb3a02423d2a4c529c7cc8bc 500.connman_upgrade.sh 14efbfe125f33d44b22ade08ea64968c 500.context-service.sh 323908008385576f5b261f7d5811d8ae -500.crash-manager-upgrade.sh 743fcd0ffe0557415343123311138765 +500.crash-manager-upgrade.sh 9f11ad44cde7a8b27d4e69f0a5fa3f74 500.dnet_db_upgrade_30_40.sh 2718a6306157b4eba917c9c940a7f590 500.fontconfig.sh dafd6efdcd6b343623f9085606b594aa 500.mcc_mnc_oper_list_upgrade_30_40.sh 83823fa7036779564758a640fc5da58a 500.screen-reader.sh 75f0b2dd6d398d0ef7ab67ed72587d68 500.starter.upgrade.sh 8c8a71d8b5c22322485e2634ef772071 -500.winsys_upgrade.sh dce8187e4eb518f8f36b21955759cbfc +500.winsys_upgrade.sh 3a02e97e2c007ffae542275d5414a73f 502.syspopup_upgrade.sh 80de43183255616ae7635be9293e49a5 505.notification_upgrade.sh d1ffa24f36b0aa265b682f2ca2d0d515 -700.pkgmgr.patch.sh bd40d3ce483e5912f45fb733907f4cdd +700.pkgmgr.patch.sh e809a64bc4f9e55bccf13b14d966a263 701.app2sd.patch.sh 857033620ccd4878446e89c376b61974 -711.security_privacy_package_migration.sh f7f579f189766050c72e0cdf5d6dc2c8 +711.security_privacy_package_migration.sh 69c4ce7f82d9a125f60cdb32b8891c18 720.wrt.upgrade.sh b419dc607df95afbd389b84bccc2f1a7 -- 2.7.4 From 05bac516402f396763da22c12f90fa25630a6494 Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Wed, 20 Dec 2017 11:26:55 +0900 Subject: [PATCH 08/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 09/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 10/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 11/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 12/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 13/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 14/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 15/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 16/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