Name: system-rw-update
-Summary: System RW update management
+Summary: System RW Update Manager
Version: 1.2.4
Release: 0
Group: Base/Startup
Source1001: %{name}.manifest
BuildRequires: cmake
-BuildRequires: pkgconfig(libsmack)
BuildRequires: pkgconfig(libtzplatform-config)
# rstsmack is provided by Public factory-reset
# Please consider it when you migrate this package
Requires: %{_bindir}/rstsmack
+%define upgrade_dir %TZ_SYS_UPGRADE
+
%description
-This package provides files for RW update
-which is implemented by using systemd offline update.
+System RW update manager provides interface for running platform/application update scripts
+after software is updated to new version which is implemented by using systemd offline update.
%prep
%setup -q
%install
-%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/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
+ln -s ../offline-update.service %{buildroot}%{_unitdir}/system-update.target.wants/
ln -s ../getty.target %{buildroot}%{_unitdir}/system-update.target.wants
ln -s ../cynara.socket %{buildroot}%{_unitdir}/system-update.target.wants
ln -s ../dbus.socket %{buildroot}%{_unitdir}/system-update.target.wants
#!/bin/sh
#
-# RW update script
+# System RW Update Script
#
-PATH=/bin:/usr/bin:/sbin:/usr/sbin
COLOR_ERROR='\033[01;31m'
COLOR_DEBUG='\033[01;34m'
COLOR_NOTIFY='\033[01;33m'
COLOR_RESET='\033[00;00m'
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+SHELL=/bin/bash
-RW_UPDATE_ERROR_NONE=00
-
-UPI_RW_UPDATE_ERROR_PREFIX=FA
-UPI_RW_UPDATE_ERROR=${UPI_RW_UPDATE_ERROR_PREFIX}1A
-
-TMP_DIR=/tmp/upgrade
-UPDATE_DIR=@TZ_SYS_UPGRADE@
UPDATE_SCRIPT_DIR=@TZ_SYS_UPGRADE_SCRIPTS@
UPDATE_DATA_DIR=/opt/data/update
-RESULT_FILE=${UPDATE_DATA_DIR}/result
SDB_RULE=${UPDATE_DATA_DIR}/99-sdb-switch.rules
-VERSION_FILE=/opt/etc/version
-RW_MACRO=${UPDATE_DIR}/rw-update-macro.inc
-SHELL=/bin/bash
-RW_GUI=
-RW_ANI=/usr/bin/rw-update-ani
+RW_MACRO=@TZ_SYS_UPGRADE@/rw-update-macro.inc
DEBUG()
{
echo -e "${COLOR_NOTIFY}${LOG_TEXT}${COLOR_RESET}"
}
-#------------------------------------------------
-# main
-#------------------------------------------------
+PROGRESS_DIR=/tmp/upgrade
+PROGRESS_INIT()
+{
+ mkdir -p ${PROGRESS_DIR}
+ echo "$1" > ${PROGRESS_DIR}/total
+ echo "0" > ${PROGRESS_DIR}/progress
-# Check GUI availability
-if [ -e ${RW_ANI} ]; then
- RW_GUI=1
-fi
+ # if GUI is available, run the GUI
+ if [ -e "/usr/bin/rw-update-ani" ]; then
+ export XDG_RUNTIME_DIR=/run
+ export TBM_DISPLAY_SERVER=1
+ /usr/bin/rw-update-ani --wait &
+ fi
+}
+
+PROGRESS()
+{
+ echo "$1" > ${PROGRESS_DIR}/progress
+}
-mkdir -p ${RECOVERY_DIR}
+# This result file will be used for Platform Update Control API to get update result.
+UPDATE_RESULT_FILE=${UPDATE_DATA_DIR}/result
+UPI_RW_UPDATE_ERROR_NONE=00
+UPI_RW_UPDATE_ERROR_PREFIX=FA
+UPI_RW_UPDATE_ERROR_FAIL=${UPI_RW_UPDATE_ERROR_PREFIX}1A
+SET_UPDATE_RESULT()
+{
+ echo "$1" > ${UPDATE_RESULT_FILE}
+}
+NOTIFY "----------------------------------------------------------------------"
NOTIFY "System RW update: rw update started"
-# Execute update scripts
+UPDATE_PREPARE_ERR=0
+UPDATE_PROGRESS_ERR=0
+
+if [ -f $RW_MACRO ];
+then
+ source $RW_MACRO
+else
+ ERROR "FAIL: Upgrade macro does not exist"
+ UPDATE_PREPARE_ERR=1
+fi
+
if [ ! -d ${UPDATE_SCRIPT_DIR} ]
then
ERROR "FAIL: Upgrade directory does not exist"
- echo "${UPI_RW_UPDATE_ERROR}" > ${RESULT_FILE}
+ UPDATE_PREPARE_ERR=1
+fi
+
+# Execute update scripts
+if [ ${UPDATE_PREPARE_ERR} = "1" ]
+then
+ ERROR "FAIL: Update preparation was failed"
+ SET_UPDATE_RESULT ${UPI_RW_UPDATE_ERROR_FAIL}
else
- if [ "${RW_GUI}" = "1" ]; then
- progress=0
- total=`ls -l ${UPDATE_SCRIPT_DIR} | grep -c '^-'`
- mkdir -p ${TMP_DIR}
- echo ${total} > ${TMP_DIR}/total
- export XDG_RUNTIME_DIR=/run
- export TBM_DISPLAY_SERVER=1
- /usr/bin/rw-update-ani --wait &
- fi
+ get_version_info
+ DEBUG "Version OLD: ${OLD_VER}, NEW: ${NEW_VER}"
- UPDATE_SCRIPTS=`/bin/ls ${UPDATE_SCRIPT_DIR}`
+ TOTAL_TASKS=`ls -l ${UPDATE_SCRIPT_DIR} | grep -c '^-'`
+ PROGRESS_INIT ${TOTAL_TASKS}
+ UPDATE_SCRIPTS=`/bin/ls ${UPDATE_SCRIPT_DIR}`
+ NOTIFY "TOTAL TASKS: ${TOTAL_TASKS}"
for UPSCRIPT in ${UPDATE_SCRIPTS}; do
- if [ "${RW_GUI}" = "1" ]; then
- progress=$((progress+1))
- echo ${progress} > ${TMP_DIR}/progress
- fi
+ NOTIFY "CURRENT TASK: ${CURRENT_TASK} ${UPSCRIPT}"
${SHELL} ${UPDATE_SCRIPT_DIR}/${UPSCRIPT}
if [ $? -ne 0 ]; then
ERROR "[FAIL] ${UPSCRIPT}"
+ UPDATE_PROGRESS_ERR=1
else
DEBUG "[DONE] ${UPSCRIPT}"
fi
+ PROGRESS ${CURRENT_TASK}
+ CURRENT_TASK=$(( ${CURRENT_TASK} + 1 ))
done
- sync
+ write_version_info
- NOTIFY "SUCCESS: Upgrade successfully finished"
- echo "${RW_UPDATE_ERROR_NONE}" > ${RESULT_FILE}
+ if [ ${UPDATE_PROGRESS_ERR} = "1" ]
+ then
+ NOTIFY "SUCCESS: Upgrade finished, but some scripts are failed"
+ SET_UPDATE_RESULT ${UPI_RW_UPDATE_ERROR_FAIL}
+ else
+ NOTIFY "SUCCESS: Upgrade successfully finished"
+ SET_UPDATE_RESULT ${UPI_RW_UPDATE_ERROR_NONE}
+ fi
fi
if [ -e ${SDB_RULE} ]; then
rm ${SDB_RULE}
fi
-if [ -e ${VERSION_FILE} ]; then
- rm ${VERSION_FILE}
- if [ -e ${RW_MACRO} ]; then
- source ${RW_MACRO}
- write_version_info
- fi
-fi
+/bin/sync
+NOTIFY "----------------------------------------------------------------------"
-# Reboot
-reboot -f
+#Reboot
+/sbin/reboot -f