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
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
%{_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
--- /dev/null
+[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
--- /dev/null
+#!/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
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
# 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
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
Verity_Check() {
if [ "z$1" = "z" ]; then
- echo "Input Shell Script Null" >> ${RESULT_FILE}
+ echo "Input Shell Script Null" >> ${RW_LOG}
return 1
fi
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
}
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
sync
- echo "SUCCESS: Upgrade successfully finished" >> ${RESULT_FILE}
+ echo "SUCCESS: Upgrade successfully finished" >> ${RW_LOG}
fi
if [ -e ${SDB_RULE} ]; then