Changeset 4466


Ignore:
Timestamp:
06/02/08 18:11:25 (5 years ago)
Author:
thomas
Message:

opkg: consolidate error enums and add an error for when no package matches
current architecture

Location:
trunk/src/target/opkg/libopkg
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/target/opkg/libopkg/opkg.c

    r4465 r4466  
    2828#include "opkg_remove.h" 
    2929#include "opkg_upgrade.h" 
     30#include "opkg_error.h" 
    3031 
    3132#include "sprintf_alloc.h" 
     
    386387  } 
    387388 
    388   new = pkg_hash_fetch_best_installation_candidate_by_name(opkg->conf, package_name); 
     389  new = pkg_hash_fetch_best_installation_candidate_by_name(opkg->conf, package_name, NULL); 
    389390  if (!new) 
    390391  { 
     
    490491    switch (err) 
    491492    { 
    492       case PKG_INSTALL_ERR_NOT_TRUSTED: return OPKG_GPG_ERROR; 
    493       case PKG_INSTALL_ERR_DOWNLOAD: return OPKG_DOWNLOAD_FAILED; 
    494       case PKG_INSTALL_ERR_DEPENDENCIES: 
    495       case PKG_INSTALL_ERR_CONFLICTS: return OPKG_DEPENDENCIES_FAILED; 
    496       case PKG_INSTALL_ERR_ALREADY_INSTALLED: return OPKG_PACKAGE_ALREADY_INSTALLED; 
    497       case PKG_INSTALL_ERR_SIGNATURE: return OPKG_GPG_ERROR; 
    498       case PKG_INSTALL_ERR_MD5: return OPKG_MD5_ERROR; 
     493      case OPKG_INSTALL_ERR_NOT_TRUSTED: return OPKG_GPG_ERROR; 
     494      case OPKG_INSTALL_ERR_DOWNLOAD: return OPKG_DOWNLOAD_FAILED; 
     495      case OPKG_INSTALL_ERR_DEPENDENCIES: 
     496      case OPKG_INSTALL_ERR_CONFLICTS: return OPKG_DEPENDENCIES_FAILED; 
     497      case OPKG_INSTALL_ERR_ALREADY_INSTALLED: return OPKG_PACKAGE_ALREADY_INSTALLED; 
     498      case OPKG_INSTALL_ERR_SIGNATURE: return OPKG_GPG_ERROR; 
     499      case OPKG_INSTALL_ERR_MD5: return OPKG_MD5_ERROR; 
    499500      default: return OPKG_UNKNOWN_ERROR; 
    500501    } 
     
    626627    switch (err) 
    627628    { 
    628       case PKG_INSTALL_ERR_NOT_TRUSTED: return OPKG_GPG_ERROR; 
    629       case PKG_INSTALL_ERR_DOWNLOAD: return OPKG_DOWNLOAD_FAILED; 
    630       case PKG_INSTALL_ERR_DEPENDENCIES: 
    631       case PKG_INSTALL_ERR_CONFLICTS: return OPKG_DEPENDENCIES_FAILED; 
    632       case PKG_INSTALL_ERR_ALREADY_INSTALLED: return OPKG_PACKAGE_ALREADY_INSTALLED; 
    633       case PKG_INSTALL_ERR_SIGNATURE: return OPKG_GPG_ERROR; 
    634       case PKG_INSTALL_ERR_MD5: return OPKG_MD5_ERROR; 
     629      case OPKG_INSTALL_ERR_NOT_TRUSTED: return OPKG_GPG_ERROR; 
     630      case OPKG_INSTALL_ERR_DOWNLOAD: return OPKG_DOWNLOAD_FAILED; 
     631      case OPKG_INSTALL_ERR_DEPENDENCIES: 
     632      case OPKG_INSTALL_ERR_CONFLICTS: return OPKG_DEPENDENCIES_FAILED; 
     633      case OPKG_INSTALL_ERR_ALREADY_INSTALLED: return OPKG_PACKAGE_ALREADY_INSTALLED; 
     634      case OPKG_INSTALL_ERR_SIGNATURE: return OPKG_GPG_ERROR; 
     635      case OPKG_INSTALL_ERR_MD5: return OPKG_MD5_ERROR; 
    635636      default: return OPKG_UNKNOWN_ERROR; 
    636637    } 
     
    918919      continue; 
    919920 
    920     new = pkg_hash_fetch_best_installation_candidate_by_name(opkg->conf, old->name); 
     921    new = pkg_hash_fetch_best_installation_candidate_by_name(opkg->conf, old->name, NULL); 
    921922    if (new == NULL) { 
    922923      /* XXX: Notice: Assuming locally install package is up to date */ 
  • trunk/src/target/opkg/libopkg/opkg_cmd.c

    r4448 r4466  
    117117          pkg_write_changed_filelists(conf); 
    118118     } else {  
    119           opkg_message(conf, OPKG_NOTICE, "Nothing to be done\n"); 
     119          opkg_message(conf, OPKG_DEBUG, "Nothing to be done\n"); 
    120120     } 
    121121} 
     
    147147        result = (cmd->fun)(conf, argc, argv); 
    148148 
    149         if ( result != 0 ) { 
     149        if ( result != 0 && !error_list) { 
    150150           opkg_message(conf, OPKG_NOTICE, "An error ocurred, return value: %d.\n", result); 
    151151        } 
     
    157157           /* Here we print the errors collected and free the list */ 
    158158           while (error_list != NULL) { 
    159                  opkg_message(conf, OPKG_NOTICE, "%s",error_list->errmsg); 
     159                 opkg_message(conf, OPKG_NOTICE, " * %s", error_list->errmsg); 
    160160                 error_list = error_list->next; 
    161161 
     
    594594          if (err == OPKG_PKG_HAS_NO_CANDIDATE) { 
    595595               opkg_message(conf, OPKG_ERROR, 
    596                             "Cannot find package %s.\n" 
    597                             "Check the spelling or perhaps run 'opkg update'\n", 
     596                            "Cannot find package %s.\n", 
    598597                            arg); 
    599598          } 
     
    684683          arg = argv[i]; 
    685684 
    686           pkg = pkg_hash_fetch_best_installation_candidate_by_name(conf, arg); 
     685          pkg = pkg_hash_fetch_best_installation_candidate_by_name(conf, arg, &err); 
    687686          if (pkg == NULL) { 
    688687               opkg_message(conf, OPKG_ERROR, 
  • trunk/src/target/opkg/libopkg/opkg_error.h

    r4345 r4466  
    1818 
    1919enum opkg_error { 
    20     OPKG_SUCCESS = 0, 
    21     OPKG_PKG_DEPS_UNSATISFIED, 
    22     OPKG_PKG_IS_ESSENTIAL, 
    23     OPKG_PKG_HAS_DEPENDENTS, 
    24     OPKG_PKG_HAS_NO_CANDIDATE 
     20  OPKG_ERR_UNKNOWN = -1, 
     21  OPKG_ERR_NONE = 0, 
     22 
     23  OPKG_PKG_DEPS_UNSATISFIED, 
     24  OPKG_PKG_IS_ESSENTIAL, 
     25  OPKG_PKG_HAS_DEPENDENTS, 
     26  OPKG_PKG_HAS_NO_CANDIDATE, 
     27  OPKG_PKG_HAS_NO_AVAILABLE_ARCH, 
     28 
     29  OPKG_INSTALL_ERR_NOT_TRUSTED, 
     30  OPKG_INSTALL_ERR_DOWNLOAD, 
     31  OPKG_INSTALL_ERR_CONFLICTS, 
     32  OPKG_INSTALL_ERR_ALREADY_INSTALLED, 
     33  OPKG_INSTALL_ERR_DEPENDENCIES, 
     34  OPKG_INSTALL_ERR_NO_DOWNGRADE, 
     35  OPKG_INSTALL_ERR_NO_SPACE, 
     36  OPKG_INSTALL_ERR_SIGNATURE, 
     37  OPKG_INSTALL_ERR_MD5, 
     38  OPKG_INSTALL_ERR_INTERNAL, 
     39 
    2540}; 
    2641typedef enum opkg_error opkg_error_t; 
  • trunk/src/target/opkg/libopkg/opkg_install.c

    r4458 r4466  
    138138opkg_error_t opkg_install_by_name(opkg_conf_t *conf, const char *pkg_name) 
    139139{ 
    140      int cmp; 
     140     int cmp, err; 
    141141     pkg_t *old, *new; 
    142142     char *old_version, *new_version; 
     
    148148     
    149149     opkg_message(conf, OPKG_DEBUG2, " Getting new  from pkg_hash_fetch \n" ); 
    150      new = pkg_hash_fetch_best_installation_candidate_by_name(conf, pkg_name); 
     150     new = pkg_hash_fetch_best_installation_candidate_by_name(conf, pkg_name, &err); 
    151151     if ( new )  
    152152        opkg_message(conf, OPKG_DEBUG2, " New versions from pkg_hash_fetch %s \n",  new->version ); 
     
    166166 
    167167     if (new == NULL) { 
    168           return OPKG_PKG_HAS_NO_CANDIDATE; 
     168          if (err) 
     169            return err; 
     170          else 
     171            return OPKG_PKG_HAS_NO_CANDIDATE; 
    169172     } 
    170173 
     
    308311     return 0; 
    309312} 
    310  
     313#if 0 
    311314int name_mark_dependencies_for_installation(opkg_conf_t *conf, const char *pkg_name, pkg_vec_t *pkgs_needed) 
    312315{ 
     
    361364} 
    362365 
    363  
     366#endif 
    364367 
    365368int satisfy_dependencies_for(opkg_conf_t *conf, pkg_t *pkg) 
     
    763766          opkg_message(conf, OPKG_ERROR, 
    764767                       "INTERNAL ERROR: null pkg passed to opkg_install_pkg\n"); 
    765           return PKG_INSTALL_ERR_INTERNAL; 
     768          return OPKG_INSTALL_ERR_INTERNAL; 
    766769     } 
    767770 
     
    771774          opkg_message(conf, OPKG_ERROR, "INTERNAL ERROR: architecture %s for pkg %s is unsupported.\n", 
    772775                       pkg->architecture, pkg->name); 
    773           return PKG_INSTALL_ERR_INTERNAL; 
     776          return OPKG_INSTALL_ERR_INTERNAL; 
    774777     } 
    775778     if (pkg->state_status == SS_INSTALLED && conf->force_reinstall == 0 && conf->nodeps == 0) { 
    776779          err = satisfy_dependencies_for(conf, pkg); 
    777           if (err) { return PKG_INSTALL_ERR_DEPENDENCIES; } 
     780          if (err) { return OPKG_INSTALL_ERR_DEPENDENCIES; } 
    778781 
    779782          opkg_message(conf, OPKG_NOTICE, 
     
    790793 
    791794     err = opkg_install_check_downgrade(conf, pkg, old_pkg, message); 
    792      if (err) { return PKG_INSTALL_ERR_NO_DOWNGRADE; } 
     795     if (err) { return OPKG_INSTALL_ERR_NO_DOWNGRADE; } 
    793796 
    794797     pkg->state_want = SW_INSTALL; 
     
    800803     /* Abhaya: conflicts check */ 
    801804     err = check_conflicts_for(conf, pkg); 
    802      if (err) { return PKG_INSTALL_ERR_CONFLICTS; } 
     805     if (err) { return OPKG_INSTALL_ERR_CONFLICTS; } 
    803806     
    804807     /* this setup is to remove the upgrade scenario in the end when 
     
    810813     
    811814     err = verify_pkg_installable(conf, pkg); 
    812      if (err) { return PKG_INSTALL_ERR_NO_SPACE; } 
     815     if (err) { return OPKG_INSTALL_ERR_NO_SPACE; } 
    813816 
    814817     if (pkg->local_filename == NULL) { 
     
    818821                            "Failed to download %s. Perhaps you need to run 'opkg update'?\n", 
    819822                            pkg->name); 
    820                return PKG_INSTALL_ERR_DOWNLOAD; 
     823               return OPKG_INSTALL_ERR_DOWNLOAD; 
    821824          } 
    822825     } 
     
    836839     { 
    837840       if (opkg_verify_file (conf, list_file_name, sig_file_name)) 
    838          return PKG_INSTALL_ERR_SIGNATURE; 
     841         return OPKG_INSTALL_ERR_SIGNATURE; 
    839842     } 
    840843 
     
    854857                           pkg->name); 
    855858              free(file_md5); 
    856               return PKG_INSTALL_ERR_MD5; 
     859              return OPKG_INSTALL_ERR_MD5; 
    857860         } 
    858861         free(file_md5); 
     
    867870/* That's rather strange that files don't change owner. Investigate !!!!!!*/ 
    868871     err = update_file_ownership(conf, pkg, old_pkg); 
    869      if (err) { return PKG_INSTALL_ERR_UNKNOWN; } 
     872     if (err) { return OPKG_ERR_UNKNOWN; } 
    870873 
    871874     if (conf->nodeps == 0) { 
    872875          err = satisfy_dependencies_for(conf, pkg); 
    873           if (err) { return PKG_INSTALL_ERR_DEPENDENCIES; } 
     876          if (err) { return OPKG_INSTALL_ERR_DEPENDENCIES; } 
    874877     } 
    875878 
     
    10201023 
    10211024          pkg_vec_free (replacees); 
    1022           return PKG_INSTALL_ERR_UNKNOWN; 
     1025          return OPKG_ERR_UNKNOWN; 
    10231026     } 
    10241027     opkg_set_current_state (conf, OPKG_STATE_NONE, NULL); 
  • trunk/src/target/opkg/libopkg/opkg_install.h

    r4458 r4466  
    2323#include "opkg_error.h" 
    2424 
    25 enum { 
    26   PKG_INSTALL_ERR_NONE, 
    27   PKG_INSTALL_ERR_NOT_TRUSTED, 
    28   PKG_INSTALL_ERR_DOWNLOAD, 
    29   PKG_INSTALL_ERR_CONFLICTS, 
    30   PKG_INSTALL_ERR_ALREADY_INSTALLED, 
    31   PKG_INSTALL_ERR_DEPENDENCIES, 
    32   PKG_INSTALL_ERR_NO_DOWNGRADE, 
    33   PKG_INSTALL_ERR_NO_SPACE, 
    34   PKG_INSTALL_ERR_SIGNATURE, 
    35   PKG_INSTALL_ERR_MD5, 
    36   PKG_INSTALL_ERR_INTERNAL, 
    37   PKG_INSTALL_ERR_UNKNOWN 
    38 }; 
    39  
    4025opkg_error_t opkg_install_by_name(opkg_conf_t *conf, const char *pkg_name); 
    4126opkg_error_t opkg_install_multi_by_name(opkg_conf_t *conf, const char *pkg_name); 
  • trunk/src/target/opkg/libopkg/opkg_upgrade.c

    r4443 r4466  
    3434     } 
    3535 
    36      new = pkg_hash_fetch_best_installation_candidate_by_name(conf, old->name); 
     36     new = pkg_hash_fetch_best_installation_candidate_by_name(conf, old->name, NULL); 
    3737     if (new == NULL) { 
    3838          old_version = pkg_version_str_alloc(old); 
  • trunk/src/target/opkg/libopkg/pkg.c

    r4448 r4466  
    17141714          if (!pkg->arch_priority && (pkg->state_flag || (pkg->state_want != SW_UNKNOWN))) { 
    17151715               /* clear flags and want for any uninstallable package */ 
    1716                opkg_message(conf, OPKG_NOTICE, "Clearing state_want and state_flag for pkg=%s (arch_priority=%d flag=%d want=%d)\n",  
     1716               opkg_message(conf, OPKG_DEBUG, "Clearing state_want and state_flag for pkg=%s (arch_priority=%d flag=%d want=%d)\n",  
    17171717                            pkg->name, pkg->arch_priority, pkg->state_flag, pkg->state_want); 
    17181718               pkg->state_want = SW_UNKNOWN; 
  • trunk/src/target/opkg/libopkg/pkg_depends.c

    r4445 r4466  
    174174                    pkg_hash_fetch_best_installation_candidate(conf, satisfying_apkg,  
    175175                                                               pkg_installed_and_constraint_satisfied,  
    176                                                                dependence_to_satisfy, 1); 
     176                                                               dependence_to_satisfy, 1, NULL); 
    177177               /* Being that I can't test constraing in pkg_hash, I will test it here */ 
    178178               if (satisfying_pkg != NULL) { 
     
    198198                         pkg_hash_fetch_best_installation_candidate(conf, satisfying_apkg,  
    199199                                                                    pkg_constraint_satisfied,  
    200                                                                     dependence_to_satisfy, 1); 
     200                                                                    dependence_to_satisfy, 1, NULL); 
    201201                    /* Being that I can't test constraing in pkg_hash, I will test it here too */ 
    202202                    if (satisfying_pkg != NULL) { 
  • trunk/src/target/opkg/libopkg/pkg_hash.c

    r4445 r4466  
    171171 
    172172pkg_t *pkg_hash_fetch_best_installation_candidate(opkg_conf_t *conf, abstract_pkg_t *apkg,  
    173                                                   int (*constraint_fcn)(pkg_t *pkg, void *cdata), void *cdata, int quiet) 
     173                                                  int (*constraint_fcn)(pkg_t *pkg, void *cdata), void *cdata, int quiet, int *err) 
    174174{ 
    175175     int i;  
     
    186186     pkg_t *good_pkg_by_name = NULL; 
    187187 
     188     if (err) 
     189       *err = 0; 
     190 
    188191     if (matching_apkgs == NULL || providers == NULL ||  
    189192         apkg == NULL || apkg->provided_by == NULL || (apkg->provided_by->len == 0)) 
     
    252255                    } 
    253256               } 
     257 
     258                if (vec->len > 0 && matching_pkgs->len < 1) 
     259                { 
     260                  opkg_message (conf, OPKG_ERROR, "   Packages found, but none available for the current " 
     261                                                  "architecture\n"); 
     262                  if (err) 
     263                    *err = OPKG_PKG_HAS_NO_AVAILABLE_ARCH; 
     264                } 
    254265          } 
    255266     } 
     
    352363} 
    353364 
    354 pkg_t *pkg_hash_fetch_best_installation_candidate_by_name(opkg_conf_t *conf, const char *name) 
     365pkg_t *pkg_hash_fetch_best_installation_candidate_by_name(opkg_conf_t *conf, const char *name, int *err) 
    355366{ 
    356367     hash_table_t *hash = &conf->pkg_hash; 
    357368     abstract_pkg_t *apkg = NULL; 
     369     pkg_t *ret; 
    358370 
    359371     if (!(apkg = abstract_pkg_fetch_by_name(hash, name))) 
    360372          return NULL; 
    361       
    362      return pkg_hash_fetch_best_installation_candidate(conf, apkg, pkg_name_constraint_fcn, apkg->name, 0); 
     373 
     374     ret = pkg_hash_fetch_best_installation_candidate(conf, apkg, pkg_name_constraint_fcn, apkg->name, 0, err); 
     375 
     376     return ret; 
    363377} 
    364378 
     
    518532    while (dependents [i] != NULL && i < ab_pkg->provided_by->len) 
    519533      printf ("\tprovided by - %s\n", dependents [i ++]->name); 
    520   pkg = pkg_hash_fetch_best_installation_candidate_by_name (conf, ab_pkg->name); 
     534  pkg = pkg_hash_fetch_best_installation_candidate_by_name (conf, ab_pkg->name, NULL); 
    521535  if (pkg) { 
    522536    i = 0; 
  • trunk/src/target/opkg/libopkg/pkg_hash.h

    r4357 r4466  
    4646abstract_pkg_vec_t *pkg_hash_fetch_all_installation_candidates(hash_table_t *hash, const char *name); 
    4747pkg_t *pkg_hash_fetch_best_installation_candidate(opkg_conf_t *conf, abstract_pkg_t *apkg,  
    48                                                   int (*constraint_fcn)(pkg_t *pkg, void *data), void *cdata, int quiet); 
    49 pkg_t *pkg_hash_fetch_best_installation_candidate_by_name(opkg_conf_t *conf, const char *name); 
     48                                                  int (*constraint_fcn)(pkg_t *pkg, void *data), void *cdata, int quiet, int *error); 
     49pkg_t *pkg_hash_fetch_best_installation_candidate_by_name(opkg_conf_t *conf, const char *name, int *err); 
    5050pkg_t *pkg_hash_fetch_installed_by_name(hash_table_t *hash, 
    5151                                        const char *pkg_name); 
Note: See TracChangeset for help on using the changeset viewer.