summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--libopkg/opkg.c21
-rw-r--r--libopkg/opkg.h12
3 files changed, 24 insertions, 11 deletions
diff --git a/configure.ac b/configure.ac
index e71a5be..8ecb2ac 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
# Process this file with autoconf to produce a configure script
AC_INIT(libopkg/libopkg.c)
-AM_INIT_AUTOMAKE([opkg], [0.1.3])
+AM_INIT_AUTOMAKE([opkg], [0.1.4])
AM_CONFIG_HEADER(libopkg/config.h)
AC_CANONICAL_HOST
diff --git a/libopkg/opkg.c b/libopkg/opkg.c
index 0c1985d..1875b13 100644
--- a/libopkg/opkg.c
+++ b/libopkg/opkg.c
@@ -378,14 +378,14 @@ opkg_install_package (opkg_t *opkg, const char *package_name, opkg_progress_call
if (old)
{
/* XXX: Error: Package is already installed. */
- return 1;
+ return OPKG_PACKAGE_ALREADY_INSTALLED;
}
new = pkg_hash_fetch_best_installation_candidate_by_name(opkg->conf, package_name);
if (!new)
{
/* XXX: Error: Could not find package to install */
- return 1;
+ return OPKG_PACKAGE_NOT_FOUND;
}
new->state_flag |= SF_USER;
@@ -403,7 +403,7 @@ opkg_install_package (opkg_t *opkg, const char *package_name, opkg_progress_call
{
/* XXX: Error: Could not satisfy dependencies */
pkg_vec_free (deps);
- return 1;
+ return OPKG_DEPENDANCIES_FAILED;
}
/* insert the package we are installing so that we download it */
@@ -427,7 +427,7 @@ opkg_install_package (opkg_t *opkg, const char *package_name, opkg_progress_call
if (pkg->src == NULL)
{
/* XXX: Error: Package not available from any configured src */
- return 1;
+ return OPKG_PACKAGE_NOT_AVAILABLE;
}
sprintf_alloc(&url, "%s/%s", pkg->src->value, pkg->filename);
@@ -515,7 +515,7 @@ opkg_remove_package (opkg_t *opkg, const char *package_name, opkg_progress_callb
if (pkg == NULL)
{
/* XXX: Error: Package not installed. */
- return 1;
+ return OPKG_PACKAGE_NOT_INSTALLED;
}
pdata.action = OPKG_REMOVE;
@@ -526,7 +526,7 @@ opkg_remove_package (opkg_t *opkg, const char *package_name, opkg_progress_callb
if (pkg->state_status == SS_NOT_INSTALLED)
{
/* XXX: Error: Package seems to be not installed (STATUS = NOT_INSTALLED). */
- return 1;
+ return OPKG_PACKAGE_NOT_INSTALLED;
}
progress (pdata, 25);
@@ -577,7 +577,7 @@ opkg_upgrade_package (opkg_t *opkg, const char *package_name, opkg_progress_call
if (pkg == NULL)
{
/* XXX: Error: Package not installed in default_dest */
- return 1;
+ return OPKG_PACKAGE_NOT_INSTALLED;
}
}
else
@@ -589,7 +589,7 @@ opkg_upgrade_package (opkg_t *opkg, const char *package_name, opkg_progress_call
if (!pkg)
{
/* XXX: Error: Package not installed */
- return 1;
+ return OPKG_PACKAGE_NOT_INSTALLED;
}
pdata.action = OPKG_INSTALL;
@@ -652,7 +652,7 @@ int
opkg_update_package_lists (opkg_t *opkg, opkg_progress_callback_t progress_callback, void *user_data)
{
char *tmp;
- int err;
+ int err, result = 0;
char *lists_dir;
pkg_src_list_elt_t *iter;
pkg_src_t *src;
@@ -762,6 +762,7 @@ opkg_update_package_lists (opkg_t *opkg, opkg_progress_callback_t progress_callb
if (err)
{
/* XXX: Error: download error */
+ result = OPKG_DOWNLOAD_FAILED;
}
free (url);
@@ -815,7 +816,7 @@ opkg_update_package_lists (opkg_t *opkg, opkg_progress_callback_t progress_callb
free (tmp);
free (lists_dir);
- return 0;
+ return result;
}
diff --git a/libopkg/opkg.h b/libopkg/opkg.h
index 73f18c9..d2a5bd0 100644
--- a/libopkg/opkg.h
+++ b/libopkg/opkg.h
@@ -32,6 +32,18 @@ enum _opkg_action_t
OPKG_DOWNLOAD
};
+enum _opkg_error_code_t
+{
+ OPKG_NO_ERROR,
+ OPKG_UNKNOWN_ERROR,
+ OPKG_DOWNLOAD_FAILED,
+ OPKG_DEPENDANCIES_FAILED,
+ OPKG_PACKAGE_ALREADY_INSTALLED,
+ OPKG_PACKAGE_NOT_AVAILABLE,
+ OPKG_PACKAGE_NOT_FOUND,
+ OPKG_PACKAGE_NOT_INSTALLED
+};
+
struct _opkg_package_t
{
char *name;