summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2018-04-04 21:59:45 +0200
committerSebastien Douheret <sebastien.douheret@iot.bzh>2018-04-05 01:30:31 +0200
commit1775ce4b91aa9c871d510d23a7d037f773d52b09 (patch)
tree7f2b42c385ee2cc72790fb83ce97ed98fb72362c /scripts
parent607fa1dcb03e482415cf70a50fcd094c8bd88c9d (diff)
Rework SDK default directory.
Default SDK directory is $HOME/xds-workspace/.sdks expect if /xdt/sdk exists (backward compatibility). Default SDK directory can be set by defining XDT_SDK variable in /etc/xdtrc file Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/sdks/agl/_env-init.sh7
-rwxr-xr-xscripts/sdks/agl/db-dump9
2 files changed, 10 insertions, 6 deletions
diff --git a/scripts/sdks/agl/_env-init.sh b/scripts/sdks/agl/_env-init.sh
index a08f798..921f319 100755
--- a/scripts/sdks/agl/_env-init.sh
+++ b/scripts/sdks/agl/_env-init.sh
@@ -1,6 +1,6 @@
#!/bin/bash
###########################################################################
-# Copyright 2017 IoT.bzh
+# Copyright 2017-2018 IoT.bzh
#
# author: Sebastien Douheret <sebastien@iot.bzh>
#
@@ -19,7 +19,10 @@
[ -f /etc/xdtrc ] && . /etc/xdtrc
-[ -z "$XDT_SDK" ] && XDT_SDK=/xdt/sdk
+if [ -z "$XDT_SDK" ]; then
+ # For backward compatibility and compliance with AGL DevKit docker image
+ [ -d "/xdt/sdk" ] && export XDT_SDK=/xdt/sdk || export XDT_SDK=$HOME/xds-workspace/.sdks
+fi
export SDK_FAMILY_NAME="agl"
export SDK_ROOT_DIR="$XDT_SDK"
diff --git a/scripts/sdks/agl/db-dump b/scripts/sdks/agl/db-dump
index 5c040ea..379be3e 100755
--- a/scripts/sdks/agl/db-dump
+++ b/scripts/sdks/agl/db-dump
@@ -49,7 +49,7 @@ ENV = subprocess.check_output(
for elt in ENV:
k, v = elt.split('=', 1)
if k == 'SDK_ROOT_DIR':
- SDK_ROOT_DIR = v
+ SDK_ROOT_DIR = v.rstrip('/')
elif k == 'SDK_ENV_SETUP_FILENAME':
SDK_ENV_SETUP_FILENAME = v
@@ -96,9 +96,10 @@ for root, dirs, files in os.walk(SDK_ROOT_DIR):
for one_sdk in INSTALLED_SDK:
logging.debug("Processing %s", one_sdk['ENV_FILE'])
- PROFILE = one_sdk['ENV_FILE'].split('/')[3]
- VERSION = one_sdk['ENV_FILE'].split('/')[4]
- ARCH = one_sdk['ENV_FILE'].split('/')[5]
+ envFile = one_sdk['ENV_FILE'].split(SDK_ROOT_DIR+'/')[1]
+ PROFILE = envFile.split('/')[0]
+ VERSION = envFile.split('/')[1]
+ ARCH = envFile.split('/')[2]
DIR = os.path.dirname(one_sdk['ENV_FILE'])
if PROFILE == '' or VERSION == '' or ARCH == '' or DIR == '':
logging.debug('Path not compliant, skipping')
/* Keyword.Type */ .highlight .ld { color: #e6db74 } /* Literal.Date */ .highlight .m { color: #ae81ff } /* Literal.Number */ .highlight .s { color: #e6db74 } /* Literal.String */ .highlight .na { color: #a6e22e } /* Name.Attribute */ .highlight .nb { color: #f8f8f2 } /* Name.Builtin */ .highlight .nc { color: #a6e22e } /* Name.Class */ .highlight .no { color: #66d9ef } /* Name.Constant */ .highlight .nd { color: #a6e22e } /* Name.Decorator */ .highlight .ni { color: #f8f8f2 } /* Name.Entity */ .highlight .ne { color: #a6e22e } /* Name.Exception */ .highlight .nf { color: #a6e22e } /* Name.Function */ .highlight .nl { color: #f8f8f2 } /* Name.Label */ .highlight .nn { color: #f8f8f2 } /* Name.Namespace */ .highlight .nx { color: #a6e22e } /* Name.Other */ .highlight .py { color: #f8f8f2 } /* Name.Property */ .highlight .nt { color: #f92672 } /* Name.Tag */ .highlight .nv { color: #f8f8f2 } /* Name.Variable */ .highlight .ow { color: #f92672 } /* Operator.Word */ .highlight .w { color: #f8f8f2 } /* Text.Whitespace */ .highlight .mb { color: #ae81ff } /* Literal.Number.Bin */ .highlight .mf { color: #ae81ff } /* Literal.Number.Float */ .highlight .mh { color: #ae81ff } /* Literal.Number.Hex */ .highlight .mi { color: #ae81ff } /* Literal.Number.Integer */ .highlight .mo { color: #ae81ff } /* Literal.Number.Oct */ .highlight .sa { color: #e6db74 } /* Literal.String.Affix */ .highlight .sb { color: #e6db74 } /* Literal.String.Backtick */ .highlight .sc { color: #e6db74 } /* Literal.String.Char */ .highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */ .highlight .sd { color: #e6db74 } /* Literal.String.Doc */ .highlight .s2 { color: #e6db74 } /* Literal.String.Double */ .highlight .se { color: #ae81ff } /* Literal.String.Escape */ .highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */ .highlight .si { color: #e6db74 } /* Literal.String.Interpol */ .highlight .sx { color: #e6db74 } /* Literal.String.Other */ .highlight .sr { color: #e6db74 } /* Literal.String.Regex */ .highlight .s1 { color: #e6db74 } /* Literal.String.Single */ .highlight .ss { color: #e6db74 } /* Literal.String.Symbol */ .highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #a6e22e } /* Name.Function.Magic */ .highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */ .highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */ .highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */ .highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */ .highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */ } @media (prefers-color-scheme: light) { .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
# AGL Framework Binder

This project provides the binder component of the the microservice architecture 
of Automotive Grade Linux (AGL).

This project is available there https://git.automotivelinux.org/src/app-framework-binder/

It can be cloned with **git clone https://git.automotivelinux.org/src/app-framework-binder**.


## License and copying

This software is an open source software funded by LinuxFoundation and Renesas.

This software is delivered under the terms of the open source license Apache 2.

This license is available in the file LICENSE-2.0.txt or on the worl wide web at the
location https://opensource.org/licenses/Apache-2.0


## Building

### Requirements

Building the AGL framework binder has been tested under 
  **Ubuntu**, **Debian** and **Fedora 26** with gcc 6 and 7.

It requires the following libraries:

 * libmagic ("libmagic-dev" under Ubuntu, "file-devel" under Fedora);
 * libmicrohttpd >= 0.9.60  (fetch and build from "http://ftp.gnu.org/gnu/libmicrohttpd");
 * json-c ("libjson-c-dev/devel");
 * uuid ("uuid-dev/libuuid-devel");
 * openssl ("libssl-dev/openssl-devel");
 * systemd >= 222 ("libsystemd-dev/systemd-devel");

The following library can be used for checking permissions:

 * cynara (https://github.com/Samsung/cynara)

and the following tools:

 * gcc;
 * pkg-config;
 * cmake >= 3.0

To install all dependencies under Ubuntu (excepting libmicrohttpd), please type:

	$ apt-get install libmagic-dev libjson-c-dev uuid-dev libsystemd-dev libssl-dev gcc make pkg-config cmake

or under Fedora (excepting libmicrohttpd and rtl-sdr):

	$ dnf install git passwd iproute openssh-server openssh-client
	$ dnf install file-devel gcc gdb make pkgconfig cmake
	$ dnf install json-c-devel libuuid-devel systemd-devel openssl-devel

### Simple compilation

The following commands will install the binder in your subdirectory
**$HOME/local** (instead of **/usr/local** the default when 
*CMAKE_INSTALL_PREFIX* isn't set).

	$ git clone https://git.automotivelinux.org/src/app-framework-binder
	$ cd app-framework-binder
	$ mkdir build
	$ cd build
	$ cmake -DCMAKE_INSTALL_PREFIX=$HOME/local ..
	$ make install

### Advanced compilation

You can tune options when calling cmake. Here are the known options with
their default values.

	$ git clone https://git.automotivelinux.org/src/app-framework-binder
	$ cd app-framework-binder
	$ mkdir build
	$ cd build
	$ cmake \
	      -DCMAKE_INSTALL_PREFIX=/usr/local  \
	      -DAGL_DEVEL=OFF                    \
	      -DINCLUDE_MONITORING=OFF           \
	      -DINCLUDE_SUPERVISOR=OFF           \
	      -DINCLUDE_DBUS_TRANSPARENCY=OFF    \
	      -DINCLUDE_LEGACY_BINDING_V1=OFF    \
	      -DINCLUDE_LEGACY_BINDING_VDYN=OFF  \
	      -DAFS_SUPERVISOR_PORT=1619         \
	      -DAFS_SUPERVISOR_TOKEN="HELLO"     \
	      -DAFS_SUPERVISION_SOCKET="@urn:AGL:afs:supervision:socket" \
	      -DUNITDIR_SYSTEM=${CMAKE_INSTALL_LIBDIR}/systemd/system    \
	    ..
	$ make install

The configuration options are:

| Variable                    | Type    | Feature
|:----------------------------|:-------:|:------------------------------
| AGL_DEVEL                   | BOOLEAN | Activates development features
| INCLUDE_MONITORING          | BOOLEAN | Activates installation of monitoring
| INCLUDE_SUPERVISOR          | BOOLEAN | Activates installation of supervisor
| INCLUDE_DBUS_TRANSPARENCY   | BOOLEAN | Allows API transparency over DBUS
| INCLUDE_LEGACY_BINDING_V1   | BOOLEAN | Includes the legacy Binding API version 1
| INCLUDE_LEGACY_BINDING_VDYN | BOOLEAN | Includes the legacy Binding API version dynamic
| AFS_SUPERVISOR_PORT         | INTEGER | Port of service for the supervisor
| AFS_SUPERVISOR_TOKEN        | STRING  | Secret token for the supervisor
| AFS_SUPERVISION_SOCKET      | STRING  | Internal socket path for supervision (internal if starts with @)
| UNITDIR_SYSTEM              | STRING  | Path to systemd system unit files for installing supervisor




***** TO BE COMPLETED *****












## Simple demo




### Testing/Debug

```
$ ${AFB_DAEMON_DIR}/build/src/afb-daemon --help
$ ${AFB_DAEMON_DIR}/build/src/afb-daemon --port=1234 --token='' --ldpaths=${AFB_DAEMON_DIR}/build --workdir=/tmp --rootdir=${AFB_DAEMON_DIR}/test
```

### Starting

```
$ afb-daemon --help
$ afb-daemon --verbose --port=<port> --token='' --workdir=<working directory> --rootdir=<web directory (index.html)>
```

### Example

```
$ afb-daemon --verbose --port=1234 --token='' --workdir=/tmp --rootdir=/srv/www/htdocs --alias=icons:/usr/share/icons
```

### Directories & Paths

Default behaviour is to locate ROOTDIR in $HOME/.AFB

### REST API

Developers are intended to provide a structure containing : API name, corresponding methods/callbacks, and optionally a context and a handle.
A handle is a void* structure automatically passed to API callbacks.
Callbacks also receive HTTP GET data as well as HTTP POST data, in case a POST method was used.
Every method should return a JSON object or NULL in case of error.

API plugins can be protected from timeout and other errors. By default this behaviour is deactivated, use --apitimeout to activate it.

        STATIC AFB_restapi myApis[]= {
          {"ping"    , AFB_SESSION_NONE,  (AFB_apiCB)ping,     "Ping Function"},
          {"action1" , AFB_SESSION_CHECK, (AFB_apiCB)action1 , "Action-1"},
          {"action2" , AFB_SESSION_CHECK, (AFB_apiCB)action2 , "Action-2"},
          {NULL}
        };

        PUBLIC AFB_plugin *pluginRegister () {
            AFB_plugin *plugin = malloc (sizeof (AFB_plugin));
            plugin->type  = AFB_PLUGIN_JSON;
            plugin->info  = "Plugin Sample";
            plugin->prefix= "myPlugin";
            plugin->apis  = myApis;
            return (plugin);
        }

### HTML5 and AngularJS Redirects

Binder supports HTML5 redirect mode even with an application baseurl.
Default value for application base URL is /opa.
See Application Framework HTML5 Client template at https://github.com/iotbzh/afb-client-sample

If the Binder receives something like _http://myopa/sample_ when sample is not the homepage of the AngularJS OPA,
it will redirect to _http://myopa/#!sample_.
This redirect will return the _index.html_ OPA file and will notify AngularJS not to display the homepage, but the sample page.

Warning: in order for AngularJS applications to be able to work with both BASEURL="/" and BASEURL="/MyApp/", all page references have to be relative.

Recommended model is to develop with a BASEURL="/opa" as any application working with a BASEURL will work without, while the opposite is not true.

Note: If a resource is not accessible from ROOTDIR then the "--alias" switch should be used, as in: --alias=/icons:/usr/share/icons.
Only use alias for external support static files. This should not be used for API and OPA.


### Ongoing work

Javascript plugins. As of today, only C plugins are supported, but JS plugins are on the TODO list.