summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packaging/system-plugin.spec42
-rw-r--r--packaging/systemd-user-helper.manifest3
-rw-r--r--rules/99-usb-ethernet.rules6
-rw-r--r--scripts/fixed-multi-user.sh19
-rw-r--r--scripts/make_upgrade_image.sh88
-rw-r--r--scripts/usb_net_init.sh9
-rw-r--r--src/systemd-user-helper/systemd-user-helper.c255
-rw-r--r--units/init-update.service9
-rw-r--r--units/offline-update.service2
-rw-r--r--upgrade/data/.gitignore0
-rw-r--r--upgrade/scripts/.gitignore0
-rwxr-xr-xupgrade/update-image.sh11
-rwxr-xr-xupgrade/update-init.sh35
-rwxr-xr-xupgrade/update-post.sh30
-rwxr-xr-xupgrade/update.sh22
15 files changed, 426 insertions, 105 deletions
diff --git a/packaging/system-plugin.spec b/packaging/system-plugin.spec
index d65ac9e..8cfaef4 100644
--- a/packaging/system-plugin.spec
+++ b/packaging/system-plugin.spec
@@ -136,7 +136,8 @@ cp %{SOURCE3} .
--disable-debug-mode \
--disable-eng-mode
-%__make %{?jobs:-j%jobs}
+%__make %{?jobs:-j%jobs} \
+ CFLAGS+=-DLIBDIR=\\\"%{_libdir}\\\"
%install
rm -rf %{buildroot}
@@ -147,7 +148,6 @@ mkdir -p %{buildroot}/csa
mkdir -p %{buildroot}/initrd
install -m 644 units/resize2fs@.service %{buildroot}%{_unitdir}
install -m 644 units/tizen-system-env.service %{buildroot}%{_unitdir}
-install -m 644 units/ivi-network.service %{buildroot}%{_unitdir}
# csa mount
install -m 644 units/csa.mount %{buildroot}%{_unitdir}
@@ -165,11 +165,11 @@ ln -s ../resize2fs@.service %{buildroot}%{_unitdir}/basic.target.wants/resize2fs
ln -s ../resize2fs@.service %{buildroot}%{_unitdir}/basic.target.wants/resize2fs@dev-disk-by\\x2dpartlabel-rootfs.service
ln -s ../tizen-system-env.service %{buildroot}%{_unitdir}/basic.target.wants/tizen-system-env.service
-%install_service multi-user.target.wants ivi-network.service
mkdir -p %{buildroot}%{_prefix}/lib/udev/rules.d/
install -m 644 rules/51-system-plugin-exynos.rules %{buildroot}%{_prefix}/lib/udev/rules.d/
install -m 644 rules/51-system-plugin-spreadtrum.rules %{buildroot}%{_prefix}/lib/udev/rules.d/
+install -m 644 rules/99-usb-ethernet.rules %{buildroot}%{_prefix}/lib/udev/rules.d/
# fstab
mkdir -p %{buildroot}%{_sysconfdir}
@@ -197,9 +197,16 @@ install -m 755 scripts/tizen-fstrim-on-charge.sh %{buildroot}%{_bindir}
mkdir -p %{buildroot}%{_datadir}
cp -r upgrade %{buildroot}%{_datadir}
mkdir -p %{buildroot}%{_unitdir}/system-update.target.wants
+install -m 644 units/init-update.service %{buildroot}%{_unitdir}
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 %{_datadir}/upgrade %{buildroot}/system-update
+ln -s ../init-update.service %{buildroot}%{_unitdir}/system-update.target.wants/init-update.service
+ln -s ../getty.target %{buildroot}%{_unitdir}/system-update.target.wants
+
+# ivi
+install -m 755 scripts/usb_net_init.sh %{buildroot}%{_bindir}
+
+# fixed-multi-user
+install -m 775 -D scripts/fixed-multi-user.sh %{buildroot}%{_datadir}/fixed_multiuser/fixed-multi-user.sh
# init_wrapper
mkdir -p %{buildroot}%{_sbindir}
@@ -294,6 +301,7 @@ mv %{_sysconfdir}/fstab_lazymnt %{_sysconfdir}/fstab
%{_unitdir}/tizen-fstrim-user.timer
%{_unitdir}/tizen-fstrim-user.service
%{_bindir}/tizen-fstrim-on-charge.sh
+%{_datadir}/fixed_multiuser/fixed-multi-user.sh
%files -n liblazymount
%defattr(-,root,root,-)
@@ -320,25 +328,31 @@ mv %{_sysconfdir}/fstab_lazymnt %{_sysconfdir}/fstab
%endif
%files -n system-upgrade
-%{_datadir}/upgrade
+%{_datadir}/upgrade/*
%{_unitdir}/offline-update.service
-%{_unitdir}/system-update.target.wants/offline-update.service
-/system-update
+%{_unitdir}/init-update.service
+#%{_unitdir}/system-update.target.wants/offline-update.service
+%{_unitdir}/system-update.target.wants/init-update.service
+%{_unitdir}/system-update.target.wants/getty.target
%files -n systemd-user-helper
%manifest systemd-user-helper.manifest
%caps(cap_sys_admin,cap_mac_admin,cap_mac_override,cap_dac_override,cap_setgid=ei) %{_bindir}/systemd_user_helper
+#TODO: when uninstalling, it should be restored to original file
%posttrans -n systemd-user-helper
cp -a /usr/lib/systemd/system/user\@.service /usr/lib/systemd/system/__user@.service
-/usr/bin/sed -i -e 's/Type=\(.*\)/Type=simple/' /usr/lib/systemd/system/user\@.service
-/usr/bin/sed -i -e 's/ExecStart=\(.*\)/ExecStart=\/usr\/bin\/systemd_user_helper %i/' /usr/lib/systemd/system/user\@.service
-/usr/bin/sed -i -e '/RemainAfterExit=\(.*\)/d' /usr/lib/systemd/system/user\@.service
-echo 'RemainAfterExit=yes' >> /usr/lib/systemd/system/user\@.service
+/usr/bin/sed -i -e 's/Type=\(.*\)/Type=forking/' /usr/lib/systemd/system/user\@.service
+/usr/bin/sed -i -e 's/ExecStart=\(.*\)/ExecStart=\/usr\/bin\/systemd_user_helper start %i/' /usr/lib/systemd/system/user\@.service
+/usr/bin/sed -i -e '/ExecStart=\(.*\)/ a ExecStop=\/usr\/bin\/systemd_user_helper stop %i' /usr/lib/systemd/system/user\@.service
+/usr/bin/sed -i -e '/PIDFile=\(.*\)/d' /usr/lib/systemd/system/user\@.service
+/usr/bin/sed -i -e '/XDG_RUNTIME_DIR/ a Environment=XDG_RUNTIME_EXT_DIR=/run/user_ext/%i' /usr/lib/systemd/system/user\@.service
+echo 'PIDFile=/run/user/%i/.systemd.pid' >> /usr/lib/systemd/system/user\@.service
+echo "d /run/user_ext 0755 root root -" >> /usr/lib/tmpfiles.d/systemd.conf
%files profile_ivi
-%{_unitdir}/ivi-network.service
-%{_unitdir}/multi-user.target.wants/ivi-network.service
+%{_prefix}/lib/udev/rules.d/99-usb-ethernet.rules
+%{_bindir}/usb_net_init.sh
%files init_wrapper
diff --git a/packaging/systemd-user-helper.manifest b/packaging/systemd-user-helper.manifest
index 2a0cec5..90334b8 100644
--- a/packaging/systemd-user-helper.manifest
+++ b/packaging/systemd-user-helper.manifest
@@ -2,4 +2,7 @@
<request>
<domain name="_"/>
</request>
+ <assign>
+ <filesystem path="/usr/bin/systemd_user_helper" label="_" exec_label="System::Privileged" />
+ </assign>
</manifest>
diff --git a/rules/99-usb-ethernet.rules b/rules/99-usb-ethernet.rules
new file mode 100644
index 0000000..6c0307d
--- /dev/null
+++ b/rules/99-usb-ethernet.rules
@@ -0,0 +1,6 @@
+# USB ETHERNET
+SUBSYSTEM!="net", GOTO="usb_ethernet_end"
+
+ACTION=="add", ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="8152", RUN+="/usr/bin/usb_net_init.sh %k"
+
+LABEL="usb_ethernet_end"
diff --git a/scripts/fixed-multi-user.sh b/scripts/fixed-multi-user.sh
new file mode 100644
index 0000000..bfdae4b
--- /dev/null
+++ b/scripts/fixed-multi-user.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+#
+# Fixed Multi-User: executes fixed multiuser scripts
+#
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+
+SCRIPT_DIR=/usr/share/fixed_multiuser/scripts
+
+if [ ! -d ${SCRIPT_DIR} ]
+then
+ exit 0
+fi
+
+SCRIPTS=`/bin/ls ${SCRIPT_DIR}`
+
+for SCRIPT in ${SCRIPTS}; do
+ echo "Run ${SCRIPT}..."
+ /bin/sh ${SCRIPT_DIR}/${SCRIPT}
+done
diff --git a/scripts/make_upgrade_image.sh b/scripts/make_upgrade_image.sh
new file mode 100644
index 0000000..15968ce
--- /dev/null
+++ b/scripts/make_upgrade_image.sh
@@ -0,0 +1,88 @@
+#!/bin/sh
+#
+# make_upgrade_image.sh
+#
+# Convert Tizen 3.0 platform image to upgrade image (2.4 -> 3.0)
+
+# For sdb debugging
+
+sdb_debugging=1
+sdb_rule='SUBSYSTEM=="switch", ATTR{name}=="usb_cable", ATTR{state}=="1", RUN+="/usr/bin/direct_set_debug.sh --sdb-set"\nSUBSYSTEM=="switch", ATTR{name}=="usb_cable", ATTR{state}=="0", RUN+="/usr/bin/direct_set_debug.sh --sdb-unset"'
+
+# Back up /home/owner & rpm db
+backup () {
+ echo "Back up home & rpm db"
+
+ local tmp_path=$1
+
+ umount ${tmp_path}
+ e2fsck -f rootfs.img
+ resize2fs rootfs.img 1G
+ mount rootfs.img ${tmp_path}
+
+ mount system-data.img ${tmp_path}/opt
+ mount user.img ${tmp_path}/opt/usr
+
+ mkdir ${tmp_path}/usr/share/upgrade/data/home
+ cp -af ${tmp_path}/opt/usr/home/owner ${tmp_path}/usr/share/upgrade/data/home
+
+ mkdir ${tmp_path}/usr/share/upgrade/data/rpm
+ cp -af ${tmp_path}/opt/var/lib/rpm/* ${tmp_path}/usr/share/upgrade/data/rpm
+
+ sync
+
+ umount -l ${tmp_path}/opt/usr
+ umount -l ${tmp_path}/opt
+
+ umount ${tmp_path}
+ e2fsck -f rootfs.img
+ resize2fs -M rootfs.img
+ mount rootfs.img ${tmp_path}
+}
+
+if [ `id -u` -ne 0 ]
+then
+ echo "make_upgrade_image.sh should be executed as root"
+ exit
+fi
+
+if [ ! $1 ]
+then
+ echo "usage: $0 [tizen-3.0-image(tar.gz)]"
+ exit
+fi
+
+echo "Decompressing $1"
+imgs=`tar zxvf $1`
+
+tmp_root=`mktemp -d system.XXX`
+echo "Mount rootfs.img"
+mount rootfs.img ${tmp_root}
+
+cwd=`pwd`
+backup ${cwd}/${tmp_root}
+
+echo "Make /system-update"
+ln -s /usr/share/upgrade/ ${tmp_root}/system-update
+
+# For sdb debugging
+if [ ${sdb_debugging} -eq 1 ]
+then
+ echo "Install sdb rule file"
+ rule_file="99-sdb-switch.rules"
+ echo ${sdb_rule} > ${rule_file}
+ install -m 644 ${rule_file} ${tmp_root}/usr/lib/udev/rules.d
+ rm ${rule_file}
+fi
+
+sync
+umount ${tmp_root}
+
+upgrade_img=`echo $1 | sed -e 's/\.tar\.gz//'`-upgrade.tar.gz
+echo "Compressing upgrade image ${upgrade_img}"
+tar zcf ${upgrade_img} dzImage modules.img rootfs.img
+
+echo "Remove dummies"
+rm -rf ${imgs} ${tmp_root}
+
+echo "Done"
diff --git a/scripts/usb_net_init.sh b/scripts/usb_net_init.sh
new file mode 100644
index 0000000..ab245b1
--- /dev/null
+++ b/scripts/usb_net_init.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+interface=$1
+
+/sbin/ifconfig ${interface} down
+/sbin/ifconfig ${interface} 192.20.16.11
+/sbin/ifconfig ${interface} up
+
diff --git a/src/systemd-user-helper/systemd-user-helper.c b/src/systemd-user-helper/systemd-user-helper.c
index a5e22e0..a8145fa 100644
--- a/src/systemd-user-helper/systemd-user-helper.c
+++ b/src/systemd-user-helper/systemd-user-helper.c
@@ -19,22 +19,32 @@
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
+#include <signal.h>
#include <errno.h>
+#include <limits.h>
+#include <sys/stat.h>
#include <sched.h>
#include <sys/mount.h>
#include <tzplatform_config.h>
+#include <sys/types.h>
+#include <grp.h>
+#include <string.h>
+
+#define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0]))
+#define PIDFILE_PATH ".systemd.pid"
+
// For compatibility, Using hard-coded path
#define LEGACY_CONTENTS_DIR "/opt/usr/media"
#define LEGACY_APPS_DIR "/opt/usr/apps"
-#define LAZYMOUNT_LIB "/usr/lib/liblazymount.so.0"
-#define CONTAINER_LIB "/usr/lib/security/pam_krate.so"
+#define LAZYMOUNT_LIB LIBDIR"/liblazymount.so.0"
+#define CONTAINER_LIB LIBDIR"/security/pam_krate.so"
#define LOAD_SYMBOL(handle, sym, name) \
- do{ \
+ do { \
sym = dlsym(handle, name); \
if (!sym) { \
fprintf(stderr, "dlsym %s error\n", name); \
@@ -43,20 +53,138 @@
} \
} while (0);
+#define MOUNT_SIZE "10000k"
+#define MAX_GRP_BUF_SIZE (1024 * 4)
+#define GRP_NAME_SYSTEM_SHARE "system_share"
+
static void *container_handle = NULL;
+static const char *systemd_arg[] = {
+ "/usr/lib/systemd/systemd",
+ "--user",
+ NULL
+};
+
+int mac_smack_use(void) {
+ static int cached_use = -1;
+
+ if (cached_use < 0)
+ cached_use = access("/sys/fs/smackfs/", F_OK) >= 0;
+
+ return cached_use;
+}
+
+static int mount_user_ext(char *username)
+{
+ char *mount_point = NULL;
+ char *mount_option = NULL;
+ uid_t mnt_uid;
+ gid_t mnt_gid;
+ struct group *p_grp = NULL, grp_buf;
+ char buf[MAX_GRP_BUF_SIZE];
+ int r;
+
+ mnt_uid = atoi(username);
+ if(mnt_uid <= 0)
+ return -1;
+
+ r = asprintf(&mount_point, "/run/user_ext/%s", username);
+ if (r < 0) {
+ fprintf(stderr, "Failed to set mount point for user_ext\n");
+ return r;
+ }
+
+ (void) mkdir(mount_point, 0750);
+
+ r = getgrnam_r(GRP_NAME_SYSTEM_SHARE, &grp_buf, buf, sizeof(buf), &p_grp);
+ if( r == 0 && p_grp != NULL)
+ {
+ mnt_gid = p_grp->gr_gid;
+ }
+ else
+ {
+ free(mount_point);
+ return -2;
+ }
+
+ if (mac_smack_use())
+ r = asprintf(&mount_option, "mode=0750,smackfstransmute=System::Run,uid=%d,gid=%d,size=%s", mnt_uid, mnt_gid, MOUNT_SIZE);
+ else
+ r = asprintf(&mount_option, "mode=0750,uid=%d,gid=%d,size=%s", mnt_uid, mnt_gid, MOUNT_SIZE);
+
+ if (r < 0) {
+ fprintf(stderr, "Failed to set mount option for user_ext\n");
+ free(mount_point);
+ return r;
+ }
+
+ r = mount("tmpfs", mount_point, "tmpfs", MS_NODEV|MS_NOSUID|MS_NOEXEC, mount_option);
+ free(mount_point);
+ free(mount_option);
+
+ if (r < 0) {
+ fprintf(stderr, "Failed to mount user_ext\n");
+ return r;
+ }
+ return 0;
+}
+
+static int umount_user_ext(char *username)
+{
+ int r;
+ char *mount_point = NULL;
+
+ r = asprintf(&mount_point, "/run/user_ext/%s", username);
+ if (r < 0) {
+ fprintf(stderr, "Failed to set mount point for user_ext\n");
+ return r;
+ }
+ r = umount2(mount_point, MNT_DETACH);
+ if (r < 0) {
+ fprintf(stderr, "Failed to umount user_ext\n");
+ free(mount_point);
+ return r;
+ }
+ r = rmdir(mount_point);
+ if (r < 0) {
+ fprintf(stderr, "Failed to rmdir user_ext\n");
+ free(mount_point);
+ return r;
+ }
+ free(mount_point);
+ return 0;
+}
+
+static int stop_process(char *username)
+{
+ int r;
+
+ (void)umount_user_ext(username);
+ r = umount2(tzplatform_getenv(TZ_USER_CONTENT), MNT_DETACH);
+ if (r < 0) {
+ fprintf(stderr, "Warning : Failed to umount user content\n");
+ }
+
+ r = umount2(tzplatform_getenv(TZ_USER_APP), MNT_DETACH);
+ if (r < 0) {
+ fprintf(stderr, "Warning : Failed to umount application content\n");
+ }
+ return 0;
+}
+
static int normal_user_preprocess(char *username)
{
int r;
+
r = unshare(CLONE_NEWNS);
if (r < 0) {
- fprintf(stderr,"unshare failed\n");
+ fprintf(stderr, "unshare failed\n");
return r;
}
r = mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL);
if (r < 0) {
- fprintf(stderr,"Failed to change the propagation type of root to SLAVE\n");
+ fprintf(stderr, "Failed to change the propagation type of root to SLAVE\n");
return r;
}
@@ -69,14 +197,14 @@ static int normal_user_postprocess(char *username)
r = mount(tzplatform_getenv(TZ_USER_CONTENT),
LEGACY_CONTENTS_DIR, NULL, MS_BIND, NULL);
if (r < 0) {
- fprintf(stderr, "user content bind mount failed - %d\n",errno);
+ fprintf(stderr, "user content bind mount failed - %d\n", errno);
return r;
}
r = mount(tzplatform_getenv(TZ_USER_APP),
LEGACY_APPS_DIR, NULL, MS_BIND, NULL);
if (r < 0) {
- fprintf(stderr, "user app bind mount failed - %d\n",errno);
+ fprintf(stderr, "user app bind mount failed - %d\n", errno);
return r;
}
@@ -143,8 +271,8 @@ static int wait_condition(void)
int (*wait_mount_user)(void);
- r = access(LAZYMOUNT_LIB,F_OK);
- if (r < 0){
+ r = access(LAZYMOUNT_LIB, F_OK);
+ if (r < 0) {
fprintf(stderr, "cannot find lazymount module - No support lazymount\n");
return 0;
}
@@ -168,18 +296,112 @@ static int wait_condition(void)
return 0;
}
+static int make_pid_file(int pid, char* user_id)
+{
+ FILE *fp;
+ char pidpath[PATH_MAX];
+ int r = 0;
+
+ snprintf(pidpath, PATH_MAX, "/run/user/%s/%s", user_id, PIDFILE_PATH);
+
+ fp = fopen(pidpath, "w+");
+ if (fp != NULL) {
+ fprintf(fp, "%d", pid);
+ fclose(fp);
+ } else
+ r = -1;
+
+ return r;
+}
+
+static int change_smack_for_user_session()
+{
+ FILE *fp;
+ int r = 0;
+
+ fp = fopen("/proc/self/attr/current", "w");
+
+ if(fp == NULL)
+ {
+ r = -errno;
+ return r;
+ }
+ r = fputs("User", fp);
+ if(r == EOF)
+ {
+ fclose(fp);
+ r = -errno;
+ return r;
+ }
+ fclose(fp);
+
+ return 0;
+}
+
+int run_child(int argc, const char *argv[], char* user_id)
+{
+ pid_t pid;
+ int r = 0;
+ int i;
+
+ if (!argv)
+ return -EINVAL;
+
+ pid = fork();
+
+ if (pid < 0) {
+ fprintf(stderr, "failed to fork");
+ r = -errno;
+ } else if (pid == 0) {
+ for (i = 0; i < _NSIG; ++i)
+ signal(i, SIG_DFL);
+
+ r = execv(argv[0], (char **)argv);
+ /* NOT REACH */
+ } else{
+ make_pid_file(pid, user_id);
+ r = pid;
+ }
+
+ return r;
+}
+
int main(int argc, char *argv[])
{
int r = 0;
int support_container = 0;
+ char *operation;
+ char *username;
- if (argc < 2) {
+ if (argc < 3) {
fprintf(stderr, "require user argument\n");
return -1;
}
+ operation = argv[1];
+ username = argv[2];
+
+ if (strcmp(operation,"stop") == 0) {
+ return stop_process(username);
+ } else if (strcmp(operation, "start") == 0) {
+ } else {
+ fprintf(stderr, "option is invalid(%s)\n", operation);
+ return -2;
+ }
+
+ r = mount_user_ext(username);
+ if (r < 0) {
+ fprintf(stderr, "mount user_ext failed\n");
+ return r;
+ }
+ r = change_smack_for_user_session();
+ if(r != 0)
+ {
+ fprintf(stderr, "failed to change smack\n");
+ return r;
+ }
/* pre-processing */
- r = normal_user_preprocess(argv[1]);
+ r = normal_user_preprocess(username);
if (r < 0) {
fprintf(stderr, "normal user preprocess failed\n");
return r;
@@ -188,32 +410,33 @@ int main(int argc, char *argv[])
/* If container supports below funcs, below line should be enabled. */
support_container = (access(CONTAINER_LIB, F_OK) == 0) ? 1 : 0;
if (support_container) {
- r = container_preprocess(argv[1]);
+ r = container_preprocess(username);
if (r < 0) {
fprintf(stderr, "container preprocess failed\n");
return r;
}
}
- /* TODO: fork & exec */
- r = system("/usr/lib/systemd/systemd --user &");
+ r = run_child(ARRAY_SIZE(systemd_arg), systemd_arg, username);
if (r < 0) {
fprintf(stderr, "systemd user execution failed\n");
return r;
+ } else{
+ fprintf(stderr, "success = pid = %d\n", r);
}
/* sync-style since there is no need to process other signal */
wait_condition();
/* post-processing */
- r = normal_user_postprocess(argv[1]);
+ r = normal_user_postprocess(username);
if (r < 0) {
fprintf(stderr, "normal user postprocess failed\n");
return r;
}
if (support_container) {
- r = container_postprocess(argv[1]);
+ r = container_postprocess(username);
if (r < 0) {
fprintf(stderr, "container postprocess failed\n");
return r;
diff --git a/units/init-update.service b/units/init-update.service
new file mode 100644
index 0000000..d211f0e
--- /dev/null
+++ b/units/init-update.service
@@ -0,0 +1,9 @@
+[Unit]
+Description=System update initialize service
+Requires=sysinit.target
+After=sysinit.target
+Before=sdbd.service
+
+[Service]
+Type=oneshot
+ExecStart=/system-update/update-init.sh
diff --git a/units/offline-update.service b/units/offline-update.service
index c90b4e0..ed00616 100644
--- a/units/offline-update.service
+++ b/units/offline-update.service
@@ -1,7 +1,7 @@
[Unit]
Description=System update script service
Requires=sysinit.target
-After=sysinit.target
+After=sysinit.target init-update.service
[Service]
Type=simple
diff --git a/upgrade/data/.gitignore b/upgrade/data/.gitignore
deleted file mode 100644
index e69de29..0000000
--- a/upgrade/data/.gitignore
+++ /dev/null
diff --git a/upgrade/scripts/.gitignore b/upgrade/scripts/.gitignore
deleted file mode 100644
index e69de29..0000000
--- a/upgrade/scripts/.gitignore
+++ /dev/null
diff --git a/upgrade/update-image.sh b/upgrade/update-image.sh
deleted file mode 100755
index 6d73b74..0000000
--- a/upgrade/update-image.sh
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/sh
-#
-# Modify normal image to upgrade image
-#
-
-# Back rpm db up for Tizen 3.0
-mkdir /usr/share/upgrade/data/rpm
-cp -arf /var/lib/rpm/* /usr/share/upgrade/data/rpm
-
-# remove RW partitions' files
-rm -rf /opt/*
diff --git a/upgrade/update-init.sh b/upgrade/update-init.sh
index 63f993b..4974e9e 100755
--- a/upgrade/update-init.sh
+++ b/upgrade/update-init.sh
@@ -18,23 +18,24 @@ fi
# Create home directory
test ! -e /opt/usr/home && mkdir -p /opt/usr/home
-
-gum-utils --offline -u --uid 5001
+chsmack -a "_" /opt/usr/home
+cp -af /usr/share/upgrade/data/home/owner /opt/usr/home
# Copy 3.0 rpm db
rm -rf /var/lib/rpm/*
-cp -arf /usr/share/upgrade/data/rpm/* /var/lib/rpm
-
-# Disable cynara-check
-buxton2ctl security-disable
-
-####### filesystem update #######
-rm -rf /var/lock
-ln -snf /run/lock /var/lock
-
-# Directory for compatibility
-chown root:root /opt/usr/media
-chsmack -a '_' -T /opt/usr/media
-# The operation done by generic-base.post
-chown root:root /opt/var/log
-chsmack -a '*' -t /opt/var/log
+cp -af /usr/share/upgrade/data/rpm/* /var/lib/rpm
+
+
+# For sdb debugging
+/usr/share/upgrade/scripts/200.filesystem-pre.patch.sh
+/usr/share/upgrade/scripts/201.tizen-platform-config_upgrade.sh
+/usr/share/upgrade/scripts/210.dlog_upgrade.sh
+/usr/share/upgrade/scripts/201.security_upgrade.sh
+/usr/share/upgrade/scripts/500.buxton2_upgrade.sh
+
+# Prevent executing again
+mv /usr/share/upgrade/scripts/200.filesystem-pre.patch.sh /usr/share/upgrade
+mv /usr/share/upgrade/scripts/201.tizen-platform-config_upgrade.sh /usr/share/upgrade
+mv /usr/share/upgrade/scripts/210.dlog_upgrade.sh /usr/share/upgrade
+mv /usr/share/upgrade/scripts/201.security_upgrade.sh /usr/share/upgrade
+mv /usr/share/upgrade/scripts/500.buxton2_upgrade.sh /usr/share/upgrade
diff --git a/upgrade/update-post.sh b/upgrade/update-post.sh
deleted file mode 100755
index 11fc065..0000000
--- a/upgrade/update-post.sh
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/sh
-#
-# RW update post script
-#
-PATH=/bin:/usr/bin:/sbin:/usr/sbin
-
-rm -rf /opt/usr/live
-rm -rf /opt/driver
-rm -rf /opt/storage
-
-# Migrate user contents to 3.0 path
-. /etc/tizen-platform.conf
-export `tzplatform-get --user $TZ_SYS_DEFAULT_USER TZ_USER_CONTENT`
-CONTENTS24=/opt/usr/media
-CONTENTS30=$TZ_USER_CONTENT
-
-cp -rT --preserve=mode,timestamps $CONTENTS24/DCIM $CONTENTS30/Camera
-cp -rT --preserve=mode,timestamps $CONTENTS24/Documents $CONTENTS30/Documents
-cp -rT --preserve=mode,timestamps $CONTENTS24/Downloads $CONTENTS30/Downloads
-cp -rT --preserve=mode,timestamps $CONTENTS24/Images $CONTENTS30/Images
-cp -rT --preserve=mode,timestamps $CONTENTS24/Music $CONTENTS30/Music
-cp -rT --preserve=mode,timestamps $CONTENTS24/Others $CONTENTS30/Others
-cp -rT --preserve=mode,timestamps $CONTENTS24/Sounds $CONTENTS30/Sounds
-cp -rT --preserve=mode,timestamps $CONTENTS24/Videos $CONTENTS30/Videos
-
-# Remove remain garbage files
-rm -rf /opt/usr/media
-mkdir -m 755 /opt/usr/media
-chsmack -a '_' /opt/usr/media
-rm -rf /opt/home/app
diff --git a/upgrade/update.sh b/upgrade/update.sh
index bd883d7..0985749 100755
--- a/upgrade/update.sh
+++ b/upgrade/update.sh
@@ -5,38 +5,28 @@
PATH=/bin:/usr/bin:/sbin:/usr/sbin
PATCH_DIR=/usr/share/upgrade/scripts
-UPDATE_DIR=/opt/upgrade
-RESULT_FILE=${UPDATE_DIR}/update_result
-UPDATE_LOG=${UPDATE_DIR}/update_log
+RESULT_FILE=/upgrade_result
RUN=/bin/sh
# Change to normal mode from next booting
rm /system-update
+rm /usr/lib/udev/rules.d/99-sdb-switch.rules
# Execute update scripts
if [ ! -d ${PATCH_DIR} ]
then
echo "FAIL: Upgrade directory does not exist" > ${RESULT_FILE}
else
- mkdir -p ${UPDATE_DIR}
-
- echo "UPDATE: initializing" >> ${UPDATE_LOG}
- ${RUN} /usr/share/upgrade/update-init.sh >> ${UPDATE_LOG} 2>&1
-
PATCHES=`/bin/ls ${PATCH_DIR}`
- echo "UPDATE: RW update scripts" >> ${UPDATE_LOG}
for PATCH in ${PATCHES}; do
- echo "${PATCH} is started..." >> ${UPDATE_LOG}
- ${RUN} ${PATCH_DIR}/${PATCH} >> ${UPDATE_LOG} 2>&1
- echo "${PATCH} is ended..." >> ${UPDATE_LOG}
+ ${RUN} ${PATCH_DIR}/${PATCH}
done
- echo "UPDATE: post operations" >> ${UPDATE_LOG}
- ${RUN} /usr/share/upgrade/update-post.sh >> ${UPDATE_LOG} 2>&1
+ sync
- echo "SUCCESS: Upgrade successfully finished" >> ${RESULT_FILE}
+ echo "SUCCESS: Upgrade successfully finished" > ${RESULT_FILE}
fi
# Reboot
-systemctl reboot
+reboot -f