TIZEN_MANIFEST=tizen-manifest.xml
OWNER_SYSTEM_SHARE=owner:system_share
-TRUSTED_LABEL=User::Author::1
RESTRICTION_DBPATH=/var/lib/package-manager
RESTRICTION_DBNAME=restriction.db
done
}
-function move_user_tpk_ro_files(){
- #this copy will copy whole things include userdata
+function move_user_pkg_ro_files(){
local package=$1
- cp -af $OPT_USR_APPS/$package $DEFAULT_PKG_APP_LOCATION/
- chown -R $DEFAULT_RO_OWNER_GROUP $DEFAULT_PKG_APP_LOCATION/$package
- chsmack -E $DEFAULT_PKG_APP_LOCATION/$package/bin/*
-
- #remove file except author-signature.xml, bin, lib, res, shared/res, signature1.xml, tizen-manifest.xml
- if [ -e "$DEFAULT_PKG_APP_LOCATION/$package/data" ]; then
- rm -r "$DEFAULT_PKG_APP_LOCATION/$package/data"
- fi
- if [ -e "$DEFAULT_PKG_APP_LOCATION/$package/cache" ]; then
- rm -r "$DEFAULT_PKG_APP_LOCATION/$package/cache"
- fi
+ mkdir $DEFAULT_PKG_APP_LOCATION/$package
+ mkdir $DEFAULT_PKG_APP_LOCATION/$package/shared
+ chown -R $DEFAULT_RO_OWNER_GROUP $DEFAULT_PKG_APP_LOCATION/$package
- if [ -e "$DEFAULT_PKG_APP_LOCATION/$package/shared/cache" ]; then
- rm -r "$DEFAULT_PKG_APP_LOCATION/$package/shared/cache"
- fi
+ #move only readonly files
+ ls $OPT_USR_APPS/$package | while read filename
+ do
+ if [ $filename != "data" ] && [ $filename != "cache" ] && [ $filename != "shared" ]
+ then
+ mv $OPT_USR_APPS/$package/$filename $DEFAULT_PKG_APP_LOCATION/$package
+ fi
+ done
- if [ -e "$DEFAULT_PKG_APP_LOCATION/$package/shared/data" ]; then
- rm -r "$DEFAULT_PKG_APP_LOCATION/$package/shared/data"
+ if [ -e "$OPT_USR_APPS/$package/shared/res" ]; then
+ mv $OPT_USR_APPS/$package/shared/res $DEFAULT_PKG_APP_LOCATION/$package/shared
fi
- if [ -e "$DEFAULT_PKG_APP_LOCATION/$package/shared/trusted" ]; then
- rm -r "$DEFAULT_PKG_APP_LOCATION/$package/shared/trusted"
+ if [ -e $DEFAULT_PKG_APP_LOCATION/$package/bin/ ]; then
+ chsmack -E $DEFAULT_PKG_APP_LOCATION/$package/bin/*
fi
-
chsmack -r -a $DEFAULT_SMACK_LABEL $DEFAULT_PKG_APP_LOCATION/$package/*
}
-function move_user_tpk_rw_files(){
+function move_user_pkg_rw_files(){
local package=$1
+ local source="$OPT_USR_APPS/$package"
local target="$DEFAULT_USER_APPS_RW/$package"
chown -R $DEFAULT_RW_OWNER_GROUP $target
- local source="$OPT_USR_APPS/$package"
-
- rm -rf $source/shared/cache
if [ -e $source/cache ]; then
- cp -aR --no-preserve=mode,ownership,context $source/cache $target/
- chown -R owner:system_share $target/cache/
+ mv $source/cache/* $target/cache/
+ chown -R $OWNER_SYSTEM_SHARE $target/cache/
+ chsmack -r -a $DEFAULT_RW_SMACK_LABEL$package $target/cache
fi
if [ -e $source/data ]; then
- cp -aR --no-preserve=mode,ownership,context $source/data $target/
- chown -R owner:system_share $target/data/
+ mv $source/data/* $target/data/
+ chown -R $OWNER_SYSTEM_SHARE $target/data/
+ chsmack -r -a $DEFAULT_RW_SMACK_LABEL$package $target/data
fi
- if [ -e $source/shared ]; then
- cp -aR --no-preserve=mode,ownership,context $source/shared $target/
- if [ -e $target/shared/data ]; then
- chown -R owner:system_share $target/shared/data
- fi
- if [ -e $target/shared/trusted ]; then
- chown -R owner:users $target/shared/trusted
- fi
+
+ if [ -e $source/shared/data ]; then
+ mv $source/shared/data/* $target/shared/data/
+ chsmack -r -a $DEFAULT_RW_SMACK_LABEL$package::SharedRO $target/shared/data
+ chown -R $OWNER_SYSTEM_SHARE $target/shared/data
+ fi
+
+ if [ -e $source/shared/trusted ] && [ -e $target/shared/trusted ]; then
+ cp -aR --no-preserve=mode,ownership,context $source/shared/trusted/* $target/shared/trusted
+ chown -R owner:users $target/shared/trusted
fi
+
rm -rf $source
}
function copy_user_tpk_manifest(){
local package=$1
- cp $DEFAULT_PKG_APP_LOCATION/$1/$TIZEN_MANIFEST $DEFAULT_PKG_MANIFEST_LOCATION/$package.xml
+ cp $DEFAULT_PKG_APP_LOCATION/$package/$TIZEN_MANIFEST $DEFAULT_PKG_MANIFEST_LOCATION/$package.xml
chsmack -a System $DEFAULT_PKG_MANIFEST_LOCATION/$package.xml
}
while read package
do
echo "processing user tpk $package..."
- move_user_tpk_ro_files $package
+ move_user_pkg_ro_files $package
copy_user_tpk_manifest $package
done < $DB_RESULT_FILE
rm -f $DB_RESULT_FILE
}
-function move_user_wgt_ro_files(){
- #this copy will copy whole things include userdata
- local package=$1
- cp -af $OPT_USR_APPS/$package $DEFAULT_PKG_APP_LOCATION/
- chown -R $DEFAULT_RO_OWNER_GROUP $DEFAULT_PKG_APP_LOCATION/$package
- chsmack -E $DEFAULT_PKG_APP_LOCATION/$package/bin/*
-
- if [ -e "$DEFAULT_PKG_APP_LOCATION/$package/data" ]; then
- rm -r "$DEFAULT_PKG_APP_LOCATION/$package/data"
- fi
-
- if [ -e "$DEFAULT_PKG_APP_LOCATION/$package/cache" ]; then
- rm -r "$DEFAULT_PKG_APP_LOCATION/$package/cache"
- fi
-
- if [ -e "$DEFAULT_PKG_APP_LOCATION/$package/shared/cache" ]; then
- rm -r "$DEFAULT_PKG_APP_LOCATION/$package/shared/cache"
- fi
-
- if [ -e "$DEFAULT_PKG_APP_LOCATION/$package/shared/data" ]; then
- rm -r "$DEFAULT_PKG_APP_LOCATION/$package/shared/data"
- fi
-
- if [ -e "$DEFAULT_PKG_APP_LOCATION/$package/shared/trusted" ]; then
- rm -r "$DEFAULT_PKG_APP_LOCATION/$package/shared/trusted"
- fi
-
- chsmack -r -a $DEFAULT_SMACK_LABEL $DEFAULT_PKG_APP_LOCATION/$package/*
-}
-
-function move_user_wgt_rw_files(){
- local package=$1
-
- local target="$DEFAULT_USER_APPS_RW/$package"
- chown -R $DEFAULT_RW_OWNER_GROUP $target
-
- local source="$OPT_USR_APPS/$package"
-
- rm -rf $source/shared/cache
- if [ -e $source/cache ]; then
- cp -aR --no-preserve=mode,ownership,context $source/cache $target/
- chown -R owner:system_share $target/cache/
- fi
- if [ -e $source/data ]; then
- cp -aR --no-preserve=mode,ownership,context $source/data $target/
- chown -R owner:system_share $target/data/
- fi
- if [ -e $source/shared ]; then
- cp -aR --no-preserve=mode,ownership,context $source/shared/ $target/
- if [ -e $target/shared/data ]; then
- chown -R owner:system_share $target/shared/data
- fi
- if [ -e $target/shared/trusted ]; then
- chown -R owner:users $target/shared/trusted
- fi
-
- fi
- rm -r $source
-}
-
-
function move_user_wgt_files(){
echo "#move user WGT's files"
echo "SELECT package FROM package_info WHERE package_readonly='false' COLLATE NOCASE AND package_type='wgt' COLLATE NOCASE;" |
while read package
do
echo "processing user wgt $package..."
- move_user_wgt_ro_files $package
+ move_user_pkg_ro_files $package
done < $DB_RESULT_FILE
rm -f $DB_RESULT_FILE
mkdir -m 770 -p /opt/dbspace/user/5001
chmod 755 /opt/dbspace/user
- chsmack -r -a User::Home /opt/dbspace/user
+ chsmack -r -a $DEFAULT_RO_SMACK_LABEL /opt/dbspace/user
chown $OWNER_SYSTEM_SHARE /opt/dbspace/user/5001
pkg_initdb --uid 5001
echo "processing preload pkg $package..."
local source="$OPT_USR_APPS/$package"
local target="$DEFAULT_USER_APPS_RW/$package"
- rm -rf $source/shared/cache
if [ -e $source/cache ]; then
- cp -aR --no-preserve=mode,ownership,context $source/cache $target/
- chown -R owner:system_share $target/cache/
+ mv $source/cache/* $target/cache/
+ chown -R $OWNER_SYSTEM_SHARE $target/cache/
+ chsmack -r -a $DEFAULT_RW_SMACK_LABEL$package $target/cache
fi
if [ -e $source/data ]; then
- cp -aR --no-preserve=mode,ownership,context $source/data $target/
- chown -R owner:system_share $target/data/
+ mv $source/data/* $target/data/
+ chown -R $OWNER_SYSTEM_SHARE $target/data/
+ chsmack -r -a $DEFAULT_RW_SMACK_LABEL$package $target/data
fi
- if [ -e $source/shared ]; then
- cp -aR --no-preserve=mode,ownership,context $source/shared $target/
- if [ -e $target/shared/data ]; then
- chown -R owner:system_share $target/shared/data
- fi
- if [ -e $target/shared/trusted ]; then
- chown -R owner:users $target/shared/trusted
- fi
+ if [ -e $source/shared/data ]; then
+ mv $source/shared/data/* $target/shared/data/
+ chsmack -r -a $DEFAULT_RW_SMACK_LABEL$package::SharedRO $target/shared/data
+ chown -R $OWNER_SYSTEM_SHARE $target/shared/data
fi
+ if [ -e $source/shared/trusted ] && [ -e $target/shared/trusted ]; then
+ cp -aR --no-preserve=mode,ownership,context $source/shared/trusted/* $target/shared/trusted
+ chown -R owner:users $target/shared/trusted
+ fi
rm -rf $source
done < $DB_RESULT_FILE
rm -f $DB_RESULT_FILE
rm -f $CERT_TEMP_FILEPATH/$package.txt
migrate_cert_info $package
- move_user_tpk_rw_files $package
+ move_user_pkg_rw_files $package
else
#if exists, remove RO files in rw location
echo "Remove readonly updated pkg $package"
wgt-backend -y $package --preload-rw
fi
- move_user_wgt_rw_files $package
+ move_user_pkg_rw_files $package
else
echo "Remove readonly updated pkg $package"
if [ -e "$DEFAULT_PKG_APP_LOCATION/$package" ]; then
rm -f $CERT_TEMP_FILEPATH/$package.txt
migrate_cert_info $package
- move_user_tpk_rw_files $package
+ move_user_pkg_rw_files $package
done < $DB_RESULT_FILE
rm -f $DB_RESULT_FILE
}
echo "init user wgt package $package..."
wgt-backend -y $package
chsmack -a System $DEFAULT_PKG_MANIFEST_LOCATION/$package.xml
- move_user_wgt_rw_files $package
+ move_user_pkg_rw_files $package
done < $DB_RESULT_FILE
rm -f $DB_RESULT_FILE
}
echo "processing web widget $app_id..."
rm -f $DEFAULT_PKG_APP_LOCATION/$package/bin/$app_id
ln -sf /usr/bin/web-widget-runtime $DEFAULT_PKG_APP_LOCATION/$package/bin/$app_id
- chsmack -a User::Home $DEFAULT_PKG_APP_LOCATION/$package/bin/$app_id
+ chsmack -a $DEFAULT_RO_SMACK_LABEL $DEFAULT_PKG_APP_LOCATION/$package/bin/$app_id
chown $DEFAULT_RO_OWNER_GROUP $DEFAULT_PKG_APP_LOCATION/$package/bin/$app_id
chmod 755 $DEFAULT_PKG_APP_LOCATION/$package/bin/$app_id
rm -f $DB_RESULT_FILE
}
+shopt -s dotglob
+
backup_db
create_restriction_db