Generate database during build, include it in the package 02/23502/3
authorRafal Krypa <r.krypa@samsung.com>
Thu, 26 Jun 2014 17:37:47 +0000 (19:37 +0200)
committerRafal Krypa <r.krypa@samsung.com>
Tue, 1 Jul 2014 09:15:15 +0000 (02:15 -0700)
Initialized, empty sqlite database will be included into security-manager
package to enable integration with the code.

Change-Id: I3e5389d15a9e3a370941ef70f425da765bfc2690
Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
packaging/security-manager.spec
src/CMakeLists.txt
src/server/CMakeLists.txt
src/server/db/app-permissions-db.sql

index 5a26ef0..85d5550 100644 (file)
@@ -7,6 +7,7 @@ License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
 Source1:    security-manager.manifest
 Source3:    libsecurity-manager-client.manifest
+Requires(post): smack
 BuildRequires: cmake
 BuildRequires: zip
 BuildRequires: pkgconfig(dlog)
@@ -58,6 +59,7 @@ export LDFLAGS+="-Wl,--rpath=%{_libdir}"
 
 %cmake . -DVERSION=%{version} \
         -DBIN_INSTALL_DIR=%{_bindir} \
+        -DDB_INSTALL_DIR=%{TZ_SYS_DB} \
         -DCMAKE_BUILD_TYPE=%{?build_type:%build_type}%{!?build_type:RELEASE} \
         -DCMAKE_VERBOSE_MAKEFILE=ON
 make %{?jobs:-j%jobs}
@@ -90,6 +92,8 @@ if [ $1 = 2 ]; then
     # update
     systemctl restart security-manager.service
 fi
+chsmack -a System %{TZ_SYS_DB}/.security-manager.db
+chsmack -a System %{TZ_SYS_DB}/.security-manager.db-journal
 
 %preun
 if [ $1 = 0 ]; then
@@ -118,6 +122,8 @@ fi
 %attr(-,root,root) %{_unitdir}/sockets.target.wants/security-manager-installer.socket
 %attr(-,root,root) %{_unitdir}/security-manager-installer.socket
 %attr(-,root,root) %{TZ_SYS_SMACK}/app-rules-template.smack
+%config(noreplace) %attr(0600,root,root) %{TZ_SYS_DB}/.security-manager.db
+%config(noreplace) %attr(0600,root,root) %{TZ_SYS_DB}/.security-manager.db-journal
 %{_datadir}/license/%{name}
 
 %files -n libsecurity-manager-client
index 68f107f..01f2aa5 100644 (file)
@@ -7,6 +7,7 @@ SET(DPL_PATH     ${PROJECT_SOURCE_DIR}/src/dpl)
 SET(TARGET_SERVER "security-manager")
 SET(TARGET_CLIENT "security-manager-client")
 SET(TARGET_COMMON "security-manager-commons")
+SET(TARGET_DB ".security-manager.db")
 
 ADD_SUBDIRECTORY(include)
 ADD_SUBDIRECTORY(common)
index 0005118..313dee9 100644 (file)
@@ -58,4 +58,14 @@ TARGET_LINK_LIBRARIES(${TARGET_SERVER}
     ${SERVER_DEP_LIBRARIES}
     )
 
+ADD_CUSTOM_COMMAND(
+    OUTPUT ${TARGET_DB} ${TARGET_DB}-journal
+    COMMAND sqlite3 ${TARGET_DB} <db/app-permissions-db.sql
+    )
+
+# Add a dummy build target to trigger building of ${TARGET_DB}
+ADD_CUSTOM_TARGET(DB ALL DEPENDS ${TARGET_DB})
+
 INSTALL(TARGETS ${TARGET_SERVER} DESTINATION ${BIN_INSTALL_DIR})
+INSTALL(FILES ${TARGET_DB} DESTINATION ${DB_INSTALL_DIR})
+INSTALL(FILES ${TARGET_DB}-journal DESTINATION ${DB_INSTALL_DIR})
index a54fc97..debeaa2 100644 (file)
@@ -1,3 +1,4 @@
+PRAGMA journal_mode = PERSIST;
 PRAGMA foreign_keys = ON;
 PRAGMA auto_vacuum = NONE;