{
/* XXX: Error: Could not satisfy dependencies */
pkg_vec_free (deps);
- return OPKG_DEPENDANCIES_FAILED;
+ return OPKG_DEPENDENCIES_FAILED;
}
/* insert the package we are installing so that we download it */
if (err)
{
opkg_package_free (pdata.package);
- 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;
+ default: return OPKG_UNKNOWN_ERROR;
+ }
}
progress (pdata, 75);
pkg_src_t *src;
int sources_list_count, sources_done;
opkg_progress_data_t pdata;
- char *tmp_file_name = NULL;
opkg_assert (opkg != NULL);
return 1;
}
- /* cout the number of sources so we can give some progress updates */
+ /* count the number of sources so we can give some progress updates */
sources_list_count = 0;
sources_done = 0;
iter = opkg->conf->pkg_src_list.head;
for (iter = opkg->conf->pkg_src_list.head; iter; iter = iter->next)
{
- char *url, *list_file_name;
+ char *url, *list_file_name = NULL, *sig_file_name = NULL;
src = iter->data;
{
FILE *in, *out;
struct _curl_cb_data cb_data;
+ char *tmp_file_name = NULL;
sprintf_alloc (&tmp_file_name, "%s/%s.gz", tmp, src->name);
fclose (out);
unlink (tmp_file_name);
}
+ free (tmp_file_name);
}
else
err = opkg_download (opkg->conf, url, list_file_name, NULL, NULL);
- free (tmp_file_name);
if (err)
{
else
sprintf_alloc (&url, "%s/%s", src->value, "Packages.sig");
- /* create temporary file for it */
- sprintf_alloc (&tmp_file_name, "%s/%s", tmp, "Packages.sig");
+ /* create filename for signature */
+ sprintf_alloc (&sig_file_name, "%s/%s.sig", lists_dir, src->name);
- err = opkg_download (opkg->conf, url, tmp_file_name, NULL, NULL);
+ /* make sure there is no existing signature file */
+ unlink (sig_file_name);
+
+ err = opkg_download (opkg->conf, url, sig_file_name, NULL, NULL);
if (err)
{
/* XXX: Warning: Download failed */
else
{
int err;
- err = opkg_verify_file (opkg->conf, list_file_name, tmp_file_name);
+ err = opkg_verify_file (opkg->conf, list_file_name, sig_file_name);
if (err == 0)
{
/* XXX: Notice: Signature check passed */
/* XXX: Warning: Signature check failed */
}
}
- unlink (tmp_file_name);
- free (tmp_file_name);
+ free (sig_file_name);
+ free (list_file_name);
free (url);
#else
/* XXX: Note: Signiture check for %s skipped because GPG support was not
* enabled in this build
*/
#endif
- free (list_file_name);
sources_done++;
progress (pdata, 100 * sources_done / sources_list_count);
OPKG_NO_ERROR,
OPKG_UNKNOWN_ERROR,
OPKG_DOWNLOAD_FAILED,
- OPKG_DEPENDANCIES_FAILED,
+ OPKG_DEPENDENCIES_FAILED,
OPKG_PACKAGE_ALREADY_INSTALLED,
OPKG_PACKAGE_NOT_AVAILABLE,
OPKG_PACKAGE_NOT_FOUND,
- OPKG_PACKAGE_NOT_INSTALLED
+ OPKG_PACKAGE_NOT_INSTALLED,
+ OPKG_GPG_ERROR,
+ OPKG_MD5_ERROR
};
struct _opkg_package_t
int old_state_flag;
char* file_md5;
char *pkgid;
-
if ( from_upgrade )
message = 1; /* Coming from an upgrade, and should change the output message */
if (!pkg) {
opkg_message(conf, OPKG_ERROR,
"INTERNAL ERROR: null pkg passed to opkg_install_pkg\n");
- return -EINVAL;
+ return PKG_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 -EINVAL;
+ return PKG_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 err; }
+ if (err) { return PKG_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 err; }
+ if (err) { return PKG_INSTALL_ERR_NO_DOWNGRADE; }
pkg->state_want = SW_INSTALL;
if (old_pkg){
/* Abhaya: conflicts check */
err = check_conflicts_for(conf, pkg);
- if (err) { return err; }
+ if (err) { return PKG_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 err; }
+ if (err) { return PKG_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 err;
+ return PKG_INSTALL_ERR_DOWNLOAD;
}
}
-/* Check for md5 values */
+ /* check that the repository is valid */
+ #if HAVE_GPGME
+ char *list_file_name, *sig_file_name, *lists_dir;
+
+ sprintf_alloc (&lists_dir, "%s",
+ (conf->restrict_to_default_dest)
+ ? conf->default_dest->lists_dir
+ : conf->lists_dir);
+ sprintf_alloc (&list_file_name, "%s/%s", lists_dir, pkg->src->name);
+ sprintf_alloc (&sig_file_name, "%s/%s.sig", lists_dir, pkg->src->name);
+
+ if (file_exists (sig_file_name))
+ {
+ if (opkg_verify_file (conf, list_file_name, sig_file_name))
+ return PKG_INSTALL_ERR_SIGNATURE;
+ }
+
+ free (lists_dir);
+ free (list_file_name);
+ free (sig_file_name);
+ #endif
+
+ /* Check for md5 values */
if (pkg->md5sum)
{
file_md5 = file_md5sum_alloc(pkg->local_filename);
"Package %s md5sum mismatch. Either the opkg or the package index are corrupt. Try 'opkg update'.\n",
pkg->name);
free(file_md5);
- return err;
+ return PKG_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 err; }
+ if (err) { return PKG_INSTALL_ERR_UNKNOWN; }
if (conf->nodeps == 0) {
err = satisfy_dependencies_for(conf, pkg);
- if (err) { return err; }
+ if (err) { return PKG_INSTALL_ERR_DEPENDENCIES; }
}
replacees = pkg_vec_alloc();
sigprocmask(SIG_UNBLOCK, &newset, &oldset);
pkg_vec_free (replacees);
- return err;
+ return PKG_INSTALL_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);
opkg_package_t *find_pkg = NULL;
-char *errors[8] = {
+char *errors[10] = {
"No Error",
"Unknown Eror",
"Download failed",
"Package already installed",
"Package not available",
"Package not found",
- "Package not installed"
+ "Package not installed",
+ "Signature check failed",
+ "MD5 sum failed"
};
+
+#define TEST_PACKAGE "aspell"
+
void
progress_callback (opkg_t *opkg, const opkg_progress_data_t *progress, void *data)
{
else
printf ("No package available to test find_package.\n");
- err = opkg_install_package (opkg, "aspell", progress_callback, "Installing...");
+ err = opkg_install_package (opkg, TEST_PACKAGE, progress_callback, "Installing...");
printf ("\nopkg_install_package returned %d (%s)\n", err, errors[err]);
- err = opkg_upgrade_package (opkg, "aspell", progress_callback, "Upgrading...");
+ err = opkg_upgrade_package (opkg, TEST_PACKAGE, progress_callback, "Upgrading...");
printf ("\nopkg_upgrade_package returned %d (%s)\n", err, errors[err]);
- err = opkg_remove_package (opkg, "aspell", progress_callback, "Removing...");
+ err = opkg_remove_package (opkg, TEST_PACKAGE, progress_callback, "Removing...");
printf ("\nopkg_remove_package returned %d (%s)\n", err, errors[err]);
printf ("Listing upgradable packages...\n");