X-Git-Url: https://git.librecmc.org/?p=oweals%2Fopkg-lede.git;a=blobdiff_plain;f=libopkg%2Fopkg_install.c;h=779950e5e128a4c764f19885dca78301df07fa96;hp=2ee240fd6400f96fa59ed7e71579be3dad835674;hb=2b9b8fa95e3cce41b718ee205d34105a46e4b695;hpb=5c709efb3d63562930b181a342a1bc258bccee83 diff --git a/libopkg/opkg_install.c b/libopkg/opkg_install.c index 2ee240f..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 */ @@ -453,25 +455,29 @@ opkg_install_check_downgrade(pkg_t *pkg, pkg_t *old_pkg, int message) } if (cmp > 0) { - opkg_msg(NOTICE, - "Not downgrading package %s on %s from %s to %s.\n", - old_pkg->name, old_pkg->dest->name, old_version, new_version); + if(!conf->download_only) + opkg_msg(NOTICE, + "Not downgrading package %s on %s from %s to %s.\n", + old_pkg->name, old_pkg->dest->name, old_version, new_version); rc = 1; } else if (cmp < 0) { - opkg_msg(NOTICE, "%s%s on %s from %s to %s...\n", - message_out, pkg->name, old_pkg->dest->name, old_version, new_version); + if(!conf->download_only) + opkg_msg(NOTICE, "%s%s on %s from %s to %s...\n", + message_out, pkg->name, old_pkg->dest->name, old_version, new_version); pkg->dest = old_pkg->dest; rc = 0; } else /* cmp == 0 */ { if (conf->force_reinstall) { - opkg_msg(NOTICE, "Reinstalling %s (%s) on %s...\n", - pkg->name, new_version, old_pkg->dest->name); + if(!conf->download_only) + opkg_msg(NOTICE, "Reinstalling %s (%s) on %s...\n", + pkg->name, new_version, old_pkg->dest->name); pkg->dest = old_pkg->dest; rc = 0; } else { - opkg_msg(NOTICE, "%s (%s) already install on %s." - " Not reinstalling.\n", - pkg->name, new_version, old_pkg->dest->name); + if(!conf->download_only) + opkg_msg(NOTICE, "%s (%s) already install on %s." + " Not reinstalling.\n", + pkg->name, new_version, old_pkg->dest->name); rc = 1; } } @@ -479,19 +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); - - opkg_msg(NOTICE, "%s%s (%s) to %s...\n", message_out, - pkg->name, version, pkg->dest->name); - free(version); - return 0; + 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; } @@ -924,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; @@ -979,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 @@ -1232,7 +1239,7 @@ opkg_install_pkg(pkg_t *pkg, int from_upgrade) pkg->state_want = SW_INSTALL; if (old_pkg){ - old_pkg->state_want = SW_DEINSTALL; /* needed for check_data_file_clashes of dependences */ + old_pkg->state_want = SW_DEINSTALL; /* needed for check_data_file_clashes of dependencies */ } err = check_conflicts_for(pkg); @@ -1251,7 +1258,15 @@ opkg_install_pkg(pkg_t *pkg, int from_upgrade) return -1; if (pkg->local_filename == NULL) { - err = opkg_download_pkg(pkg, conf->tmp_dir); + if(!conf->cache && conf->download_only){ + char cwd[4096]; + if(getcwd(cwd, sizeof(cwd)) != NULL) + err = opkg_download_pkg(pkg, cwd); + else + return -1; + } else { + err = opkg_download_pkg(pkg, conf->tmp_dir); + } if (err) { opkg_msg(ERROR, "Failed to download %s. " "Perhaps you need to run 'opkg update'?\n", @@ -1329,6 +1344,14 @@ opkg_install_pkg(pkg_t *pkg, int from_upgrade) free(file_sha256); } #endif + if(conf->download_only) { + if (conf->nodeps == 0) { + err = satisfy_dependencies_for(pkg); + if (err) + return -1; + } + return 0; + } if (pkg->tmp_unpack_dir == NULL) { if (unpack_pkg_control_files(pkg) == -1) {