From a7c0aa98328bb1bb3a63d63269f62042ff2d9d37 Mon Sep 17 00:00:00 2001 From: Jiyong Min Date: Mon, 19 Sep 2016 11:18:52 +0900 Subject: [PATCH] Add upgrade scripts 2.4 to 3.0 Change-Id: Id2b99c00546a7f9950a39d5131c93e5c93084634 Signed-off-by: Jiyong Min --- 30_media-server-add.post | 3 +++ packaging/media-server.spec | 10 +++++++++- packaging/media-server.upgrade.sh | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 packaging/media-server.upgrade.sh diff --git a/30_media-server-add.post b/30_media-server-add.post index a5a9a13..37dc8c1 100644 --- a/30_media-server-add.post +++ b/30_media-server-add.post @@ -5,6 +5,8 @@ NEW_USER=$1 export `tzplatform-get --user $NEW_USER TZ_USER_SHARE` export `tzplatform-get --user $NEW_USER TZ_USER_DB` +if [ ! -e /system-update ] +then /usr/bin/touch $TZ_USER_DB/.media.db /usr/bin/chown multimedia_fw:multimedia_fw $TZ_USER_DB/.media.db /usr/bin/chmod 0644 $TZ_USER_DB/.media.db @@ -17,3 +19,4 @@ export `tzplatform-get --user $NEW_USER TZ_USER_DB` /usr/bin/chmod 0775 $TZ_USER_SHARE/media /usr/bin/chmod -R 0777 $TZ_USER_SHARE/media/.thumb /usr/bin/find $NEW_USER $TZ_USER_SHARE/media/.thumb -type d -exec /usr/bin/chsmack -a 'User::App::Shared' -t {} + +fi diff --git a/packaging/media-server.spec b/packaging/media-server.spec index bd7777e..9704a80 100755 --- a/packaging/media-server.spec +++ b/packaging/media-server.spec @@ -1,6 +1,6 @@ Name: media-server Summary: A server for media content management -Version: 0.3.0 +Version: 0.3.1 Release: 0 Group: Multimedia/Service License: Apache-2.0 @@ -9,6 +9,7 @@ Source1: media-server.service Source2: media-server-user.service Source3: media-server-user.path Source4: media-server.path +Source5: media-server.upgrade.sh Source1001: %{name}.manifest Source1002: libmedia-utils.manifest Source1003: libmedia-utils-devel.manifest @@ -40,6 +41,8 @@ BuildRequires: pkgconfig(capi-system-power-tv) %define product_tv 0 %endif +%define upgrade_script_path /usr/share/upgrade/scripts + %description Description: A server for media content management. @@ -265,6 +268,10 @@ cp -rf %{_builddir}/%{name}-%{version}/data/media_product.db %{buildroot}/etc/mu cp -rf %{_builddir}/%{name}-%{version}/data/media.db %{buildroot}/etc/multimedia/.media.db %endif +#OS Upgrade +mkdir -p %{buildroot}%{upgrade_script_path} +cp -f %{SOURCE5} %{buildroot}%{upgrade_script_path} + %post # setup dbupdate in user session mkdir -p %{_unitdir_user}/basic.target.wants/ @@ -308,6 +315,7 @@ buxton2ctl -i -u 100 create-int32 "system" "db/mediascanner/poweroff_status" "0" /etc/multimedia/.media.db %{_datadir}/locale/*/LC_MESSAGES/* %license LICENSE.APLv2.0 +%{upgrade_script_path}/media-server.upgrade.sh %files -n libmedia-utils %manifest libmedia-utils.manifest diff --git a/packaging/media-server.upgrade.sh b/packaging/media-server.upgrade.sh new file mode 100644 index 0000000..582bcaf --- /dev/null +++ b/packaging/media-server.upgrade.sh @@ -0,0 +1,39 @@ +#!/bin/sh -e +PATH=/bin:/usr/bin:/sbin:/usr/sbin + +# Macro +DB_DIR_24=/opt/usr/dbspace +DB_DIR_30=/opt/usr/home/owner/.applications/dbspace +MEDIA_DIR_24=/opt/usr/media +MEDIA_DIR_30=/opt/usr/home/owner/content +SHARE_DIR_24=/opt/usr/share +SHARE_DIR_30=/opt/usr/home/owner/share + +DB_FILE_24=$DB_DIR_24/.media.db +DB_FILE_30=$DB_DIR_30/.media.db + +# Move +mv $DB_FILE_24 $DB_FILE_30 +rm -f $DB_FILE_24-journal + +# DB update +sqlite3 $DB_FILE_30 "UPDATE media SET path = replace( path, '/opt/usr/media', '/opt/usr/home/owner/content' ), thumbnail_path = NULL WHERE path LIKE '/opt/usr/media/%'; +UPDATE folder SET path = replace( path, '/opt/usr/media', '/opt/usr/home/owner/content' ) WHERE path LIKE '/opt/usr/media/%' OR path = '/opt/usr/media'; +DELETE FROM media WHERE path LIKE '/opt/storage/%'; +DELETE FROM folder WHERE path LIKE '/opt/storage/%'; +DELETE FROM storage WHERE storage_path LIKE '/opt/storage/%'; +" + +# Set permission +touch $DB_FILE_30 +chown multimedia_fw:multimedia_fw $DB_FILE_30 +chmod 0644 $DB_FILE_30 +chsmack -a 'User::Home' $DB_FILE_30 + +mkdir -p $SHARE_DIR_30/media/.thumb/phone +mkdir -p $SHARE_DIR_30/media/.thumb/mmc +chown -R multimedia_fw:multimedia_fw $SHARE_DIR_30/media +chsmack -a 'User::App::Shared' -t $SHARE_DIR_30/media +chmod 0775 $SHARE_DIR_30/media +chmod -R 0777 $SHARE_DIR_30/media/.thumb +find $SHARE_DIR_30/media/.thumb -type d -exec /usr/bin/chsmack -a 'User::App::Shared' -t {} + -- 2.7.4