demo and examples [re]packaging
authorLeandro Dorileo <leandro.maciel.dorileo@intel.com>
Fri, 16 Aug 2013 19:42:03 +0000 (16:42 -0300)
committerLeandro Dorileo <leandro.maciel.dorileo@intel.com>
Mon, 19 Aug 2013 17:02:45 +0000 (14:02 -0300)
This patch reorganizes the packaging for demo and example. With that
we now generate 3 packages: 1) the exentions itself, 2) examples and
3) demo.

The resulting packages are:
   tizen-extensions-crosswalk-${version}-${release}.${arch}.rpm
   tizen-extensions-crosswalk-bluetooth-demo-${version}-${release}.${arch}.rpm
   tizen-extensions-crosswalk-examples-${version}-${release}.${arch}.rpm

For both demo and examples packages a manifest xml file is generated
so we can have a launcher icon within tizen menu-screen.

Installation:
The extensions rpm installation remains the same(i.e rpm -Uvh --force
tizen-extensions-crosswalk-${version}-${release}.${arch}.rpm).

The additional packages(demo and examples) must be installed with
pkgcmd, like:
   $ pkgcmd -i -t rpm -p tizen-extensions-crosswalk-bluetooth-demo-0.2-0.i586.rpm -q
   $ pkgcmd -i -t rpm -p tizen-extensions-crosswalk-examples-0.2-0.i586.rpm -q

.gitignore
packaging/tizen-extensions-crosswalk-bluetooth-demo [new file with mode: 0755]
packaging/tizen-extensions-crosswalk-examples [new file with mode: 0755]
packaging/tizen-extensions-crosswalk.png [new file with mode: 0644]
packaging/tizen-extensions-crosswalk.spec
tizen-extensions-crosswalk.xml.in [new file with mode: 0644]
tizen-wrt.gyp
tools/generate_manifest.py [new file with mode: 0755]

index cdec58c..3e1fd1b 100644 (file)
@@ -3,3 +3,4 @@ out/
 *.swp
 cscope.*
 tags
+*.xml
diff --git a/packaging/tizen-extensions-crosswalk-bluetooth-demo b/packaging/tizen-extensions-crosswalk-bluetooth-demo
new file mode 100755 (executable)
index 0000000..8400f68
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+exec /usr/bin/tizen-extensions-crosswalk /usr/share/tizen-extensions-crosswalk/demos/tizen/bluetooth.html
diff --git a/packaging/tizen-extensions-crosswalk-examples b/packaging/tizen-extensions-crosswalk-examples
new file mode 100755 (executable)
index 0000000..8b52587
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+exec /usr/bin/tizen-extensions-crosswalk /usr/share/tizen-extensions-crosswalk/examples/index.html
diff --git a/packaging/tizen-extensions-crosswalk.png b/packaging/tizen-extensions-crosswalk.png
new file mode 100644 (file)
index 0000000..0a3e2dc
Binary files /dev/null and b/packaging/tizen-extensions-crosswalk.png differ
index 5a39c2e..fe63a99 100644 (file)
@@ -1,3 +1,8 @@
+%define _manifestdir /opt/share/packages
+%define _desktop_icondir /opt/share/icons/default/small
+%define _bluetooth_demo_package tizen-extensions-crosswalk-bluetooth-demo
+%define _examples_package tizen-extensions-crosswalk-examples
+
 Name:       tizen-extensions-crosswalk
 Version:    0.2
 Release:    0
@@ -7,6 +12,9 @@ Summary:    Tizen Web APIs implemented using Crosswalk
 URL:        https://github.com/otcshare/tizen-extensions-crosswalk
 Source0:    %{name}-%{version}.tar.gz
 Source1:    %{name}
+Source2:    %{name}.png
+Source3:    %{_bluetooth_demo_package}
+Source4:    %{_examples_package}
 Source1001: %{name}.manifest
 
 BuildRequires: python
@@ -33,10 +41,29 @@ Requires:      crosswalk
 %description
 Tizen Web APIs implemented using Crosswalk.
 
+%package -n %{_bluetooth_demo_package}
+Summary: Tizen Web APIs using Crosswalk demo
+Group: Development/Libraries
+Requires:      %{name}
+
+%description  -n %{_bluetooth_demo_package}
+Tizen Web APIs bluetooth demo implementation using Crosswalk.
+
+%package -n %{_examples_package}
+Summary: Tizen Web APIs using Crosswalk examples
+Group: Development/Libraries
+Requires:      %{name}
+
+%description  -n %{_examples_package}
+Tizen Web APIs examples using Crosswalk.
+
 %prep
 %setup -q
 
 cp %{SOURCE1001} .
+cp %{SOURCE2} .
+cp %{SOURCE3} .
+cp %{SOURCE4} .
 
 %build
 
@@ -52,6 +79,8 @@ make %{?_smp_mflags}
 
 # Binary wrapper.
 install -m 755 -D %{SOURCE1} %{buildroot}%{_bindir}/%{name}
+install -m 755 -D %{SOURCE3} %{buildroot}%{_bindir}/%{_bluetooth_demo_package}
+install -m 755 -D %{SOURCE4} %{buildroot}%{_bindir}/%{_examples_package}
 
 # Extensions.
 mkdir -p %{buildroot}%{_libdir}/%{name}
@@ -72,14 +101,29 @@ install -p -m 644 demos/tizen/*.html %{buildroot}%{_datarootdir}/%{name}/demos/t
 install -p -m 644 demos/tizen/css/*.css %{buildroot}%{_datarootdir}/%{name}/demos/tizen/css
 install -p -m 644 demos/tizen/js/*.js %{buildroot}%{_datarootdir}/%{name}/demos/tizen/js
 
+# register to the package manager
+install -m 644 -D %{_examples_package}.xml %{buildroot}%{_manifestdir}/%{_examples_package}.xml
+install -m 644 -D %{_bluetooth_demo_package}.xml %{buildroot}%{_manifestdir}/%{_bluetooth_demo_package}.xml
+install -p -D %{name}.png %{buildroot}%{_desktop_icondir}/%{_examples_package}.png
+install -p -D %{name}.png %{buildroot}%{_desktop_icondir}/%{_bluetooth_demo_package}.png
+
 %files
 # TODO(rakuco): This causes problems on 2.1 when creating the package.
 # %license LICENSE
 %{_bindir}/%{name}
 %{_libdir}/%{name}/libtizen*.so
-%{_datarootdir}/%{name}/examples/*.html
-%{_datarootdir}/%{name}/examples/js/*.js
 
+%files -n %{_bluetooth_demo_package}
+%{_bindir}/%{_bluetooth_demo_package}
+%{_manifestdir}/%{_bluetooth_demo_package}.xml
+%{_desktop_icondir}/%{_bluetooth_demo_package}.png
 %{_datarootdir}/%{name}/demos/tizen/*.html
 %{_datarootdir}/%{name}/demos/tizen/css/*.css
 %{_datarootdir}/%{name}/demos/tizen/js/*.js
+
+%files -n %{_examples_package}
+%{_bindir}/%{_examples_package}
+%{_manifestdir}/%{_examples_package}.xml
+%{_desktop_icondir}/%{_examples_package}.png
+%{_datarootdir}/%{name}/examples/*.html
+%{_datarootdir}/%{name}/examples/js/*.js
diff --git a/tizen-extensions-crosswalk.xml.in b/tizen-extensions-crosswalk.xml.in
new file mode 100644 (file)
index 0000000..1e461bb
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns="http://tizen.org/ns/packages" package="@PACKAGE_NAME@" version="@PACKAGE_VERSION@" install-location="internal-only">
+  <label>@PACKAGE_LABEL@</label>
+  <author email="cameo-dev@linux.intel.com" href="www.intel.com">XWalkDev</author>
+  <description>@PACKAGE_LABEL@</description>
+  <ui-application appid="@APP_ID@" exec="@PACKAGE_EXEC@" nodisplay="false" multiple="false" type="capp" taskmanage="true">
+    <label>@PACKAGE_LABEL@</label>
+    <icon>@PACKAGE_NAME@.png</icon>
+  </ui-application>
+</manifest>
index 294eba2..db32642 100644 (file)
@@ -1,4 +1,8 @@
 {
+  'includes':[
+    'common/common.gypi',
+  ],
+
   'targets': [
     {
       'target_name': 'build_all_tizen_extensions',
         'download/download.gyp:*',
       ],
     },
+    {
+      'target_name': 'generate_manifest',
+      'type': 'none',
+
+      'conditions': [
+        [ 'extension_host_os == "mobile"', {
+          'actions': [
+            {
+              'variables': {
+                'generate_args': [
+                  '_examples_package',
+                  'crosswalk-examples',
+                  '/usr/bin/tizen-extensions-crosswalk-examples',
+                  'Crosswalk Examples',
+                ],
+              },
+              'action_name': 'examples',
+              'inputs': [
+                'tools/generate_manifest.py',
+                'packaging/tizen-extensions-crosswalk.spec',
+                'tizen-extensions-crosswalk.xml.in',
+              ],
+              'outputs': [
+                'tizen-extensions-crosswalk-examples.xml',
+              ],
+              'action': [
+                'python',
+                '<@(_inputs)',
+                '<@(generate_args)',
+                '<@(_outputs)',
+              ],
+            },
+            {
+              'variables': {
+                'generate_args': [
+                  '_bluetooth_demo_package',
+                  'crosswalk-bluetooth-demo',
+                  '/usr/bin/tizen-extensions-crosswalk-bluetooth-demo',
+                  'Crosswalk Bluetooth Demo',
+                ],
+              },
+              'action_name': 'demo',
+              'inputs': [
+                'tools/generate_manifest.py',
+                'packaging/tizen-extensions-crosswalk.spec',
+                'tizen-extensions-crosswalk.xml.in',
+              ],
+              'outputs': [
+                'tizen-extensions-crosswalk-bluetooth-demo.xml',
+              ],
+              'action': [
+                'python',
+                '<@(_inputs)',
+                '<@(generate_args)',
+                '<@(_outputs)',
+              ],
+            },
+          ],
+        }],
+      ],
+    },
   ],
 }
diff --git a/tools/generate_manifest.py b/tools/generate_manifest.py
new file mode 100755 (executable)
index 0000000..dc366ec
--- /dev/null
@@ -0,0 +1,30 @@
+# Copyright (c) 2013 Intel Corporation. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import sys, os, re, errno
+
+spec = sys.argv[1]
+origin = sys.argv[2]
+
+if len(sys.argv) != 8:
+    print 'Invalid arguments'
+    sys.exit(errno.EINVAL)
+
+if not os.path.isfile(spec) or not os.path.isfile(origin):
+    print 'No such spec(%s) or input xml(%s) file' % (spec, origin)
+    sys.exit(errno.ENOENT)
+
+spec = file(spec).read()
+version = re.search('(?<=Version:).*', spec).group(0).strip()
+package_name = re.search('(?<=%define '+sys.argv[3]+').*', spec).group(0).strip()
+
+template = file(origin).read().replace('@PACKAGE_VERSION@', version)
+template = template.replace('@PACKAGE_NAME@', package_name)
+template = template.replace('@APP_ID@', sys.argv[4])
+template = template.replace('@PACKAGE_EXEC@', sys.argv[5])
+template = template.replace('@PACKAGE_LABEL@', sys.argv[6])
+
+output = open(sys.argv[7], 'w')
+output.write(template)
+output.close()