X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=libopkg%2Fopkg_cmd.c;h=8386fcea50091136b7a9818f8736952162b35b90;hb=1f08c9e15caa6377c58f55c0fdaab8f4fab1ad5e;hp=e91a24c7357947b50f0884ad5d1f25dae3dc8323;hpb=9e85c59c8df6dd151fce6238811844d8d66ea1c0;p=oweals%2Fopkg-lede.git diff --git a/libopkg/opkg_cmd.c b/libopkg/opkg_cmd.c index e91a24c..8386fce 100644 --- a/libopkg/opkg_cmd.c +++ b/libopkg/opkg_cmd.c @@ -72,6 +72,7 @@ static int opkg_whatreplaces_cmd(opkg_conf_t *conf, int argc, char **argv); static int opkg_compare_versions_cmd(opkg_conf_t *conf, int argc, char **argv); static int opkg_print_architecture_cmd(opkg_conf_t *conf, int argc, char **argv); static int opkg_configure_cmd(opkg_conf_t *conf, int argc, char **argv); +static int pkg_mark_provides(pkg_t *pkg); /* XXX: CLEANUP: The usage strings should be incorporated into this array for easier maintenance */ @@ -287,7 +288,7 @@ static int opkg_update_cmd(opkg_conf_t *conf, int argc, char **argv) free (tmp_file_name); free (url); #else - opkg_message (conf, OPKG_NOTICE, "Signiture check for %s skipped " + opkg_message (conf, OPKG_NOTICE, "Signature check for %s skipped " "because GPG support was not enabled in this build\n", src->name); #endif free(list_file_name); @@ -300,36 +301,6 @@ static int opkg_update_cmd(opkg_conf_t *conf, int argc, char **argv) } -/* scan the args passed and cache the local filenames of the packages */ -int opkg_multiple_files_scan(opkg_conf_t *conf, int argc, char **argv) -{ - int i; - int err; - - /* - * First scan through package names/urls - * For any urls, download the packages and install in database. - * For any files, install package info in database. - */ - for (i = 0; i < argc; i ++) { - char *filename = argv [i]; - //char *tmp = basename (tmp); - //int tmplen = strlen (tmp); - - //if (strcmp (tmp + (tmplen - strlen (OPKG_PKG_EXTENSION)), OPKG_PKG_EXTENSION) != 0) - // continue; - //if (strcmp (tmp + (tmplen - strlen (DPKG_PKG_EXTENSION)), DPKG_PKG_EXTENSION) != 0) - // continue; - - opkg_message(conf, OPKG_DEBUG2, "Debug mfs: %s \n",filename ); - - err = opkg_prepare_url_for_install(conf, filename, &argv[i]); - if (err) - return err; - } - return 0; -} - struct opkg_intercept { char *oldpath; @@ -338,14 +309,21 @@ struct opkg_intercept typedef struct opkg_intercept *opkg_intercept_t; -opkg_intercept_t opkg_prep_intercepts(opkg_conf_t *conf) +static opkg_intercept_t opkg_prep_intercepts(opkg_conf_t *conf) { opkg_intercept_t ctx; + char *oldpath; char *newpath; int gen; ctx = malloc (sizeof (*ctx)); - ctx->oldpath = strdup (getenv ("PATH")); + oldpath = getenv ("PATH"); + if (oldpath) { + ctx->oldpath = strdup (oldpath); + } else { + ctx->oldpath = 0; + } + sprintf_alloc (&newpath, "%s/opkg/intercept:%s", DATADIR, ctx->oldpath); setenv ("PATH", newpath, 1); @@ -367,14 +345,18 @@ opkg_intercept_t opkg_prep_intercepts(opkg_conf_t *conf) return ctx; } -int opkg_finalize_intercepts(opkg_intercept_t ctx) +static int opkg_finalize_intercepts(opkg_intercept_t ctx) { char *cmd; 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) { @@ -398,7 +380,7 @@ int opkg_finalize_intercepts(opkg_intercept_t ctx) perror (ctx->statedir); sprintf_alloc (&cmd, "rm -rf %s", ctx->statedir); - system (cmd); + err = system (cmd); free (cmd); free (ctx->statedir); @@ -415,7 +397,7 @@ int opkg_finalize_intercepts(opkg_intercept_t ctx) used to end recursion and avoid an infinite loop on graph cycles. pkg_vec ordered will finally contain the ordered set of packages. */ -int opkg_recurse_pkgs_in_order(opkg_conf_t *conf, pkg_t *pkg, pkg_vec_t *all, +static int opkg_recurse_pkgs_in_order(opkg_conf_t *conf, pkg_t *pkg, pkg_vec_t *all, pkg_vec_t *visited, pkg_vec_t *ordered) { int j,k,l,m; @@ -497,7 +479,7 @@ int opkg_recurse_pkgs_in_order(opkg_conf_t *conf, pkg_t *pkg, pkg_vec_t *all, } -int opkg_configure_packages(opkg_conf_t *conf, char *pkg_name) +static int opkg_configure_packages(opkg_conf_t *conf, char *pkg_name) { pkg_vec_t *all, *ordered, *visited; int i; @@ -938,9 +920,9 @@ static int opkg_remove_cmd(opkg_conf_t *conf, int argc, char **argv) done = 0; - available = pkg_vec_alloc(); pkg_info_preinstall_check(conf); if ( argc > 0 ) { + available = pkg_vec_alloc(); pkg_hash_fetch_all_installed(&conf->pkg_hash, available); for (i=0; i < argc; i++) { pkg_name = malloc(strlen(argv[i])+2); @@ -1329,7 +1311,7 @@ static int opkg_what_depends_conflicts_cmd(opkg_conf_t *conf, enum what_field_ty return 0; } -int pkg_mark_provides(pkg_t *pkg) +static int pkg_mark_provides(pkg_t *pkg) { int provides_count = pkg->provides_count; abstract_pkg_t **provides = pkg->provides;