diff options
author | Ned Ludd <solar@gentoo.org> | 2005-11-01 21:12:12 +0000 |
---|---|---|
committer | Ned Ludd <solar@gentoo.org> | 2005-11-01 21:12:12 +0000 |
commit | 37851f4712fb17ab631fb4700b6f6ca41e936050 (patch) | |
tree | c17d90e74dc4152f18c83fad417bf2bbe4b6b61e | |
parent | - its easy enough to save last commiter and revisions. displayed only at verb... (diff) | |
download | portage-utils-37851f4712fb17ab631fb4700b6f6ca41e936050.tar.gz portage-utils-37851f4712fb17ab631fb4700b6f6ca41e936050.tar.bz2 portage-utils-37851f4712fb17ab631fb4700b6f6ca41e936050.zip |
- added vdb virtual providers resolving code
-rw-r--r-- | libq/virtuals.c | 12 | ||||
-rw-r--r-- | main.c | 74 | ||||
-rw-r--r-- | qdepends.c | 4 | ||||
-rw-r--r-- | quse.c | 4 |
4 files changed, 79 insertions, 15 deletions
diff --git a/libq/virtuals.c b/libq/virtuals.c index 47a43faf..a2c769a9 100644 --- a/libq/virtuals.c +++ b/libq/virtuals.c @@ -1,12 +1,12 @@ /* * Copyright 2005 Gentoo Foundation * Distributed under the terms of the GNU General Public License v2 - * $Header: /var/cvsroot/gentoo-projects/portage-utils/libq/virtuals.c,v 1.7 2005/10/31 14:37:01 solar Exp $ + * $Header: /var/cvsroot/gentoo-projects/portage-utils/libq/virtuals.c,v 1.8 2005/11/01 21:12:12 solar Exp $ * * Copyright 2005 Ned Ludd - <solar@gentoo.org> * Copyright 2005 Mike Frysinger - <vapier@gentoo.org> * - * $Header: /var/cvsroot/gentoo-projects/portage-utils/libq/virtuals.c,v 1.7 2005/10/31 14:37:01 solar Exp $ + * $Header: /var/cvsroot/gentoo-projects/portage-utils/libq/virtuals.c,v 1.8 2005/11/01 21:12:12 solar Exp $ */ @@ -24,6 +24,9 @@ struct queue_t { typedef struct queue_t queue; +/* global */ +queue *virtuals = NULL; + queue *del_set(char *s, queue *q, int *ok); queue *add_set(char *vv, char *ss, queue *q); @@ -145,8 +148,7 @@ void print_sets(queue *list) printf("%s -> %s\n", ll->name, ll->item); } - -queue *virtuals = NULL; +extern queue *resolve_vdb_virtuals(); static queue *resolve_local_profile_virtuals(); static queue *resolve_local_profile_virtuals() { @@ -188,6 +190,7 @@ static queue *resolve_virtuals() { free_sets(virtuals); virtuals = resolve_local_profile_virtuals(); + virtuals = resolve_vdb_virtuals(); if ((chdir("/etc/")) == (-1)) return virtuals; @@ -231,3 +234,4 @@ static queue *resolve_virtuals() { chdir(savecwd); return virtuals; } + @@ -1,7 +1,7 @@ /* * Copyright 2005 Gentoo Foundation * Distributed under the terms of the GNU General Public License v2 - * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.69 2005/10/30 16:19:12 solar Exp $ + * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.70 2005/11/01 21:12:12 solar Exp $ * * Copyright 2005 Ned Ludd - <solar@gentoo.org> * Copyright 2005 Mike Frysinger - <vapier@gentoo.org> @@ -102,7 +102,7 @@ void init_coredumps(void) /* variables to control runtime behavior */ -static const char *rcsid = "$Id: main.c,v 1.69 2005/10/30 16:19:12 solar Exp $"; +static const char *rcsid = "$Id: main.c,v 1.70 2005/11/01 21:12:12 solar Exp $"; static char color = 1; static char exact = 0; @@ -743,10 +743,6 @@ void cache_free(portage_cache *cache) free(cache); } -void cleanup() { - free_sets(virtuals); -} - #include "q.c" #include "qcheck.c" #include "qdepends.c" @@ -760,6 +756,71 @@ void cleanup() { #include "qxpak.c" #include "qpkg.c" +queue *resolve_vdb_virtuals(); +queue *resolve_vdb_virtuals() { + DIR *dir, *dirp; + struct dirent *dentry_cat, *dentry_pkg; + char buf[BUFSIZE]; + depend_atom *atom; + + chdir("/"); + + /* now try to run through vdb and locate matches for user inputs */ + if ((dir = opendir(portvdb)) == NULL) + return virtuals; + + /* scan all the categories */ + while ((dentry_cat = q_vdb_get_next_dir(dir)) != NULL) { + snprintf(buf, sizeof(buf), "%s/%s", portvdb, dentry_cat->d_name); + if ((dirp = opendir(buf)) == NULL) + continue; + + /* scan all the packages in this category */ + while ((dentry_pkg = q_vdb_get_next_dir(dirp)) != NULL) { + FILE *fp; + char *p; + /* see if user wants any of these packages */ + snprintf(buf, sizeof(buf), "%s/%s/%s/PROVIDE", portvdb, dentry_cat->d_name, dentry_pkg->d_name); + if ((fp = fopen(buf, "r")) != NULL) { + fgets(buf, sizeof(buf), fp); + + if ((p = strrchr(buf, '\n')) != NULL) + *p = 0; + + rmspace(buf); + + if (*buf) { + int ok = 0; + char *v, *tmp = xstrdup(buf); + snprintf(buf, sizeof(buf), "%s/%s", dentry_cat->d_name, dentry_pkg->d_name); + + atom = atom_explode(buf); + if (!atom) { + warn("could not explode '%s'", buf); + continue; + } + sprintf(buf, "%s/%s", atom->CATEGORY, atom->PN); + if ((v = virtual(tmp, virtuals)) != NULL) { + IF_DEBUG(fprintf(stderr, "%s provided by %s (removing)\n", tmp, v)); + virtuals = del_set(tmp, virtuals, &ok); + } + virtuals = add_set(tmp, buf, virtuals); + IF_DEBUG(fprintf(stderr, "%s provided by %s/%s (adding)\n", tmp, atom->CATEGORY, dentry_pkg->d_name)); + free(tmp); + atom_implode(atom); + } + fclose(fp); + } + } + } + return virtuals; +} + +void cleanup() { + reinitialize_as_needed(); + free_sets(virtuals); +} + int main(int argc, char **argv) { IF_DEBUG(init_coredumps()); @@ -772,7 +833,6 @@ int main(int argc, char **argv) #endif portroot = (getenv("ROOT") ? : "/"); initialize_portdir(); - atexit(reinitialize_as_needed); atexit(cleanup); optind = 0; return q_main(argc, argv); @@ -1,7 +1,7 @@ /* * Copyright 2005 Gentoo Foundation * Distributed under the terms of the GNU General Public License v2 - * $Header: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v 1.22 2005/10/30 00:48:51 solar Exp $ + * $Header: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v 1.23 2005/11/01 21:12:12 solar Exp $ * * Copyright 2005 Ned Ludd - <solar@gentoo.org> * Copyright 2005 Mike Frysinger - <vapier@gentoo.org> @@ -314,7 +314,7 @@ void _dep_flatten_tree(dep_node *root, char *buf, size_t *pos) if (root->type == DEP_NULL) goto this_node_sucks; if (root->type == DEP_NORM) { size_t len = strlen(root->info); -#if SPANKY +#if 1 if (*root->info == 'v') if (strncmp(root->info, "virtual/", 8) == 0) { if (virtuals == NULL) @@ -1,7 +1,7 @@ /* * Copyright 2005 Gentoo Foundation * Distributed under the terms of the GNU General Public License v2 - * $Header: /var/cvsroot/gentoo-projects/portage-utils/quse.c,v 1.27 2005/11/01 19:08:39 solar Exp $ + * $Header: /var/cvsroot/gentoo-projects/portage-utils/quse.c,v 1.28 2005/11/01 21:12:12 solar Exp $ * * Copyright 2005 Ned Ludd - <solar@gentoo.org> * Copyright 2005 Mike Frysinger - <vapier@gentoo.org> @@ -327,7 +327,7 @@ int quse_main(int argc, char **argv) } if (ok) { if (verbose > 3) - printf("%s %s ", user == NULL ? "0" : user , revision == NULL ? "0" : revision); + printf("%s %s ", *user ? user : "MISSING", *revision ? revision : "MISSING"); printf("%s%s%s ", CYAN, ebuild, NORM); print_highlighted_use_flags(&buf0[search_len+1], optind, argc, argv); |