+++ /dev/null
-[Desktop Entry]
-Name=Annex
-Type=Application
-Exec=/usr/bin/xwalk-launcher hnabpnbionlaokfnobomjleblmmiefig
-Icon=/opt/share/widget_demo/annex.png
-
--- /dev/null
+[Desktop Entry]
+Name=Annex
+Type=Application
+Exec=/usr/bin/xwalk-launcher hnabpnbionlaokfnobomjleblmmiefig
+Icon=/opt/share/widget_demo/annex.png
+
--- /dev/null
+[Desktop Entry]
+Name=Bubblewrap
+Type=Application
+Exec=/usr/bin/xwalk-launcher kmnbdhfbkjkeilhpbooaecgpllbollfn
+Icon=/opt/share/widget_demo/bubblewrap.png
+
--- /dev/null
+[Desktop Entry]
+Name=Go
+Type=Application
+Exec=/usr/bin/xwalk-launcher clnlcbphcafhecdadfkjddinnigipace
+Icon=/opt/share/widget_demo/go.png
+
--- /dev/null
+[Desktop Entry]
+Name=Mancala
+Type=Application
+Exec=/usr/bin/xwalk-launcher fidoaebfkacalgdedfodionhmopneipb
+Icon=/opt/share/widget_demo/mancala.png
+
+++ /dev/null
-[Desktop Entry]
-Name=Bubblewrap
-Type=Application
-Exec=/usr/bin/xwalk-launcher kmnbdhfbkjkeilhpbooaecgpllbollfn
-Icon=/opt/share/widget_demo/bubblewrap.png
-
+++ /dev/null
-[Desktop Entry]
-Name=Go
-Type=Application
-Exec=/usr/bin/xwalk-launcher clnlcbphcafhecdadfkjddinnigipace
-Icon=/opt/share/widget_demo/go.png
-
#!/bin/sh
+. /etc/tizen-platform.conf
+
+function info() {
+ local ts=$(date +%Y%m%d.%H%M%S)
+ echo $ts "$@" >&2
+}
+
+function do_install() {
+ info "------------- wrt_widgets install start --------------"
+
+ local wgtdir=${TZ_SYS_SHARE}/widget_demo
+ if [ -n "$(ls $wgtdir/*.wgt 2> /dev/null)" ]; then
+ local nbinstall=0
+ for wgt in $(grep "^$USER" $wgtdir/install.conf | cut -f2 -d':'); do
+ info "installing $wgt"
+ local try=1
+ local ok=0
+ while [ $try -le 3 ]; do
+ xwalkctl -i $wgtdir/$wgt && { ok=1; break; }
+ try=$((try+1))
+ sleep 3
+ done
+ [ $ok -eq 1 ] && {
+ info "$wgt installed successfully"
+ nbinstall=$((nbinstall+1))
+ } || info "failed to install $wgt"
+ done
+
+ # signal tz-launcher that new apps were installed
+ info "$nbinstall applications installed"
+ if [ $nbinstall -gt 0 ]; then
+ info "sending restart signal to tz-launcher"
+ pkill -U $UID -USR1 tz-launcher
+ fi
+ else
+ info "$wgtdir doesn't contains any widgets (.wgt)"
+ fi
-#echo "Widget Installation"
-#if [ "$(id -u)" != "0" ]; then
-# echo "This script must be run as root" >&2
-# exit 1
-#fi
-
-source /etc/tizen-platform.conf
+ info "------------- wrt_widgets install end --------------"
+}
-wgtdir=${TZ_SYS_SHARE}/widget_demo
-if [ -z "$(ls $wgtdir/*.wgt 2> /dev/null)" ]; then
- echo "$wgtdir doesn't contains any widgets (.wgt)" 1>&2
- exit 1
-fi
+do_install >>~/.applications/install.log 2>&1 </dev/null &
-for wgt in $(grep "^$USER" $wgtdir/install.conf | cut -f2 -d':'); do
- echo "installing $wgt"
- if [ -x /usr/bin/wrt-installer ]; then
- wrt-installer -i $wgtdir/$wgt
- else
- xwalkctl -i $wgtdir/$wgt
- fi
-done
-
-[[ "$(id -u)" == "0" ]] && chmod -R a+rw ${TZ_SYS_DB}/
-
-if [ -x /usr/bin/wrt-launcher ]; then
- repo=${TZ_USER_APP}/
-
- wrt-launcher --list |
- awk 'NR>2{print $2, $5, $6}' |
- while read name packid appid
- do
- bin=$repo/$packid/bin/$appid
- for x in $repo/$packid/res/wgt/*[iI][cC][oO][nN]*; do
- if [[ -f $x ]]; then
- res=$(file -b $x|cut -d , -f 2|tr -d ' '|egrep '[0-9]+x[0-9]+')
- if [[ -n "$res" ]]; then
- diric=${TZ_SYS_SHARE}/icons/hicolor/$res/apps
- [[ -d $diric ]] || mkdir -p $diric
- cp $x $diric/$name.png
- fi
- fi
- done
- desk=${TZ_SYS_RO_DESKTOP_APP}/$name.desktop
- cat << EOC > $desk
- [Desktop Entry]
- Type=Application
- Name=$name
- Exec=$bin
- Icon=$name
- Terminal=false
- Categories=WRT;Game
-EOC
- done
-fi
-
-#update-desktop-database
-#xdg-icon-resource forceupdate
+# never fail
+exit 0
+++ /dev/null
-[Desktop Entry]
-Name=Mancala
-Type=Application
-Exec=/usr/bin/xwalk-launcher fidoaebfkacalgdedfodionhmopneipb
-Icon=/opt/share/widget_demo/mancala.png
-
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
License: Apache-2.0
BuildArch: noarch
Source0: %{name}-%{version}.tar.gz
+Source1001: wrt-widgets.manifest
BuildRequires: pkgconfig(libtzplatform-config)
Requires: libtzplatform-config
Requires: desktop-skin
%description
Wrt-widgets prepare a suitable pc oriented environment to install Web apps
-After installing wrt-widgets, launch install_widgets.sh script as root to install them.
+After installing wrt-widgets, widgets will be installed at first boot.
%prep
%setup -q
+cp %{SOURCE1001} .
%build
cp prepare_widgets.sh %{buildroot}/%{_bindir}
mkdir -p %{buildroot}/%{TZ_SYS_SHARE}/widget_demo
-cp -r *.wgt %{buildroot}/%{TZ_SYS_SHARE}/widget_demo/
-cp -r *.png %{buildroot}/%{TZ_SYS_SHARE}/widget_demo/
-cp -r *.desktop %{buildroot}/%{TZ_SYS_SHARE}/widget_demo/
+cp -r apps/*.wgt %{buildroot}/%{TZ_SYS_SHARE}/widget_demo/
+#cp -r apps/*.png %{buildroot}/%{TZ_SYS_SHARE}/widget_demo/
+#cp -r apps/*.desktop %{buildroot}/%{TZ_SYS_SHARE}/widget_demo/
cp install.conf %{buildroot}/%{TZ_SYS_SHARE}/widget_demo/
+# install xwalk preinstall service in user session
+mkdir -p %{buildroot}%{_unitdir_user}
+install -m 644 xwalk_widgets_preinstall.service %{buildroot}%{_unitdir_user}/
+
%post
+# setup xwalk preinstall service (inside user session)
+mkdir -p %{_unitdir_user}/default.target.wants/
+ln -sf ../xwalk_widgets_preinstall.service %{_unitdir_user}/default.target.wants/
+
+%postun
+rm -f %{_unitdir_user}/default.target.wants/xwalk_widgets_preinstall.service
%files
+%manifest %{name}.manifest
+%defattr(-,root,root)
%{TZ_SYS_SHARE}/widget_demo/*
%attr(755,root,root) %{_bindir}/install_widgets.sh
%attr(755,root,root) %{_bindir}/prepare_widgets.sh
+%{_unitdir_user}/xwalk_widgets_preinstall.service
+
########################################################################
# PC Specific Environment settings
-
mkdir -p ${TZ_SYS_RW_PACKAGES}
rm -f ${TZ_SYS_DB}/.wrt*
-if [ -x /usr/bin/wrt-client ]; then
- wrt_commons_create_clean_db.sh
- wrt_reset_db.sh
-fi
pkg_initdb
ail_initdb
--- /dev/null
+[Unit]
+Description=Installation of pre-installed widgets
+After=dbus.service
+ConditionPathExists=!%h/.config/xwalk-service/applications.db
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/install_widgets.sh
+
+[Install]
+WantedBy=default.target
+EOF
+