r4466 - trunk/src/target/opkg/libopkg
thomas at docs.openmoko.org
thomas at docs.openmoko.org
Mon Jun 2 18:11:27 CEST 2008
Author: thomas
Date: 2008-06-02 18:11:25 +0200 (Mon, 02 Jun 2008)
New Revision: 4466
Modified:
trunk/src/target/opkg/libopkg/opkg.c
trunk/src/target/opkg/libopkg/opkg_cmd.c
trunk/src/target/opkg/libopkg/opkg_error.h
trunk/src/target/opkg/libopkg/opkg_install.c
trunk/src/target/opkg/libopkg/opkg_install.h
trunk/src/target/opkg/libopkg/opkg_upgrade.c
trunk/src/target/opkg/libopkg/pkg.c
trunk/src/target/opkg/libopkg/pkg_depends.c
trunk/src/target/opkg/libopkg/pkg_hash.c
trunk/src/target/opkg/libopkg/pkg_hash.h
Log:
opkg: consolidate error enums and add an error for when no package matches
current architecture
Modified: trunk/src/target/opkg/libopkg/opkg.c
===================================================================
--- trunk/src/target/opkg/libopkg/opkg.c 2008-05-31 15:02:32 UTC (rev 4465)
+++ trunk/src/target/opkg/libopkg/opkg.c 2008-06-02 16:11:25 UTC (rev 4466)
@@ -27,6 +27,7 @@
#include "opkg_download.h"
#include "opkg_remove.h"
#include "opkg_upgrade.h"
+#include "opkg_error.h"
#include "sprintf_alloc.h"
#include "file_util.h"
@@ -385,7 +386,7 @@
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 */
@@ -489,13 +490,13 @@
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;
}
}
@@ -625,13 +626,13 @@
{
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;
}
}
@@ -917,7 +918,7 @@
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;
Modified: trunk/src/target/opkg/libopkg/opkg_cmd.c
===================================================================
--- trunk/src/target/opkg/libopkg/opkg_cmd.c 2008-05-31 15:02:32 UTC (rev 4465)
+++ trunk/src/target/opkg/libopkg/opkg_cmd.c 2008-06-02 16:11:25 UTC (rev 4466)
@@ -116,7 +116,7 @@
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");
}
}
@@ -146,7 +146,7 @@
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);
}
@@ -156,7 +156,7 @@
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;
}
@@ -593,8 +593,7 @@
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);
}
}
@@ -683,7 +682,7 @@
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"
Modified: trunk/src/target/opkg/libopkg/opkg_error.h
===================================================================
--- trunk/src/target/opkg/libopkg/opkg_error.h 2008-05-31 15:02:32 UTC (rev 4465)
+++ trunk/src/target/opkg/libopkg/opkg_error.h 2008-06-02 16:11:25 UTC (rev 4466)
@@ -17,11 +17,26 @@
#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;
Modified: trunk/src/target/opkg/libopkg/opkg_install.c
===================================================================
--- trunk/src/target/opkg/libopkg/opkg_install.c 2008-05-31 15:02:32 UTC (rev 4465)
+++ trunk/src/target/opkg/libopkg/opkg_install.c 2008-06-02 16:11:25 UTC (rev 4466)
@@ -137,7 +137,7 @@
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;
@@ -147,7 +147,7 @@
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 );
@@ -165,7 +165,10 @@
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;
@@ -307,7 +310,7 @@
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;
@@ -360,7 +363,7 @@
return pkg_mark_dependencies_for_installation(conf, new, pkgs_needed);
}
-
+#endif
int satisfy_dependencies_for(opkg_conf_t *conf, pkg_t *pkg)
{
@@ -762,7 +765,7 @@
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__);
@@ -770,11 +773,11 @@
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",
@@ -789,7 +792,7 @@
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){
@@ -799,7 +802,7 @@
/* 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
@@ -809,7 +812,7 @@
&& 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);
@@ -817,7 +820,7 @@
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;
}
}
@@ -835,7 +838,7 @@
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);
@@ -853,7 +856,7 @@
"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);
}
@@ -866,11 +869,11 @@
/* 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();
@@ -1019,7 +1022,7 @@
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);
}
Modified: trunk/src/target/opkg/libopkg/opkg_install.h
===================================================================
--- trunk/src/target/opkg/libopkg/opkg_install.h 2008-05-31 15:02:32 UTC (rev 4465)
+++ trunk/src/target/opkg/libopkg/opkg_install.h 2008-06-02 16:11:25 UTC (rev 4466)
@@ -22,21 +22,6 @@
#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);
Modified: trunk/src/target/opkg/libopkg/opkg_upgrade.c
===================================================================
--- trunk/src/target/opkg/libopkg/opkg_upgrade.c 2008-05-31 15:02:32 UTC (rev 4465)
+++ trunk/src/target/opkg/libopkg/opkg_upgrade.c 2008-06-02 16:11:25 UTC (rev 4466)
@@ -33,7 +33,7 @@
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,
Modified: trunk/src/target/opkg/libopkg/pkg.c
===================================================================
--- trunk/src/target/opkg/libopkg/pkg.c 2008-05-31 15:02:32 UTC (rev 4465)
+++ trunk/src/target/opkg/libopkg/pkg.c 2008-06-02 16:11:25 UTC (rev 4466)
@@ -1713,7 +1713,7 @@
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;
Modified: trunk/src/target/opkg/libopkg/pkg_depends.c
===================================================================
--- trunk/src/target/opkg/libopkg/pkg_depends.c 2008-05-31 15:02:32 UTC (rev 4465)
+++ trunk/src/target/opkg/libopkg/pkg_depends.c 2008-06-02 16:11:25 UTC (rev 4466)
@@ -173,7 +173,7 @@
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)) {
@@ -197,7 +197,7 @@
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)) {
Modified: trunk/src/target/opkg/libopkg/pkg_hash.c
===================================================================
--- trunk/src/target/opkg/libopkg/pkg_hash.c 2008-05-31 15:02:32 UTC (rev 4465)
+++ trunk/src/target/opkg/libopkg/pkg_hash.c 2008-06-02 16:11:25 UTC (rev 4466)
@@ -170,7 +170,7 @@
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;
@@ -185,6 +185,9 @@
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;
@@ -251,6 +254,14 @@
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;
+ }
}
}
@@ -351,15 +362,18 @@
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;
}
@@ -517,7 +531,7 @@
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)
Modified: trunk/src/target/opkg/libopkg/pkg_hash.h
===================================================================
--- trunk/src/target/opkg/libopkg/pkg_hash.h 2008-05-31 15:02:32 UTC (rev 4465)
+++ trunk/src/target/opkg/libopkg/pkg_hash.h 2008-06-02 16:11:25 UTC (rev 4466)
@@ -45,8 +45,8 @@
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,
More information about the commitlog
mailing list