Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 154405 | Differences between
and this patch

Collapse All | Expand All

(-)portage-utils-0.1.21/applets.h (-19 / +19 lines)
Lines 29-35 DECLARE_APPLET(qxpak) Link Here
29
DECLARE_APPLET(qpkg)
29
DECLARE_APPLET(qpkg)
30
DECLARE_APPLET(qgrep)
30
DECLARE_APPLET(qgrep)
31
DECLARE_APPLET(qatom)
31
DECLARE_APPLET(qatom)
32
DECLARE_APPLET(qmerge)
32
DECLARE_APPLET(qmerge) 
33
DECLARE_APPLET(qcache)
33
DECLARE_APPLET(qcache)
34
DECLARE_APPLET(qpy)
34
DECLARE_APPLET(qpy)
35
DECLARE_APPLET(qglsa) /* disable */
35
DECLARE_APPLET(qglsa) /* disable */
Lines 47-70 struct applet_t { Link Here
47
	const char *desc;
47
	const char *desc;
48
} applets[] = {
48
} applets[] = {
49
	/* q must always be the first applet */
49
	/* q must always be the first applet */
50
	{"q",         q_main,         "<applet> <args>", "virtual applet"},
50
	{"q",         q_main,         "<applet> <args>", "virtual applet"		},
51
	{"qatom",     qatom_main,     "<pkg>",           "split atom strings"},
51
	{"qatom",     qatom_main,     "<pkg>",           "split atom strings"		},
52
	{"qcache",    qcache_main,    "<action> <args>", "search the metadata cache"},
52
	{"qcache",    qcache_main,    "<action> <args>", "search the metadata cache"	},
53
	{"qcheck",    qcheck_main,    "<pkgname>",       "verify mtimes/digests"},
53
	{"qcheck",    qcheck_main,    "<pkgname>",       "verify mtimes/digests"	},
54
	{"qdepends",  qdepends_main,  "<pkgname>",       "show dependency info"},
54
	{"qdepends",  qdepends_main,  "<pkgname>",       "show dependency info"		},
55
	{"qfile",     qfile_main,     "<filename>",      "list all pkgs owning files"},
55
	{"qfile",     qfile_main,     "<filename>",      "list all pkgs owning files"	},
56
	{"qglsa",     qglsa_main,     "<action> <list>", "check GLSAs against system"},
56
	{"qgrep",     qgrep_main,     "<misc args>",     "grep in ebuilds"		},
57
	{"qgrep",     qgrep_main,     "<misc args>",     "grep in ebuilds"},
57
	{"qlist",     qlist_main,     "<pkgname>",       "list files owned by pkgname"	},
58
	{"qlist",     qlist_main,     "<pkgname>",       "list files owned by pkgname"},
58
	{"qlop",      qlop_main,      "<pkgname>",       "paludis log analyzer"		},
59
	{"qlop",      qlop_main,      "<pkgname>",       "emerge log analyzer"},
59
	{"qpkg",      qpkg_main,      "<misc args>",     "manipulate Gentoo binpkgs"	},
60
	{"qmerge",    qmerge_main,    "<pkgnames>",      "fetch and merge binary package"},
60
	{"qsearch",   qsearch_main,   "<regex>",         "search pkgname/desc"		},
61
	{"qpkg",      qpkg_main,      "<misc args>",     "manipulate Gentoo binpkgs"},
61
	{"qsize",     qsize_main,     "<pkgname>",       "calculate size usage"		},
62
	{"qpy",      qpy_main,      "<misc args>",     "python interface"},
62
	{"qtbz2",     qtbz2_main,     "<misc args>",     "manipulate tbz2 packages"	},
63
	{"qsearch",   qsearch_main,   "<regex>",         "search pkgname/desc"},
63
	{"quse",      quse_main,      "<useflag>",       "find pkgs using useflags"	},
64
	{"qsize",     qsize_main,     "<pkgname>",       "calculate size usage"},
64
	{"qxpak",     qxpak_main,     "<misc args>",     "manipulate xpak archives"	},
65
	{"qtbz2",     qtbz2_main,     "<misc args>",     "manipulate tbz2 packages"},
65
	{"qmerge",    qmerge_main,    "<pkgnames>",      "fetch and merge binary package"},	
66
	{"quse",      quse_main,      "<useflag>",       "find pkgs using useflags"},
66
	{"qglsa",     qglsa_main,     "<action> <list>", NULL				},		/* "check GLSAs against system" */
67
	{"qxpak",     qxpak_main,     "<misc args>",     "manipulate xpak archives"},
67
	{"qpy",       qpy_main,       "<misc args>",     NULL				},		/* "python interface" */
68
68
69
69
70
	/* aliases for equery capatability */
70
	/* aliases for equery capatability */
(-)portage-utils-0.1.21/main.c (-89 / +196 lines)
Lines 71-76 int rematch(const char *, const char *, Link Here
71
static char *rmspace(char *);
71
static char *rmspace(char *);
72
72
73
void initialize_portage_env(void);
73
void initialize_portage_env(void);
74
void initialize_overlays (char portdir_overlay[]);
74
void initialize_ebuild_flat(void);
75
void initialize_ebuild_flat(void);
75
void reinitialize_ebuild_flat(void);
76
void reinitialize_ebuild_flat(void);
76
void reinitialize_as_needed(void);
77
void reinitialize_as_needed(void);
Lines 85-97 static int quiet = 0; Link Here
85
static char pretend = 0;
86
static char pretend = 0;
86
static char reinitialize = 0;
87
static char reinitialize = 0;
87
static char reinitialize_metacache = 0;
88
static char reinitialize_metacache = 0;
88
static char portdir[_Q_PATH_MAX] = "/usr/portage";
89
static char portarch[20] = "";
89
static char portarch[20] = "";
90
static char portvdb[] = "var/db/pkg";
90
static char portvdb[] = "var/db/pkg";
91
static char portcachedir[] = "metadata/cache";
91
static char portcachedir[] = "metadata/cache";
92
static char portroot[_Q_PATH_MAX] = "/";
92
static char portroot[_Q_PATH_MAX] = "/";
93
static char config_protect[_Q_PATH_MAX] = "/etc/";
93
static char config_protect[_Q_PATH_MAX] = "/etc/";
94
94
95
typedef struct overlay_t overlay_t;
96
struct overlay_t {
97
	char name[64];
98
	char path[_Q_PATH_MAX];
99
	struct overlay_t *next;
100
};
101
102
static overlay_t *overlay_gentoo = NULL;
103
95
char pkgdir[512] = "/usr/portage/packages/";
104
char pkgdir[512] = "/usr/portage/packages/";
96
char port_tmpdir[512] = "/var/tmp/portage/";
105
char port_tmpdir[512] = "/var/tmp/portage/";
97
106
Lines 176-182 void no_colors() { Link Here
176
	getopt_long(argc, argv, ex A ## _FLAGS, a ## _long_opts, NULL)
185
	getopt_long(argc, argv, ex A ## _FLAGS, a ## _long_opts, NULL)
177
/* display usage and exit */
186
/* display usage and exit */
178
static void usage(int status, const char *flags, struct option const opts[], 
187
static void usage(int status, const char *flags, struct option const opts[], 
179
                  const char *help[], int blabber)
188
		  const char *help[], int blabber)
180
{
189
{
181
	unsigned long i;
190
	unsigned long i;
182
	if (blabber == 0) {
191
	if (blabber == 0) {
Lines 199-208 static void usage(int status, const char Link Here
199
	for (i = 0; opts[i].name; ++i) {
208
	for (i = 0; opts[i].name; ++i) {
200
		assert(help[i] != NULL); /* this assert is a life saver when adding new applets. */
209
		assert(help[i] != NULL); /* this assert is a life saver when adding new applets. */
201
		if (opts[i].has_arg == no_argument)
210
		if (opts[i].has_arg == no_argument)
202
			printf("  -%c, --%-15s%s*%s %s\n", opts[i].val,
211
			printf("  -%c, --%-16s%s*%s %s\n", opts[i].val,
203
				opts[i].name, RED, NORM, _(help[i]));
212
				opts[i].name, RED, NORM, _(help[i]));
204
		else
213
		else
205
			printf("  -%c, --%-8s %s<arg>%s %s*%s %s\n", opts[i].val,
214
			printf("  -%c, --%-9s %s<arg>%s %s*%s %s\n", opts[i].val,
206
				opts[i].name, DKBLUE, NORM, RED, NORM, _(help[i]));
215
				opts[i].name, DKBLUE, NORM, RED, NORM, _(help[i]));
207
	}
216
	}
208
	exit(status);
217
	exit(status);
Lines 213-219 static void version_barf(const char *Id) Link Here
213
# define VERSION "cvs"
222
# define VERSION "cvs"
214
#endif
223
#endif
215
	printf("portage-utils-%s: compiled on %s\n%s\n"
224
	printf("portage-utils-%s: compiled on %s\n%s\n"
216
	       "%s written for Gentoo by <solar and vapier @ gentoo.org>\n",
225
	       "%s written for Gentoo by <solar and vapier @ gentoo.org>\n"
226
	       "modified for overlay support by samuelethiec @ hotmail.com\n",
217
	       VERSION, __DATE__, Id, argv0);
227
	       VERSION, __DATE__, Id, argv0);
218
	exit(EXIT_SUCCESS);
228
	exit(EXIT_SUCCESS);
219
}
229
}
Lines 298-336 static char *remove_extra_space(char *st Link Here
298
void freeargv(int, char **);
308
void freeargv(int, char **);
299
void freeargv(int argc, char **argv) {
309
void freeargv(int argc, char **argv) {
300
	int i;
310
	int i;
301
        if (argc > 0) {
311
	if (argc > 0) {
302
                for (i = 0; i < argc; i++)
312
		for (i = 0; i < argc; i++)
303
                        free(argv[i]);
313
			free(argv[i]);
304
                free(argv);
314
		free(argv);
305
        }
315
	}
306
}
316
}
307
317
308
void makeargv(char *string, int *argc, char ***argv);
318
void makeargv(char *string, int *argc, char ***argv);
309
void makeargv(char *string, int *argc, char ***argv) {
319
void makeargv(char *string, int *argc, char ***argv) {
310
	int curc = 2;
320
	int curc = 2;
311
	char *q, *p, *str;        
321
	char *q, *p, *str;	
312
	(*argv) = (char **) malloc(sizeof(char **) * curc);
322
	(*argv) = (char **) malloc(sizeof(char **) * curc);
313
323
314
	*argc = 1;        
324
	*argc = 1;	
315
	(*argv)[0] = xstrdup(argv0);
325
	(*argv)[0] = xstrdup(argv0);
316
	q = xstrdup(string);        
326
	q = xstrdup(string);	
317
	str = q;
327
	str = q;
318
328
319
	remove_extra_space(str);        
329
	remove_extra_space(str);	
320
	rmspace(str);
330
	rmspace(str);
321
331
322
	while (str) {
332
	while (str) {
323
		if ((p = strchr(str, ' ')) != NULL)
333
		if ((p = strchr(str, ' ')) != NULL)
324
			*(p++) = '\0';
334
			*(p++) = '\0';
325
335
326
                if (*argc == curc) {
336
		if (*argc == curc) {
327
			curc *= 2;
337
			curc *= 2;
328
			(*argv) = (char **) realloc(*argv, sizeof(char **) * curc);
338
			(*argv) = (char **) realloc(*argv, sizeof(char **) * curc);
329
                }
339
		}
330
                (*argv)[*argc] = xstrdup(str);
340
		(*argv)[*argc] = xstrdup(str);
331
                (*argc)++;
341
		(*argc)++;
332
                str = p;
342
		str = p;
333
        }
343
	}
334
	free(q);
344
	free(q);
335
}
345
}
336
346
Lines 453-469 char *strincr_var(const char *name, char Link Here
453
	return (char *) value;
463
	return (char *) value;
454
}
464
}
455
465
466
void initialize_overlays (char portdir_overlay[])
467
{
468
	short merror = 0;
469
	char buf[BUFSIZE], file[_Q_PATH_MAX], *s, *p, *t;
470
	overlay_t *cur_overlay;
471
	FILE *repo_nameFP;
472
	s = portdir_overlay;
473
	cur_overlay = overlay_gentoo;
474
475
	while (*s) {
476
		cur_overlay->next = (overlay_t *) xmalloc ( sizeof (*cur_overlay->next));
477
		cur_overlay = cur_overlay->next;
478
		cur_overlay->next = NULL;
479
480
		if ( (p=strchr(s,' ')))
481
			*p = 0;
482
483
		strncpy(cur_overlay->path, s, sizeof(cur_overlay->path));
484
485
		/* find the name for the overlay */
486
		strncpy(file, cur_overlay->path, _Q_PATH_MAX);
487
		strncat(file, "/profiles/repo_name", _Q_PATH_MAX);
488
		if (( repo_nameFP = fopen(file, "r") ))
489
		{
490
			if ( ! ( fgets(buf, sizeof(buf),repo_nameFP)) )
491
				merror++;
492
493
			rmspace(buf);
494
			if ( (t = strchr(buf,'\n')))
495
				*t = 0;
496
497
			strncpy(cur_overlay->name, buf, sizeof(cur_overlay->name));
498
499
			fclose(repo_nameFP);
500
501
		} else 
502
			merror++;
503
504
		if (merror) {
505
			/* delete trailing '/' */
506
			t = cur_overlay->path + strlen(cur_overlay->path) - 1;
507
			if ( *t == '/' )
508
				*t = 0;
509
510
			strncat(cur_overlay->name, basename(cur_overlay->path), sizeof(cur_overlay->name));
511
			merror=0;
512
		}
513
514
		if (p)
515
			s = p+1;
516
		else
517
			break;
518
	}
519
	
520
}
521
522
456
void initialize_portage_env(void)
523
void initialize_portage_env(void)
457
{
524
{
458
	char nocolor = 0;
525
	char nocolor = 0;
459
	int i, f;
526
	int i, f;
460
	struct stat st;
527
	struct stat st;
461
	FILE *fp;
528
	FILE *fp;
529
	char tmp_portdir[_Q_PATH_MAX];
530
	char portdir_overlay[2048] = "";
531
462
	char buf[BUFSIZE], *s, *p;
532
	char buf[BUFSIZE], *s, *p;
463
533
464
	char profile[_Q_PATH_MAX], portage_file[_Q_PATH_MAX];
534
	char profile[_Q_PATH_MAX], portage_file[_Q_PATH_MAX];
535
465
	const char *files[] = {portage_file, "/etc/make.globals", "/etc/make.conf"};
536
	const char *files[] = {portage_file, "/etc/make.globals", "/etc/make.conf"};
466
	typedef enum { _Q_BOOL, _Q_STR, _Q_ISTR } var_types;
537
	typedef enum { _Q_BOOL, _Q_STR, _Q_ISTR } var_types;
538
	
467
	struct {
539
	struct {
468
		const char *name;
540
		const char *name;
469
		const size_t name_len;
541
		const size_t name_len;
Lines 471-489 void initialize_portage_env(void) Link Here
471
		char *value;
543
		char *value;
472
		const size_t value_len;
544
		const size_t value_len;
473
	} vars_to_read[] = {
545
	} vars_to_read[] = {
474
		{"ACCEPT_LICENSE", 14, _Q_STR,  accept_license, sizeof(accept_license)},
546
		{"ACCEPT_LICENSE",	14, _Q_STR,	accept_license,		 sizeof(accept_license)		},
475
		{"INSTALL_MASK", 12, _Q_ISTR,  install_mask, sizeof(install_mask)},
547
		{"INSTALL_MASK",	12, _Q_ISTR,	install_mask,		 sizeof(install_mask)		},
476
		{"ARCH",    4, _Q_STR,  portarch, sizeof(portarch)},
548
		{"ARCH",		4, _Q_STR,	portarch,		 sizeof(portarch)		},
477
		{"CONFIG_PROTECT",    14, _Q_STR,  config_protect, sizeof(config_protect)},
549
		{"CONFIG_PROTECT",	14, _Q_STR,	config_protect,		 sizeof(config_protect)		},
478
		{"NOCOLOR", 7, _Q_BOOL, &nocolor, 1},
550
		{"NOCOLOR",		7, _Q_BOOL,	&nocolor,		 1				},
479
		{"FEATURES",8, _Q_ISTR,  features, sizeof(features)},
551
		{"FEATURES",		8, _Q_ISTR,	features,		 sizeof(features)		},
480
		{"PORTDIR", 7, _Q_STR,  portdir, sizeof(portdir)},
552
		{"PORTDIR",		7, _Q_STR,	tmp_portdir,		 sizeof(tmp_portdir)		},
481
		{"PORTAGE_BINHOST",   15, _Q_STR,  binhost, sizeof(binhost)},
553
		{"PORTDIR_OVERLAY",	15, _Q_ISTR,	portdir_overlay,	 sizeof(portdir_overlay)	},
482
		{"PORTAGE_TMPDIR",    14, _Q_STR,  port_tmpdir, sizeof(port_tmpdir)},
554
		{"PORTAGE_BINHOST",	15, _Q_STR,	binhost,		 sizeof(binhost)		},
483
		{"PKGDIR",  6, _Q_STR,  pkgdir, sizeof(pkgdir)},
555
		{"PORTAGE_TMP",		9, _Q_STR,	port_tmpdir,		 sizeof(port_tmpdir)		},
484
		{"ROOT",    4, _Q_STR,  portroot, sizeof(portroot)}
556
		{"PKGDIR",		6, _Q_STR,	pkgdir,			 sizeof(pkgdir)			},
557
		{"ROOT",		4, _Q_STR,	portroot,		 sizeof(portroot)		}
485
	};
558
	};
486
559
560
	overlay_gentoo = (overlay_t*) xmalloc(sizeof(*overlay_gentoo));
561
	strcpy(overlay_gentoo->name,"gentoo");
562
	strcpy(overlay_gentoo->path,"/usr/portage");
563
	overlay_gentoo->next = NULL;
564
565
487
	if ((p = strchr(portroot, '/')) != NULL)
566
	if ((p = strchr(portroot, '/')) != NULL)
488
		if (strlen(p) != 1)
567
		if (strlen(p) != 1)
489
			strncat(portroot, "/", sizeof(portroot));
568
			strncat(portroot, "/", sizeof(portroot));
Lines 575-580 void initialize_portage_env(void) Link Here
575
		no_colors();
654
		no_colors();
576
	else
655
	else
577
		color_remap();
656
		color_remap();
657
658
659
	strncpy(overlay_gentoo->path, tmp_portdir, sizeof(overlay_gentoo->path));
660
661
	/* now we initiliase the overlay chained list with overlay_gentoo the first 'item'  */
662
	initialize_overlays(portdir_overlay);
663
578
}
664
}
579
665
580
enum {
666
enum {
Lines 603-621 const char *initialize_flat(int cache_ty Link Here
603
	int a, b, c, d, e, i;
689
	int a, b, c, d, e, i;
604
	int frac, secs, count;
690
	int frac, secs, count;
605
	FILE *fp;
691
	FILE *fp;
692
	overlay_t *cur_overlay;
606
693
607
	a = b = c = d = e = i = 0;
694
	a = b = c = d = e = i = 0;
608
	count = frac = secs = 0;
695
	count = frac = secs = 0;
696
	cur_overlay = overlay_gentoo;
609
697
610
	cache_file = (cache_type == CACHE_EBUILD ? CACHE_EBUILD_FILE : CACHE_METADATA_FILE);
698
	cache_file = (cache_type == CACHE_EBUILD ? CACHE_EBUILD_FILE : CACHE_METADATA_FILE);
611
699
612
	if (chdir(portdir) != 0) {
700
	if (chdir(overlay_gentoo->path) != 0) {
613
		warnp("chdir to PORTDIR '%s' failed", portdir);
701
		warnp("chdir to PORTDIR '%s' failed", overlay_gentoo->path);
614
		goto ret;
702
		goto ret;
615
	}
703
	}
616
704
617
	if (cache_type == CACHE_METADATA && chdir(portcachedir) != 0) {
705
	if (cache_type == CACHE_METADATA && chdir(portcachedir) != 0) {
618
		warnp("chdir to portage cache '%s/%s' failed", portdir, portcachedir);
706
		warnp("chdir to paludis cache '%s/%s' failed", overlay_gentoo->path, portcachedir);
619
		goto ret;
707
		goto ret;
620
	}
708
	}
621
709
Lines 631-694 const char *initialize_flat(int cache_ty Link Here
631
719
632
	unlink(cache_file);
720
	unlink(cache_file);
633
	if (errno != ENOENT) {
721
	if (errno != ENOENT) {
634
		warnfp("unlinking '%s/%s' failed", portdir, cache_file);
722
		warnfp("unlinking '%s/%s' failed", overlay_gentoo->path, cache_file);
635
		goto ret;
723
		goto ret;
636
	}
724
	}
637
725
638
	if ((fp = fopen(cache_file, "w")) == NULL) {
726
	if ((fp = fopen(cache_file, "w")) == NULL) {
639
		warnfp("opening '%s/%s' failed", portdir, cache_file);
727
		warnfp("opening '%s/%s' failed", overlay_gentoo->path, cache_file);
640
		goto ret;
728
		goto ret;
641
	}
729
	}
642
730
643
	gettimeofday(&start, NULL);
731
	gettimeofday(&start, NULL);
644
732
645
	if ((a = scandir(".", &category, filter_hidden, alphasort)) < 0)
733
	do {
646
		goto ret;
734
		if ( cur_overlay == overlay_gentoo || chdir(cur_overlay->path) == 0) {
647
735
			if ((a = scandir(".", &category, filter_hidden, alphasort)) < 0)
648
	for (i = 0 ; i < a; i++) {
649
		stat(category[i]->d_name, &st);
650
		if (!S_ISDIR(st.st_mode))
651
			continue;
652
		if (strchr(category[i]->d_name, '-') == NULL)
653
			if ((strncmp(category[i]->d_name, "virtual", 7)) != 0)
654
				continue;
736
				continue;
655
737
656
		if ((b = scandir(category[i]->d_name, &pn, filter_hidden, alphasort)) < 0)
738
			for (i = 0 ; i < a; i++) {
657
			continue;
739
				stat(category[i]->d_name, &st);
658
		for (c = 0; c < b; c++) {
740
				if (!S_ISDIR(st.st_mode))
659
			char de[_Q_PATH_MAX];
741
					continue;
742
				if (strchr(category[i]->d_name, '-') == NULL)
743
					if ((strncmp(category[i]->d_name, "virtual", 7)) != 0)
744
						continue;
660
745
661
			snprintf(de, sizeof(de), "%s/%s", category[i]->d_name, pn[c]->d_name);
746
				if ((b = scandir(category[i]->d_name, &pn, filter_hidden, alphasort)) < 0)
747
					continue;
748
				for (c = 0; c < b; c++) {
749
					char de[_Q_PATH_MAX];
662
750
663
			if (stat(de, &st) < 0)
751
					snprintf(de, sizeof(de), "%s/%s", category[i]->d_name, pn[c]->d_name);
664
				continue;
665
752
666
			switch (cache_type) {
753
					if (stat(de, &st) < 0)
667
			case CACHE_EBUILD:
754
						continue;
668
				if (!S_ISDIR(st.st_mode))
755
669
					continue;
756
					switch (cache_type) {
670
				break;
757
					case CACHE_EBUILD:
671
			case CACHE_METADATA:
758
						if (!S_ISDIR(st.st_mode))
672
				if (S_ISREG(st.st_mode))
759
							continue;
673
					fprintf(fp, "%s\n", de);
760
						break;
674
				continue;
761
					case CACHE_METADATA:
675
				break;
762
						if (S_ISREG(st.st_mode))
676
			}
763
							fprintf(fp, "%s\n", de);
677
			if ((e = scandir(de, &eb, filter_hidden, alphasort)) < 0)
764
						continue;
678
				continue;
765
						break;
679
			for (d = 0 ; d < e; d++) {
766
					}
680
				if ((p = strrchr(eb[d]->d_name, '.')) != NULL)
767
					if ((e = scandir(de, &eb, filter_hidden, alphasort)) < 0)
681
					if (strcmp(p, ".ebuild") == 0) {
768
						continue;
682
						count++;
769
					for (d = 0 ; d < e; d++) {
683
						fprintf(fp, "%s/%s/%s\n", category[i]->d_name, pn[c]->d_name, eb[d]->d_name);
770
						if ((p = strrchr(eb[d]->d_name, '.')) != NULL)
771
							if (strcmp(p, ".ebuild") == 0) {
772
								count++;
773
								fprintf(fp, "%s::%s/%s/%s\n", cur_overlay->name, category[i]->d_name, pn[c]->d_name, eb[d]->d_name);
774
							}
684
					}
775
					}
776
					while(d--)
777
						free(eb[d]);
778
					free(eb);
779
				}
780
				while(b--)
781
					free(pn[b]);
782
				free(pn);
685
			}
783
			}
686
			while(d--) free(eb[d]);
784
		} else
687
			free(eb);
785
			warnp("chdir to PORTDIR '%s' failed, skipping the %s repository", cur_overlay->path, cur_overlay->name);
688
		}
786
689
		while(b--) free(pn[b]);
787
	} while ( (cur_overlay = cur_overlay->next));
690
		free(pn);
788
691
	}
692
	fclose(fp);
789
	fclose(fp);
693
	while(a--) free(category[a]);
790
	while(a--) free(category[a]);
694
	free(category);
791
	free(category);
Lines 699-705 const char *initialize_flat(int cache_ty Link Here
699
	if (start.tv_usec > finish.tv_usec) {
796
	if (start.tv_usec > finish.tv_usec) {
700
		finish.tv_usec += 1000000;
797
		finish.tv_usec += 1000000;
701
		finish.tv_sec--;
798
		finish.tv_sec--;
702
        
799
	
703
	}
800
	}
704
	frac = (finish.tv_usec - start.tv_usec);
801
	frac = (finish.tv_usec - start.tv_usec);
705
	secs = (finish.tv_sec - start.tv_sec);
802
	secs = (finish.tv_sec - start.tv_sec);
Lines 708-714 const char *initialize_flat(int cache_ty Link Here
708
805
709
	warn("Finished %u entries in %d.%06d seconds", count, secs, frac);
806
	warn("Finished %u entries in %d.%06d seconds", count, secs, frac);
710
	if (secs > 100)
807
	if (secs > 100)
711
		warn("You should consider a faster file system such as reiserfs for PORTDIR='%s'", portdir);
808
		warn("You should consider a faster file system such as reiserfs for PORTDIR='%s'", overlay_gentoo->path);
712
ret:
809
ret:
713
	return cache_file;
810
	return cache_file;
714
}
811
}
Lines 717-724 ret: Link Here
717
814
718
void reinitialize_ebuild_flat(void)
815
void reinitialize_ebuild_flat(void)
719
{
816
{
720
	if ((chdir(portdir)) != 0) {
817
	if ((chdir(overlay_gentoo->path)) != 0) {
721
		warnp("chdir to PORTDIR '%s' failed", portdir);
818
		warnp("chdir to PORTDIR '%s' failed", overlay_gentoo->path);
722
		return;
819
		return;
723
	}
820
	}
724
	unlink(CACHE_EBUILD_FILE);
821
	unlink(CACHE_EBUILD_FILE);
Lines 900-918 void cache_free(portage_cache *cache) Link Here
900
997
901
char *grab_vdb_item(const char *, const char *, const char *);
998
char *grab_vdb_item(const char *, const char *, const char *);
902
char *grab_vdb_item(const char *item, const char *CATEGORY, const char *PF) {
999
char *grab_vdb_item(const char *item, const char *CATEGORY, const char *PF) {
903
        static char buf[_Q_PATH_MAX];
1000
	static char buf[_Q_PATH_MAX];
904
        char *p;
1001
	char *p;
905
        FILE *fp;
1002
	FILE *fp;
906
1003
907
	snprintf(buf, sizeof(buf), "%s%s/%s/%s/%s", portroot, portvdb, CATEGORY, PF, item);
1004
	snprintf(buf, sizeof(buf), "%s%s/%s/%s/%s", portroot, portvdb, CATEGORY, PF, item);
908
	if ((fp = fopen(buf, "r")) == NULL)
1005
	if ((fp = fopen(buf, "r")) == NULL)
909
		return NULL;        
1006
		return NULL;	
910
	fgets(buf, sizeof(buf), fp);
1007
	fgets(buf, sizeof(buf), fp);
911
	if ((p = strchr(buf, '\n')) != NULL)                
1008
	if ((p = strchr(buf, '\n')) != NULL)
912
		*p = 0;
1009
		*p = 0;
913
	fclose(fp);
1010
	fclose(fp);
914
	rmspace(buf);
1011
	rmspace(buf);
915
        
1012
	
916
	return buf;
1013
	return buf;
917
}
1014
}
918
1015
Lines 922-928 queue *get_vdb_atoms(void) { Link Here
922
	int dfd, i;
1019
	int dfd, i;
923
1020
924
	char buf[_Q_PATH_MAX];
1021
	char buf[_Q_PATH_MAX];
925
        static char savecwd[_POSIX_PATH_MAX];
1022
	static char savecwd[_POSIX_PATH_MAX];
926
1023
927
	struct dirent **cat;
1024
	struct dirent **cat;
928
	struct dirent **pf;
1025
	struct dirent **pf;
Lines 930-936 queue *get_vdb_atoms(void) { Link Here
930
	depend_atom *atom = NULL;
1027
	depend_atom *atom = NULL;
931
	queue *cpf = NULL;
1028
	queue *cpf = NULL;
932
1029
933
        getcwd(savecwd, sizeof(savecwd));
1030
	getcwd(savecwd, sizeof(savecwd));
934
1031
935
	assert(chdir(savecwd) == 0);
1032
	assert(chdir(savecwd) == 0);
936
1033
Lines 974-980 queue *get_vdb_atoms(void) { Link Here
974
				snprintf(buf, sizeof(buf), "%s/%s-%s", atom->CATEGORY, atom->PN, atom->PV);
1071
				snprintf(buf, sizeof(buf), "%s/%s-%s", atom->CATEGORY, atom->PN, atom->PV);
975
			atom_implode(atom);
1072
			atom_implode(atom);
976
			cpf = add_set(buf, "0", cpf);
1073
			cpf = add_set(buf, "0", cpf);
977
			
1074
978
		}
1075
		}
979
		chdir("..");
1076
		chdir("..");
980
		while(dfd--) free(pf[dfd]);
1077
		while(dfd--) free(pf[dfd]);
Lines 990-998 fuckit: Link Here
990
	return cpf;
1087
	return cpf;
991
}
1088
}
992
1089
1090
/* free overlays */
1091
void free_overlays(overlay_t *overlay);
1092
void free_overlays(overlay_t *overlay)
1093
{
1094
	if ( overlay->next )
1095
		free_overlays(overlay->next);
1096
	free(overlay);
1097
}
1098
993
void cleanup() {
1099
void cleanup() {
994
	reinitialize_as_needed();
1100
	reinitialize_as_needed();
995
	free_sets(virtuals);
1101
	free_sets(virtuals);
1102
	free_overlays(overlay_gentoo);
996
	fclose(stderr);
1103
	fclose(stderr);
997
}
1104
}
998
1105
(-)portage-utils-0.1.21/q.c (-1 / +13 lines)
Lines 7-21 Link Here
7
 * Copyright 2005-2006 Mike Frysinger  - <vapier@gentoo.org>
7
 * Copyright 2005-2006 Mike Frysinger  - <vapier@gentoo.org>
8
 */
8
 */
9
9
10
#define Q_FLAGS "irm" COMMON_FLAGS
10
#define Q_FLAGS "ilrm" COMMON_FLAGS
11
static struct option const q_long_opts[] = {
11
static struct option const q_long_opts[] = {
12
	{"install",      no_argument, NULL, 'i'},
12
	{"install",      no_argument, NULL, 'i'},
13
	{"ls-overlays",  no_argument, NULL, 'l'},
13
	{"reinitialize", no_argument, NULL, 'r'},
14
	{"reinitialize", no_argument, NULL, 'r'},
14
	{"metacache",    no_argument, NULL, 'm'},
15
	{"metacache",    no_argument, NULL, 'm'},
15
	COMMON_LONG_OPTS
16
	COMMON_LONG_OPTS
16
};
17
};
17
static const char *q_opts_help[] = {
18
static const char *q_opts_help[] = {
18
	"Install symlinks for applets",
19
	"Install symlinks for applets",
20
	"List configured overlays",
19
	"Reinitialize ebuild cache",
21
	"Reinitialize ebuild cache",
20
	"Reinitialize metadata cache",
22
	"Reinitialize metadata cache",
21
	COMMON_OPTS_HELP
23
	COMMON_OPTS_HELP
Lines 70-75 int q_main(int argc, char **argv) Link Here
70
	int i;
72
	int i;
71
	char *p;
73
	char *p;
72
	APPLET func;
74
	APPLET func;
75
	overlay_t * cur_overlay;
73
76
74
	if (argc == 0)
77
	if (argc == 0)
75
		return 1;
78
		return 1;
Lines 89-94 int q_main(int argc, char **argv) Link Here
89
		COMMON_GETOPTS_CASES(q)
92
		COMMON_GETOPTS_CASES(q)
90
		case 'm': reinitialize_metacache = 1; break;
93
		case 'm': reinitialize_metacache = 1; break;
91
		case 'r': reinitialize = 1; break;
94
		case 'r': reinitialize = 1; break;
95
		case 'l': {
96
			printf("\n%sOverlay(s) :%s\n\n", GREEN, NORM);
97
			cur_overlay=overlay_gentoo;
98
			do {
99
				printf("   Name : %s%-20.20s%s \tlocation : %s%s%s\n", CYAN, cur_overlay->name, NORM, CYAN, cur_overlay->path, NORM);
100
			} while ( (cur_overlay=cur_overlay->next));
101
			fputc('\n', stdout);
102
			return 0;
103
			}
92
		case 'i': {
104
		case 'i': {
93
			char buf[_Q_PATH_MAX];
105
			char buf[_Q_PATH_MAX];
94
			/* always bzero a buffer before using readlink() */
106
			/* always bzero a buffer before using readlink() */
(-)portage-utils-0.1.21/qcache.c (-5 / +5 lines)
Lines 323-331 int traverse_metadata_cache(void (*func) Link Here
323
	char *pathcat, *pathpkg, *pathebld, *pathcache, *ebuild, *category;
323
	char *pathcat, *pathpkg, *pathebld, *pathcache, *ebuild, *category;
324
	struct direct **categories, **packages, **ebuilds;
324
	struct direct **categories, **packages, **ebuilds;
325
325
326
	len = strlen(portdir) + strlen(portcachedir) + 3;
326
	len = strlen(overlay_gentoo->path) + strlen(portcachedir) + 3;
327
	pathcache = (char *) xmalloc(len);
327
	pathcache = (char *) xmalloc(len);
328
	snprintf(pathcache,len,"%s/%s/",portdir,portcachedir);
328
	snprintf(pathcache,len,"%s/%s/",overlay_gentoo->path,portcachedir);
329
329
330
	qcache_numcat = numcat = scandir(pathcache, &categories, file_select, alphasort);
330
	qcache_numcat = numcat = scandir(pathcache, &categories, file_select, alphasort);
331
	if (numcat == (-1))
331
	if (numcat == (-1))
Lines 335-343 int traverse_metadata_cache(void (*func) Link Here
335
		warn("%s is empty!", pathcache);
335
		warn("%s is empty!", pathcache);
336
336
337
	for (i = 0; i < numcat; i++) {
337
	for (i = 0; i < numcat; i++) {
338
		len = strlen(portdir) + strlen(categories[i]->d_name) + 2;
338
		len = strlen(overlay_gentoo->path) + strlen(categories[i]->d_name) + 2;
339
		pathcat = (char *) xmalloc(len);
339
		pathcat = (char *) xmalloc(len);
340
		snprintf(pathcat,len,"%s/%s",portdir,categories[i]->d_name);
340
		snprintf(pathcat,len,"%s/%s",overlay_gentoo->path,categories[i]->d_name);
341
341
342
		current_category = categories[i]->d_name;
342
		current_category = categories[i]->d_name;
343
343
Lines 538-544 void qcache_not(char *path, char *catego Link Here
538
		} while (!isdigit(*temp));
538
		} while (!isdigit(*temp));
539
		*(temp-1) = '\0';
539
		*(temp-1) = '\0';
540
540
541
		printf("%s%s/%s%s%s\n",BOLD,category,BLUE,ebuild,NORM);		
541
		printf("%s%s/%s%s%s\n",BOLD,category,BLUE,ebuild,NORM);
542
	}
542
	}
543
}
543
}
544
544
(-)portage-utils-0.1.21/qcheck.c (-3 / +3 lines)
Lines 74-80 int qcheck_main(int argc, char **argv) Link Here
74
			if (!search_all) {
74
			if (!search_all) {
75
				for (i = optind; i < argc; ++i) {
75
				for (i = optind; i < argc; ++i) {
76
					snprintf(buf, sizeof(buf), "%s/%s", dentry->d_name, 
76
					snprintf(buf, sizeof(buf), "%s/%s", dentry->d_name, 
77
					         de->d_name);
77
						 de->d_name);
78
					if (rematch(argv[i], buf, REG_EXTENDED) == 0)
78
					if (rematch(argv[i], buf, REG_EXTENDED) == 0)
79
						break;
79
						break;
80
					if (rematch(argv[i], de->d_name, REG_EXTENDED) == 0)
80
					if (rematch(argv[i], de->d_name, REG_EXTENDED) == 0)
Lines 85-91 int qcheck_main(int argc, char **argv) Link Here
85
			}
85
			}
86
86
87
			snprintf(buf, sizeof(buf), "%s%s/%s/%s/CONTENTS", portroot, portvdb,
87
			snprintf(buf, sizeof(buf), "%s%s/%s/%s/CONTENTS", portroot, portvdb,
88
			         dentry->d_name, de->d_name);
88
				 dentry->d_name, de->d_name);
89
			if ((fp = fopen(buf, "r")) == NULL)
89
			if ((fp = fopen(buf, "r")) == NULL)
90
				continue;
90
				continue;
91
			strncat(buf, "~", sizeof(buf));
91
			strncat(buf, "~", sizeof(buf));
Lines 154-160 int qcheck_main(int argc, char **argv) Link Here
154
						switch (hash_algo) {
154
						switch (hash_algo) {
155
							case HASH_MD5:  digest_disp = "MD5"; break;
155
							case HASH_MD5:  digest_disp = "MD5"; break;
156
							case HASH_SHA1: digest_disp = "SHA1"; break;
156
							case HASH_SHA1: digest_disp = "SHA1"; break;
157
							default:        digest_disp = "UNK"; break;
157
							default:	digest_disp = "UNK"; break;
158
						}
158
						}
159
						printf(" %s%s-DIGEST%s: %s", RED, digest_disp, NORM, e->name);
159
						printf(" %s%s-DIGEST%s: %s", RED, digest_disp, NORM, e->name);
160
						if (verbose)
160
						if (verbose)
(-)portage-utils-0.1.21/qdepends.c (-7 / +7 lines)
Lines 374-380 int qdepends_main_vdb(const char *depend Link Here
374
			/* see if this cat/pkg is requested */
374
			/* see if this cat/pkg is requested */
375
			for (i = optind; i < argc; ++i) {
375
			for (i = optind; i < argc; ++i) {
376
				snprintf(buf, sizeof(buf), "%s/%s", dentry->d_name, 
376
				snprintf(buf, sizeof(buf), "%s/%s", dentry->d_name, 
377
				         de->d_name);
377
					 de->d_name);
378
				if (rematch(argv[i], buf, REG_EXTENDED) == 0)
378
				if (rematch(argv[i], buf, REG_EXTENDED) == 0)
379
					break;
379
					break;
380
				if (rematch(argv[i], de->d_name, REG_EXTENDED) == 0)
380
				if (rematch(argv[i], de->d_name, REG_EXTENDED) == 0)
Lines 384-390 int qdepends_main_vdb(const char *depend Link Here
384
				continue;
384
				continue;
385
385
386
			snprintf(buf, sizeof(buf), "%s%s/%s/%s/%s", portroot, portvdb,
386
			snprintf(buf, sizeof(buf), "%s%s/%s/%s/%s", portroot, portvdb,
387
			         dentry->d_name, de->d_name, depend_file);
387
				 dentry->d_name, de->d_name, depend_file);
388
388
389
			/* >=portage-2.1_pre3 wont ensure these files always exist. */
389
			/* >=portage-2.1_pre3 wont ensure these files always exist. */
390
			/* So we must verify they exist before attempting to eat_file on them. */
390
			/* So we must verify they exist before attempting to eat_file on them. */
Lines 413-419 int qdepends_main_vdb(const char *depend Link Here
413
			}
413
			}
414
414
415
			snprintf(buf, sizeof(buf), "%s%s/%s/%s/USE", portroot, portvdb,
415
			snprintf(buf, sizeof(buf), "%s%s/%s/%s/USE", portroot, portvdb,
416
			         dentry->d_name, de->d_name);
416
				 dentry->d_name, de->d_name);
417
			if (!eat_file(buf, use, sizeof(use))) {
417
			if (!eat_file(buf, use, sizeof(use))) {
418
				warn("Could not eat_file(%s), you'll prob have incorrect output", buf);
418
				warn("Could not eat_file(%s), you'll prob have incorrect output", buf);
419
			} else {
419
			} else {
Lines 471-477 int qdepends_vdb_deep(const char *depend Link Here
471
				continue;
471
				continue;
472
472
473
			snprintf(buf, sizeof(buf), "%s%s/%s/%s/%s", portroot, portvdb,
473
			snprintf(buf, sizeof(buf), "%s%s/%s/%s/%s", portroot, portvdb,
474
			         dentry->d_name, de->d_name, depend_file);
474
				 dentry->d_name, de->d_name, depend_file);
475
			if (!eat_file(buf, depend, sizeof(depend))) {
475
			if (!eat_file(buf, depend, sizeof(depend))) {
476
				warn("i'm such a fatty, could not eat_file(%s)", buf);
476
				warn("i'm such a fatty, could not eat_file(%s)", buf);
477
				continue;
477
				continue;
Lines 482-488 int qdepends_vdb_deep(const char *depend Link Here
482
			if (dep_tree == NULL) continue;
482
			if (dep_tree == NULL) continue;
483
483
484
			snprintf(buf, sizeof(buf), "%s%s/%s/%s/USE", portroot, portvdb,
484
			snprintf(buf, sizeof(buf), "%s%s/%s/%s/USE", portroot, portvdb,
485
			         dentry->d_name, de->d_name);
485
				 dentry->d_name, de->d_name);
486
			assert(eat_file(buf, use, sizeof(use)) == 1);
486
			assert(eat_file(buf, use, sizeof(use)) == 1);
487
			for (ptr = use; *ptr; ++ptr)
487
			for (ptr = use; *ptr; ++ptr)
488
				if (*ptr == '\n' || *ptr == '\t')
488
				if (*ptr == '\n' || *ptr == '\t')
Lines 553-565 int qdepends_main(int argc, char **argv) Link Here
553
		for (i = 0; depend_files[i]; ++i) {
553
		for (i = 0; depend_files[i]; ++i) {
554
			printf(" %s*%s %s\n", GREEN, NORM, depend_files[i]);
554
			printf(" %s*%s %s\n", GREEN, NORM, depend_files[i]);
555
			ret += (query ? qdepends_vdb_deep(depend_files[i], query)
555
			ret += (query ? qdepends_vdb_deep(depend_files[i], query)
556
			              : qdepends_main_vdb(depend_files[i], argc, argv));
556
				      : qdepends_main_vdb(depend_files[i], argc, argv));
557
		}
557
		}
558
		return ret;
558
		return ret;
559
	}
559
	}
560
560
561
	return (query ? qdepends_vdb_deep(depend_file, query)
561
	return (query ? qdepends_vdb_deep(depend_file, query)
562
	              : qdepends_main_vdb(depend_file, argc, argv));
562
		      : qdepends_main_vdb(depend_file, argc, argv));
563
}
563
}
564
564
565
#else
565
#else
(-)portage-utils-0.1.21/qfile.c (-1 / +1 lines)
Lines 76-82 void qfile(char *path, int argc, char* r Link Here
76
76
77
			// used to cut the number of strcmp() calls
77
			// used to cut the number of strcmp() calls
78
			bn_firstchar = entry_basename[0];
78
			bn_firstchar = entry_basename[0];
79
			
79
80
			for(i = 0; i < argc; i++) {
80
			for(i = 0; i < argc; i++) {
81
				if (base_names[i] == NULL)
81
				if (base_names[i] == NULL)
82
					continue;
82
					continue;
(-)portage-utils-0.1.21/qgrep.c (-4 / +49 lines)
Lines 10-20 Link Here
10
10
11
#ifdef APPLET_qgrep
11
#ifdef APPLET_qgrep
12
12
13
#define QGREP_FLAGS "IiHce" COMMON_FLAGS
13
#define QGREP_FLAGS "IiHo:ce" COMMON_FLAGS
14
static struct option const qgrep_long_opts[] = {
14
static struct option const qgrep_long_opts[] = {
15
	{"invert-match",  no_argument, NULL, 'I'},
15
	{"invert-match",  no_argument, NULL, 'I'},
16
	{"ignore-case",   no_argument, NULL, 'i'},
16
	{"ignore-case",   no_argument, NULL, 'i'},
17
	{"with-filename", no_argument, NULL, 'H'},
17
	{"with-filename", no_argument, NULL, 'H'},
18
	{"overlay",        a_argument, NULL, 'o'},
18
	{"count",         no_argument, NULL, 'c'},
19
	{"count",         no_argument, NULL, 'c'},
19
	{"regexp",        no_argument, NULL, 'e'},
20
	{"regexp",        no_argument, NULL, 'e'},
20
	COMMON_LONG_OPTS
21
	COMMON_LONG_OPTS
Lines 23-28 static const char *qgrep_opts_help[] = { Link Here
23
	"Select non-matching lines",
24
	"Select non-matching lines",
24
	"Ignore case distinctions",
25
	"Ignore case distinctions",
25
	"Print the filename for each match",
26
	"Print the filename for each match",
27
	"Only consider the <arg> overlay",
26
	"Only print a count of matching lines per FILE",
28
	"Only print a count of matching lines per FILE",
27
	"Use PATTERN as a regular expression",
29
	"Use PATTERN as a regular expression",
28
	COMMON_OPTS_HELP
30
	COMMON_OPTS_HELP
Lines 34-40 int qgrep_main(int argc, char **argv) Link Here
34
{
36
{
35
	int i;
37
	int i;
36
	int count = 0;
38
	int count = 0;
37
	char *p;
39
	short myerror = 0, repo = 0;
40
	char overlay_name[64], repo_search[64];
41
	char *p, *str;
38
	char do_count, do_regex;
42
	char do_count, do_regex;
39
	char show_filename;
43
	char show_filename;
40
	FILE *fp;
44
	FILE *fp;
Lines 42-51 int qgrep_main(int argc, char **argv) Link Here
42
	char buf0[BUFSIZ];
46
	char buf0[BUFSIZ];
43
	int reflags = REG_NOSUB;
47
	int reflags = REG_NOSUB;
44
	char invert_match = 0;
48
	char invert_match = 0;
49
	overlay_t *cur_overlay, *overlay_tmp;
45
50
46
	typedef char *(*FUNC) (char *, char *);
51
	typedef char *(*FUNC) (char *, char *);
47
	FUNC strfunc = (FUNC) strstr;
52
	FUNC strfunc = (FUNC) strstr;
48
53
54
	cur_overlay = overlay_gentoo;
55
	overlay_name[0] = 0;
56
	repo_search[0] = 0;
57
49
	DBG("argc=%d argv[0]=%s argv[1]=%s",
58
	DBG("argc=%d argv[0]=%s argv[1]=%s",
50
	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
59
	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
51
60
Lines 58-66 int qgrep_main(int argc, char **argv) Link Here
58
			strfunc = (FUNC) strcasestr;
67
			strfunc = (FUNC) strcasestr;
59
			reflags |= REG_ICASE;
68
			reflags |= REG_ICASE;
60
			break;
69
			break;
70
		case 'H': show_filename = 1; break;
71
		case 'o': 
72
			repo = 1;
73
			strncpy(repo_search, optarg, sizeof(repo_search));
74
			break;
61
		case 'c': do_count = 1; break;
75
		case 'c': do_count = 1; break;
62
		case 'e': do_regex = 1; break;
76
		case 'e': do_regex = 1; break;
63
		case 'H': show_filename = 1; break;
64
		COMMON_GETOPTS_CASES(qgrep)
77
		COMMON_GETOPTS_CASES(qgrep)
65
		}
78
		}
66
	}
79
	}
Lines 73-78 int qgrep_main(int argc, char **argv) Link Here
73
		return 1;
86
		return 1;
74
	while ((fgets(ebuild, sizeof(ebuild), fp)) != NULL) {
87
	while ((fgets(ebuild, sizeof(ebuild), fp)) != NULL) {
75
		FILE *newfp;
88
		FILE *newfp;
89
		if ( ( p = strchr(ebuild, ':')))
90
		{
91
			*p = 0;
92
			str = p+2;			/* separator is '::' */
93
			p = ebuild;
94
			if ( repo && strncmp(repo_search, p, sizeof( repo_search)))
95
				continue;
96
			if ( strcmp(overlay_name, p))
97
			{
98
				for ( overlay_tmp=overlay_gentoo ; overlay_tmp->next ; overlay_tmp=overlay_tmp->next )
99
				{
100
					if ( ! strncmp(overlay_tmp->name, p, sizeof(overlay_tmp->name)))
101
						break;
102
				}
103
				if ( ! strncmp(overlay_tmp->name, p, sizeof(overlay_tmp->name)))
104
				{
105
					cur_overlay = overlay_tmp;
106
					if (chdir(cur_overlay->path) != 0) {
107
						warnp("chdir to PORTDIR '%s' failed", cur_overlay->path);
108
						myerror=1;
109
					}
110
				} else 
111
					myerror=1;
112
				if ( myerror) {
113
					myerror=0;
114
					continue;
115
				}
116
				strncpy(overlay_name, cur_overlay->name, sizeof(overlay_name));
117
			}
118
			strcpy(ebuild, str) ;
119
		}
120
76
		if ((p = strchr(ebuild, '\n')) != NULL)
121
		if ((p = strchr(ebuild, '\n')) != NULL)
77
			*p = 0;
122
			*p = 0;
78
		if ((newfp = fopen(ebuild, "r")) != NULL) {
123
		if ((newfp = fopen(ebuild, "r")) != NULL) {
Lines 102-108 int qgrep_main(int argc, char **argv) Link Here
102
				count++;
147
				count++;
103
				if (do_count) continue;
148
				if (do_count) continue;
104
				if (verbose || show_filename) {
149
				if (verbose || show_filename) {
105
					printf("%s:", ebuild); 
150
					printf("%s::%s:", cur_overlay->name, ebuild); 
106
					if (verbose > 1) printf("%d:", lineno);
151
					if (verbose > 1) printf("%d:", lineno);
107
					printf(" ");
152
					printf(" ");
108
				}
153
				}
(-)portage-utils-0.1.21/qlist.c (-1 / +1 lines)
Lines 251-257 int qlist_main(int argc, char **argv) Link Here
251
			}
251
			}
252
252
253
			snprintf(buf, sizeof(buf), "%s%s/%s/%s/CONTENTS", portroot, portvdb,
253
			snprintf(buf, sizeof(buf), "%s%s/%s/%s/CONTENTS", portroot, portvdb,
254
			         cat[j]->d_name, de[x]->d_name);
254
				 cat[j]->d_name, de[x]->d_name);
255
255
256
			if (verbose > 1)
256
			if (verbose > 1)
257
				printf("%s%s/%s%s%s\n%sCONTENTS%s:\n", BOLD, cat[j]->d_name, BLUE, de[x]->d_name, NORM, DKBLUE, NORM);
257
				printf("%s%s/%s%s%s\n%sCONTENTS%s:\n", BOLD, cat[j]->d_name, BLUE, de[x]->d_name, NORM, DKBLUE, NORM);
(-)portage-utils-0.1.21/qmerge.c (-8 / +8 lines)
Lines 17-24 Link Here
17
#endif
17
#endif
18
18
19
/*
19
/*
20
  --nofiles                        don't verify files in package
20
  --nofiles			don't verify files in package
21
  --noscript                       don't execute pkg_{pre,post}{inst,rm} (if any)
21
  --noscript			don't execute pkg_{pre,post}{inst,rm} (if any)
22
*/
22
*/
23
23
24
// #define BUSYBOX "/bin/busybox"
24
// #define BUSYBOX "/bin/busybox"
Lines 50-56 static const char *qmerge_opts_help[] = Link Here
50
	"Don't prompt before overwriting",
50
	"Don't prompt before overwriting",
51
	"Don't merge dependencies",
51
	"Don't merge dependencies",
52
	"Don't verify MD5 digest of files",
52
	"Don't verify MD5 digest of files",
53
        COMMON_OPTS_HELP
53
	COMMON_OPTS_HELP
54
};
54
};
55
55
56
static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.53 2006/08/21 00:14:57 solar Exp $";
56
static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.53 2006/08/21 00:14:57 solar Exp $";
Lines 700-706 void pkg_merge(int level, depend_atom *a Link Here
700
		line[0] = 0;
700
		line[0] = 0;
701
701
702
		/* portage has code that handes fifo's but it looks unused */
702
		/* portage has code that handes fifo's but it looks unused */
703
    
703
704
		if ((S_ISCHR(st.st_mode)) || \
704
		if ((S_ISCHR(st.st_mode)) || \
705
			(S_ISBLK(st.st_mode))); // block or character device
705
			(S_ISBLK(st.st_mode))); // block or character device
706
		if (S_ISFIFO(st.st_mode));	// FIFO (named pipe)
706
		if (S_ISFIFO(st.st_mode));	// FIFO (named pipe)
Lines 772-778 void pkg_merge(int level, depend_atom *a Link Here
772
			assert(strlen(&buf[1]));
772
			assert(strlen(&buf[1]));
773
			readlink(buf, path, sizeof(path));
773
			readlink(buf, path, sizeof(path));
774
			assert(strlen(path));;
774
			assert(strlen(path));;
775
			
775
776
			snprintf(line, sizeof(line), "sym %s -> %s%s%lu", &buf[1], path, " ", st.st_mtime);
776
			snprintf(line, sizeof(line), "sym %s -> %s%s%lu", &buf[1], path, " ", st.st_mtime);
777
			// snprintf(line, sizeof(line), "sym %s -> %s", &buf[1], path);
777
			// snprintf(line, sizeof(line), "sym %s -> %s", &buf[1], path);
778
			// we better have one byte here to play with
778
			// we better have one byte here to play with
Lines 1125-1136 void print_Pkg(int full, struct pkg_t *p Link Here
1125
			int ret;
1125
			int ret;
1126
			char *icolor = (char *) RED;
1126
			char *icolor = (char *) RED;
1127
			ret = atom_compare_str(buf, p);
1127
			ret = atom_compare_str(buf, p);
1128
			switch(ret) {                                
1128
			switch(ret) {
1129
				case EQUAL: icolor = (char *) RED; break;
1129
				case EQUAL: icolor = (char *) RED; break;
1130
				case NEWER: icolor = (char *) YELLOW; break;                          
1130
				case NEWER: icolor = (char *) YELLOW; break;
1131
				case OLDER: icolor = (char *) BLUE; break;
1131
				case OLDER: icolor = (char *) BLUE; break;
1132
				default: icolor = (char *) NORM; break;
1132
				default: icolor = (char *) NORM; break;
1133
                        }
1133
			}
1134
			printf(" %sInstalled%s:%s %s%s%s\n", DKGREEN, YELLOW, NORM, icolor, p, NORM);
1134
			printf(" %sInstalled%s:%s %s%s%s\n", DKGREEN, YELLOW, NORM, icolor, p, NORM);
1135
		}
1135
		}
1136
	}
1136
	}
(-)portage-utils-0.1.21/qpy.c (-2 / +2 lines)
Lines 75-84 int import_portage_settings(void) Link Here
75
		return 1;
75
		return 1;
76
	}
76
	}
77
	if (!(portage.settings = PyObject_GetAttrString(portage.interp, (char *) "settings"))) {
77
	if (!(portage.settings = PyObject_GetAttrString(portage.interp, (char *) "settings"))) {
78
		Py_DECREF(portage.interp);      
78
		Py_DECREF(portage.interp);
79
		fprintf(stderr, "getting settings failed");
79
		fprintf(stderr, "getting settings failed");
80
		return 1;
80
		return 1;
81
	}   
81
	}
82
	return 0;
82
	return 0;
83
}
83
}
84
84
(-)portage-utils-0.1.21/qsearch.c (-11 / +78 lines)
Lines 9-18 Link Here
9
9
10
#ifdef APPLET_qsearch
10
#ifdef APPLET_qsearch
11
11
12
#define QSEARCH_FLAGS "acsSNH" COMMON_FLAGS
12
#define QSEARCH_FLAGS "aco:psSNH" COMMON_FLAGS
13
static struct option const qsearch_long_opts[] = {
13
static struct option const qsearch_long_opts[] = {
14
	{"all",       no_argument, NULL, 'a'},
14
	{"all",       no_argument, NULL, 'a'},
15
	{"cache",     no_argument, NULL, 'c'},
15
	{"cache",     no_argument, NULL, 'c'},
16
	{"overlay",    a_argument, NULL, 'o'},
17
	{"show-path", no_argument, NULL, 'p'},
16
	{"search",    no_argument, NULL, 's'},
18
	{"search",    no_argument, NULL, 's'},
17
	{"desc",       a_argument, NULL, 'S'},
19
	{"desc",       a_argument, NULL, 'S'},
18
	{"name-only", no_argument, NULL, 'N'},
20
	{"name-only", no_argument, NULL, 'N'},
Lines 22-27 static struct option const qsearch_long_ Link Here
22
static const char *qsearch_opts_help[] = {
24
static const char *qsearch_opts_help[] = {
23
	"List the descriptions of every package in the cache",
25
	"List the descriptions of every package in the cache",
24
	"Use the portage cache",
26
	"Use the portage cache",
27
	"Search only in the <arg> overlay",
28
	"Show the path to the ebuild",
25
	"Regex search package basenames",
29
	"Regex search package basenames",
26
	"Regex search package descriptions",
30
	"Regex search package descriptions",
27
	"Only show package name",
31
	"Only show package name",
Lines 40-52 int qsearch_main(int argc, char **argv) Link Here
40
	char last[126] = "";
44
	char last[126] = "";
41
	char dp[126] = "";
45
	char dp[126] = "";
42
	char bp[126] = "";
46
	char bp[126] = "";
43
	char *p, *q, *str;
47
	short repo = 0;
48
	char repo_search[64];
49
	char *p, *q, *str, overlay_name[64];
44
	char *search_me = NULL;
50
	char *search_me = NULL;
45
	char show_homepage = 0, show_name_only = 0;
51
	char show_homepage = 0, show_name_only = 0, show_path_to_ebuild = 0;
46
	char search_desc = 0, search_all = 0, search_name = 1, search_cache = CACHE_EBUILD;
52
	char search_desc = 0, search_all = 0, search_name = 1, search_cache = CACHE_EBUILD;
47
	const char *search_vars[] = { "DESCRIPTION=", "HOMEPAGE=" };
53
	const char *search_vars[] = { "DESCRIPTION=", "HOMEPAGE=" };
48
	size_t search_len;
54
	size_t search_len;
49
	int i, idx=0;
55
	overlay_t *cur_overlay, *overlay_tmp;
56
	int i, idx=0, myerror=0;
57
58
	cur_overlay = overlay_gentoo;
59
	overlay_name[0] = 0 ;
60
	repo_search[0] = 0;
50
61
51
	DBG("argc=%d argv[0]=%s argv[1]=%s",
62
	DBG("argc=%d argv[0]=%s argv[1]=%s",
52
	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
63
	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
Lines 56-61 int qsearch_main(int argc, char **argv) Link Here
56
		COMMON_GETOPTS_CASES(qsearch)
67
		COMMON_GETOPTS_CASES(qsearch)
57
		case 'a': search_all = 1; break;
68
		case 'a': search_all = 1; break;
58
		case 'c': search_cache = CACHE_METADATA; break;
69
		case 'c': search_cache = CACHE_METADATA; break;
70
		case 'o': repo = 1; strncpy(repo_search, optarg, sizeof(repo_search)); break;
71
		case 'p': show_path_to_ebuild = 1; break;
59
		case 's': search_desc = 0; search_name = 1; break;
72
		case 's': search_desc = 0; search_name = 1; break;
60
		case 'S': search_desc = 1; search_name = 0; break;
73
		case 'S': search_desc = 1; search_name = 0; break;
61
		case 'N': show_name_only = 1; break;
74
		case 'N': show_name_only = 1; break;
Lines 93-103 int qsearch_main(int argc, char **argv) Link Here
93
			if ((pcache = cache_read_file(ebuild)) != NULL) {
106
			if ((pcache = cache_read_file(ebuild)) != NULL) {
94
				if ((strcmp(pcache->atom->PN, last)) != 0) {
107
				if ((strcmp(pcache->atom->PN, last)) != 0) {
95
					strncpy(last, pcache->atom->PN, sizeof(last));
108
					strncpy(last, pcache->atom->PN, sizeof(last));
96
					if ((rematch(search_me, (search_desc ? pcache->DESCRIPTION : ebuild), REG_EXTENDED | REG_ICASE)) == 0)
109
					if ((rematch(search_me, (search_desc ? pcache->DESCRIPTION : ebuild), REG_EXTENDED | REG_ICASE)) == 0) {
97
						printf("%s%s/%s%s%s %s\n", BOLD, pcache->atom->CATEGORY, BLUE,
110
						if ( show_path_to_ebuild) {
98
						       pcache->atom->PN, NORM,
111
							printf("%s%s/%s%s%s::%s\t %s%s/%s/\n",	
99
						       (show_name_only ? "" :
112
							BOLD, pcache->atom->CATEGORY,
100
						        (show_homepage ? pcache->HOMEPAGE : pcache->DESCRIPTION)));
113
							BLUE, pcache->atom->PN,
114
							YELLOW,cur_overlay->name, NORM,
115
							cur_overlay->path, dirname(ebuild));
116
						} else {
117
							printf("%s%s/%s%s%s::%s %s%s\n",
118
							BOLD, pcache->atom->CATEGORY,
119
							BLUE, pcache->atom->PN,
120
							YELLOW,cur_overlay->name, NORM,
121
							(show_name_only ? "" : 
122
							(show_homepage ? pcache->HOMEPAGE : pcache->DESCRIPTION)));
123
						}
124
					}
101
				}
125
				}
102
				cache_free(pcache);
126
				cache_free(pcache);
103
			} else {
127
			} else {
Lines 110-115 int qsearch_main(int argc, char **argv) Link Here
110
134
111
		case CACHE_EBUILD: {
135
		case CACHE_EBUILD: {
112
			FILE *ebuildfp;
136
			FILE *ebuildfp;
137
			if ( ( p = strchr(ebuild, ':')))
138
			{
139
				*p = 0;
140
				str = p+2;			/* separator is '::' */
141
				p = ebuild;
142
				if ( repo && strncmp( repo_search, p, sizeof(repo_search)))
143
					continue;
144
				if ( strcmp(overlay_name, p))
145
				{
146
					for ( overlay_tmp=overlay_gentoo ; overlay_tmp->next ; overlay_tmp=overlay_tmp->next )
147
					{
148
						if ( ! strncmp(overlay_tmp->name, p, sizeof(overlay_tmp->name)))
149
							break;
150
					}
151
					if ( ! strncmp(overlay_tmp->name, p, sizeof(overlay_tmp->name)))
152
					{
153
						cur_overlay = overlay_tmp;
154
						if (chdir(cur_overlay->path) != 0) {
155
							warnp("chdir to PORTDIR '%s' failed", cur_overlay->path);
156
							myerror=1;
157
						}
158
					} else 
159
						myerror=1;
160
					if ( myerror) {
161
						if (!reinitialize)
162
							warnfp("(cache update pending) %s", ebuild);
163
						reinitialize = 1;
164
						break;
165
					}
166
					strncpy(overlay_name, cur_overlay->name, sizeof(overlay_name));
167
				}
168
				strcpy(ebuild, str) ;		/* separator is '::' */
169
			}
170
113
			str = xstrdup(ebuild);
171
			str = xstrdup(ebuild);
114
			p = (char *) dirname(str);
172
			p = (char *) dirname(str);
115
173
Lines 134-143 int qsearch_main(int argc, char **argv) Link Here
134
							// doing operations with them.
192
							// doing operations with them.
135
							strncpy(dp, p, sizeof(dp));
193
							strncpy(dp, p, sizeof(dp));
136
							strncpy(bp, p, sizeof(bp));
194
							strncpy(bp, p, sizeof(bp));
137
							printf("%s%s/%s%s%s %s\n", 
195
							if ( show_path_to_ebuild) {
138
								BOLD, dirname(dp), BLUE, basename(bp), NORM,
196
								printf("%s%s/%s%s%s::%s\t %s%s/%s/\n",
197
								BOLD, dirname(dp), BLUE, basename(bp),
198
								YELLOW,cur_overlay->name, NORM,
199
								cur_overlay->path, dirname(ebuild));
200
							} else {
201
								printf("%s%s/%s%s%s::%s %s%s\n",
202
								BOLD, dirname(dp), BLUE, basename(bp),
203
								YELLOW,cur_overlay->name, NORM,
139
								(show_name_only ? "" : q));
204
								(show_name_only ? "" : q));
205
							}
140
							break;
206
							break;
207
141
						}
208
						}
142
					}
209
					}
143
					fclose(ebuildfp);
210
					fclose(ebuildfp);
(-)portage-utils-0.1.21/qsize.c (-2 / +2 lines)
Lines 93-99 int qsize_main(int argc, char **argv) Link Here
93
			if (!search_all) {
93
			if (!search_all) {
94
				for (i = optind; i < argc; ++i) {
94
				for (i = optind; i < argc; ++i) {
95
					snprintf(buf, sizeof(buf), "%s/%s", dentry->d_name, 
95
					snprintf(buf, sizeof(buf), "%s/%s", dentry->d_name, 
96
					         de->d_name);
96
						 de->d_name);
97
					if (rematch(argv[i], buf, REG_EXTENDED) == 0)
97
					if (rematch(argv[i], buf, REG_EXTENDED) == 0)
98
						break;
98
						break;
99
					if (rematch(argv[i], de->d_name, REG_EXTENDED) == 0)
99
					if (rematch(argv[i], de->d_name, REG_EXTENDED) == 0)
Lines 104-110 int qsize_main(int argc, char **argv) Link Here
104
			}
104
			}
105
105
106
			snprintf(buf, sizeof(buf), "%s%s/%s/%s/CONTENTS", portroot, portvdb,
106
			snprintf(buf, sizeof(buf), "%s%s/%s/%s/CONTENTS", portroot, portvdb,
107
			         dentry->d_name, de->d_name);
107
				 dentry->d_name, de->d_name);
108
			if ((fp = fopen(buf, "r")) == NULL)
108
			if ((fp = fopen(buf, "r")) == NULL)
109
				continue;
109
				continue;
110
110
(-)portage-utils-0.1.21/quse.c (-86 / +176 lines)
Lines 14-23 Link Here
14
 quse -Ke --  nls
14
 quse -Ke --  nls
15
*/
15
*/
16
16
17
#define QUSE_FLAGS "eavKLDF:N" COMMON_FLAGS
17
#define QUSE_FLAGS "eao:vKLDF:N" COMMON_FLAGS
18
static struct option const quse_long_opts[] = {
18
static struct option const quse_long_opts[] = {
19
	{"exact",     no_argument, NULL, 'e'},
19
	{"exact",     no_argument, NULL, 'e'},
20
	{"all",       no_argument, NULL, 'a'},
20
	{"all",       no_argument, NULL, 'a'},
21
	{"overlay",    a_argument, NULL, 'o'},
21
	{"keywords",  no_argument, NULL, 'K'},
22
	{"keywords",  no_argument, NULL, 'K'},
22
	{"license",   no_argument, NULL, 'L'},
23
	{"license",   no_argument, NULL, 'L'},
23
	{"describe",  no_argument, NULL, 'D'},
24
	{"describe",  no_argument, NULL, 'D'},
Lines 28-33 static struct option const quse_long_opt Link Here
28
static const char *quse_opts_help[] = {
29
static const char *quse_opts_help[] = {
29
	"Show exact non regexp matching using strcmp",
30
	"Show exact non regexp matching using strcmp",
30
	"Show annoying things in IUSE",
31
	"Show annoying things in IUSE",
32
	"Only consider the <arg> overlay",
31
	"Use the KEYWORDS vs IUSE",
33
	"Use the KEYWORDS vs IUSE",
32
	"Use the LICENSE vs IUSE",
34
	"Use the LICENSE vs IUSE",
33
	"Describe the USE flag",
35
	"Describe the USE flag",
Lines 38-44 static const char *quse_opts_help[] = { Link Here
38
static const char quse_rcsid[] = "$Id: quse.c,v 1.52 2006/06/10 14:01:21 vapier Exp $";
40
static const char quse_rcsid[] = "$Id: quse.c,v 1.52 2006/06/10 14:01:21 vapier Exp $";
39
#define quse_usage(ret) usage(ret, QUSE_FLAGS, quse_long_opts, quse_opts_help, lookup_applet_idx("quse"))
41
#define quse_usage(ret) usage(ret, QUSE_FLAGS, quse_long_opts, quse_opts_help, lookup_applet_idx("quse"))
40
42
41
int quse_describe_flag(int ind, int argc, char **argv);
43
int quse_describe_flag(int ind, short repo, char repo_search[], int argc, char **argv);
42
44
43
char quse_name_only = 0;
45
char quse_name_only = 0;
44
46
Lines 80-86 static void print_highlighted_use_flags( Link Here
80
	}
82
	}
81
}
83
}
82
84
83
int quse_describe_flag(int ind, int argc, char **argv)
85
int quse_describe_flag(int ind, short repo, char repo_search[], int argc, char **argv)
84
{
86
{
85
#define NUM_SEARCH_FILES ARR_SIZE(search_files)
87
#define NUM_SEARCH_FILES ARR_SIZE(search_files)
86
	char buf[BUFSIZE], *p;
88
	char buf[BUFSIZE], *p;
Lines 90-210 int quse_describe_flag(int ind, int argc Link Here
90
	FILE *fp[NUM_SEARCH_FILES];
92
	FILE *fp[NUM_SEARCH_FILES];
91
	DIR *d;
93
	DIR *d;
92
	struct dirent *de;
94
	struct dirent *de;
95
	overlay_t *cur_overlay;
93
96
94
	for (i = 0; i < NUM_SEARCH_FILES; ++i) {
97
	cur_overlay=overlay_gentoo;
95
		snprintf(buf, sizeof(buf), "%s/profiles/%s", portdir, search_files[i]);
96
		if ((fp[i] = fopen(buf, "r")) == NULL)
97
			warnp("skipping %s", search_files[i]);
98
	}
99
98
100
	for (i = ind; i < argc; i++) {
99
	do {
101
		s = strlen(argv[i]);
100
		if ( repo && strncmp(repo_search, cur_overlay->name, sizeof( repo_search)))
101
			continue;
102
		for (i = 0; i < NUM_SEARCH_FILES; ++i) {
103
			snprintf(buf, sizeof(buf), "%s/profiles/%s", cur_overlay->path, search_files[i]);
104
			if ((fp[i] = fopen(buf, "r")) == NULL)
105
				if ( verbose )
106
					warnp("skipping %s for the %s overlay", search_files[i], cur_overlay->name);
107
		}
102
108
103
		for (f = 0; f < NUM_SEARCH_FILES; ++f) {
109
		for (i = ind; i < argc; i++) {
104
			if (fp[f] == NULL)
110
			s = strlen(argv[i]);
105
				continue;
106
111
107
			while (fgets(buf, sizeof(buf), fp[f]) != NULL) {
112
			for (f = 0; f < NUM_SEARCH_FILES; ++f) {
108
				if (buf[0] == '#' || buf[0] == '\n')
113
				if (fp[f] == NULL)
109
					continue;
114
					continue;
110
115
111
				if ((p = strrchr(buf, '\n')) != NULL)
116
				while (fgets(buf, sizeof(buf), fp[f]) != NULL) {
112
					*p = '\0';
117
					if (buf[0] == '#' || buf[0] == '\n')
118
						continue;
113
119
114
				switch (f) {
120
					if ((p = strrchr(buf, '\n')) != NULL)
115
					case 0: /* Global use.desc */
121
						*p = '\0';
116
						if (!strncmp(buf, argv[i], s))
117
							if (buf[s] == ' ' && buf[s+1] == '-') {
118
								printf(" %sglobal%s:%s%s%s: %s\n", BOLD, NORM, BLUE, argv[i], NORM, buf+s+3);
119
								goto skip_file;
120
							}
121
						break;
122
122
123
					case 1: /* Local use.local.desc */
123
					switch (f) {
124
						if ((p = strchr(buf, ':')) == NULL)
124
						case 0: /* Global use.desc */
125
							if (!strncmp(buf, argv[i], s))
126
								if (buf[s] == ' ' && buf[s+1] == '-') {
127
									if ( cur_overlay == overlay_gentoo )
128
										printf(" %sglobal%s:%s%s%s: %s\n", BOLD, NORM, BLUE, argv[i], NORM, buf+s+3);
129
									else 
130
										printf(" (%s) %sglobal%s:%s%s%s: %s\n", cur_overlay->name, BOLD, NORM, BLUE, argv[i], NORM, buf+s+3);
131
									goto skip_file;
132
								}
125
							break;
133
							break;
126
						++p;
127
						if (!strncmp(p, argv[i], s)) {
128
							if (p[s] == ' ' && p[s+1] == '-') {
129
								*p = '\0';
130
								printf(" %slocal%s:%s%s%s:%s%s%s %s\n", BOLD, NORM, BLUE, argv[i], NORM, BOLD, buf, NORM, p+s+3);
131
							}
132
						}
133
						break;
134
134
135
					case 2: /* Architectures arch.list */
135
						case 1: /* Local use.local.desc */
136
						if (!strcmp(buf, argv[i])) {
136
							if ((p = strchr(buf, ':')) == NULL)
137
							printf(" %sarch%s:%s%s%s: %s architecture\n", BOLD, NORM, BLUE, argv[i], NORM, argv[i]);
137
								break;
138
							goto skip_file;
138
							++p;
139
						}
139
							if (!strncmp(p, argv[i], s)) {
140
						break;
140
								if (p[s] == ' ' && p[s+1] == '-') {
141
									*p = '\0';
142
									if ( cur_overlay == overlay_gentoo )
143
										printf(" %slocal%s:%s%s%s:%s%s%s %s\n", BOLD, NORM, BLUE, argv[i], NORM, BOLD, buf, NORM, p+s+3);
144
									else 
145
										printf(" (%s) %slocal%s:%s%s%s:%s%s%s %s\n", cur_overlay->name, BOLD, NORM, BLUE, argv[i], NORM, BOLD, buf, NORM, p+s+3);
146
								}
147
							}
148
							break;
141
149
142
					case 3: /* Languages lang.desc */
150
						case 2: /* Architectures arch.list */
143
						if (!strncmp(buf, argv[i], s))
151
							if (!strcmp(buf, argv[i])) {
144
							if (buf[s] == ' ' && buf[s+1] == '-') {
152
								if ( cur_overlay == overlay_gentoo )
145
								printf(" %slang%s:%s%s%s: %s lingua\n", BOLD, NORM, BLUE, argv[i], NORM, buf+s+3);
153
									printf(" %sarch%s:%s%s%s: %s architecture\n", BOLD, NORM, BLUE, argv[i], NORM, argv[i]);
154
								else 
155
									printf(" (%s) %sarch%s:%s%s%s: %s architecture\n", cur_overlay->name, BOLD, NORM, BLUE, argv[i], NORM, argv[i]);
146
								goto skip_file;
156
								goto skip_file;
147
							}
157
							}
148
						break;
158
							break;
159
160
						case 3: /* Languages lang.desc */
161
							if (!strncmp(buf, argv[i], s))
162
								if (buf[s] == ' ' && buf[s+1] == '-') {
163
									if ( cur_overlay == overlay_gentoo )
164
										printf(" %slang%s:%s%s%s: %s lingua\n", BOLD, NORM, BLUE, argv[i], NORM, buf+s+3);
165
									else 
166
										printf(" (%s) %slang%s:%s%s%s: %s lingua\n", cur_overlay->name, BOLD, NORM, BLUE, argv[i], NORM, buf+s+3);
167
									goto skip_file;
168
								}
169
							break;
170
					}
149
				}
171
				}
150
			}
151
172
152
skip_file:
173
skip_file:
153
			rewind(fp[f]);
174
				rewind(fp[f]);
175
			}
176
177
			if ( i == (argc - 1) )
178
				for (f=0; f<NUM_SEARCH_FILES; ++f) 
179
					if ( fp[f] ) {
180
						fclose(fp[f]);
181
						fp[f] = NULL;
182
					}
154
		}
183
		}
155
	}
156
184
157
	for (f=0; f<NUM_SEARCH_FILES; ++f)
185
	} while ( (cur_overlay=cur_overlay->next));
158
		fclose(fp[f]);
159
186
160
	/* now scan the desc dir */
187
	/* now scan the desc dir */
161
	snprintf(buf, sizeof(buf), "%s/profiles/desc/", portdir);
188
	cur_overlay=overlay_gentoo;
162
	d = opendir(buf);
189
	do {
163
	while ((de = readdir(d)) != NULL) {
190
		if ( repo && strncmp(repo_search, cur_overlay->name, sizeof( repo_search)))
164
		if (strcmp(de->d_name+strlen(de->d_name)-5, ".desc"))
165
			continue;
191
			continue;
166
192
		snprintf(buf, sizeof(buf), "%s/profiles/desc/", cur_overlay->path);
167
		snprintf(buf, sizeof(buf), "%s/profiles/desc/%s", portdir, de->d_name);
193
		if ( ! (d = opendir(buf))) {
168
		if ((fp[0]=fopen(buf, "r")) == NULL) {
194
			if ( verbose ) 
169
			warn("Could not open '%s' for reading; skipping", de->d_name);
195
				warn("Could not open %s -> skipping", buf); 
170
			continue;
196
			continue;
171
		}
197
		}
198
		while ((de = readdir(d)) != NULL) {
199
			if (strcmp(de->d_name+strlen(de->d_name)-5, ".desc"))
200
				continue;
172
201
173
		while (fgets(buf, sizeof(buf), fp[0]) != NULL) {
202
			snprintf(buf, sizeof(buf), "%s/profiles/desc/%s", cur_overlay->path, de->d_name);
174
			if (buf[0] == '#' || buf[0] == '\n')
203
			if ((fp[0]=fopen(buf, "r")) == NULL) {
204
				warn("Could not open '%s' for reading; skipping", de->d_name);
175
				continue;
205
				continue;
206
			}
207
208
			while (fgets(buf, sizeof(buf), fp[0]) != NULL) {
209
				if (buf[0] == '#' || buf[0] == '\n')
210
					continue;
176
211
177
			if ((p = strrchr(buf, '\n')) != NULL)
212
				if ((p = strrchr(buf, '\n')) != NULL)
178
				*p = '\0';
213
					*p = '\0';
179
214
180
			if ((p = strchr(buf, '-')) == NULL) {
215
				if ((p = strchr(buf, '-')) == NULL) {
181
invalid_line:
216
invalid_line:
182
				warn("Invalid line in '%s': %s", de->d_name, buf);
217
					warn("Invalid line in '%s': %s", de->d_name, buf);
183
				continue;
218
					continue;
184
			}
219
				}
185
			while (p[-1] != ' ' && p[1] != ' ') {
220
				while (p[-1] != ' ' && p[1] != ' ') {
186
				/* maybe the flag has a '-' in it ... */
221
					/* maybe the flag has a '-' in it ... */
187
				if ((p = strchr(p+1, '-')) == NULL)
222
					if ((p = strchr(p+1, '-')) == NULL)
188
					goto invalid_line;
223
						goto invalid_line;
189
			}
224
				}
190
			p[-1] = '\0';
225
				p[-1] = '\0';
191
			p += 2;
226
				p += 2;
192
227
193
			for (i = ind; i < argc; i++)
228
				for (i = ind; i < argc; i++)
194
				if (!strcmp(argv[i], buf))
229
					if (!strcmp(argv[i], buf)) {
195
					printf(" %s%s%s:%s%s%s: %s\n", BOLD, de->d_name, NORM, BLUE, argv[i], NORM, p);
230
						if ( cur_overlay == overlay_gentoo )
196
		}
231
							printf(" %s%s%s:%s%s%s: %s\n", BOLD, de->d_name, NORM, BLUE, argv[i], NORM, p);
197
		close(f);
232
						else
198
	}
233
							printf(" (%s) %s%s%s:%s%s%s: %s\n", cur_overlay->name, BOLD, de->d_name, NORM, BLUE, argv[i], NORM, p);
199
	closedir(d);
234
					}
200
235
236
			}
237
			fclose(fp[0]);
238
		}
239
		closedir(d);
240
	} while ( (cur_overlay=cur_overlay->next));
201
	return 0;
241
	return 0;
202
}
242
}
203
243
204
int quse_main(int argc, char **argv)
244
int quse_main(int argc, char **argv)
205
{
245
{
206
	FILE *fp;
246
	FILE *fp;
207
	char *p;
247
	char *p, *str;
248
	short myerror = 0, repo = 0;
249
	char repo_search[64];
250
	char overlay_name[64];
208
251
209
	char buf0[_Q_PATH_MAX];
252
	char buf0[_Q_PATH_MAX];
210
	char buf1[_Q_PATH_MAX];
253
	char buf1[_Q_PATH_MAX];
Lines 217-222 int quse_main(int argc, char **argv) Link Here
217
	short quse_all = 0;
260
	short quse_all = 0;
218
	int regexp_matching = 1, i, idx = 0;
261
	int regexp_matching = 1, i, idx = 0;
219
	size_t search_len;
262
	size_t search_len;
263
	overlay_t *cur_overlay, *overlay_tmp;
264
265
	cur_overlay = overlay_gentoo;
266
	overlay_name[0] = 0;
267
	repo_search[0] = 0;
220
268
221
	DBG("argc=%d argv[0]=%s argv[1]=%s",
269
	DBG("argc=%d argv[0]=%s argv[1]=%s",
222
	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
270
	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
Lines 225-230 int quse_main(int argc, char **argv) Link Here
225
		switch (i) {
273
		switch (i) {
226
		case 'e': regexp_matching = 0; break;
274
		case 'e': regexp_matching = 0; break;
227
		case 'a': quse_all = 1; break;
275
		case 'a': quse_all = 1; break;
276
		case 'o': 
277
			repo = 1;
278
			strncpy(repo_search, optarg, sizeof(repo_search));
279
			break;
228
		case 'K': idx = 1; break;
280
		case 'K': idx = 1; break;
229
		case 'L': idx = 2; break;
281
		case 'L': idx = 2; break;
230
		case 'D': idx = -1; break;
282
		case 'D': idx = -1; break;
Lines 233-243 int quse_main(int argc, char **argv) Link Here
233
		COMMON_GETOPTS_CASES(quse)
285
		COMMON_GETOPTS_CASES(quse)
234
		}
286
		}
235
	}
287
	}
236
	if (argc == optind && !quse_all && idx >= 0)
288
	if (argc == optind && !quse_all && idx >= 0) {
289
		if ( idx == 3 )
290
			free(search_vars+idx);
237
		quse_usage(EXIT_FAILURE);
291
		quse_usage(EXIT_FAILURE);
292
	}
238
293
239
	if (idx == -1)
294
	if (idx == -1)
240
		return quse_describe_flag(optind, argc, argv);
295
		return quse_describe_flag(optind, repo, repo_search, argc, argv);
241
296
242
	if (quse_all) optind = argc;
297
	if (quse_all) optind = argc;
243
	initialize_ebuild_flat();	/* sets our pwd to $PORTDIR */
298
	initialize_ebuild_flat();	/* sets our pwd to $PORTDIR */
Lines 249-254 int quse_main(int argc, char **argv) Link Here
249
		return 1;
304
		return 1;
250
	while ((fgets(ebuild, sizeof(ebuild), fp)) != NULL) {
305
	while ((fgets(ebuild, sizeof(ebuild), fp)) != NULL) {
251
		FILE *newfp;
306
		FILE *newfp;
307
		if ( ( p = strchr(ebuild, ':')))
308
		{
309
			*p = 0;
310
			str = p+2;			/* separator is '::' */
311
			p = ebuild;
312
			if ( repo && strncmp( repo_search, p, sizeof(repo_search)))
313
				continue;
314
			if ( strcmp(overlay_name, p))
315
			{
316
				for ( overlay_tmp=overlay_gentoo ; overlay_tmp->next ; overlay_tmp=overlay_tmp->next )
317
				{
318
					if ( ! strncmp(overlay_tmp->name, p, sizeof(overlay_tmp->name)))
319
						break;
320
				}
321
				if ( ! strncmp(overlay_tmp->name, p, sizeof(overlay_tmp->name)))
322
				{
323
					cur_overlay = overlay_tmp;
324
					if (chdir(cur_overlay->path) != 0) {
325
						warnp("chdir to PORTDIR '%s' failed", cur_overlay->path);
326
						myerror=1;
327
					}
328
				} else 
329
					myerror=1;
330
				if ( myerror) {
331
					if (!reinitialize)
332
						warnf("(cache update pending) %s : %s", ebuild, strerror(errno));
333
					reinitialize = 1;
334
					myerror=0;
335
					continue;
336
				}
337
				strncpy(overlay_name, cur_overlay->name, sizeof(overlay_name));
338
			}
339
			strcpy(ebuild, str) ;
340
		}
341
252
		if ((p = strchr(ebuild, '\n')) != NULL)
342
		if ((p = strchr(ebuild, '\n')) != NULL)
253
			*p = 0;
343
			*p = 0;
254
		if ((newfp = fopen(ebuild, "r")) != NULL) {
344
		if ((newfp = fopen(ebuild, "r")) != NULL) {
Lines 374-380 int quse_main(int argc, char **argv) Link Here
374
					if (verbose > 3)
464
					if (verbose > 3)
375
						printf("%s %s %s ", *user ? user : "MISSING", *revision ? revision : "MISSING", *date ? date : "MISSING");
465
						printf("%s %s %s ", *user ? user : "MISSING", *revision ? revision : "MISSING", *date ? date : "MISSING");
376
466
377
					printf("%s%s%s ", CYAN, ebuild, NORM);
467
					printf("%s%s::%s%s ", CYAN, cur_overlay->name, ebuild, NORM);
378
					print_highlighted_use_flags(&buf0[search_len+1], optind, argc, argv);
468
					print_highlighted_use_flags(&buf0[search_len+1], optind, argc, argv);
379
					puts(NORM);
469
					puts(NORM);
380
					if (verbose > 1) {
470
					if (verbose > 1) {
Lines 382-388 int quse_main(int argc, char **argv) Link Here
382
						int ARGC = 0;
472
						int ARGC = 0;
383
						makeargv(&buf0[search_len+1], &ARGC, &ARGV);
473
						makeargv(&buf0[search_len+1], &ARGC, &ARGV);
384
						if (ARGC > 0) {
474
						if (ARGC > 0) {
385
							quse_describe_flag(1, ARGC, ARGV);
475
							quse_describe_flag(1, repo, repo_search, ARGC, ARGV);
386
							for (i = 0; i < ARGC; i++)
476
							for (i = 0; i < ARGC; i++)
387
								free(ARGV[i]);
477
								free(ARGV[i]);
388
							free(ARGV);
478
							free(ARGV);
(-)portage-utils-0.1.21/qxpak.c (-6 / +6 lines)
Lines 335-348 void xpak_create(const char *file, int a Link Here
335
	rewind(fdata);
335
	rewind(fdata);
336
336
337
	/* "XPAKPACK" + (index_len) + (data_len) + index + data + "XPAKSTOP" */
337
	/* "XPAKPACK" + (index_len) + (data_len) + index + data + "XPAKSTOP" */
338
	fwrite(XPAK_START_MSG, 1, XPAK_START_MSG_LEN, fout); /* "XPAKPACK" */
338
	fwrite(XPAK_START_MSG, 1, XPAK_START_MSG_LEN, fout);	/* "XPAKPACK" */
339
	p = tbz2_encode_int(index_len);
339
	p = tbz2_encode_int(index_len);
340
	fwrite(p, 1, 4, fout);                               /* (index_len) */
340
	fwrite(p, 1, 4, fout);					/* (index_len) */
341
	p = tbz2_encode_int(data_len);
341
	p = tbz2_encode_int(data_len);
342
	fwrite(p, 1, 4, fout);                               /* (data_len) */
342
	fwrite(p, 1, 4, fout);			       		/* (data_len) */
343
	_tbz2_copy_file(findex, fout);                       /* index */
343
	_tbz2_copy_file(findex, fout);		       		/* index */
344
	_tbz2_copy_file(fdata, fout);                        /* data */
344
	_tbz2_copy_file(fdata, fout);				/* data */
345
	fwrite(XPAK_END_MSG, 1, XPAK_END_MSG_LEN, fout);     /* "XPAKSTOP" */
345
	fwrite(XPAK_END_MSG, 1, XPAK_END_MSG_LEN, fout);	/* "XPAKSTOP" */
346
346
347
	strcpy(path, file); strcat(path, ".index"); unlink(path);
347
	strcpy(path, file); strcat(path, ".index"); unlink(path);
348
	strcpy(path, file); strcat(path, ".dat");   unlink(path);
348
	strcpy(path, file); strcat(path, ".dat");   unlink(path);

Return to bug 154405