Use pkgmgr API to get the parser db path 24/81324/8
authorHwankyu Jhun <h.jhun@samsung.com>
Mon, 25 Jul 2016 12:07:35 +0000 (21:07 +0900)
committerHwanKyu Jhun <h.jhun@samsung.com>
Sun, 7 Aug 2016 22:42:02 +0000 (15:42 -0700)
- Requires
https://review.tizen.org/gerrit/81322

Change-Id: Ieb0403b6d95ef57a9ddd569d03f89f46475cf25d
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
packaging/app-installers.spec
src/pkg_initdb/10_package-manager-add.post
src/pkg_initdb/11_package-manager-del.post [new file with mode: 0644]
src/pkg_initdb/CMakeLists.txt
src/pkg_initdb/pkg_initdb.cc

index 56e8c9a..5a236e4 100644 (file)
@@ -94,6 +94,7 @@ make %{?_smp_mflags}
 %{_unitdir}/pkgdir-tool.service
 %{_bindir}/pkg_initdb
 %attr(0755,root,root) %{_sysconfdir}/gumd/useradd.d/10_package-manager-add.post
+%attr(0755,root,root) %{_sysconfdir}/gumd/userdel.d/11_package-manager-del.post
 %license LICENSE
 
 %files devel
index aa13d61..c88d69f 100644 (file)
@@ -1 +1,12 @@
+#!/bin/sh
+
+PATH=/bin:/usr/bin:/sbin:/usr/bin
+
+mkdir -p -Z User::Home -m 755 /opt/dbspace/user
+
+export `tzplatform-get --user $2 TZ_USER_NAME`
+
+mkdir -p -Z User::Home -m 770 /opt/dbspace/user/$2
+chown $TZ_USER_NAME:system_share /opt/dbspace/user/$2
+
 pkg_initdb --uid $2
diff --git a/src/pkg_initdb/11_package-manager-del.post b/src/pkg_initdb/11_package-manager-del.post
new file mode 100644 (file)
index 0000000..fdbcfab
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+PATH=/bin:/usr/bin:/sbin:/usr/bin
+
+rm -rf /opt/dbspace/user/$2
+
index 8e1b7bd..424c62d 100644 (file)
@@ -19,3 +19,4 @@ SET_TARGET_PROPERTIES(${TARGET_PKG_INITDB} PROPERTIES LINK_FLAGS "-pie")
 # Install
 INSTALL(TARGETS ${TARGET_PKG_INITDB} DESTINATION ${BINDIR})
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/10_package-manager-add.post  DESTINATION ${SYSCONF_INSTALL_DIR}/gumd/useradd.d/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/11_package-manager-del.post  DESTINATION ${SYSCONF_INSTALL_DIR}/gumd/userdel.d/)
index fc9cf21..0df326b 100644 (file)
@@ -81,18 +81,17 @@ void InitdbLoadDirectory(uid_t uid, const bf::path& directory, bool preload) {
 }
 
 void RemoveOldDatabases(uid_t uid) {
-  if (!IsGlobal(uid))
-    tzplatform_set_user(uid);
+  char *parser_db = getUserPkgParserDBPathUID(uid);
+  char *cert_db = getUserPkgCertDBPathUID(uid);
+  std::string journal = "-journal";
+  std::string parser_db_journal = parser_db + journal;
+  std::string cert_db_journal = cert_db + journal;
 
   bs::error_code error;
-  bf::path info_db_path(tzplatform_mkpath(
-      IsGlobal(uid) ? TZ_SYS_DB : TZ_USER_DB, ".pkgmgr_parser.db"));
-  bf::path info_db_journal_path(tzplatform_mkpath(
-      IsGlobal(uid) ? TZ_SYS_DB : TZ_USER_DB, ".pkgmgr_parser.db-journal"));
-  bf::path cert_db_path(tzplatform_mkpath(
-      IsGlobal(uid) ? TZ_SYS_DB : TZ_USER_DB, ".pkgmgr_cert.db"));
-  bf::path  cert_db_journal_path(tzplatform_mkpath(
-      IsGlobal(uid) ? TZ_SYS_DB : TZ_USER_DB, ".pkgmgr_cert.db-journal"));
+  bf::path info_db_path(parser_db);
+  bf::path info_db_journal_path(parser_db_journal.c_str());
+  bf::path cert_db_path(cert_db);
+  bf::path cert_db_journal_path(cert_db_journal.c_str());
 
   bf::remove(info_db_path, error);
   if (error)
@@ -107,7 +106,8 @@ void RemoveOldDatabases(uid_t uid) {
   if (error)
     std::cerr << cert_db_journal_path << " is not removed" << std::endl;
 
-  tzplatform_reset_user();
+  free(cert_db);
+  free(parser_db);
 }
 
 }  // namespace