diff options
author | MyoungJune Park <mj2004.park@samsung.com> | 2017-03-27 13:37:59 +0900 |
---|---|---|
committer | MyoungJune Park <mj2004.park@samsung.com> | 2017-06-12 16:15:18 +0900 |
commit | 98d02ddb1a4b4bf4b0879fb189707543d06bc6bf (patch) | |
tree | 05be6983bb828d98b320899e31b09f3794ec1c57 /script/build-backup-data.sh | |
parent | 41f717fb0857f466c34797859cc0c5525daa4e54 (diff) | |
download | factory-reset-98d02ddb1a4b4bf4b0879fb189707543d06bc6bf.tar.gz factory-reset-98d02ddb1a4b4bf4b0879fb189707543d06bc6bf.tar.bz2 factory-reset-98d02ddb1a4b4bf4b0879fb189707543d06bc6bf.zip |
init code
Change-Id: Ie6cb5cdbcabca325d23d3a230027d40f67c09644
Signed-off-by: MyoungJune Park <mj2004.park@samsung.com>
Diffstat (limited to 'script/build-backup-data.sh')
-rwxr-xr-x | script/build-backup-data.sh | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/script/build-backup-data.sh b/script/build-backup-data.sh new file mode 100755 index 0000000..bb8d58e --- /dev/null +++ b/script/build-backup-data.sh @@ -0,0 +1,97 @@ +#!/bin/bash +# +# Copyright (c) 20014- 2017 Samsung Electronics Co., Ltd. +# +# Contact: MyoungJune Park <mj2004.park@samsung.com> +# Created by Wonil Choi <wonil22.choi@samsung.com> +# +# 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. +# + + + +## build backup data for factory reset + + +[ $INSTALL_ROOT ] || INSTALL_ROOT="/" +rdir=$INSTALL_ROOT/usr/system/RestoreDir +optdir=$INSTALL_ROOT/opt +CURDIR=`pwd` +BACKUPLIST=`ls -1 $optdir` +EXCLUDE_OPTION= +# For removable preload app +RESTORE_EXCEPTION_LIST= +if [ -e $INSTALL_ROOT/usr/packages/restore_exception.list ]; then + xlist=$INSTALL_ROOT/usr/packages/restore_exception.list + RESTORE_EXCEPTION_LIST=`sed -e "s#^\/##g" $xlist` +fi + +create_archive() { + echo "Create_Archive --------------------------------------------" + mkdir -p $rdir + + BACKUP_FULLPATH="" + for i in $BACKUPLIST; do + BACKUP_FULLPATH="$BACKUP_FULLPATH opt/$i" + done + + # create tar archives + echo "create archives... $BACKUP_FULLPATH" + cd $INSTALL_ROOT + bash -c "$BACKUPCMD $BACKUP_FULLPATH $EXCLUDE_OPTION" + + # checksum + echo "calculate checksum..." + xpath="! \( -path \"opt/var/tmp/*\" \)" + for i in $RESTORE_EXCEPTION_LIST; do + xpath="$xpath ! \( -path \"$i/*\" \)" + done + + for i in $BACKUP_FULLPATH; do + bash -c "find $i $xpath -type f -exec md5sum {} \; >> $rdir/checksum.md5" + bash -c "find $i $xpath -exec /usr/bin/chsmack {} \; >> $rdir/smack_label.txt" + done + + chmod go-rwx $rdir/* $rdir $rdir/.. +} + +case "$1" in +tar) +#SCM use opt/var/tmp for temporal files, the files are removed before the binary creation + EXCLUDE_OPTION="--exclude=opt/var/tmp/*" + for i in $RESTORE_EXCEPTION_LIST; do + EXCLUDE_OPTION="$EXCLUDE_OPTION --exclude=$i" + done + BACKUPCMD="tar czf $rdir/opt.tar.gz" + create_archive + ;; +""|zip) +#SCM use opt/var/tmp for temporal files, the files are removed before the binary creation + EXCLUDE_OPTION="-x "opt/var/tmp/*"" + for i in $RESTORE_EXCEPTION_LIST; do + EXCLUDE_OPTION="$EXCLUDE_OPTION \"$i/*\"" + done + BACKUPCMD="zip -yrX- $rdir/opt.zip" + create_archive + ;; +*) + echo "Usage: $0 {tar|zip}" + echo "zip is used by default" + cd $CURDIR + exit 2 + ;; +esac + +cd $CURDIR +## end - building backup data + |