From: jongmyeongko Date: Mon, 21 Nov 2016 12:02:31 +0000 (+0900) Subject: add prelaod-rw installation to preload installation tool. X-Git-Tag: accepted/tizen/3.0/common/20161125.101804^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1f1651c2b93aab66d2109852ff6867006b33d435;p=platform%2Fcore%2Fappfw%2Fpkgmgr-tool.git add prelaod-rw installation to preload installation tool. Change-Id: I29a56bc8aa3fb66cb14831317d9a7e21761ef23c Signed-off-by: jongmyeongko --- diff --git a/src/install_preload_pkg.c b/src/install_preload_pkg.c index ea797ca..bd8ddb0 100644 --- a/src/install_preload_pkg.c +++ b/src/install_preload_pkg.c @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -50,8 +51,11 @@ #define WGT_BACKEND_CMD "/usr/bin/wgt-backend" #define TPK_DIR tzplatform_mkpath(TZ_SYS_RO_APP, ".preload-tpk") #define WGT_DIR tzplatform_mkpath(TZ_SYS_RO_APP, ".preload-wgt") +#define TPK_RW_DIR tzplatform_mkpath(TZ_SYS_RO_APP, ".preload-rw-tpk") +#define WGT_RW_DIR tzplatform_mkpath(TZ_SYS_RO_APP, ".preload-rw-wgt") -static int _install_preload_pkg(const char *backend, const char *directory) +static int _install_preload_pkg(const char *backend, const char *directory, + bool readonly) { DIR *dir; struct dirent file_info, *result; @@ -86,7 +90,8 @@ static int _install_preload_pkg(const char *backend, const char *directory) pid_t pid = fork(); if (pid == 0) { execl(backend, backend, "-i", file_path, - "--preload", (char *)NULL); + readonly? "--preload":"--preload-rw", + (char *)NULL); } else if (pid < 0) { _E("failed to fork and execute %s!", backend); closedir(dir); @@ -99,13 +104,16 @@ static int _install_preload_pkg(const char *backend, const char *directory) } /* remove a file after installation */ - ret = remove(file_path); - if (ret < 0) { - _E("Failed to remove the file [%s] because [%s]", - file_path, strerror_r(errno, err_buf, - sizeof(err_buf))); - closedir(dir); - return -1; + /* keep rw packages for factory-reset */ + if (readonly) { + ret = remove(file_path); + if (ret < 0) { + _E("Failed to remove the file [%s] because [%s]", + file_path, strerror_r(errno, err_buf, + sizeof(err_buf))); + closedir(dir); + return -1; + } } } @@ -134,10 +142,16 @@ int main(int argc, char *argv[]) return -1; } - if (_install_preload_pkg(TPK_BACKEND_CMD, TPK_DIR) < 0) + if (_install_preload_pkg(TPK_BACKEND_CMD, TPK_DIR, true) < 0) + goto error; + + if (_install_preload_pkg(WGT_BACKEND_CMD, WGT_DIR, true) < 0) + goto error; + + if (_install_preload_pkg(TPK_BACKEND_CMD, TPK_RW_DIR, false) < 0) goto error; - if (_install_preload_pkg(WGT_BACKEND_CMD, WGT_DIR) < 0) + if (_install_preload_pkg(WGT_BACKEND_CMD, WGT_RW_DIR, false) < 0) goto error; return 0;