#include "opkg_download.h"
#include "opkg_remove.h"
#include "opkg_upgrade.h"
+#include "opkg_error.h"
#include "sprintf_alloc.h"
#include "file_util.h"
return OPKG_PACKAGE_ALREADY_INSTALLED;
}
- new = pkg_hash_fetch_best_installation_candidate_by_name(opkg->conf, package_name);
+ new = pkg_hash_fetch_best_installation_candidate_by_name(opkg->conf, package_name, NULL);
if (!new)
{
/* XXX: Error: Could not find package to install */
opkg_package_free (pdata.package);
switch (err)
{
- case PKG_INSTALL_ERR_NOT_TRUSTED: return OPKG_GPG_ERROR;
- case PKG_INSTALL_ERR_DOWNLOAD: return OPKG_DOWNLOAD_FAILED;
- case PKG_INSTALL_ERR_DEPENDENCIES:
- case PKG_INSTALL_ERR_CONFLICTS: return OPKG_DEPENDENCIES_FAILED;
- case PKG_INSTALL_ERR_ALREADY_INSTALLED: return OPKG_PACKAGE_ALREADY_INSTALLED;
- case PKG_INSTALL_ERR_SIGNATURE: return OPKG_GPG_ERROR;
- case PKG_INSTALL_ERR_MD5: return OPKG_MD5_ERROR;
+ case OPKG_INSTALL_ERR_NOT_TRUSTED: return OPKG_GPG_ERROR;
+ case OPKG_INSTALL_ERR_DOWNLOAD: return OPKG_DOWNLOAD_FAILED;
+ case OPKG_INSTALL_ERR_DEPENDENCIES:
+ case OPKG_INSTALL_ERR_CONFLICTS: return OPKG_DEPENDENCIES_FAILED;
+ case OPKG_INSTALL_ERR_ALREADY_INSTALLED: return OPKG_PACKAGE_ALREADY_INSTALLED;
+ case OPKG_INSTALL_ERR_SIGNATURE: return OPKG_GPG_ERROR;
+ case OPKG_INSTALL_ERR_MD5: return OPKG_MD5_ERROR;
default: return OPKG_UNKNOWN_ERROR;
}
}
{
switch (err)
{
- case PKG_INSTALL_ERR_NOT_TRUSTED: return OPKG_GPG_ERROR;
- case PKG_INSTALL_ERR_DOWNLOAD: return OPKG_DOWNLOAD_FAILED;
- case PKG_INSTALL_ERR_DEPENDENCIES:
- case PKG_INSTALL_ERR_CONFLICTS: return OPKG_DEPENDENCIES_FAILED;
- case PKG_INSTALL_ERR_ALREADY_INSTALLED: return OPKG_PACKAGE_ALREADY_INSTALLED;
- case PKG_INSTALL_ERR_SIGNATURE: return OPKG_GPG_ERROR;
- case PKG_INSTALL_ERR_MD5: return OPKG_MD5_ERROR;
+ case OPKG_INSTALL_ERR_NOT_TRUSTED: return OPKG_GPG_ERROR;
+ case OPKG_INSTALL_ERR_DOWNLOAD: return OPKG_DOWNLOAD_FAILED;
+ case OPKG_INSTALL_ERR_DEPENDENCIES:
+ case OPKG_INSTALL_ERR_CONFLICTS: return OPKG_DEPENDENCIES_FAILED;
+ case OPKG_INSTALL_ERR_ALREADY_INSTALLED: return OPKG_PACKAGE_ALREADY_INSTALLED;
+ case OPKG_INSTALL_ERR_SIGNATURE: return OPKG_GPG_ERROR;
+ case OPKG_INSTALL_ERR_MD5: return OPKG_MD5_ERROR;
default: return OPKG_UNKNOWN_ERROR;
}
}
if (old->state_status != SS_INSTALLED)
continue;
- new = pkg_hash_fetch_best_installation_candidate_by_name(opkg->conf, old->name);
+ new = pkg_hash_fetch_best_installation_candidate_by_name(opkg->conf, old->name, NULL);
if (new == NULL) {
/* XXX: Notice: Assuming locally install package is up to date */
continue;
opkg_conf_write_status_files(conf);
pkg_write_changed_filelists(conf);
} else {
- opkg_message(conf, OPKG_NOTICE, "Nothing to be done\n");
+ opkg_message(conf, OPKG_DEBUG, "Nothing to be done\n");
}
}
result = (cmd->fun)(conf, argc, argv);
- if ( result != 0 ) {
+ if ( result != 0 && !error_list) {
opkg_message(conf, OPKG_NOTICE, "An error ocurred, return value: %d.\n", result);
}
opkg_message(conf, OPKG_NOTICE, "Collected errors:\n");
/* Here we print the errors collected and free the list */
while (error_list != NULL) {
- opkg_message(conf, OPKG_NOTICE, "%s",error_list->errmsg);
+ opkg_message(conf, OPKG_NOTICE, " * %s", error_list->errmsg);
error_list = error_list->next;
}
err = opkg_install_by_name(conf, arg);
if (err == OPKG_PKG_HAS_NO_CANDIDATE) {
opkg_message(conf, OPKG_ERROR,
- "Cannot find package %s.\n"
- "Check the spelling or perhaps run 'opkg update'\n",
+ "Cannot find package %s.\n",
arg);
}
}
for (i = 0; i < argc; i++) {
arg = argv[i];
- pkg = pkg_hash_fetch_best_installation_candidate_by_name(conf, arg);
+ pkg = pkg_hash_fetch_best_installation_candidate_by_name(conf, arg, &err);
if (pkg == NULL) {
opkg_message(conf, OPKG_ERROR,
"Cannot find package %s.\n"
#define OPKG_ERROR_H
enum opkg_error {
- OPKG_SUCCESS = 0,
- OPKG_PKG_DEPS_UNSATISFIED,
- OPKG_PKG_IS_ESSENTIAL,
- OPKG_PKG_HAS_DEPENDENTS,
- OPKG_PKG_HAS_NO_CANDIDATE
+ OPKG_ERR_UNKNOWN = -1,
+ OPKG_ERR_NONE = 0,
+
+ OPKG_PKG_DEPS_UNSATISFIED,
+ OPKG_PKG_IS_ESSENTIAL,
+ OPKG_PKG_HAS_DEPENDENTS,
+ OPKG_PKG_HAS_NO_CANDIDATE,
+ OPKG_PKG_HAS_NO_AVAILABLE_ARCH,
+
+ OPKG_INSTALL_ERR_NOT_TRUSTED,
+ OPKG_INSTALL_ERR_DOWNLOAD,
+ OPKG_INSTALL_ERR_CONFLICTS,
+ OPKG_INSTALL_ERR_ALREADY_INSTALLED,
+ OPKG_INSTALL_ERR_DEPENDENCIES,
+ OPKG_INSTALL_ERR_NO_DOWNGRADE,
+ OPKG_INSTALL_ERR_NO_SPACE,
+ OPKG_INSTALL_ERR_SIGNATURE,
+ OPKG_INSTALL_ERR_MD5,
+ OPKG_INSTALL_ERR_INTERNAL,
+
};
typedef enum opkg_error opkg_error_t;
opkg_error_t opkg_install_by_name(opkg_conf_t *conf, const char *pkg_name)
{
- int cmp;
+ int cmp, err;
pkg_t *old, *new;
char *old_version, *new_version;
opkg_message(conf, OPKG_DEBUG2, " Old versions from pkg_hash_fetch %s \n", old->version );
opkg_message(conf, OPKG_DEBUG2, " Getting new from pkg_hash_fetch \n" );
- new = pkg_hash_fetch_best_installation_candidate_by_name(conf, pkg_name);
+ new = pkg_hash_fetch_best_installation_candidate_by_name(conf, pkg_name, &err);
if ( new )
opkg_message(conf, OPKG_DEBUG2, " New versions from pkg_hash_fetch %s \n", new->version );
opkg_message(conf, OPKG_DEBUG2, " \n");
if (new == NULL) {
- return OPKG_PKG_HAS_NO_CANDIDATE;
+ if (err)
+ return err;
+ else
+ return OPKG_PKG_HAS_NO_CANDIDATE;
}
new->state_flag |= SF_USER;
return 0;
}
-
+#if 0
int name_mark_dependencies_for_installation(opkg_conf_t *conf, const char *pkg_name, pkg_vec_t *pkgs_needed)
{
int cmp;
return pkg_mark_dependencies_for_installation(conf, new, pkgs_needed);
}
-\f
+#endif
int satisfy_dependencies_for(opkg_conf_t *conf, pkg_t *pkg)
{
if (!pkg) {
opkg_message(conf, OPKG_ERROR,
"INTERNAL ERROR: null pkg passed to opkg_install_pkg\n");
- return PKG_INSTALL_ERR_INTERNAL;
+ return OPKG_INSTALL_ERR_INTERNAL;
}
opkg_message(conf, OPKG_DEBUG2, "Function: %s calling pkg_arch_supported %s \n", __FUNCTION__, __FUNCTION__);
if (!pkg_arch_supported(conf, pkg)) {
opkg_message(conf, OPKG_ERROR, "INTERNAL ERROR: architecture %s for pkg %s is unsupported.\n",
pkg->architecture, pkg->name);
- return PKG_INSTALL_ERR_INTERNAL;
+ return OPKG_INSTALL_ERR_INTERNAL;
}
if (pkg->state_status == SS_INSTALLED && conf->force_reinstall == 0 && conf->nodeps == 0) {
err = satisfy_dependencies_for(conf, pkg);
- if (err) { return PKG_INSTALL_ERR_DEPENDENCIES; }
+ if (err) { return OPKG_INSTALL_ERR_DEPENDENCIES; }
opkg_message(conf, OPKG_NOTICE,
"Package %s is already installed in %s.\n",
old_pkg = pkg_hash_fetch_installed_by_name(&conf->pkg_hash, pkg->name);
err = opkg_install_check_downgrade(conf, pkg, old_pkg, message);
- if (err) { return PKG_INSTALL_ERR_NO_DOWNGRADE; }
+ if (err) { return OPKG_INSTALL_ERR_NO_DOWNGRADE; }
pkg->state_want = SW_INSTALL;
if (old_pkg){
/* Abhaya: conflicts check */
err = check_conflicts_for(conf, pkg);
- if (err) { return PKG_INSTALL_ERR_CONFLICTS; }
+ if (err) { return OPKG_INSTALL_ERR_CONFLICTS; }
/* this setup is to remove the upgrade scenario in the end when
installing pkg A, A deps B & B deps on A. So both B and A are
&& conf->force_reinstall == 0) return 0;
err = verify_pkg_installable(conf, pkg);
- if (err) { return PKG_INSTALL_ERR_NO_SPACE; }
+ if (err) { return OPKG_INSTALL_ERR_NO_SPACE; }
if (pkg->local_filename == NULL) {
err = opkg_download_pkg(conf, pkg, conf->tmp_dir);
opkg_message(conf, OPKG_ERROR,
"Failed to download %s. Perhaps you need to run 'opkg update'?\n",
pkg->name);
- return PKG_INSTALL_ERR_DOWNLOAD;
+ return OPKG_INSTALL_ERR_DOWNLOAD;
}
}
if (file_exists (sig_file_name))
{
if (opkg_verify_file (conf, list_file_name, sig_file_name))
- return PKG_INSTALL_ERR_SIGNATURE;
+ return OPKG_INSTALL_ERR_SIGNATURE;
}
free (lists_dir);
"Package %s md5sum mismatch. Either the opkg or the package index are corrupt. Try 'opkg update'.\n",
pkg->name);
free(file_md5);
- return PKG_INSTALL_ERR_MD5;
+ return OPKG_INSTALL_ERR_MD5;
}
free(file_md5);
}
/* Pigi: check if it will pass from here when replacing. It seems to fail */
/* That's rather strange that files don't change owner. Investigate !!!!!!*/
err = update_file_ownership(conf, pkg, old_pkg);
- if (err) { return PKG_INSTALL_ERR_UNKNOWN; }
+ if (err) { return OPKG_ERR_UNKNOWN; }
if (conf->nodeps == 0) {
err = satisfy_dependencies_for(conf, pkg);
- if (err) { return PKG_INSTALL_ERR_DEPENDENCIES; }
+ if (err) { return OPKG_INSTALL_ERR_DEPENDENCIES; }
}
replacees = pkg_vec_alloc();
sigprocmask(SIG_UNBLOCK, &newset, &oldset);
pkg_vec_free (replacees);
- return PKG_INSTALL_ERR_UNKNOWN;
+ return OPKG_ERR_UNKNOWN;
}
opkg_set_current_state (conf, OPKG_STATE_NONE, NULL);
}
#include "opkg_conf.h"
#include "opkg_error.h"
-enum {
- PKG_INSTALL_ERR_NONE,
- PKG_INSTALL_ERR_NOT_TRUSTED,
- PKG_INSTALL_ERR_DOWNLOAD,
- PKG_INSTALL_ERR_CONFLICTS,
- PKG_INSTALL_ERR_ALREADY_INSTALLED,
- PKG_INSTALL_ERR_DEPENDENCIES,
- PKG_INSTALL_ERR_NO_DOWNGRADE,
- PKG_INSTALL_ERR_NO_SPACE,
- PKG_INSTALL_ERR_SIGNATURE,
- PKG_INSTALL_ERR_MD5,
- PKG_INSTALL_ERR_INTERNAL,
- PKG_INSTALL_ERR_UNKNOWN
-};
-
opkg_error_t opkg_install_by_name(opkg_conf_t *conf, const char *pkg_name);
opkg_error_t opkg_install_multi_by_name(opkg_conf_t *conf, const char *pkg_name);
int opkg_install_from_file(opkg_conf_t *conf, const char *filename);
return 0;
}
- new = pkg_hash_fetch_best_installation_candidate_by_name(conf, old->name);
+ new = pkg_hash_fetch_best_installation_candidate_by_name(conf, old->name, NULL);
if (new == NULL) {
old_version = pkg_version_str_alloc(old);
opkg_message(conf, OPKG_NOTICE,
pkg_t *pkg = available_pkgs->pkgs[i];
if (!pkg->arch_priority && (pkg->state_flag || (pkg->state_want != SW_UNKNOWN))) {
/* clear flags and want for any uninstallable package */
- opkg_message(conf, OPKG_NOTICE, "Clearing state_want and state_flag for pkg=%s (arch_priority=%d flag=%d want=%d)\n",
+ opkg_message(conf, OPKG_DEBUG, "Clearing state_want and state_flag for pkg=%s (arch_priority=%d flag=%d want=%d)\n",
pkg->name, pkg->arch_priority, pkg->state_flag, pkg->state_want);
pkg->state_want = SW_UNKNOWN;
pkg->state_flag = 0;
pkg_t *satisfying_pkg =
pkg_hash_fetch_best_installation_candidate(conf, satisfying_apkg,
pkg_installed_and_constraint_satisfied,
- dependence_to_satisfy, 1);
+ dependence_to_satisfy, 1, NULL);
/* Being that I can't test constraing in pkg_hash, I will test it here */
if (satisfying_pkg != NULL) {
if (!pkg_installed_and_constraint_satisfied ( satisfying_pkg,dependence_to_satisfy)) {
pkg_t *satisfying_pkg =
pkg_hash_fetch_best_installation_candidate(conf, satisfying_apkg,
pkg_constraint_satisfied,
- dependence_to_satisfy, 1);
+ dependence_to_satisfy, 1, NULL);
/* Being that I can't test constraing in pkg_hash, I will test it here too */
if (satisfying_pkg != NULL) {
if (!pkg_constraint_satisfied ( satisfying_pkg,dependence_to_satisfy)) {
pkg_t *pkg_hash_fetch_best_installation_candidate(opkg_conf_t *conf, abstract_pkg_t *apkg,
- int (*constraint_fcn)(pkg_t *pkg, void *cdata), void *cdata, int quiet)
+ int (*constraint_fcn)(pkg_t *pkg, void *cdata), void *cdata, int quiet, int *err)
{
int i;
int nprovides = 0;
pkg_t *held_pkg = NULL;
pkg_t *good_pkg_by_name = NULL;
+ if (err)
+ *err = 0;
+
if (matching_apkgs == NULL || providers == NULL ||
apkg == NULL || apkg->provided_by == NULL || (apkg->provided_by->len == 0))
return NULL;
pkg_vec_insert(matching_pkgs, maybe);
}
}
+
+ if (vec->len > 0 && matching_pkgs->len < 1)
+ {
+ opkg_message (conf, OPKG_ERROR, " Packages found, but none available for the current "
+ "architecture\n");
+ if (err)
+ *err = OPKG_PKG_HAS_NO_AVAILABLE_ARCH;
+ }
}
}
return 0;
}
-pkg_t *pkg_hash_fetch_best_installation_candidate_by_name(opkg_conf_t *conf, const char *name)
+pkg_t *pkg_hash_fetch_best_installation_candidate_by_name(opkg_conf_t *conf, const char *name, int *err)
{
hash_table_t *hash = &conf->pkg_hash;
abstract_pkg_t *apkg = NULL;
+ pkg_t *ret;
if (!(apkg = abstract_pkg_fetch_by_name(hash, name)))
return NULL;
-
- return pkg_hash_fetch_best_installation_candidate(conf, apkg, pkg_name_constraint_fcn, apkg->name, 0);
+
+ ret = pkg_hash_fetch_best_installation_candidate(conf, apkg, pkg_name_constraint_fcn, apkg->name, 0, err);
+
+ return ret;
}
if (dependents != NULL)
while (dependents [i] != NULL && i < ab_pkg->provided_by->len)
printf ("\tprovided by - %s\n", dependents [i ++]->name);
- pkg = pkg_hash_fetch_best_installation_candidate_by_name (conf, ab_pkg->name);
+ pkg = pkg_hash_fetch_best_installation_candidate_by_name (conf, ab_pkg->name, NULL);
if (pkg) {
i = 0;
while (i < pkg->depends_count)
const char * version);
abstract_pkg_vec_t *pkg_hash_fetch_all_installation_candidates(hash_table_t *hash, const char *name);
pkg_t *pkg_hash_fetch_best_installation_candidate(opkg_conf_t *conf, abstract_pkg_t *apkg,
- int (*constraint_fcn)(pkg_t *pkg, void *data), void *cdata, int quiet);
-pkg_t *pkg_hash_fetch_best_installation_candidate_by_name(opkg_conf_t *conf, const char *name);
+ int (*constraint_fcn)(pkg_t *pkg, void *data), void *cdata, int quiet, int *error);
+pkg_t *pkg_hash_fetch_best_installation_candidate_by_name(opkg_conf_t *conf, const char *name, int *err);
pkg_t *pkg_hash_fetch_installed_by_name(hash_table_t *hash,
const char *pkg_name);
pkg_t *pkg_hash_fetch_installed_by_name_dest(hash_table_t *hash,