meta-agl: split wireplumber to run in multiple instances
[AGL/meta-agl.git] / meta-app-framework / recipes-security / security-manager / security-manager / 0014-Ensure-post-install-initialization-of-database.patch
1 From c7f9d14e38a1b6d40b2fffa01433a3025eff9abd Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Jos=C3=A9=20Bollo?= <jose.bollo@iot.bzh>
3 Date: Tue, 26 Nov 2019 12:34:39 +0100
4 Subject: [PATCH 14/14] Ensure post install initialization of database
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Creation of the database was made during image creation,
10 leading to issue with SOTA. This adds the creation on
11 need before launching the service.
12
13 Change-Id: Idfd0676bd87d39f7c10eaafd63f3a318f675c972
14 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
15 ---
16  db/CMakeLists.txt                   | 14 ++++++--------
17  db/security-manager-setup           | 14 ++++++++++++++
18  systemd/security-manager.service.in |  1 +
19  3 files changed, 21 insertions(+), 8 deletions(-)
20  create mode 100644 db/security-manager-setup
21
22 diff --git a/db/CMakeLists.txt b/db/CMakeLists.txt
23 index d7af1a0..dcf5bc8 100644
24 --- a/db/CMakeLists.txt
25 +++ b/db/CMakeLists.txt
26 @@ -1,12 +1,10 @@
27 -SET(TARGET_DB "$(DB_FILENAME)")
28 -
29  ADD_CUSTOM_COMMAND(
30 -    OUTPUT ${TARGET_DB} ${TARGET_DB}-journal
31 -    COMMAND sqlite3 ${TARGET_DB} <db.sql
32 -    )
33 +    OUTPUT .security-manager-setup
34 +    COMMAND sed '/--DB\.SQL--/r db.sql' security-manager-setup > .security-manager-setup
35 +    DEPENDS security-manager-setup db.sql
36 +)
37  
38  # Add a dummy build target to trigger building of ${TARGET_DB}
39 -ADD_CUSTOM_TARGET(DB ALL DEPENDS ${TARGET_DB})
40 +ADD_CUSTOM_TARGET(DB ALL DEPENDS .security-manager-setup)
41  
42 -INSTALL(FILES ${TARGET_DB} DESTINATION ${DB_INSTALL_DIR})
43 -INSTALL(FILES ${TARGET_DB}-journal DESTINATION ${DB_INSTALL_DIR})
44 +INSTALL(PROGRAMS .security-manager-setup DESTINATION ${BIN_INSTALL_DIR})
45 diff --git a/db/security-manager-setup b/db/security-manager-setup
46 new file mode 100644
47 index 0000000..5675baf
48 --- /dev/null
49 +++ b/db/security-manager-setup
50 @@ -0,0 +1,14 @@
51 +#!/bin/sh
52 +
53 +if test -f "$1"; then exit; fi
54 +set -e
55 +dbdir="$(dirname "$1")"
56 +dbfile="$(basename "$1")"
57 +test -n "$dbfile"
58 +test -n "$dbdir"
59 +mkdir -p "$dbdir"
60 +cd "$dbdir"
61 +sqlite3 "$dbfile" << END-OF-CAT
62 +--DB.SQL--
63 +END-OF-CAT
64 +
65 diff --git a/systemd/security-manager.service.in b/systemd/security-manager.service.in
66 index 23fd1b2..2bf97d7 100644
67 --- a/systemd/security-manager.service.in
68 +++ b/systemd/security-manager.service.in
69 @@ -3,5 +3,6 @@ Description=Start the security manager
70  
71  [Service]
72  Type=notify
73 +ExecStartPre=@BIN_INSTALL_DIR@/.security-manager-setup @DB_INSTALL_DIR@/@DB_FILENAME@
74  ExecStart=@BIN_INSTALL_DIR@/security-manager
75  Sockets=security-manager.socket
76 -- 
77 2.21.0
78