2 * Copyright 2013 Samsung Electronics Co., Ltd
5 * Contact: Minsu Seo <minsu15.seo@samsung.com>
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 #include <sys/types.h>
22 #include <sys/xattr.h>
33 #include <pkgmgr-info.h>
34 #include <pkgmgr_installer_info.h>
36 #define WORKER "/etc/package-manager/parserlib/worker.sh"
39 #define TZDATA_UPDATE_PARSER_TAG "TZDATA_UPDATE_PARSER"
41 #define DEBUG_LOG(frmt, args...) \
42 do { SLOG(LOG_DEBUG,TZDATA_UPDATE_PARSER_TAG, "[tzdata_update_parser] %s: "frmt"\n",\
43 __func__, ##args);} while (0)
45 #define DEBUG_WARNING(frmt, args...) \
46 do { SLOG(LOG_WARN,TZDATA_UPDATE_PARSER_TAG, "[tzdata_update_parser] %s: "frmt"\n",\
47 __func__, ##args);} while (0)
49 #define DEBUG_ERROR(frmt, args...) \
50 do { SLOG(LOG_ERROR,TZDATA_UPDATE_PARSER_TAG, "[tzdata_update_parser] %s: "frmt"\n",\
51 __func__, ##args);} while (0)
53 #define TRACE_BEGIN do {\
54 SLOG(LOG_DEBUG,TZDATA_UPDATE_PARSER_TAG, "[ENTER tzdata_update_parser] %s\n",\
57 #define TRACE_END do {\
58 SLOG(LOG_DEBUG,TZDATA_UPDATE_PARSER_TAG, "[LEAVE tzdata_update_parser] %s\n",\
62 static void alt_system()
67 //char *const args[2] = {"/home/mjpark", NULL};
69 //extern char **environ;
70 /* ... Sanitize arguments ... */
74 } else if (pid != 0) {
75 while ((ret = waitpid(pid, &status, 0)) == -1) {
82 (!WIFEXITED(status) || !WEXITSTATUS(status)) ) {
83 /* Report unexpected child status */
85 DEBUG_LOG(" ----> parent ? : %d ", ret);
88 /* ... Initialize env as a sanitized copy of environ ... */
89 //ret = execl("/home/mjpark/cprog/dir_copy/work.sh", "work.sh", (char *)0);
90 //if (execve("/bin/ls", args, env) == -1) {
91 //ret = execl("/bin/ls", "-1", (char *)0);
92 DEBUG_LOG(" ------------> run execl: %s ", WORKER);
93 ret = execl("/bin/bash", "bash", "-c", WORKER, (char *) NULL);
96 DEBUG_LOG("error occured : %s", WORKER);
97 printf("error occured\n");
100 DEBUG_LOG("run OK !!!!!!!!!!!!!!!!!!!!!!!!!!!!");
105 //DEBUG_ERROR("srcdir length is not available \n");
106 //DEBUG_LOG("srcdir =%s\n",(char *) srcdir);
107 int COMMON_PKGMGR_PLUGIN_INSTALL(const char *pkgid, const char *appid, GList *list)
111 pkgmgrinfo_pkginfo_h handle = NULL;
112 const char *app_root_path = NULL;
113 //const char *dest_path = NULL;
116 pkgmgr_installer_info_get_target_uid(&uid);
117 ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, uid, &handle);
121 DEBUG_ERROR("pkgid[%s] handle get fail", pkgid);
125 ret = pkgmgrinfo_pkginfo_get_root_path(handle, (char **)&app_root_path);
128 DEBUG_ERROR("pkgid[%s] path get fail", pkgid);
134 DEBUG_ERROR("appid is NULL \n");
139 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
144 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
150 int COMMON_PKGMGR_PLUGIN_UPGRADE(const char *pkgid, const char *appid, GList *list)
154 pkgmgrinfo_pkginfo_h handle = NULL;
155 const char* app_root_path = NULL;
156 //const char* dest_path = NULL;
159 pkgmgr_installer_info_get_target_uid(&uid);
160 ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, uid, &handle);
164 DEBUG_ERROR("pkgid[%s] handle get fail", pkgid);
168 ret = pkgmgrinfo_pkginfo_get_root_path(handle, (char **)&app_root_path);
171 DEBUG_ERROR("pkgid[%s] path get fail", pkgid);
177 DEBUG_ERROR("appid is NULL \n");
181 DEBUG_LOG("-----------------------------------------------------");
182 DEBUG_LOG("pkgid : %s ", pkgid);
183 DEBUG_LOG("APP root path : %s ", app_root_path);
184 DEBUG_LOG("-----------------------------------------------------");
187 DEBUG_LOG("-----------------------------------------------------");
189 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
194 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
201 int COMMON_PKGMGR_PLUGIN_UNINSTALL(const char *pkgid, const char *appid, GList *list)
204 pkgmgrinfo_pkginfo_h handle = NULL;
205 const char* app_root_path = NULL;
206 //const char *dest_path = NULL;
212 DEBUG_ERROR("appid is NULL \n");
216 pkgmgr_installer_info_get_target_uid(&uid);
217 ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, uid, &handle);
221 DEBUG_ERROR("pkgid[%s] handle get fail", pkgid);
225 ret = pkgmgrinfo_pkginfo_get_root_path(handle, (char **)&app_root_path);
228 DEBUG_ERROR("pkgid[%s] path get fail", pkgid);
232 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
237 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
243 int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgid, const char *appid, GList *list)
246 return COMMON_PKGMGR_PLUGIN_INSTALL(pkgid, appid, list);
249 int PKGMGR_MDPARSER_PLUGIN_UPGRADE(const char *pkgid, const char *appid, GList *list)
252 return COMMON_PKGMGR_PLUGIN_UPGRADE(pkgid, appid, list);
255 int PKGMGR_MDPARSER_PLUGIN_UNINSTALL(const char *pkgid, const char *appid, GList *list)
258 return COMMON_PKGMGR_PLUGIN_UNINSTALL(pkgid, appid, list);
262 int PKGMGR_CATEGORY_PARSER_PLUGIN_INSTALL(const char *pkgid, const char *appid, GList *list)
265 return COMMON_PKGMGR_PLUGIN_INSTALL(pkgid, appid, list);
268 int PKGMGR_CATEGORY_PARSER_PLUGIN_UPGRADE(const char *pkgid, const char *appid, GList *list)
271 return COMMON_PKGMGR_PLUGIN_UPGRADE(pkgid, appid, list);
274 int PKGMGR_CATEGORY_PARSER_PLUGIN_UNINSTALL(const char *pkgid, const char *appid, GList *list)
277 return COMMON_PKGMGR_PLUGIN_UNINSTALL(pkgid, appid, list);