General Public License for more details.
*/
-#include "config.h"
-
#include <stdio.h>
#include <dirent.h>
#include <glob.h>
sprintf_alloc(&list_file_name, "%s/%s", lists_dir, src->name);
pkglist_dl_error = 0;
- if (opkg_download(url, list_file_name, NULL, NULL, 0)) {
+ if (opkg_download(url, list_file_name, 0)) {
failures++;
pkglist_dl_error = 1;
opkg_msg(NOTICE,
list_file_name);
}
free(url);
-#if defined(HAVE_GPGME) || defined(HAVE_OPENSSL) || defined(HAVE_USIGN)
+#if defined(HAVE_USIGN)
if (pkglist_dl_error == 0 && conf->check_signature) {
/* download detached signitures to verify the package lists */
/* get the url for the sig file */
sprintf_alloc(&tmp_file_name, "%s/%s.sig", lists_dir,
src->name);
- err = opkg_download(url, tmp_file_name, NULL, NULL, 0);
+ err = opkg_download(url, tmp_file_name, 0);
if (err) {
failures++;
opkg_msg(NOTICE,
ctx = xcalloc(1, sizeof(*ctx));
ctx->oldpath = xstrdup(getenv("PATH"));
- sprintf_alloc(&newpath, "%s/opkg/intercept:%s", DATADIR, ctx->oldpath);
+
+ sprintf_alloc(&newpath, "%s/opkg/intercept:%s", DATADIR,
+ ctx->oldpath ? ctx->oldpath : PATH_SPEC);
+
sprintf_alloc(&ctx->statedir, "%s/opkg-intercept-XXXXXX",
- conf->tmp_dir);
+ conf->tmp_dir);
if (mkdtemp(ctx->statedir) == NULL) {
opkg_perror(ERROR, "Failed to make temp dir %s", ctx->statedir);
- free(ctx->oldpath);
+
+ if (ctx->oldpath)
+ free(ctx->oldpath);
+
free(ctx->statedir);
free(newpath);
free(ctx);
DIR *dir;
int err = 0;
- setenv("PATH", ctx->oldpath, 1);
- free(ctx->oldpath);
+ if (ctx->oldpath) {
+ setenv("PATH", ctx->oldpath, 1);
+ free(ctx->oldpath);
+ }
+ else {
+ unsetenv("PATH");
+ }
dir = opendir(ctx->statedir);
if (dir) {
sprintf_alloc(&path, "%s/%s", ctx->statedir,
de->d_name);
if (access(path, X_OK) == 0) {
- const char *argv[] = { "sh", "-c", path, NULL };
+ const char *argv[] = { "/bin/sh", "-c", path, NULL };
xsystem(argv);
}
free(path);
char *arg;
int err = 0;
- if (conf->force_reinstall) {
- int saved_force_depends = conf->force_depends;
- conf->force_depends = 1;
- (void)opkg_remove_cmd(argc, argv);
- conf->force_depends = saved_force_depends;
- conf->force_reinstall = 0;
- }
-
signal(SIGINT, sigint_handler);
/*
if (opkg_prepare_url_for_install(arg, &argv[i]))
return -1;
}
+
+ pkg_hash_load_package_details();
+ pkg_hash_load_status_files();
+
+ if (conf->force_reinstall) {
+ int saved_force_depends = conf->force_depends;
+ conf->force_depends = 1;
+ (void)opkg_remove_cmd(argc, argv);
+ conf->force_depends = saved_force_depends;
+ conf->force_reinstall = 0;
+ }
+
pkg_info_preinstall_check();
for (i = 0; i < argc; i++) {
char *old_v, *new_v;
for (node = active_list_next(head, head); node;
node = active_list_next(head, node)) {
- _old_pkg = list_entry(node, pkg_t, list);
+ _old_pkg = node->pkg;
_new_pkg =
pkg_hash_fetch_best_installation_candidate_by_name
(_old_pkg->name);
deps = pkg_get_ptr(pkg, (what_field_type == CONFLICTS) ? PKG_CONFLICTS : PKG_DEPENDS);
- for (cdep = deps; cdep->type; cdep++) {
+ for (cdep = deps; cdep && cdep->type; cdep++) {
if (what_field_type != cdep->type)
continue;
abpkgs = pkg_get_ptr(pkg, (what_field_type == WHATPROVIDES) ? PKG_PROVIDES : PKG_REPLACES);
while (abpkgs && *abpkgs) {
- apkg = *abpkgs;
+ apkg = *abpkgs++;
if (fnmatch(target, apkg->name, conf->nocase))
continue;
opkg_msg(NOTICE, "\t%s %s\n", rel_str, apkg->name);
opkg_message(NOTICE, "\n");
- abpkgs++;
}
}
}
static int opkg_compare_versions_cmd(int argc, char **argv)
{
+ int rc;
+ pkg_t *p1, *p2;
+
if (argc == 3) {
/* this is a bit gross */
- struct pkg p1, p2;
- parse_version(&p1, argv[0]);
- parse_version(&p2, argv[2]);
- return pkg_version_satisfied(&p1, &p2, argv[1]);
+ p1 = pkg_new();
+ p2 = pkg_new();
+ parse_version(p1, argv[0]);
+ parse_version(p2, argv[2]);
+ rc = pkg_version_satisfied(p1, p2, argv[1]);
+ pkg_deinit(p1);
+ pkg_deinit(p2);
+ free(p1);
+ free(p2);
+ return rc ? 0 : 1;
} else {
opkg_msg(ERROR,
"opkg compare_versions <v1> <op> <v2>\n"
{"find", 1, (opkg_cmd_fun_t) opkg_find_cmd, PFM_SOURCE},
{"download", 1, (opkg_cmd_fun_t) opkg_download_cmd,
PFM_DESCRIPTION | PFM_SOURCE},
- {"compare_versions", 1, (opkg_cmd_fun_t) opkg_compare_versions_cmd,
- PFM_DESCRIPTION | PFM_SOURCE},
- {"compare-versions", 1, (opkg_cmd_fun_t) opkg_compare_versions_cmd,
- PFM_DESCRIPTION | PFM_SOURCE},
+ {"compare_versions", 1, (opkg_cmd_fun_t) opkg_compare_versions_cmd, 0},
+ {"compare-versions", 1, (opkg_cmd_fun_t) opkg_compare_versions_cmd, 0},
{"print-architecture", 0, (opkg_cmd_fun_t) opkg_print_architecture_cmd,
PFM_DESCRIPTION | PFM_SOURCE},
{"print_architecture", 0, (opkg_cmd_fun_t) opkg_print_architecture_cmd,