X-Git-Url: https://git.librecmc.org/?p=oweals%2Fopkg-lede.git;a=blobdiff_plain;f=libopkg%2Fopkg_install.c;h=a3893c7131f54e89cc2fc926d15d57f00af2e2cf;hp=6c1822c67db550a04aa63e4aac433a9ee2ef9000;hb=5b68464bd8b8405fae90c1d96cdd7367a506bd5c;hpb=3523443344809d2f357a5008931c9f79e91a3de3 diff --git a/libopkg/opkg_install.c b/libopkg/opkg_install.c index 6c1822c..a3893c7 100644 --- a/libopkg/opkg_install.c +++ b/libopkg/opkg_install.c @@ -137,7 +137,7 @@ int opkg_install_from_file(opkg_conf_t *conf, const char *filename) 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_error_t opkg_install_by_name(opkg_conf_t *conf, const char *pkg_name) 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_error_t opkg_install_by_name(opkg_conf_t *conf, const char *pkg_name) 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 @@ int pkg_mark_dependencies_for_installation(opkg_conf_t *conf, pkg_t *pkg, pkg_ve 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 @@ int name_mark_dependencies_for_installation(opkg_conf_t *conf, const char *pkg_n return pkg_mark_dependencies_for_installation(conf, new, pkgs_needed); } - +#endif int satisfy_dependencies_for(opkg_conf_t *conf, pkg_t *pkg) { @@ -394,6 +397,7 @@ int satisfy_dependencies_for(opkg_conf_t *conf, pkg_t *pkg) } if (ndepends <= 0) { + pkg_vec_free(depends); return 0; } @@ -502,7 +506,9 @@ static int update_file_ownership(opkg_conf_t *conf, pkg_t *new_pkg, pkg_t *old_p hash_table_insert(&conf->obs_file_hash, old_file, old_pkg); } } + pkg_free_installed_files(old_pkg); } + pkg_free_installed_files(new_pkg); return 0; } @@ -754,7 +760,6 @@ int opkg_install_pkg(opkg_conf_t *conf, pkg_t *pkg, int from_upgrade) int old_state_flag; char* file_md5; char *pkgid; - if ( from_upgrade ) message = 1; /* Coming from an upgrade, and should change the output message */ @@ -762,7 +767,7 @@ int 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 -EINVAL; + return OPKG_INSTALL_ERR_INTERNAL; } opkg_message(conf, OPKG_DEBUG2, "Function: %s calling pkg_arch_supported %s \n", __FUNCTION__, __FUNCTION__); @@ -770,11 +775,11 @@ int 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 -EINVAL; + 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 err; } + if (err) { return OPKG_INSTALL_ERR_DEPENDENCIES; } opkg_message(conf, OPKG_NOTICE, "Package %s is already installed in %s.\n", @@ -789,7 +794,7 @@ int 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 err; } + if (err) { return OPKG_INSTALL_ERR_NO_DOWNGRADE; } pkg->state_want = SW_INSTALL; if (old_pkg){ @@ -799,7 +804,7 @@ int opkg_install_pkg(opkg_conf_t *conf, pkg_t *pkg, int from_upgrade) /* Abhaya: conflicts check */ err = check_conflicts_for(conf, pkg); - if (err) { return err; } + 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 +814,7 @@ int opkg_install_pkg(opkg_conf_t *conf, pkg_t *pkg, int from_upgrade) && conf->force_reinstall == 0) return 0; err = verify_pkg_installable(conf, pkg); - if (err) { return err; } + if (err) { return OPKG_INSTALL_ERR_NO_SPACE; } if (pkg->local_filename == NULL) { err = opkg_download_pkg(conf, pkg, conf->tmp_dir); @@ -817,11 +822,37 @@ int 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 err; + return OPKG_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; + + /* check to ensure the package has come from a repository */ + if (pkg->src) + { + 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 OPKG_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); @@ -831,7 +862,7 @@ int 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 err; + return OPKG_INSTALL_ERR_MD5; } free(file_md5); } @@ -844,11 +875,11 @@ int 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 err; } + if (err) { return OPKG_ERR_UNKNOWN; } if (conf->nodeps == 0) { err = satisfy_dependencies_for(conf, pkg); - if (err) { return err; } + if (err) { return OPKG_INSTALL_ERR_DEPENDENCIES; } } replacees = pkg_vec_alloc(); @@ -966,7 +997,7 @@ int opkg_install_pkg(opkg_conf_t *conf, pkg_t *pkg, int from_upgrade) signal(SIGINT, old_handler); else sigprocmask(SIG_UNBLOCK, &newset, &oldset); - + pkg_vec_free (replacees); return 0; @@ -996,7 +1027,8 @@ int opkg_install_pkg(opkg_conf_t *conf, pkg_t *pkg, int from_upgrade) else sigprocmask(SIG_UNBLOCK, &newset, &oldset); - return err; + pkg_vec_free (replacees); + return OPKG_ERR_UNKNOWN; } opkg_set_current_state (conf, OPKG_STATE_NONE, NULL); }