summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libopkg/opkg.c27
-rw-r--r--libopkg/opkg_cmd.c6
-rw-r--r--libopkg/opkg_conf.c12
-rw-r--r--libopkg/opkg_error.h31
-rw-r--r--libopkg/opkg_install.c115
-rw-r--r--libopkg/opkg_install.h2
-rw-r--r--libopkg/opkg_remove.c4
-rw-r--r--libopkg/pkg_hash.c2
8 files changed, 65 insertions, 134 deletions
diff --git a/libopkg/opkg.c b/libopkg/opkg.c
index 437beb1..50f8752 100644
--- a/libopkg/opkg.c
+++ b/libopkg/opkg.c
@@ -513,18 +513,7 @@ opkg_install_package (opkg_t *opkg, const char *package_name, opkg_progress_call
if (err)
{
opkg_package_free (pdata.package);
- switch (err)
- {
- 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;
- case OPKG_INSTALL_ERR_SHA256: return OPKG_SHA256_ERROR;
- default: return OPKG_UNKNOWN_ERROR;
- }
+ return OPKG_UNKNOWN_ERROR;
}
progress (pdata, 75);
@@ -651,20 +640,8 @@ opkg_upgrade_package (opkg_t *opkg, const char *package_name, opkg_progress_call
/* opkg_upgrade_pkg returns the error codes of opkg_install_pkg */
if (err)
{
-
opkg_package_free (pdata.package);
- switch (err)
- {
- 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;
- case OPKG_INSTALL_ERR_SHA256: return OPKG_SHA256_ERROR;
- default: return OPKG_UNKNOWN_ERROR;
- }
+ return OPKG_UNKNOWN_ERROR;
}
progress (pdata, 75);
diff --git a/libopkg/opkg_cmd.c b/libopkg/opkg_cmd.c
index c9489d3..82a623e 100644
--- a/libopkg/opkg_cmd.c
+++ b/libopkg/opkg_cmd.c
@@ -546,10 +546,8 @@ static int opkg_install_cmd(opkg_conf_t *conf, int argc, char **argv)
for (i=0; i < argc; i++) {
arg = argv[i];
err = opkg_install_by_name(conf, arg);
- if (err == OPKG_PKG_HAS_NO_CANDIDATE) {
- opkg_message(conf, OPKG_ERROR,
- "Cannot find package %s.\n",
- arg);
+ if (err) {
+ opkg_message(conf, OPKG_ERROR, "Cannot find package %s.\n", arg);
}
}
diff --git a/libopkg/opkg_conf.c b/libopkg/opkg_conf.c
index df5b7b4..7405b48 100644
--- a/libopkg/opkg_conf.c
+++ b/libopkg/opkg_conf.c
@@ -149,7 +149,7 @@ int opkg_conf_init(opkg_conf_t *conf, const args_t *args)
if (opkg_conf_parse_file(conf, args->conf_file,
&conf->pkg_src_list, &tmp_dest_nv_pair_list)<0) {
/* Memory leakage from opkg_conf_parse-file */
- return OPKG_CONF_ERR_PARSE;
+ return -1;
}
}
@@ -177,14 +177,14 @@ int opkg_conf_init(opkg_conf_t *conf, const args_t *args)
if ( opkg_conf_parse_file(conf, globbuf.gl_pathv[i],
&conf->pkg_src_list, &tmp_dest_nv_pair_list)<0) {
/* Memory leakage from opkg_conf_parse-file */
- return OPKG_CONF_ERR_PARSE;
+ return -1;
}
if (offline_root != conf->offline_root) {
opkg_message(conf, OPKG_ERROR,
"Config file %s, within an offline "
"root contains option offline_root.\n",
globbuf.gl_pathv[i]);
- return OPKG_CONF_ERR_PARSE;
+ return -1;
}
}
}
@@ -215,7 +215,7 @@ int opkg_conf_init(opkg_conf_t *conf, const args_t *args)
opkg_message (conf, OPKG_ERROR, "Could not lock %s: %s\n",
lock_file, strerror(errno_copy));
free(lock_file);
- return OPKG_CONF_ERR_LOCK;
+ return -1;
}
free(lock_file);
@@ -233,7 +233,7 @@ int opkg_conf_init(opkg_conf_t *conf, const args_t *args)
opkg_message(conf, OPKG_ERROR,
"%s: Creating temp dir %s failed: %s\n",
__FUNCTION__, tmp2, strerror(errno));
- return OPKG_CONF_ERR_TMP_DIR;
+ return -1;
}
pkg_hash_init("pkg-hash", &conf->pkg_hash, OPKG_CONF_DEFAULT_HASH_LEN);
@@ -338,7 +338,7 @@ int opkg_conf_init(opkg_conf_t *conf, const args_t *args)
err = opkg_conf_set_default_dest(conf, args->dest);
if (err) {
nv_pair_list_deinit(&tmp_dest_nv_pair_list);
- return OPKG_CONF_ERR_DEFAULT_DEST;
+ return -1;
}
}
}
diff --git a/libopkg/opkg_error.h b/libopkg/opkg_error.h
index ec0d1c2..c40e635 100644
--- a/libopkg/opkg_error.h
+++ b/libopkg/opkg_error.h
@@ -16,37 +16,6 @@
#ifndef OPKG_ERROR_H
#define OPKG_ERROR_H
-enum opkg_error {
- OPKG_ERR_UNKNOWN = -1,
- OPKG_ERR_NONE = 0,
-
- OPKG_CONF_ERR_DEFAULT_DEST, /* could not set default dest */
- OPKG_CONF_ERR_PARSE, /* error parsing config file */
- OPKG_CONF_ERR_TMP_DIR, /* could not create temporary directory */
- OPKG_CONF_ERR_LOCK, /* could not get opkg lock */
-
- 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,
- OPKG_INSTALL_ERR_SHA256,
-
-};
-typedef enum opkg_error opkg_error_t;
-
-
struct errlist {
char * errmsg;
struct errlist * next;
diff --git a/libopkg/opkg_install.c b/libopkg/opkg_install.c
index 819410f..303877e 100644
--- a/libopkg/opkg_install.c
+++ b/libopkg/opkg_install.c
@@ -70,7 +70,7 @@ satisfy_dependencies_for(opkg_conf_t *conf, pkg_t *pkg)
"mentioned above do not yet exist (try 'opkg update'). To proceed in spite\n"
"of this problem try again with the '-force-depends' option.\n");
pkg_vec_free(depends);
- return OPKG_PKG_DEPS_UNSATISFIED;
+ return -1;
}
}
@@ -138,7 +138,7 @@ check_conflicts_for(opkg_conf_t *conf, pkg_t *pkg)
opkg_message(conf, level, " %s", conflicts->pkgs[i++]->name);
opkg_message(conf, level, "\n");
pkg_vec_free(conflicts);
- return OPKG_PKG_DEPS_UNSATISFIED;
+ return -1;
}
return 0;
}
@@ -1186,42 +1186,25 @@ resolve_conffiles(opkg_conf_t *conf, pkg_t *pkg)
}
-opkg_error_t
+int
opkg_install_by_name(opkg_conf_t *conf, const char *pkg_name)
{
int cmp, err = 0;
pkg_t *old, *new;
char *old_version, *new_version;
- opkg_message(conf, OPKG_DEBUG2, " Getting old from pkg_hash_fetch \n" );
old = pkg_hash_fetch_installed_by_name(&conf->pkg_hash, pkg_name);
- if ( old )
- opkg_message(conf, OPKG_DEBUG2, " Old versions from pkg_hash_fetch %s \n", old->version );
+ if (old)
+ 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, &err);
- if ( new )
- opkg_message(conf, OPKG_DEBUG2, " New versions from pkg_hash_fetch %s \n", new->version );
-
-/* Pigi Basically here is broken the version stuff.
- What's happening is that nothing provide the version to differents
- functions, so the returned struct is always the latest.
- That's why the install by name don't work.
-*/
- opkg_message(conf, OPKG_DEBUG2, " Versions from pkg_hash_fetch in %s ", __FUNCTION__ );
+ if (new == NULL || err)
+ return -1;
+ opkg_message(conf, OPKG_DEBUG2, "Versions from pkg_hash_fetch in %s ", __FUNCTION__);
if ( old )
- opkg_message(conf, OPKG_DEBUG2, " old %s ", old->version );
- if ( new )
- opkg_message(conf, OPKG_DEBUG2, " new %s ", new->version );
- opkg_message(conf, OPKG_DEBUG2, " \n");
-
- if (new == NULL) {
- if (err)
- return err;
- else
- return OPKG_PKG_HAS_NO_CANDIDATE;
- }
+ opkg_message(conf, OPKG_DEBUG2, " old %s ", old->version);
+ opkg_message(conf, OPKG_DEBUG2, " new %s\n", new->version);
new->state_flag |= SF_USER;
if (old) {
@@ -1263,13 +1246,7 @@ opkg_install_by_name(opkg_conf_t *conf, const char *pkg_name)
free(new_version);
}
- /* XXX: CLEANUP: The error code of opkg_install_by_name is really
- supposed to be an opkg_error_t, but opkg_install_pkg could
- return any kind of integer, (might be errno from a syscall,
- etc.). This is a real mess and will need to be cleaned up if
- anyone ever wants to make a nice libopkg. */
-
- opkg_message(conf, OPKG_DEBUG2,"Function: %s calling opkg_install_pkg \n",__FUNCTION__);
+ opkg_message(conf, OPKG_DEBUG2,"%s: calling opkg_install_pkg \n",__FUNCTION__);
return opkg_install_pkg(conf, new,0);
}
@@ -1289,6 +1266,7 @@ opkg_install_pkg(opkg_conf_t *conf, pkg_t *pkg, int from_upgrade)
#ifdef HAVE_SHA256
char* file_sha256;
#endif
+ sigset_t newset, oldset;
if ( from_upgrade )
message = 1; /* Coming from an upgrade, and should change the output message */
@@ -1296,7 +1274,7 @@ opkg_install_pkg(opkg_conf_t *conf, pkg_t *pkg, int from_upgrade)
if (!pkg) {
opkg_message(conf, OPKG_ERROR,
"INTERNAL ERROR: null pkg passed to opkg_install_pkg\n");
- return OPKG_INSTALL_ERR_INTERNAL;
+ return -1;
}
opkg_message(conf, OPKG_DEBUG2, "Function: %s calling pkg_arch_supported %s \n", __FUNCTION__, __FUNCTION__);
@@ -1304,11 +1282,12 @@ opkg_install_pkg(opkg_conf_t *conf, pkg_t *pkg, int from_upgrade)
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 OPKG_INSTALL_ERR_INTERNAL;
+ return -1;
}
if (pkg->state_status == SS_INSTALLED && conf->force_reinstall == 0 && conf->nodeps == 0) {
err = satisfy_dependencies_for(conf, pkg);
- if (err) { return OPKG_INSTALL_ERR_DEPENDENCIES; }
+ if (err)
+ return -1;
opkg_message(conf, OPKG_NOTICE,
"Package %s is already installed in %s.\n",
@@ -1323,27 +1302,28 @@ opkg_install_pkg(opkg_conf_t *conf, pkg_t *pkg, int from_upgrade)
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 OPKG_INSTALL_ERR_NO_DOWNGRADE; }
+ if (err)
+ return -1;
pkg->state_want = SW_INSTALL;
if (old_pkg){
old_pkg->state_want = SW_DEINSTALL; /* needed for check_data_file_clashes of dependences */
}
-
- /* Abhaya: conflicts check */
err = check_conflicts_for(conf, pkg);
- if (err) { return OPKG_INSTALL_ERR_CONFLICTS; }
+ if (err)
+ return -1;
/* 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
installed. Then A's installation is started resulting in an
uncecessary upgrade */
- if (pkg->state_status == SS_INSTALLED
- && conf->force_reinstall == 0) return 0;
+ if (pkg->state_status == SS_INSTALLED && conf->force_reinstall == 0)
+ return 0;
err = verify_pkg_installable(conf, pkg);
- if (err) { return OPKG_INSTALL_ERR_NO_SPACE; }
+ if (err)
+ return -1;
if (pkg->local_filename == NULL) {
err = opkg_download_pkg(conf, pkg, conf->tmp_dir);
@@ -1351,7 +1331,7 @@ opkg_install_pkg(opkg_conf_t *conf, pkg_t *pkg, int from_upgrade)
opkg_message(conf, OPKG_ERROR,
"Failed to download %s. Perhaps you need to run 'opkg update'?\n",
pkg->name);
- return OPKG_INSTALL_ERR_DOWNLOAD;
+ return -1;
}
}
@@ -1374,12 +1354,12 @@ opkg_install_pkg(opkg_conf_t *conf, pkg_t *pkg, int from_upgrade)
if (opkg_verify_file (conf, list_file_name, sig_file_name)){
opkg_message(conf, OPKG_ERROR, "Failed to verify the signature of: %s\n",
list_file_name);
- return OPKG_INSTALL_ERR_SIGNATURE;
+ return -1;
}
}else{
opkg_message(conf, OPKG_ERROR, "Signature file is missing. "
"Perhaps you need to run 'opkg update'?\n");
- return OPKG_INSTALL_ERR_SIGNATURE;
+ return -1;
}
free (lists_dir);
@@ -1398,7 +1378,7 @@ opkg_install_pkg(opkg_conf_t *conf, pkg_t *pkg, int from_upgrade)
"Package %s md5sum mismatch. Either the opkg or the package index are corrupt. Try 'opkg update'.\n",
pkg->name);
free(file_md5);
- return OPKG_INSTALL_ERR_MD5;
+ return -1;
}
if (file_md5)
free(file_md5);
@@ -1415,7 +1395,7 @@ opkg_install_pkg(opkg_conf_t *conf, pkg_t *pkg, int from_upgrade)
"Package %s sha256sum mismatch. Either the opkg or the package index are corrupt. Try 'opkg update'.\n",
pkg->name);
free(file_sha256);
- return OPKG_INSTALL_ERR_SHA256;
+ return -1;
}
if (file_sha256)
free(file_sha256);
@@ -1434,22 +1414,22 @@ opkg_install_pkg(opkg_conf_t *conf, pkg_t *pkg, int from_upgrade)
/* 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 OPKG_ERR_UNKNOWN; }
+ if (err)
+ return -1;
if (conf->nodeps == 0) {
err = satisfy_dependencies_for(conf, pkg);
- if (err) { return OPKG_INSTALL_ERR_DEPENDENCIES; }
+ if (err)
+ return -1;
if (pkg->state_status == SS_UNPACKED)
/* Circular dependency has installed it for us. */
- return 0;
+ return 0;
}
replacees = pkg_vec_alloc();
pkg_get_installed_replacees(conf, pkg, replacees);
/* this next section we do with SIGINT blocked to prevent inconsistency between opkg database and filesystem */
- {
- sigset_t newset, oldset;
sigemptyset(&newset);
sigaddset(&newset, SIGINT);
@@ -1465,27 +1445,35 @@ opkg_install_pkg(opkg_conf_t *conf, pkg_t *pkg, int from_upgrade)
* Instead, we're going to remove the replacees
*/
err = pkg_remove_installed_replacees(conf, replacees);
- if (err) goto UNWIND_REMOVE_INSTALLED_REPLACEES;
+ if (err)
+ goto UNWIND_REMOVE_INSTALLED_REPLACEES;
err = prerm_upgrade_old_pkg(conf, pkg, old_pkg);
- if (err) goto UNWIND_PRERM_UPGRADE_OLD_PKG;
+ if (err)
+ goto UNWIND_PRERM_UPGRADE_OLD_PKG;
err = prerm_deconfigure_conflictors(conf, pkg, replacees);
- if (err) goto UNWIND_PRERM_DECONFIGURE_CONFLICTORS;
+ if (err)
+ goto UNWIND_PRERM_DECONFIGURE_CONFLICTORS;
err = preinst_configure(conf, pkg, old_pkg);
- if (err) goto UNWIND_PREINST_CONFIGURE;
+ if (err)
+ goto UNWIND_PREINST_CONFIGURE;
err = backup_modified_conffiles(conf, pkg, old_pkg);
- if (err) goto UNWIND_BACKUP_MODIFIED_CONFFILES;
+ if (err)
+ goto UNWIND_BACKUP_MODIFIED_CONFFILES;
err = check_data_file_clashes(conf, pkg, old_pkg);
- if (err) goto UNWIND_CHECK_DATA_FILE_CLASHES;
+ if (err)
+ goto UNWIND_CHECK_DATA_FILE_CLASHES;
err = postrm_upgrade_old_pkg(conf, pkg, old_pkg);
- if (err) goto UNWIND_POSTRM_UPGRADE_OLD_PKG;
+ if (err)
+ goto UNWIND_POSTRM_UPGRADE_OLD_PKG;
- if (conf->noaction) return 0;
+ if (conf->noaction)
+ return 0;
/* point of no return: no unwinding after this */
if (old_pkg && !conf->force_reinstall) {
@@ -1588,6 +1576,5 @@ pkg_is_hosed:
sigprocmask(SIG_UNBLOCK, &newset, &oldset);
pkg_vec_free (replacees);
- return OPKG_ERR_UNKNOWN;
- }
+ return -1;
}
diff --git a/libopkg/opkg_install.h b/libopkg/opkg_install.h
index d6d074f..13d43d0 100644
--- a/libopkg/opkg_install.h
+++ b/libopkg/opkg_install.h
@@ -22,7 +22,7 @@
#include "opkg_conf.h"
#include "opkg_error.h"
-opkg_error_t opkg_install_by_name(opkg_conf_t *conf, const char *pkg_name);
+int opkg_install_by_name(opkg_conf_t *conf, const char *pkg_name);
int opkg_install_pkg(opkg_conf_t *conf, pkg_t *pkg, int from_upgrading);
#endif
diff --git a/libopkg/opkg_remove.c b/libopkg/opkg_remove.c
index f53ef00..a2ef09c 100644
--- a/libopkg/opkg_remove.c
+++ b/libopkg/opkg_remove.c
@@ -244,7 +244,7 @@ opkg_remove_pkg(opkg_conf_t *conf, pkg_t *pkg, int from_upgrade)
"\tyou enjoy that kind of pain, you can force opkg to proceed against\n"
"\tits will with the option: --force-removal-of-essential-packages\n",
pkg->name);
- return OPKG_PKG_IS_ESSENTIAL;
+ return -1;
}
}
@@ -270,7 +270,7 @@ opkg_remove_pkg(opkg_conf_t *conf, pkg_t *pkg, int from_upgrade)
if (!conf->force_removal_of_dependent_packages) {
print_dependents_warning(conf, parent_pkg, pkg, dependents);
free(dependents);
- return OPKG_PKG_HAS_DEPENDENTS;
+ return -1;
}
/* remove packages depending on this package - Karthik */
diff --git a/libopkg/pkg_hash.c b/libopkg/pkg_hash.c
index e02e1f2..3259eef 100644
--- a/libopkg/pkg_hash.c
+++ b/libopkg/pkg_hash.c
@@ -256,7 +256,7 @@ pkg_hash_fetch_best_installation_candidate(opkg_conf_t *conf,
{
opkg_message (conf, OPKG_ERROR, "Packages were found, but none compatible with the architectures configured\n");
if (err)
- *err = OPKG_PKG_HAS_NO_AVAILABLE_ARCH;
+ *err = -1;
}
}
}