The new platform config path TZ_SYS_UPGRADE is introduced.
Apply it to each file.
Change-Id: I7a9642e8ab9743d52e8e731970054f44b64b93c0
Signed-off-by: Sunmin Lee <sunm.lee@samsung.com>
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)
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
Source1002: %{name}-ani.manifest
BuildRequires: cmake
+BuildRequires: pkgconfig(libtzplatform-config)
%description
This package provides files for RW update
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
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
%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
+++ /dev/null
-[Unit]
-Description=System update script service
-DefaultDependencies=no
-Requires=sysinit.target
-After=sysinit.target
-
-[Service]
-Type=oneshot
-SmackProcessLabel=System::Privileged
-ExecStart=/usr/share/upgrade/update-init.sh
--- /dev/null
+[Unit]
+Description=System update script service
+DefaultDependencies=no
+Requires=sysinit.target
+After=sysinit.target
+
+[Service]
+Type=oneshot
+SmackProcessLabel=System::Privileged
+ExecStart=@TZ_SYS_UPGRADE@/update-init.sh
+++ /dev/null
-[Unit]
-Description=Install rule for udev sdb
-DefaultDependencies=no
-Before=sysinit.target systemd-udevd.service
-
-[Service]
-SmackProcessLabel=System
-Type=oneshot
-ExecStart=/usr/share/upgrade/install-sdb-rule.sh
--- /dev/null
+[Unit]
+Description=Install rule for udev sdb
+DefaultDependencies=no
+Before=sysinit.target systemd-udevd.service
+
+[Service]
+SmackProcessLabel=System
+Type=oneshot
+ExecStart=@TZ_SYS_UPGRADE@/install-sdb-rule.sh
+++ /dev/null
-#!/bin/bash
-
-SDB_RULE="99-sdb-switch.rules"
-DEST=/opt/data/update
-
-if [ ! -e ${DEST}/${SDB_RULE} ]; then
- /bin/mkdir -p ${DEST}
- /bin/cp /usr/share/upgrade/${SDB_RULE} ${DEST}
-fi
--- /dev/null
+#!/bin/bash
+
+SDB_RULE="99-sdb-switch.rules"
+DEST=@TZ_SYS_UPGRADE_DATA@
+
+if [ ! -e ${DEST}/${SDB_RULE} ]; then
+ /bin/mkdir -p ${DEST}
+ /bin/cp @TZ_SYS_UPGRADE@/${SDB_RULE} ${DEST}
+fi
+++ /dev/null
-#!/bin/sh
-RW_MACRO=/usr/share/upgrade/rw-update-macro.inc
-
-if [ -e ${RW_MACRO} ]; then
- source ${RW_MACRO}
- write_version_info
-fi
--- /dev/null
+#!/bin/sh
+RW_MACRO=@TZ_SYS_UPGRADE@/rw-update-macro.inc
+
+if [ -e ${RW_MACRO} ]; then
+ source ${RW_MACRO}
+ write_version_info
+fi
+++ /dev/null
-#!/bin/sh
-#
-# 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
-DEBUG_MODE=/opt/usr/.upgdebug
-
-if [ -f $RW_MACRO ]; then
- source $RW_MACRO
- get_version_info
-fi
-
-if [ ! "$OLD_VER" = "$NEW_VER" ]; then
- # Restore rpm db
- rm -rf /var/lib/rpm/*
- restore_backup_file -f /opt/var/lib/rpm
-fi
-
-# Permission Update for shared directories
-/etc/gumd/useradd.d/91_user-dbspace-permissions.post owner
-
-sleep 10
-if [ -f $DEBUG_MODE ]; then
- exit
-fi
-
-exec /bin/sh $RW_UPDATE
--- /dev/null
+#!/bin/sh
+#
+# RW update initialize script
+#
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+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
+ source $RW_MACRO
+ get_version_info
+fi
+
+if [ ! "$OLD_VER" = "$NEW_VER" ]; then
+ # Restore rpm db
+ rm -rf /var/lib/rpm/*
+ restore_backup_file -f /opt/var/lib/rpm
+fi
+
+# Permission Update for shared directories
+/etc/gumd/useradd.d/91_user-dbspace-permissions.post owner
+
+sleep 10
+if [ -f $DEBUG_MODE ]; then
+ exit
+fi
+
+exec /bin/sh $RW_UPDATE
+++ /dev/null
-#!/bin/sh
-#
-# RW update script
-#
-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
-VERSION_FILE=/opt/etc/version
-RW_MACRO=/usr/share/upgrade/rw-update-macro.inc
-RUN=/bin/sh
-
-RW_GUI=
-RW_ANI=/usr/bin/rw-update-ani
-
-#------------------------------------------------
-# shell script verity check
-# return 0 : pass
-# return 1 : no entry in rw-script.list
-# return 2 : verity fail
-#------------------------------------------------
-Verity_Check() {
-
- if [ "z$1" = "z" ]; then
- echo "Input Shell Script Null" >> ${LOG_FILE}
- return 1
- fi
-
- SC_FILE=`/usr/bin/basename $1`
- SC_LIST=/usr/share/upgrade/rw-script.list
- if [ -f ${SC_LIST} ]; then
- grep ${SC_FILE} ${SC_LIST} > /dev/null 2>&1
- if [ "$?" = "0" ]; then
- ret=`/usr/bin/md5sum "$1"`
- mret=($(/bin/echo $ret))
- md5result=${mret[0]}
-
- md5list=`/usr/bin/grep ${SC_FILE} ${SC_LIST} | /usr/bin/awk -F' ' '{print $2}'`
- if [ "$md5result" = "$md5list" ]; then
- echo "[PASS ] ${SC_FILE} verity check" >> ${LOG_FILE}
- return 0
- else
- echo "[MISMATCH] ${SC_FILE} md5sum" >> ${LOG_FILE}
- return 2
- fi
- else
- echo "[No entry] ${SC_FILE} in ${SC_LIST}" >> ${LOG_FILE}
- return 1
- fi
- else
- echo "No such file ${SC_LIST}" >> ${LOG_FILE}
- return 1
- fi
-}
-
-#------------------------------------------------
-# main
-#------------------------------------------------
-
-# Check GUI availability
-if [ -e ${RW_ANI} ]; then
- RW_GUI=1
-fi
-
-mkdir -p ${RECOVERY_DIR}
-
-echo "System RW update: rw update started" > ${LOG_FILE}
-
-# Execute update scripts
-if [ ! -d ${PATCH_DIR} ]
-then
- echo "FAIL: Upgrade directory does not exist" >> ${LOG_FILE}
- echo "${UPI_RW_UPDATE_ERROR}" > ${RESULT_FILE}
-else
- if [ "${RW_GUI}" = "1" ]; then
- progress=0
- total=`ls -l ${PATCH_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
-
- PATCHES=`/bin/ls ${PATCH_DIR}`
-
- for PATCH in ${PATCHES}; do
- if [ "${RW_GUI}" = "1" ]; then
- progress=$((progress+1))
- 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
- done
-
- sync
-
- echo "SUCCESS: Upgrade successfully finished" >> ${LOG_FILE}
-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
-
-# Reboot
-reboot -f
--- /dev/null
+#!/bin/sh
+#
+# RW update script
+#
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+
+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@
+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=${UPDATE_DIR}/rw-update-macro.inc
+RUN=/bin/sh
+
+RW_GUI=
+RW_ANI=/usr/bin/rw-update-ani
+
+#------------------------------------------------
+# shell script verity check
+# return 0 : pass
+# return 1 : no entry in rw-script.list
+# return 2 : verity fail
+#------------------------------------------------
+Verity_Check() {
+
+ if [ "z$1" = "z" ]; then
+ echo "Input Shell Script Null" >> ${LOG_FILE}
+ return 1
+ fi
+
+ SC_FILE=`/usr/bin/basename $1`
+ SC_LIST=${UPDATE_DIR}/rw-script.list
+ if [ -f ${SC_LIST} ]; then
+ grep ${SC_FILE} ${SC_LIST} > /dev/null 2>&1
+ if [ "$?" = "0" ]; then
+ ret=`/usr/bin/md5sum "$1"`
+ mret=($(/bin/echo $ret))
+ md5result=${mret[0]}
+
+ md5list=`/usr/bin/grep ${SC_FILE} ${SC_LIST} | /usr/bin/awk -F' ' '{print $2}'`
+ if [ "$md5result" = "$md5list" ]; then
+ echo "[PASS ] ${SC_FILE} verity check" >> ${LOG_FILE}
+ return 0
+ else
+ echo "[MISMATCH] ${SC_FILE} md5sum" >> ${LOG_FILE}
+ return 2
+ fi
+ else
+ echo "[No entry] ${SC_FILE} in ${SC_LIST}" >> ${LOG_FILE}
+ return 1
+ fi
+ else
+ echo "No such file ${SC_LIST}" >> ${LOG_FILE}
+ return 1
+ fi
+}
+
+#------------------------------------------------
+# main
+#------------------------------------------------
+
+# Check GUI availability
+if [ -e ${RW_ANI} ]; then
+ RW_GUI=1
+fi
+
+mkdir -p ${RECOVERY_DIR}
+
+echo "System RW update: rw update started" > ${LOG_FILE}
+
+# Execute update scripts
+if [ ! -d ${PATCH_DIR} ]
+then
+ echo "FAIL: Upgrade directory does not exist" >> ${LOG_FILE}
+ echo "${UPI_RW_UPDATE_ERROR}" > ${RESULT_FILE}
+else
+ if [ "${RW_GUI}" = "1" ]; then
+ progress=0
+ total=`ls -l ${PATCH_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
+
+ PATCHES=`/bin/ls ${PATCH_DIR}`
+
+ for PATCH in ${PATCHES}; do
+ if [ "${RW_GUI}" = "1" ]; then
+ progress=$((progress+1))
+ 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
+ done
+
+ sync
+
+ echo "SUCCESS: Upgrade successfully finished" >> ${LOG_FILE}
+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
+
+# Reboot
+reboot -f