Change how system-update is executed 50/4850/1
authorWilliam Douglas <william.douglas@intel.com>
Fri, 28 Jun 2013 23:27:30 +0000 (16:27 -0700)
committerWilliam Douglas <william.douglas@intel.com>
Fri, 28 Jun 2013 23:27:30 +0000 (16:27 -0700)
Instead of deciding update function based only on file system status
of key files, use systemd to pass the update type.

Signed-off-by: William Douglas <william.douglas@intel.com>
Makefile
packaging/swup.spec
system-update.sh
system-update@.service [moved from system-update.service with 79% similarity]

index d9496e0..007ab2b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -3,6 +3,6 @@ all:
 install:
        install -D -m 755 swup.py ${DESTDIR}/usr/bin/swup
        install -D -m 755 system-update.sh ${DESTDIR}/usr/bin/system-update
-       install -D -m 644 system-update.service ${DESTDIR}/usr/lib/systemd/system/system-update.service
+       install -D -m 644 system-update@.service ${DESTDIR}/usr/lib/systemd/system/system-update@.service
        install -D -m 644 system-restore.target ${DESTDIR}/usr/lib/systemd/system/system-restore.target
-       install -D -m 644 system-update.service ${DESTDIR}/usr/lib/systemd/system/factory-reset.target
+       install -D -m 644 factory-reset.target ${DESTDIR}/usr/lib/systemd/system/factory-reset.target
index e4b2f20..dd733eb 100644 (file)
@@ -23,21 +23,21 @@ Software Update Tool.
 
 %install
 %make_install
-%install_service system-update.target.wants system-update.service
-%install_service system-restore.target.wants system-update.service
-%install_service factory-reset.target.wants system-update.service
-
+%install_service system-update.target.wants system-update@update.service
+%install_service system-restore.target.wants system-update@system.service
+%install_service factory-reset.target.wants system-update@factory.service
+# fix symlinks
+ln -sf ../system-update@.service %{buildroot}/%{_unitdir}/system-update.target.wants/system-update@update.service
+ln -sf ../system-update@.service %{buildroot}/%{_unitdir}/system-restore.target.wants/system-update@system.service
+ln -sf ../system-update@.service %{buildroot}/%{_unitdir}/factory-reset.target.wants/system-update@factory.service
 
 %files
 %defattr(-,root,root)
 %{_bindir}/swup
 %{_bindir}/system-update
-%{_unitdir}/system-update.service
+%{_unitdir}/system-update@.service
 %{_unitdir}/system-restore.target
 %{_unitdir}/factory-reset.target
-%{_unitdir}/system-update.target.wants/system-update.service
-%{_unitdir}/system-restore.target.wants/system-update.service
-%{_unitdir}/factory-reset.target.wants/system-update.service
-
-%changelog
-
+%{_unitdir}/system-update.target.wants/system-update@update.service
+%{_unitdir}/system-restore.target.wants/system-update@system.service
+%{_unitdir}/factory-reset.target.wants/system-update@factory.service
index ada9ed9..eebbd5b 100755 (executable)
@@ -54,11 +54,11 @@ function factory_restore
        snapper undochange 1..0
 }
 
-if [ -f /var/lib/snapshot-restore ]; then
+if [[ "$1" = "system" && -f /var/lib/snapshot-restore ]]; then
        system_restore
-elif [ -f /var/lib/factory-restore ]; then
+elif [[ "$1" = "factory" && -f /var/lib/factory-restore ]]; then
        factory_restore
-elif [ -e /system-update ]; then
+elif [[ "$1" = "update" ]]; then
        system_update
 fi
 
similarity index 79%
rename from system-update.service
rename to system-update@.service
index 9b991f2..d069abe 100644 (file)
@@ -1,5 +1,5 @@
 [Unit]
-Description=Tizen System Updater
+Description=Tizen System Updater for %i
 DefaultDependencies=no
 OnFailure=reboot.target
 Requires=systemd-remount-fs.service plymouth-update.service dbus.service
@@ -10,4 +10,4 @@ Type=oneshot
 #StandardInput=tty-force
 StandardOutput=tty-force
 RemainAfterExit=no
-ExecStart=/usr/bin/system-update
+ExecStart=/usr/bin/system-update %i