4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
7 * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
28 #include <sys/types.h>
38 #include <ctype.h> /* for isspace () */
39 #include <pkgmgr-info.h>
40 #include <pkgmgr_parser.h>
41 #include <package-manager.h>
43 #include "rpm-installer-util.h"
44 #include "rpm-installer.h"
45 #include "rpm-frontend.h"
47 #define PRE_CHECK_FOR_MANIFEST
48 #define INSTALL_SCRIPT "/usr/bin/install_rpm_package.sh"
49 #define UNINSTALL_SCRIPT "/usr/bin/uninstall_rpm_package.sh"
50 #define UPGRADE_SCRIPT "/usr/bin/upgrade_rpm_package.sh"
51 #define RPM2CPIO "/usr/bin/rpm2cpio"
53 enum rpm_request_type {
59 #define APP2EXT_ENABLE
61 #include <app2ext_interface.h>
64 typedef enum rpm_request_type rpm_request_type;
65 extern char *gpkgname;
67 static int __rpm_xsystem(const char *argv[]);
68 static void __rpm_process_line(char *line);
69 static void __rpm_perform_read(int fd);
70 static void __rpm_clear_dir_list(GList* dir_list);
71 static GList * __rpm_populate_dir_list();
73 static void __rpm_process_line(char *line)
76 tok = strtok(line, " ");
78 if (!strncmp(tok, "%%", 2)) {
79 tok = strtok(NULL, " ");
81 _d_msg(DEBUG_INFO, "Install percentage is %s\n",
83 _ri_broadcast_status_notification(gpkgname,
86 _ri_stat_cb(gpkgname, "install_percent", tok);
94 static void __rpm_perform_read(int fd)
99 static char buffer[1024] = { 0, };
100 static int buffer_position;
102 size = read(fd, &buffer[buffer_position],
103 sizeof(buffer) - buffer_position);
104 buffer_position += size;
108 /* Process each line of the recieved buffer */
109 buf_ptr = tmp_ptr = buffer;
110 while ((tmp_ptr = (char *)memchr(buf_ptr, '\n',
111 buffer + buffer_position - buf_ptr)) !=
114 __rpm_process_line(buf_ptr);
115 /* move to next line and continue */
116 buf_ptr = tmp_ptr + 1;
119 /*move the remaining bits at the start of the buffer
120 and update the buffer position */
121 buf_ptr = (char *)memrchr(buffer, 0, buffer_position);
125 /* we have processed till the last \n which has now become
126 0x0. So we increase the pointer to next position */
129 memmove(buffer, buf_ptr, buf_ptr - buffer);
130 buffer_position = buffer + buffer_position - buf_ptr;
133 static int __rpm_xsystem(const char *argv[])
140 if (pipe(pipefd) == -1) {
141 _d_msg(DEBUG_ERR, "pipe creation failed\n");
144 /*Read progress info via pipe */
149 _d_msg(DEBUG_ERR, "fork failed\n");
159 if (execvp(argv[0], (char *const *)argv) == -1) {
160 _d_msg(DEBUG_ERR, "execvp failed\n");
171 while ((err = waitpid(pid, &status, WNOHANG)) != pid) {
175 _d_msg(DEBUG_ERR, "waitpid failed\n");
184 FD_SET(pipefd[0], &rfds);
188 pselect(pipefd[0] + 1, &rfds, NULL, NULL, &tv, NULL);
192 else if (select_ret < 0 && errno == EINTR)
194 else if (select_ret < 0) {
195 _d_msg(DEBUG_ERR, "select() returned error\n");
198 if (FD_ISSET(pipefd[0], &rfds))
199 __rpm_perform_read(pipefd[0]);
203 /* Check for an error code. */
204 if (WIFEXITED(status) == 0 || WEXITSTATUS(status) != 0) {
206 if (WIFSIGNALED(status) != 0 && WTERMSIG(status) == SIGSEGV) {
208 ("Sub-process %s received a segmentation fault. \n",
210 } else if (WIFEXITED(status) != 0) {
211 printf("Sub-process %s returned an error code (%u)\n",
212 argv[0], WEXITSTATUS(status));
214 printf("Sub-process %s exited unexpectedly\n", argv[0]);
217 return WEXITSTATUS(status);
220 static void __rpm_clear_dir_list(GList* dir_list)
223 app2ext_dir_details* dir_detail = NULL;
225 list = g_list_first(dir_list);
227 dir_detail = (app2ext_dir_details *)list->data;
228 if (dir_detail && dir_detail->name) {
229 free(dir_detail->name);
231 list = g_list_next(list);
233 g_list_free(dir_list);
237 static GList * __rpm_populate_dir_list()
239 GList *dir_list = NULL;
241 app2ext_dir_details* dir_detail = NULL;
243 char pkg_ro_content_rpm[3][5] = { "bin", "res", "lib" };
246 for (i=0; i<3; i++) {
247 dir_detail = (app2ext_dir_details*) calloc(1, sizeof(app2ext_dir_details));
248 if (dir_detail == NULL) {
249 printf("\nMemory allocation failed\n");
252 dir_detail->name = (char*) calloc(1, sizeof(char)*(strlen(pkg_ro_content_rpm[i])+2));
253 if (dir_detail->name == NULL) {
254 printf("\nMemory allocation failed\n");
258 snprintf(dir_detail->name, (strlen(pkg_ro_content_rpm[i])+1), "%s", pkg_ro_content_rpm[i]);
259 dir_detail->type = APP2EXT_DIR_RO;
260 dir_list = g_list_append(dir_list, dir_detail);
263 list = g_list_first(dir_list);
265 dir_detail = (app2ext_dir_details *)list->data;
266 list = g_list_next(list);
272 list = g_list_first(dir_list);
274 dir_detail = (app2ext_dir_details *)list->data;
275 if (dir_detail && dir_detail->name) {
276 free(dir_detail->name);
278 list = g_list_next(list);
280 g_list_free(dir_list);
285 static GList * __rpm_move_dir_list()
287 GList *dir_list = NULL;
289 app2ext_dir_details* dir_detail = NULL;
291 char pkg_ro_content_rpm[3][5] = { "bin", "res", };
294 for (i=0; i<3; i++) {
295 dir_detail = (app2ext_dir_details*) calloc(1, sizeof(app2ext_dir_details));
296 if (dir_detail == NULL) {
297 printf("\nMemory allocation failed\n");
300 dir_detail->name = (char*) calloc(1, sizeof(char)*(strlen(pkg_ro_content_rpm[i])+2));
301 if (dir_detail->name == NULL) {
302 printf("\nMemory allocation failed\n");
306 snprintf(dir_detail->name, (strlen(pkg_ro_content_rpm[i])+1), "%s", pkg_ro_content_rpm[i]);
307 dir_detail->type = APP2EXT_DIR_RO;
308 dir_list = g_list_append(dir_list, dir_detail);
311 list = g_list_first(dir_list);
313 dir_detail = (app2ext_dir_details *)list->data;
314 list = g_list_next(list);
320 list = g_list_first(dir_list);
322 dir_detail = (app2ext_dir_details *)list->data;
323 if (dir_detail && dir_detail->name) {
324 free(dir_detail->name);
326 list = g_list_next(list);
328 g_list_free(dir_list);
333 int _rpm_uninstall_pkg(char *pkgid)
337 char buff[256] = {'\0'};
338 pkgmgr_install_location location = 1;
340 #ifdef APP2EXT_ENABLE
341 app2ext_handle *handle = NULL;
343 char *manifest = NULL;
344 pkgmgr_pkginfo_h pkghandle;
345 const char *argv[] = { UNINSTALL_SCRIPT, pkgid, NULL };
347 #ifdef APP2EXT_ENABLE
348 ret = pkgmgr_pkginfo_get_pkginfo(pkgid, &pkghandle);
350 _d_msg(DEBUG_ERR, "Failed to get pkginfo handle\n");
351 // return RPM_INSTALLER_ERR_INTERNAL;
353 ret = pkgmgr_pkginfo_get_install_location(pkghandle, &location);
355 _d_msg(DEBUG_ERR, "Failed to get install location\n");
356 pkgmgr_pkginfo_destroy_pkginfo(pkghandle);
357 return RPM_INSTALLER_ERR_INTERNAL;
359 pkgmgr_pkginfo_destroy_pkginfo(pkghandle);
360 if (location == PM_INSTALL_LOCATION_PREFER_EXTERNAL) {
361 handle = app2ext_init(APP2EXT_SD_CARD);
362 if (handle == NULL) {
363 _d_msg(DEBUG_ERR, "app2ext init failed\n");
364 return RPM_INSTALLER_ERR_INTERNAL;
366 if ((&(handle->interface) != NULL) && (handle->interface.pre_uninstall != NULL) && (handle->interface.post_uninstall != NULL)){
367 ret = app2ext_get_app_location(pkgid);
368 if (ret == APP2EXT_INTERNAL_MEM){
369 _d_msg(DEBUG_ERR, "app2xt APP is not in MMC, go internal (%d)\n", ret);
372 ret = handle->interface.pre_uninstall(pkgid);
373 if (ret == APP2EXT_ERROR_MMC_STATUS || ret == APP2EXT_SUCCESS ) {
374 _d_msg(DEBUG_ERR, "app2xt MMC is not here, go internal (%d)\n", ret);
377 _d_msg(DEBUG_ERR, "app2xt pre uninstall API failed (%d)\n", ret);
378 handle->interface.post_uninstall(pkgid);
379 return RPM_INSTALLER_ERR_INTERNAL;
387 #ifdef PRE_CHECK_FOR_MANIFEST
388 /*Manifest info should be removed first because after installation manifest
389 file is uninstalled. If uninstallation fails, we need to re-insert manifest info for consistency*/
390 manifest = pkgmgr_parser_get_manifest_file(pkgid);
391 if (manifest == NULL) {
392 _d_msg(DEBUG_ERR, "manifest name is NULL\n");
393 return RPM_INSTALLER_ERR_INTERNAL;
395 _d_msg(DEBUG_INFO, "manifest name is %s\n", manifest);
396 pkgmgr_parser_parse_manifest_for_uninstallation(manifest, NULL);
399 ret = __rpm_xsystem(argv);
401 _d_msg(DEBUG_ERR, "uninstall failed with error(%d)\n", ret);
402 #ifdef PRE_CHECK_FOR_MANIFEST
403 err = pkgmgr_parser_parse_manifest_for_installation(manifest, NULL);
405 _d_msg(DEBUG_ERR, "Parsing Manifest Failed\n");
412 #ifdef APP2EXT_ENABLE
413 if ((handle != NULL) && (handle->interface.post_uninstall != NULL)){
414 handle->interface.post_uninstall(pkgid);
420 #ifdef APP2EXT_ENABLE
421 if ((handle != NULL) && (handle->interface.post_uninstall != NULL)){
422 handle->interface.post_uninstall(pkgid);
423 app2ext_deinit(handle);
427 #ifdef PRE_CHECK_FOR_MANIFEST
433 /* Uninstallation Success. Remove the installation time key from vconf*/
434 snprintf(buff, 256, "db/app-info/%s/installed-time", pkgid);
435 err = vconf_unset(buff);
437 _d_msg(DEBUG_ERR, "unset installation time failed\n");
442 int _rpm_install_pkg(char *pkgfilepath, char *installoptions)
447 char buff[256] = {'\0'};
448 char manifest[1024] = { '\0'};
450 pkgmgrinfo_install_location location = 1;
452 #ifdef APP2EXT_ENABLE
453 app2ext_handle *handle = NULL;
454 GList *dir_list = NULL;
456 pkgmgr_pkginfo_h pkghandle;
457 const char *argv[] = {
458 INSTALL_SCRIPT, pkgfilepath, installoptions, NULL
461 #ifdef PRE_CHECK_FOR_MANIFEST
462 char cwd[1024] = {'\0'};
463 char query[1024] = {'\0'};
466 if (cwd[0] == '\0') {
467 _d_msg(DEBUG_ERR, "getcwd() Failed\n");
468 return RPM_INSTALLER_ERR_INTERNAL;
470 _d_msg(DEBUG_ERR, "Current working directory is %s\n", cwd);
473 _d_msg(DEBUG_ERR, "chdir() failed\n");
474 return RPM_INSTALLER_ERR_INTERNAL;
476 _d_msg(DEBUG_ERR, "Switched to /tmp\n");
477 snprintf(query, 1024, "/usr/bin/rpm2cpio %s | cpio -idmv", pkgfilepath);
478 _d_msg(DEBUG_INFO, "query= %s\n", query);
480 snprintf(manifest, 1024, "/tmp/opt/share/packages/%s.xml", gpkgname);
481 _d_msg(DEBUG_ERR, "Manifest name is %s\n", manifest);
482 if (access(manifest, F_OK)) {
483 _d_msg(DEBUG_ERR, "No rw Manifest File Found\n");
485 snprintf(manifest, 1024, "/tmp/usr/share/packages/%s.xml", gpkgname);
486 _d_msg(DEBUG_ERR, "Manifest ro name is %s\n", manifest);
488 if (access(manifest, F_OK)) {
489 _d_msg(DEBUG_ERR, "No ro Manifest File Found\n");
491 // return RPM_INSTALLER_ERR_NO_MANIFEST;
497 _d_msg(DEBUG_ERR, "Manifest exists\n");
501 _d_msg(DEBUG_ERR, "chdir() failed\n");
503 // return RPM_INSTALLER_ERR_INTERNAL;
507 err = pkgmgr_parser_check_manifest_validation(manifest);
509 _d_msg(DEBUG_ERR, "Invalid manifest\n");
511 return RPM_INSTALLER_ERR_INVALID_MANIFEST;
516 #ifdef APP2EXT_ENABLE
517 ret = pkgmgrinfo_pkginfo_get_location_from_xml(manifest, &location);
520 _d_msg(DEBUG_ERR, "Failed to get install location\n");
521 return RPM_INSTALLER_ERR_INTERNAL;
523 if (location == PMINFO_INSTALL_LOCATION_PREFER_EXTERNAL) {
524 ret = pkgmgrinfo_pkginfo_get_size_from_xml(manifest, &size);
526 _d_msg(DEBUG_ERR, "Failed to get package size\n");
527 return RPM_INSTALLER_ERR_INTERNAL;
532 if ((location == PMINFO_INSTALL_LOCATION_PREFER_EXTERNAL) && size > 0) {
533 handle = app2ext_init(APP2EXT_SD_CARD);
534 if (handle == NULL) {
535 _d_msg(DEBUG_ERR, "app2ext init failed\n");
536 return RPM_INSTALLER_ERR_INTERNAL;
538 if ((&(handle->interface) != NULL) && (handle->interface.pre_install != NULL) && (handle->interface.post_install != NULL)){
539 dir_list = __rpm_populate_dir_list();
540 if (dir_list == NULL) {
541 _d_msg(DEBUG_ERR, "\nError in populating the directory list\n");
542 app2ext_deinit(handle);
543 return RPM_INSTALLER_ERR_RPM_SCRIPT_WRONG_ARGS;
545 ret = handle->interface.pre_install(gpkgname, dir_list, size);
546 if (ret == APP2EXT_ERROR_MMC_STATUS) {
547 _d_msg(DEBUG_ERR, "app2xt MMC is not here, go internal\n");
548 } else if (ret == APP2EXT_SUCCESS){
549 _d_msg(DEBUG_ERR, "pre_install done, go internal\n");
552 _d_msg(DEBUG_ERR, "app2xt pre install API failed (%d)\n", ret);
553 __rpm_clear_dir_list(dir_list);
554 handle->interface.post_install(gpkgname, APP2EXT_STATUS_FAILED);
555 app2ext_deinit(handle);
556 return RPM_INSTALLER_ERR_INTERNAL;
562 err = __rpm_xsystem(argv);
565 _d_msg(DEBUG_ERR, "install complete with error(%d)\n", err);
567 #ifdef APP2EXT_ENABLE
568 if ((handle != NULL) && (handle->interface.post_install != NULL)){
569 __rpm_clear_dir_list(dir_list);
570 handle->interface.post_install(gpkgname, APP2EXT_STATUS_FAILED);
577 #ifdef APP2EXT_ENABLE
578 if ((handle != NULL) && (handle->interface.post_install != NULL)){
579 __rpm_clear_dir_list(dir_list);
580 handle->interface.post_install(gpkgname, APP2EXT_STATUS_SUCCESS);
581 app2ext_deinit(handle);
585 /*Parse the manifest to get install location and size. If installation fails, remove manifest info from DB*/
586 err = pkgmgr_parser_parse_manifest_for_installation(manifest, NULL);
588 _d_msg(DEBUG_ERR, "Parsing Manifest Failed\n");
590 // return RPM_INSTALLER_ERR_INTERNAL;
592 _d_msg(DEBUG_ERR, "Parsing Manifest Success\n");
596 #ifndef PRE_CHECK_FOR_MANIFEST
597 mfst = pkgmgr_parser_get_manifest_file(gpkgname);
599 _d_msg(DEBUG_ERR, "manifest name is NULL\n");
601 return RPM_INSTALLER_ERR_INTERNAL;
603 pkgmgr_parser_parse_manifest_for_installation(mfst, NULL);
609 /* Install Success. Store the installation time*/
610 cur_time = time(NULL);
611 snprintf(buff, 256, "db/app-info/%s/installed-time", gpkgname);
612 /* The time is stored in time_t format. It can be converted to
613 local time or GMT time as per the need by the apps*/
614 ret = vconf_set_int(buff, cur_time);
616 _d_msg(DEBUG_ERR, "setting installation time failed\n");
623 int _rpm_upgrade_pkg(char *pkgfilepath, char *installoptions)
628 char buff[256] = {'\0'};
629 char manifest[1024] = { '\0'};
631 pkgmgr_install_location location = 1;
633 #ifdef APP2EXT_ENABLE
634 app2ext_handle *handle = NULL;
635 GList *dir_list = NULL;
637 pkgmgr_pkginfo_h pkghandle;
638 const char *argv[] = {
639 UPGRADE_SCRIPT, pkgfilepath, installoptions, NULL
642 #ifdef PRE_CHECK_FOR_MANIFEST
643 char cwd[1024] = {'\0'};
644 char query[1024] = {'\0'};
647 if (cwd[0] == '\0') {
648 _d_msg(DEBUG_ERR, "getcwd() Failed\n");
649 return RPM_INSTALLER_ERR_INTERNAL;
651 _d_msg(DEBUG_ERR, "Current working directory is %s\n", cwd);
654 _d_msg(DEBUG_ERR, "chdir() failed\n");
655 return RPM_INSTALLER_ERR_INTERNAL;
657 _d_msg(DEBUG_ERR, "Switched to /tmp\n");
658 snprintf(query, 1024, "/usr/bin/rpm2cpio %s | cpio -idmv", pkgfilepath);
659 _d_msg(DEBUG_INFO, "query= %s\n", query);
661 snprintf(manifest, 1024, "/tmp/opt/share/packages/%s.xml", gpkgname);
662 _d_msg(DEBUG_ERR, "Manifest name is %s\n", manifest);
663 if (access(manifest, F_OK)) {
664 _d_msg(DEBUG_ERR, "No rw Manifest File Found\n");
666 snprintf(manifest, 1024, "/tmp/usr/share/packages/%s.xml", gpkgname);
667 _d_msg(DEBUG_ERR, "Manifest ro name is %s\n", manifest);
669 if (access(manifest, F_OK)) {
670 _d_msg(DEBUG_ERR, "No ro Manifest File Found\n");
672 // return RPM_INSTALLER_ERR_NO_MANIFEST;
678 _d_msg(DEBUG_ERR, "Manifest exists\n");
682 _d_msg(DEBUG_ERR, "chdir() failed\n");
684 // return RPM_INSTALLER_ERR_INTERNAL;
688 err = pkgmgr_parser_check_manifest_validation(manifest);
690 _d_msg(DEBUG_ERR, "Invalid manifest\n");
692 return RPM_INSTALLER_ERR_INVALID_MANIFEST;
695 /*Parse the manifest to get install location and size. If upgradation fails, remove manifest info from DB*/
696 err = pkgmgr_parser_parse_manifest_for_upgrade(manifest, NULL);
698 _d_msg(DEBUG_ERR, "Parsing Manifest Failed\n");
700 // return RPM_INSTALLER_ERR_INTERNAL;
702 _d_msg(DEBUG_ERR, "Parsing Manifest Success\n");
706 #ifdef APP2EXT_ENABLE
707 ret = pkgmgr_pkginfo_get_pkginfo(gpkgname, &pkghandle);
709 _d_msg(DEBUG_ERR, "Failed to get pkginfo handle\n");
711 // return RPM_INSTALLER_ERR_INTERNAL;
713 ret = pkgmgr_pkginfo_get_install_location(pkghandle, &location);
715 _d_msg(DEBUG_ERR, "Failed to get install location\n");
716 pkgmgr_pkginfo_destroy_pkginfo(pkghandle);
718 return RPM_INSTALLER_ERR_INTERNAL;
720 if (location == PM_INSTALL_LOCATION_PREFER_EXTERNAL) {
721 ret = pkgmgr_pkginfo_get_package_size(pkghandle, &size);
723 _d_msg(DEBUG_ERR, "Failed to get package size\n");
724 pkgmgr_pkginfo_destroy_pkginfo(pkghandle);
726 return RPM_INSTALLER_ERR_INTERNAL;
730 pkgmgr_pkginfo_destroy_pkginfo(pkghandle);
731 if ((location == PM_INSTALL_LOCATION_PREFER_EXTERNAL) && size > 0) {
732 handle = app2ext_init(APP2EXT_SD_CARD);
733 if (handle == NULL) {
734 _d_msg(DEBUG_ERR, "app2ext init failed\n");
736 return RPM_INSTALLER_ERR_INTERNAL;
738 if ((&(handle->interface) != NULL) && (handle->interface.pre_upgrade != NULL) && (handle->interface.post_upgrade != NULL)){
739 dir_list = __rpm_populate_dir_list();
740 if (dir_list == NULL) {
741 _d_msg(DEBUG_ERR, "\nError in populating the directory list\n");
742 return RPM_INSTALLER_ERR_RPM_SCRIPT_WRONG_ARGS;
744 ret = handle->interface.pre_upgrade(gpkgname, dir_list, size);
745 if (ret == APP2EXT_ERROR_MMC_STATUS || ret == APP2EXT_SUCCESS ) {
746 _d_msg(DEBUG_ERR, "app2xt MMC is not here, go internal (%d)\n", ret);
749 _d_msg(DEBUG_ERR, "app2xt pre upgrade API failed (%d)\n", ret);
750 __rpm_clear_dir_list(dir_list);
751 handle->interface.post_upgrade(gpkgname, APP2EXT_STATUS_FAILED);
753 return RPM_INSTALLER_ERR_INTERNAL;
760 err = __rpm_xsystem(argv);
762 _d_msg(DEBUG_ERR, "upgrade complete with error(%d)\n", err);
763 /*remove manifest info*/
764 #ifdef PRE_CHECK_FOR_MANIFEST
765 pkgmgr_parser_parse_manifest_for_uninstallation(manifest, NULL);
767 #ifdef APP2EXT_ENABLE
768 if ((handle != NULL) && (handle->interface.post_upgrade != NULL)){
769 __rpm_clear_dir_list(dir_list);
770 handle->interface.post_upgrade(gpkgname, APP2EXT_STATUS_FAILED);
776 #ifdef APP2EXT_ENABLE
777 if ((handle != NULL) && (handle->interface.post_upgrade != NULL)){
778 __rpm_clear_dir_list(dir_list);
779 handle->interface.post_upgrade(gpkgname, APP2EXT_STATUS_SUCCESS);
780 app2ext_deinit(handle);
783 #ifndef PRE_CHECK_FOR_MANIFEST
784 mfst = pkgmgr_parser_get_manifest_file(gpkgname);
786 _d_msg(DEBUG_ERR, "manifest name is NULL\n");
788 return RPM_INSTALLER_ERR_INTERNAL;
790 pkgmgr_parser_parse_manifest_for_upgrade(mfst, NULL);
800 int _rpm_move_pkg(char *pkgid, int move_type)
802 app2ext_handle *hdl = NULL;
805 GList *dir_list = NULL;
807 if (move_type == PM_MOVE_TO_INTERNAL)
808 movetype = APP2EXT_MOVE_TO_PHONE;
809 else if (move_type == PM_MOVE_TO_SDCARD)
810 movetype = APP2EXT_MOVE_TO_EXT;
812 return RPM_INSTALLER_ERR_WRONG_PARAM;
814 hdl = app2ext_init(APP2EXT_SD_CARD);
815 if ((hdl != NULL) && (hdl->interface.move != NULL)){
816 dir_list = __rpm_move_dir_list();
817 if (dir_list == NULL) {
818 _d_msg(DEBUG_ERR, "\nError in populating the directory list\n");
819 return RPM_INSTALLER_ERR_RPM_SCRIPT_WRONG_ARGS;
821 ret = hdl->interface.move(pkgid, dir_list, movetype);
822 __rpm_clear_dir_list(dir_list);
824 _d_msg(DEBUG_ERR, "Failed to move app\n");
825 return RPM_INSTALLER_ERR_INTERNAL;
828 return RPM_INSTALLER_SUCCESS;
830 _d_msg(DEBUG_ERR,"Failed to get app2ext handle\n");
831 return RPM_INSTALLER_ERR_INTERNAL;