From 2b9b8fa95e3cce41b718ee205d34105a46e4b695 Mon Sep 17 00:00:00 2001 From: "graham.gower" Date: Wed, 27 Jan 2010 23:11:41 +0000 Subject: [PATCH] Propagate errors up the call stack. Patch by Jens Erdmann . git-svn-id: http://opkg.googlecode.com/svn/trunk@519 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358 --- libopkg/opkg_cmd.c | 25 ++++++++++++++++--------- libopkg/opkg_install.c | 36 +++++++++++++++++++----------------- 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/libopkg/opkg_cmd.c b/libopkg/opkg_cmd.c index fceffdd..0fa471e 100644 --- a/libopkg/opkg_cmd.c +++ b/libopkg/opkg_cmd.c @@ -426,7 +426,7 @@ error: static int opkg_install_cmd(int argc, char **argv) { - int i; + int i, r; char *arg; int err=0; @@ -453,7 +453,9 @@ opkg_install_cmd(int argc, char **argv) } } - opkg_configure_packages(NULL); + r = opkg_configure_packages(NULL); + if (!err) + err = r; write_status_files_if_changed(); @@ -463,7 +465,7 @@ opkg_install_cmd(int argc, char **argv) static int opkg_upgrade_cmd(int argc, char **argv) { - int i; + int i, r; pkg_t *pkg; int err; @@ -511,7 +513,9 @@ opkg_upgrade_cmd(int argc, char **argv) pkg_vec_free(installed); } - opkg_configure_packages(NULL); + r = opkg_configure_packages(NULL); + if (!err) + err = r; write_status_files_if_changed(); @@ -521,7 +525,7 @@ opkg_upgrade_cmd(int argc, char **argv) static int opkg_download_cmd(int argc, char **argv) { - int i, err; + int i, err = 0; char *arg; pkg_t *pkg; @@ -545,7 +549,7 @@ opkg_download_cmd(int argc, char **argv) } } - return 0; + return err; } @@ -698,7 +702,7 @@ opkg_configure_cmd(int argc, char **argv) static int opkg_remove_cmd(int argc, char **argv) { - int i, a, done; + int i, a, done, r, err = 0; pkg_t *pkg; pkg_t *pkg_to_remove; pkg_vec_t *available; @@ -734,7 +738,10 @@ opkg_remove_cmd(int argc, char **argv) opkg_msg(ERROR, "Package %s not installed.\n", pkg->name); continue; } - opkg_remove_pkg(pkg_to_remove, 0); + r = opkg_remove_pkg(pkg_to_remove, 0); + if (!err) + err = r; + done = 1; } } @@ -745,7 +752,7 @@ opkg_remove_cmd(int argc, char **argv) opkg_msg(NOTICE, "No packages removed.\n"); write_status_files_if_changed(); - return 0; + return err; } static int diff --git a/libopkg/opkg_install.c b/libopkg/opkg_install.c index 72c63ab..779950e 100644 --- a/libopkg/opkg_install.c +++ b/libopkg/opkg_install.c @@ -297,7 +297,7 @@ unpack_pkg_control_files(pkg_t *pkg) static int pkg_remove_orphan_dependent(pkg_t *pkg, pkg_t *old_pkg) { - int i, j, k, l, found; + int i, j, k, l, found,r, err = 0; int n_deps; pkg_t *p; struct compound_depend *cd0, *cd1; @@ -362,7 +362,9 @@ pkg_remove_orphan_dependent(pkg_t *pkg, pkg_t *old_pkg) * which we need to ignore during removal. */ p->state_flag |= SF_REPLACE; - opkg_remove_pkg(p, 0); + r = opkg_remove_pkg(p, 0); + if (!err) + err = r; } else opkg_msg(INFO, "%s was autoinstalled and is " "still required by %d " @@ -372,7 +374,7 @@ pkg_remove_orphan_dependent(pkg_t *pkg, pkg_t *old_pkg) } } - return 0; + return err; } /* returns number of installed replacees */ @@ -483,20 +485,20 @@ opkg_install_check_downgrade(pkg_t *pkg, pkg_t *old_pkg, int message) free(new_version); return rc; } else { - char message_out[15] ; - memset(message_out,'\x0',15); - if ( message ) - strncpy( message_out,"Upgrading ",strlen("Upgrading ") ); - else - strncpy( message_out,"Installing ",strlen("Installing ") ); - char *version = pkg_version_str_alloc(pkg); - - if(!conf->download_only) - opkg_msg(NOTICE, "%s%s (%s) to %s...\n", message_out, + char message_out[15] ; + memset(message_out,'\x0',15); + if ( message ) + strncpy( message_out,"Upgrading ",strlen("Upgrading ") ); + else + strncpy( message_out,"Installing ",strlen("Installing ") ); + char *version = pkg_version_str_alloc(pkg); + + if(!conf->download_only) + opkg_msg(NOTICE, "%s%s (%s) to %s...\n", message_out, pkg->name, version, pkg->dest->name); - free(version); - return 0; + free(version); } + return 0; } @@ -929,7 +931,7 @@ postrm_upgrade_old_pkg_unwind(pkg_t *pkg, pkg_t *old_pkg) static int remove_obsolesced_files(pkg_t *pkg, pkg_t *old_pkg) { - int err; + int err = 0; str_list_t *old_files; str_list_elt_t *of; str_list_t *new_files; @@ -984,7 +986,7 @@ remove_obsolesced_files(pkg_t *pkg, pkg_t *old_pkg) pkg_free_installed_files(old_pkg); pkg_free_installed_files(pkg); - return 0; + return err; } static int -- 2.25.1