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-20070115.new/applet-list (-4 lines)
Lines 1-15 Link Here
1
qatom
1
qatom
2
qcache
3
qcheck
2
qcheck
4
qdepends
3
qdepends
5
qfile
4
qfile
6
qglsa
7
qgrep
5
qgrep
8
qlist
6
qlist
9
qlop
7
qlop
10
qmerge
11
qpkg
8
qpkg
12
qpy
13
qsearch
9
qsearch
14
qsize
10
qsize
15
qtbz2
11
qtbz2
(-)portage-utils-20070115.new/applets.h (-7 / +7 lines)
Lines 29-37 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) /* disable */
33
DECLARE_APPLET(qcache)
33
DECLARE_APPLET(qcache) /* disable */
34
DECLARE_APPLET(qpy)
34
DECLARE_APPLET(qpy) /* disable */
35
DECLARE_APPLET(qglsa) /* disable */
35
DECLARE_APPLET(qglsa) /* disable */
36
#undef DECLARE_APPLET
36
#undef DECLARE_APPLET
37
37
Lines 49-70 struct applet_t { Link Here
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"},
53
	{"qcheck",    qcheck_main,    "<pkgname>",       "verify mtimes/digests"},
52
	{"qcheck",    qcheck_main,    "<pkgname>",       "verify mtimes/digests"},
54
	{"qdepends",  qdepends_main,  "<pkgname>",       "show dependency info"},
53
	{"qdepends",  qdepends_main,  "<pkgname>",       "show dependency info"},
55
	{"qfile",     qfile_main,     "<filename>",      "list all pkgs owning files"},
54
	{"qfile",     qfile_main,     "<filename>",      "list all pkgs owning files"},
56
	{"qglsa",     qglsa_main,     "<action> <list>", "check GLSAs against system"},
57
	{"qgrep",     qgrep_main,     "<misc args>",     "grep in ebuilds"},
55
	{"qgrep",     qgrep_main,     "<misc args>",     "grep in ebuilds"},
58
	{"qlist",     qlist_main,     "<pkgname>",       "list files owned by pkgname"},
56
	{"qlist",     qlist_main,     "<pkgname>",       "list files owned by pkgname"},
59
	{"qlop",      qlop_main,      "<pkgname>",       "emerge log analyzer"},
57
	{"qlop",      qlop_main,      "<pkgname>",       "emerge log analyzer"},
60
	{"qmerge",    qmerge_main,    "<pkgnames>",      "fetch and merge binary package"},
61
	{"qpkg",      qpkg_main,      "<misc args>",     "manipulate Gentoo binpkgs"},
58
	{"qpkg",      qpkg_main,      "<misc args>",     "manipulate Gentoo binpkgs"},
62
	{"qpy",      qpy_main,      "<misc args>",     "python interface"},
63
	{"qsearch",   qsearch_main,   "<regex>",         "search pkgname/desc"},
59
	{"qsearch",   qsearch_main,   "<regex>",         "search pkgname/desc"},
64
	{"qsize",     qsize_main,     "<pkgname>",       "calculate size usage"},
60
	{"qsize",     qsize_main,     "<pkgname>",       "calculate size usage"},
65
	{"qtbz2",     qtbz2_main,     "<misc args>",     "manipulate tbz2 packages"},
61
	{"qtbz2",     qtbz2_main,     "<misc args>",     "manipulate tbz2 packages"},
66
	{"quse",      quse_main,      "<useflag>",       "find pkgs using useflags"},
62
	{"quse",      quse_main,      "<useflag>",       "find pkgs using useflags"},
67
	{"qxpak",     qxpak_main,     "<misc args>",     "manipulate xpak archives"},
63
	{"qxpak",     qxpak_main,     "<misc args>",     "manipulate xpak archives"},
64
	{"qcache",    qcache_main,    "<action> <args>", NULL},		/* "search the metadata cache" */
65
	{"qglsa",     qglsa_main,     "<action> <list>", NULL},		/* "check GLSAs against system" */
66
	{"qmerge",    qmerge_main,    "<pkgnames>",      NULL},		/* "fetch and merge binary package" */
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-20070115.new/main.c (-102 / +223 lines)
Lines 71-79 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_overlays(void);
75
void initialize_ebuild_flat(void);
75
void reinitialize_ebuild_flat(short force);
76
void reinitialize_ebuild_flat(void);
77
void reinitialize_as_needed(void);
76
void reinitialize_as_needed(void);
78
void cleanup(void);
77
void cleanup(void);
79
int lookup_applet_idx(const char *);
78
int lookup_applet_idx(const char *);
Lines 86-96 static int quiet = 0; Link Here
86
static char pretend = 0;
85
static char pretend = 0;
87
static char reinitialize = 0;
86
static char reinitialize = 0;
88
static char reinitialize_metacache = 0;
87
static char reinitialize_metacache = 0;
89
static char portarch[20] = "";
88
/* static char portarch[20] = ""; */
90
static char portvdb[_Q_PATH_MAX] = "var/db/pkg";
89
static char portvdb[_Q_PATH_MAX] = "";
91
static char portcachedir[] = "metadata/cache";
90
static char cache_file_dir[_Q_PATH_MAX]="var/cache/paludis";
92
static char portroot[_Q_PATH_MAX] = "/";
91
static char metacache_file_dir[_Q_PATH_MAX]="var/cache/paludis/metadata";
93
static char config_protect[_Q_PATH_MAX] = "/etc/";
92
static char repocachedir[] = "metadata/cache";
93
static char portroot[_Q_PATH_MAX] = "";
94
/* static char config_protect[_Q_PATH_MAX] = "/etc/"; */
94
95
95
typedef struct overlay_t overlay_t;
96
typedef struct overlay_t overlay_t;
96
struct overlay_t {
97
struct overlay_t {
Lines 101-111 struct overlay_t { Link Here
101
};
102
};
102
103
103
static overlay_t *first_overlay = NULL;
104
static overlay_t *first_overlay = NULL;
104
/* temporary workaround ? */
105
static overlay_t *overlay_gentoo = NULL;
105
static overlay_t *overlay_gentoo = NULL;
106
106
107
char pkgdir[512] = "/usr/portage/packages/";
107
char pkgdir[512] = "/var/paludis/repositories/gentoo/packages/";
108
char port_tmpdir[512] = "/var/tmp/portage/";
108
char port_tmpdir[512] = "/var/tmp/paludis/";
109
109
110
char binhost[512] = PORTAGE_BINHOST;
110
char binhost[512] = PORTAGE_BINHOST;
111
char features[512] = "noman noinfo nodoc";
111
char features[512] = "noman noinfo nodoc";
Lines 227-233 static void version_barf(const char *Id) Link Here
227
# define VERSION "cvs"
227
# define VERSION "cvs"
228
#endif
228
#endif
229
	printf("portage-utils-%s: compiled on %s\n%s\n"
229
	printf("portage-utils-%s: compiled on %s\n%s\n"
230
	       "%s written for Gentoo by <solar and vapier @ gentoo.org>\n",
230
	       "%s written for Gentoo by <solar and vapier @ gentoo.org>\n"
231
	       "modified for overlay and paludis compatibility by samuelethiec @ hotmail.com\n",
231
	       VERSION, __DATE__, Id, argv0);
232
	       VERSION, __DATE__, Id, argv0);
232
	exit(EXIT_SUCCESS);
233
	exit(EXIT_SUCCESS);
233
}
234
}
Lines 479-552 char *strincr_var(const char *name, char Link Here
479
	return (char *) value;
480
	return (char *) value;
480
}
481
}
481
482
482
void initialize_overlays (char portdir_overlay[])
483
void initialize_overlays(void)
483
{
484
{
484
	short merror = 0;
485
 	short merror = 0, first = 1;
485
	char buf[BUFSIZE], file[_Q_PATH_MAX], *s, *p, *t;
486
	int i,j;
486
	overlay_t *cur_overlay;
487
 	char *s, *p, *t;
487
	FILE *repo_nameFP;
488
 	char buf[BUFSIZE], conffile[_Q_PATH_MAX], confdir[_Q_PATH_MAX], path[_Q_PATH_MAX];
488
	s = portdir_overlay;
489
	char location[_Q_PATH_MAX], write_cache[_Q_PATH_MAX], cache[_Q_PATH_MAX], format[32];
490
 	FILE *CONFFILE, *REPO_NAME;
491
 	DIR *CONFDIR;
492
 	struct dirent *f;
493
	struct stat statcache;
494
 	overlay_t *cur_overlay;
495
496
	struct {
497
		const char *name;
498
		const size_t name_len;
499
		char *value;
500
		const size_t value_len;
501
	} vars_to_read[] = {
502
		/* order is important */
503
		{"ROOT",	4,	portroot,	sizeof(portroot)},
504
		{"location",	8,	location,	sizeof(location)},
505
		{"write_cache",	11,	write_cache,	sizeof(write_cache)},
506
		{"cache",	5,	cache,		sizeof(cache)},
507
		{"format",	6,	format,		sizeof(format)}
508
	};
489
509
490
	first_overlay = xmalloc(sizeof(*first_overlay));
510
	first_overlay = xmalloc(sizeof(*first_overlay));
491
	cur_overlay = first_overlay;
511
  	cur_overlay = first_overlay;
492
512
493
	while (*s) {
513
 	snprintf(confdir, sizeof(confdir), "%s/etc/paludis/repositories", portroot);
494
		/* except on the first loop */
514
495
		if (s!=portdir_overlay) {
515
 	if (NULL == (CONFDIR = opendir(confdir)))
496
			cur_overlay->next = xmalloc (sizeof (*cur_overlay->next));
516
 		err("%s : could not open directory", confdir);
497
			cur_overlay = cur_overlay->next;
517
518
 	while ((f =  readdir(CONFDIR))) {
519
		location[0] = 0;
520
		cache[0] = 0;
521
		write_cache[0] = 0;
522
		format[0] = 0;
523
524
 		if (f->d_name[0] == '.')
525
 			continue;
526
527
 		snprintf(conffile, sizeof(conffile), "%s/%s", confdir, f->d_name);
528
529
 		if (NULL == (CONFFILE = fopen(conffile, "r")))
530
 			continue;
531
 		merror = 0;
532
533
 		while (fgets(buf, sizeof(buf), CONFFILE )) {
534
 			rmspace(buf);
535
 			if (*buf == '#' || *buf == '\0')
536
 				continue;
537
			for (i=1; i<ARR_SIZE(vars_to_read); ++i) {
538
				if (buf[vars_to_read[i].name_len] != '=' && buf[vars_to_read[i].name_len] != ' ')
539
					continue;
540
				if (strncmp(buf, vars_to_read[i].name, vars_to_read[i].name_len))
541
					continue;
542
543
				/* make sure we handle spaces between the varname, the =, and the value:
544
				 * VAR=val   VAR = val   VAR="val"
545
				 */
546
				s = buf + vars_to_read[i].name_len;
547
				if ((p = strchr(s, '=')) != NULL)
548
					s = p + 1;
549
				while (isspace(*s))
550
					++s;
551
				if (*s == '"' || *s == '\'') {
552
					++s;
553
					s[strlen(s)-1] = '\0';
554
				}
555
556
				strncpy(vars_to_read[i].value, s, vars_to_read[i].value_len);
557
			}
558
 		}
559
 		fclose(CONFFILE);
560
561
 		if (!format[0])
562
 			continue;
563
564
		/* delete trailing '/' */
565
		for (i=0; i<ARR_SIZE(vars_to_read); ++i) {
566
			if ((p = strrchr(vars_to_read[i].value, '/')) && (p+1) && *(p+1)==0)
567
				*p = 0;
498
		}
568
		}
499
		cur_overlay->next = NULL;
500
569
501
		if ((p=strchr(s,' ')))
570
		if (strncmp(format, "ebuild", sizeof(format)) && strncmp(format, "vdb", sizeof(format)))
502
			*p = 0;
571
			continue;
503
572
504
		snprintf(cur_overlay->path, sizeof(cur_overlay->path), "%s%s", (strcmp(portroot, "/") ? portroot : ""), s);
573
		/* if the path begins with a variable such as ${ROOT}, $ROOT, or $location and so on
574
		 * we try to replace it with its value */
575
		for (i=1; i<ARR_SIZE(vars_to_read); ++i) {
576
			path[0] = 0;
577
			if (vars_to_read[i].value[0] == '$') {
578
				p = strchr(vars_to_read[i].value, '/');
579
				*p = 0;
580
581
				if (vars_to_read[i].value[1]=='{' && *(p-1)=='}') {
582
					*(p-1) = 0;
583
					s = &vars_to_read[i].value[2];
584
				} else
585
					s = &vars_to_read[i].value[1];
586
587
				for (j=0; j<ARR_SIZE(vars_to_read); ++j)
588
					if (!strcmp(s, vars_to_read[j].name)) {
589
						strcpy(path, vars_to_read[j].value);
590
						break;
591
					}
505
592
506
		/* find the name for the overlay */
593
				/* put the slash back */
507
		snprintf(file, sizeof(file), "%s/profiles/repo_name", cur_overlay->path);
594
				*p = '/';
595
				strncat(path, p, sizeof(path));
596
				strcpy(vars_to_read[i].value, path);
597
			}
598
		}
508
599
509
		if ((repo_nameFP = fopen(file, "r"))) {
600
		/* vdb location defined in etc/paludis/repositories/installed.conf */
510
			if (!(fgets(buf, sizeof(buf),repo_nameFP)))
601
		if (!strcmp("installed.conf", f->d_name) && !strcmp("vdb", format)) {
511
				merror++;
602
			strncpy(portvdb, location, sizeof(portvdb));
512
			rmspace(buf);
603
			continue;
513
			if ((t = strchr(buf,'\n')))
604
		}
514
				*t = 0;
515
			strncpy(cur_overlay->name, buf, sizeof(cur_overlay->name));
516
605
517
			fclose(repo_nameFP);
606
 		if (!first) {
518
		} else
607
			cur_overlay->next = xmalloc(sizeof(*(cur_overlay->next)));
519
			merror++;
608
			cur_overlay = cur_overlay->next;
520
521
		if (merror) {
522
			/* delete trailing '/' */
523
			t = cur_overlay->path + strlen(cur_overlay->path) - 1;
524
			if (*t == '/')
525
				*t = 0;
526
			strncpy(file, cur_overlay->path, sizeof(file));
527
			strncpy(cur_overlay->name, basename(file), sizeof(cur_overlay->name));
528
			merror=0;
529
		}
609
		}
610
 		cur_overlay->next = NULL;
611
		cur_overlay->cache[0] = 0;
530
612
531
		if (!strncmp(cur_overlay->name, "gentoo", sizeof(cur_overlay->name))) {
613
		/* time to search for the overlay->name */
532
			snprintf(cur_overlay->cache, sizeof(cur_overlay->cache), "%s/%s", cur_overlay->path, portcachedir);
614
 		snprintf(conffile, sizeof(conffile), "%s/profiles/repo_name", location);
615
 		if (NULL != (REPO_NAME = fopen(conffile, "r"))) {
616
 			if (!(fgets(buf, sizeof(buf),REPO_NAME)))
617
 				merror++;
618
 			rmspace(buf);
619
 			if ((t = strchr(buf,'\n')))
620
  				*t = 0;
621
622
			strncpy(cur_overlay->name, buf, sizeof(cur_overlay->name));
623
 			fclose(REPO_NAME);
624
 		} else {
625
 			strcpy(cur_overlay->name, "x-");
626
			/* there is no trailing '/' */
627
			if ((p=strrchr(location,'/')))
628
				p = p+1;
629
			else
630
				p = location;
631
 			strncat(cur_overlay->name, p, sizeof(cur_overlay->name));
632
 		}
633
634
		if (!strcmp(cur_overlay->name, "gentoo"))
533
			overlay_gentoo = cur_overlay;
635
			overlay_gentoo = cur_overlay;
534
		} else
636
637
		strncpy(cur_overlay->path, location, sizeof(cur_overlay->path));
638
639
		if (!cache[0])
640
			snprintf(cache, sizeof(cache), "%s/%s", location, repocachedir);
641
642
		/* now we fill cur_overlay->cache */
643
		if (!strstr(cache, "/var/empty")) {
644
			if (stat(cache, &statcache) != -1 && S_ISDIR(statcache.st_mode))
645
				strcpy(cur_overlay->cache, cache);
646
			else {
647
				if (*write_cache) {
648
					snprintf(cache, sizeof(cache), "%s/%s", write_cache, cur_overlay->name);
649
					if (stat(cache, &statcache) != -1 && S_ISDIR(statcache.st_mode))
650
						strncpy(cur_overlay->cache, cache, sizeof(cur_overlay->cache));
651
					else
652
						strncpy(cur_overlay->cache, "/var/empty", sizeof(cur_overlay->cache));
653
				} else
654
					strncpy(cur_overlay->cache, "/var/empty", sizeof(cur_overlay->cache));
655
			}
656
 		} else
535
			strcpy(cur_overlay->cache, "/var/empty");
657
			strcpy(cur_overlay->cache, "/var/empty");
536
658
537
		if (p)
659
		/* once we get there we have at least done with the first overlay */
538
			s = p+1; /* because portdir_overlay has no trailing space */
660
		if (first)
539
		else
661
			first = 0;
540
			break;
541
	}
662
	}
542
663
 	closedir(CONFDIR);
543
}
664
}
544
665
545
546
void initialize_portage_env(void)
666
void initialize_portage_env(void)
547
{
667
{
548
	char nocolor = 0;
668
	char nocolor = 0;
549
	int i, f;
669
	int i;
670
	char *s;
671
	char tmp[_Q_PATH_MAX];
672
/*
550
	struct stat st;
673
	struct stat st;
551
	FILE *fp;
674
	FILE *fp;
552
	char tmp_portdir[_Q_PATH_MAX];
675
	char tmp_portdir[_Q_PATH_MAX];
Lines 556-561 void initialize_portage_env(void) Link Here
556
	char portdir_overlay[BUFSIZE] = "";
679
	char portdir_overlay[BUFSIZE] = "";
557
680
558
	const char *files[] = {portage_file, "/etc/make.globals", "/etc/make.conf"};
681
	const char *files[] = {portage_file, "/etc/make.globals", "/etc/make.conf"};
682
*/
559
	typedef enum { _Q_BOOL, _Q_STR, _Q_ISTR } var_types;
683
	typedef enum { _Q_BOOL, _Q_STR, _Q_ISTR } var_types;
560
684
561
	struct {
685
	struct {
Lines 565-571 void initialize_portage_env(void) Link Here
565
		char *value;
689
		char *value;
566
		const size_t value_len;
690
		const size_t value_len;
567
	} vars_to_read[] = {
691
	} vars_to_read[] = {
568
		{"ACCEPT_LICENSE",   14, _Q_STR,  accept_license, sizeof(accept_license)},
692
/*		{"ACCEPT_LICENSE",   14, _Q_STR,  accept_license, sizeof(accept_license)},
569
		{"INSTALL_MASK",     12, _Q_ISTR, install_mask,   sizeof(install_mask)},
693
		{"INSTALL_MASK",     12, _Q_ISTR, install_mask,   sizeof(install_mask)},
570
		{"ARCH",              4, _Q_STR,  portarch,       sizeof(portarch)},
694
		{"ARCH",              4, _Q_STR,  portarch,       sizeof(portarch)},
571
		{"CONFIG_PROTECT",   14, _Q_STR,  config_protect, sizeof(config_protect)},
695
		{"CONFIG_PROTECT",   14, _Q_STR,  config_protect, sizeof(config_protect)},
Lines 576-588 void initialize_portage_env(void) Link Here
576
		{"PORTAGE_BINHOST",  15, _Q_STR,  binhost,        sizeof(binhost)},
700
		{"PORTAGE_BINHOST",  15, _Q_STR,  binhost,        sizeof(binhost)},
577
		{"PORTAGE_TMPDIR",   14, _Q_STR,  port_tmpdir,    sizeof(port_tmpdir)},
701
		{"PORTAGE_TMPDIR",   14, _Q_STR,  port_tmpdir,    sizeof(port_tmpdir)},
578
		{"PKGDIR",            6, _Q_STR,  pkgdir,         sizeof(pkgdir)},
702
		{"PKGDIR",            6, _Q_STR,  pkgdir,         sizeof(pkgdir)},
703
*/
579
		{"ROOT",              4, _Q_STR,  portroot,       sizeof(portroot)}
704
		{"ROOT",              4, _Q_STR,  portroot,       sizeof(portroot)}
580
	};
705
	};
581
706
582
	if ((p = strchr(portroot, '/')) != NULL)
707
#if 0
583
		if (strlen(p) != 1)
584
			strncat(portroot, "/", sizeof(portroot));
585
586
	f = 0;
708
	f = 0;
587
	if (readlink("/etc/make.profile", profile, sizeof(profile)) == -1)
709
	if (readlink("/etc/make.profile", profile, sizeof(profile)) == -1)
588
		strcpy(profile, "/etc/make.profile");
710
		strcpy(profile, "/etc/make.profile");
Lines 643-648 void initialize_portage_env(void) Link Here
643
			f = 1;
765
			f = 1;
644
		}
766
		}
645
	} while (1);
767
	} while (1);
768
#endif
646
769
647
	/* finally, check the env */
770
	/* finally, check the env */
648
	for (i=0; i<ARR_SIZE(vars_to_read); ++i) {
771
	for (i=0; i<ARR_SIZE(vars_to_read); ++i) {
Lines 671-682 void initialize_portage_env(void) Link Here
671
	else
794
	else
672
		color_remap();
795
		color_remap();
673
796
674
	snprintf(tmp_portdir, sizeof(tmp_portdir), "%s/%s", (strcmp(portroot, "/") ? portroot : ""), portvdb);
797
	snprintf(tmp,sizeof(tmp),"%s/%s", portroot, cache_file_dir);
675
	strncpy(portvdb, tmp_portdir, sizeof(portvdb));
798
	strcpy(cache_file_dir, tmp);
676
	strincr_var("PORTDIR_OVERLAY", tmp_portdir, portdir_overlay, sizeof(portdir_overlay));
799
	snprintf(tmp,sizeof(tmp),"%s/%s", portroot, metacache_file_dir);
677
800
	strcpy(metacache_file_dir, tmp);
678
	/* now we initiliase the overlay chained list */
801
	/* now we initiliase the overlay chained list */
679
	initialize_overlays(portdir_overlay);
802
	initialize_overlays();
680
803
681
}
804
}
682
805
Lines 694-702 int filter_hidden(const struct dirent *d Link Here
694
}
817
}
695
818
696
#define CACHE_EBUILD_FILE (getenv("CACHE_EBUILD_FILE") ? getenv("CACHE_EBUILD_FILE") : ".ebuild.x")
819
#define CACHE_EBUILD_FILE (getenv("CACHE_EBUILD_FILE") ? getenv("CACHE_EBUILD_FILE") : ".ebuild.x")
697
#define CACHE_METADATA_FILE ".metadata.x"
820
#define CACHE_METADATA_FILE (getenv("CACHE_METADATA_FILE") ? getenv("CACHE_METADATA_FILE") : ".metadata.x")
698
const char *initialize_flat(int cache_type);
821
const char *initialize_flat(int cache_type, short force);
699
const char *initialize_flat(int cache_type)
822
const char *initialize_flat(int cache_type, short force)
700
{
823
{
701
	struct dirent **category, **pn, **eb;
824
	struct dirent **category, **pn, **eb;
702
	struct stat st;
825
	struct stat st;
Lines 714-752 const char *initialize_flat(int cache_ty Link Here
714
837
715
	cache_file = (cache_type == CACHE_EBUILD ? CACHE_EBUILD_FILE : CACHE_METADATA_FILE);
838
	cache_file = (cache_type == CACHE_EBUILD ? CACHE_EBUILD_FILE : CACHE_METADATA_FILE);
716
839
717
	/* SAM review without gentoo! */
840
 	if (cache_type == CACHE_METADATA) {
718
	if (cache_type == CACHE_METADATA) {
841
 		if (chdir(metacache_file_dir) != 0) {
719
		if (chdir(overlay_gentoo->cache) != 0) {
842
 			warnp("chdir to cache '%s' failed", metacache_file_dir);
720
			warnp("chdir to portage cache '%s' failed", overlay_gentoo->cache);
843
 			goto ret;
721
			goto ret;
844
 		}
722
		}
845
 	} else {
723
	} else {
846
 		if (chdir(cache_file_dir) != 0) {
724
		if (chdir(overlay_gentoo->path) != 0) {
847
 			warnp("chdir to '%s' failed", cache_file_dir);
725
			warnp("chdir to PORTDIR '%s' failed", overlay_gentoo->path);
848
 			goto ret;
726
			goto ret;
849
 		}
727
		}
728
	}
850
	}
729
851
730
	if ((stat(cache_file, &st)) != (-1))
852
	if ((stat(cache_file, &st)) != (-1)) {
731
		if (st.st_size == 0)
853
		if (force || st.st_size == 0)
732
			unlink(cache_file);
854
			unlink(cache_file);
855
		else
856
			goto ret;
857
	}
733
858
734
	/* assuming --sync is used with --delete this will get recreated after every merge */
735
	if (access(cache_file, R_OK) == 0)
736
		goto ret;
737
	if (!quiet)
859
	if (!quiet)
738
		warn("Updating ebuild %scache ... ", cache_type == CACHE_EBUILD ? "" : "meta");
860
		warn("Updating ebuild %scache ... ", cache_type == CACHE_EBUILD ? "" : "meta");
739
861
740
	unlink(cache_file);
862
	unlink(cache_file);
741
	if (errno != ENOENT) {
863
	if (errno != ENOENT) {
742
		/* SAM review without gentoo! */
864
		warnfp("unlinking '%s/%s' failed", (cache_type == CACHE_EBUILD ? cache_file_dir : metacache_file_dir), cache_file);
743
		warnfp("unlinking '%s/%s' failed", overlay_gentoo->path, cache_file);
865
		warn("define CACHE_METADATA_FILE and/or CACHE_EBUILD_FILE to use different cache file");
744
		goto ret;
866
		goto ret;
745
	}
867
	}
746
868
747
	/* SAM review without gentoo! */
748
	if ((fp = fopen(cache_file, "w")) == NULL) {
869
	if ((fp = fopen(cache_file, "w")) == NULL) {
749
		warnfp("opening '%s/%s' failed", (cache_type == CACHE_EBUILD ? overlay_gentoo->path : overlay_gentoo->cache), cache_file);
870
		warnfp("opening '%s/%s' failed", (cache_type == CACHE_EBUILD ? cache_file_dir : metacache_file_dir), cache_file);
750
		goto ret;
871
		goto ret;
751
	}
872
	}
752
873
Lines 799-804 const char *initialize_flat(int cache_ty Link Here
799
					break;
920
					break;
800
				case CACHE_METADATA:
921
				case CACHE_METADATA:
801
					if (S_ISREG(st.st_mode))
922
					if (S_ISREG(st.st_mode))
923
						count++;
802
						fprintf(fp, "%s::%s\n", de, cur_overlay->name);
924
						fprintf(fp, "%s::%s\n", de, cur_overlay->name);
803
					continue;
925
					continue;
804
					break;
926
					break;
Lines 842-866 const char *initialize_flat(int cache_ty Link Here
842
ret:
964
ret:
843
	return cache_file;
965
	return cache_file;
844
}
966
}
845
#define initialize_ebuild_flat() initialize_flat(CACHE_EBUILD)
967
#define initialize_ebuild_flat(force) initialize_flat(CACHE_EBUILD, force)
846
#define initialize_metadata_flat() initialize_flat(CACHE_METADATA)
968
#define initialize_metadata_flat(force) initialize_flat(CACHE_METADATA, force)
847
969
848
void reinitialize_ebuild_flat(void)
970
void reinitialize_ebuild_flat(short force)
849
{
971
{
850
	if ((chdir(first_overlay->path)) != 0) {
972
	if ((chdir(first_overlay->path)) != 0) {
851
		warnp("chdir to PORTDIR '%s' failed", first_overlay->path);
973
		warnp("chdir to PORTDIR '%s' failed", first_overlay->path);
852
		return;
974
		return;
853
	}
975
	}
854
	unlink(CACHE_EBUILD_FILE);
976
	unlink(CACHE_EBUILD_FILE);
855
	initialize_ebuild_flat();
977
	initialize_ebuild_flat(force);
856
}
978
}
857
979
858
void reinitialize_as_needed(void)
980
void reinitialize_as_needed(void)
859
{
981
{
860
	if (reinitialize)
982
	if (reinitialize)
861
		reinitialize_ebuild_flat();
983
		reinitialize_ebuild_flat(1);
862
	if (reinitialize_metacache)
984
	if (reinitialize_metacache)
863
		initialize_metadata_flat();
985
		initialize_metadata_flat(1);
864
}
986
}
865
987
866
typedef struct {
988
typedef struct {
Lines 1039-1045 char *grab_vdb_item(const char *item, co Link Here
1039
	char *p;
1161
	char *p;
1040
	FILE *fp;
1162
	FILE *fp;
1041
1163
1042
	snprintf(buf, sizeof(buf), "%s%s/%s/%s/%s", portroot, portvdb, CATEGORY, PF, item);
1164
	snprintf(buf, sizeof(buf), "%s/%s/%s/%s", portvdb, CATEGORY, PF, item);
1043
	if ((fp = fopen(buf, "r")) == NULL)
1165
	if ((fp = fopen(buf, "r")) == NULL)
1044
		return NULL;
1166
		return NULL;
1045
	fgets(buf, sizeof(buf), fp);
1167
	fgets(buf, sizeof(buf), fp);
Lines 1070-1078 queue *get_vdb_atoms(void) Link Here
1070
1192
1071
	assert(chdir(savecwd) == 0);
1193
	assert(chdir(savecwd) == 0);
1072
1194
1073
	if (chdir(portroot) != 0)
1074
		goto fuckit;
1075
1076
	if (chdir(portvdb) != 0)
1195
	if (chdir(portvdb) != 0)
1077
		goto fuckit;
1196
		goto fuckit;
1078
1197
Lines 1167-1169 int main(int argc, char **argv) Link Here
1167
}
1286
}
1168
1287
1169
#include "include_applets.h"
1288
#include "include_applets.h"
1289
/* vim: set noet sts=8 sw=8 : */
1290
(-)portage-utils-20070115.new/man/qlop.1 (-1 / +6 lines)
Lines 5-11 qlop \- emerge log analyzer Link Here
5
.B qlop
5
.B qlop
6
\fI<pkgname>\fR
6
\fI<pkgname>\fR
7
.SH DESCRIPTION
7
.SH DESCRIPTION
8
Options: \fB\-[gtluscf:F:HvqChV]\fR
8
Options: \fB\-[gtluso:cf\fR:F:HvqChV]
9
.TP
9
.TP
10
\fB\-g\fR, \fB\-\-gauge\fR
10
\fB\-g\fR, \fB\-\-gauge\fR
11
* Gauge number of times a package has been merged
11
* Gauge number of times a package has been merged
Lines 25-30 Options: \fB\-[gtluscf:F:HvqChV]\fR Link Here
25
\fB\-s\fR, \fB\-\-sync\fR
25
\fB\-s\fR, \fB\-\-sync\fR
26
* Show sync history
26
* Show sync history
27
.TP
27
.TP
28
\fB\-o\fR, \fB\-\-overlay\fR
29
<arg>
30
.BR
31
* Only consider the <arg> overlay
32
.TP
28
\fB\-c\fR, \fB\-\-current\fR
33
\fB\-c\fR, \fB\-\-current\fR
29
* Show current emerging packages
34
* Show current emerging packages
30
.TP
35
.TP
(-)portage-utils-20070115.new/q.c (+2 lines)
Lines 145-147 int q_main(int argc, char **argv) Link Here
145
145
146
	return (func)(argc - 1, ++argv);
146
	return (func)(argc - 1, ++argv);
147
}
147
}
148
/* vim: set noet sts=8 sw=8 : */
149
(-)portage-utils-20070115.new/qfile.c (-5 lines)
Lines 543-553 int qfile_main(int argc, char **argv) Link Here
543
	if ((args_file == NULL) && (max_args != QFILE_DEFAULT_MAX_ARGS))
543
	if ((args_file == NULL) && (max_args != QFILE_DEFAULT_MAX_ARGS))
544
		warn("--max-args is only used when reading arguments from a file (with -f)");
544
		warn("--max-args is only used when reading arguments from a file (with -f)");
545
545
546
	if (chdir(portroot)) {
547
		warnp("could not chdir(%s) for ROOT", portroot);
548
		goto exit;
549
	}
550
551
	if (chdir(portvdb) != 0) {
546
	if (chdir(portvdb) != 0) {
552
		warnp("could not chdir(ROOT/%s) for installed packages database", portvdb);
547
		warnp("could not chdir(ROOT/%s) for installed packages database", portvdb);
553
		goto exit;
548
		goto exit;
(-)portage-utils-20070115.new/qfile.c.orig (-5 / +3 lines)
Lines 600-615 int qfile_main(int argc, char **argv) Link Here
600
		if (nb_of_queries < 0)
600
		if (nb_of_queries < 0)
601
			goto exit;
601
			goto exit;
602
602
603
		if (chdir(portroot)
603
		if (chdir(portvdb) != 0 || (dir = opendir(".")) == NULL) {
604
				|| chdir(portvdb) != 0
604
			warnp("could not chdir(%s) for installed packages database", portvdb);
605
				|| (dir = opendir(".")) == NULL) {
606
			warnp("could not chdir(ROOT/%s) for installed packages database", portvdb);
607
			goto exit;
605
			goto exit;
608
		}
606
		}
609
607
610
		/* Iteration over VDB categories */
608
		/* Iteration over VDB categories */
611
		while (nb_of_queries && (dentry = q_vdb_get_next_dir(dir))) {
609
		while (nb_of_queries && (dentry = q_vdb_get_next_dir(dir))) {
612
			snprintf(path, _Q_PATH_MAX, "%s/%s/%s", qfile_args->real_root, portvdb, dentry->d_name);
610
			snprintf(path, _Q_PATH_MAX, "%s/%s", portvdb, dentry->d_name);
613
			qfile(path, (assume_root_prefix ? root_prefix : NULL), qfile_args);
611
			qfile(path, (assume_root_prefix ? root_prefix : NULL), qfile_args);
614
		}
612
		}
615
613
(-)portage-utils-20070115.new/qgrep.c (-1 / +3 lines)
Lines 90-96 int qgrep_main(int argc, char **argv) Link Here
90
	if (argc == optind)
90
	if (argc == optind)
91
		qgrep_usage(EXIT_FAILURE);
91
		qgrep_usage(EXIT_FAILURE);
92
92
93
	initialize_ebuild_flat();	/* sets our pwd to $PORTDIR */
93
	initialize_ebuild_flat(0);	/* sets our pwd to $PORTDIR */
94
94
95
	if ((fp = fopen(CACHE_EBUILD_FILE, "r")) == NULL)
95
	if ((fp = fopen(CACHE_EBUILD_FILE, "r")) == NULL)
96
		return 1;
96
		return 1;
Lines 191-193 int qgrep_main(int argc, char **argv) Link Here
191
#else
191
#else
192
DEFINE_APPLET_STUB(qgrep)
192
DEFINE_APPLET_STUB(qgrep)
193
#endif
193
#endif
194
/* vim: set noet sts=8 sw=8 : */
195
(-)portage-utils-20070115.new/qlist.c (-10 / +13 lines)
Lines 137-142 int qlist_main(int argc, char **argv) Link Here
137
	char qlist_all = 0, just_pkgname = 0, dups_only = 0;
137
	char qlist_all = 0, just_pkgname = 0, dups_only = 0;
138
	char show_dir, show_obj, show_sym, show_slots, show_umap;
138
	char show_dir, show_obj, show_sym, show_slots, show_umap;
139
	struct dirent **de, **cat;
139
	struct dirent **de, **cat;
140
	char overlay[64];
140
	char buf[_Q_PATH_MAX];
141
	char buf[_Q_PATH_MAX];
141
	char swap[_Q_PATH_MAX];
142
	char swap[_Q_PATH_MAX];
142
	queue *sets = NULL;
143
	queue *sets = NULL;
Lines 146-151 int qlist_main(int argc, char **argv) Link Here
146
	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
147
	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
147
148
148
	show_dir = show_obj = show_sym = show_slots = show_umap = 0;
149
	show_dir = show_obj = show_sym = show_slots = show_umap = 0;
150
	overlay[0] = 0;
149
151
150
	while ((i = GETOPT_LONG(QLIST, qlist, "")) != -1) {
152
	while ((i = GETOPT_LONG(QLIST, qlist, "")) != -1) {
151
		switch (i) {
153
		switch (i) {
Lines 168-179 int qlist_main(int argc, char **argv) Link Here
168
	if ((argc == optind) && (!just_pkgname))
170
	if ((argc == optind) && (!just_pkgname))
169
		qlist_usage(EXIT_FAILURE);
171
		qlist_usage(EXIT_FAILURE);
170
172
171
	if (chdir(portroot))
172
		errp("could not chdir(%s) for ROOT", portroot);
173
174
	if (chdir(portvdb) != 0)
173
	if (chdir(portvdb) != 0)
175
		return EXIT_FAILURE;
174
		errp("could not chdir(%s) for VDB", portvdb);
176
177
175
178
	if ((dfd = scandir(".", &cat, filter_hidden, alphasort)) < 0)
176
	if ((dfd = scandir(".", &cat, filter_hidden, alphasort)) < 0)
179
		return EXIT_FAILURE;
177
		return EXIT_FAILURE;
Lines 223-228 int qlist_main(int argc, char **argv) Link Here
223
			if ((i == argc) && (argc != optind))
221
			if ((i == argc) && (argc != optind))
224
				continue;
222
				continue;
225
223
224
			if (verbose>1)
225
				snprintf(overlay, sizeof(overlay), "::%s",grab_vdb_item("REPOSITORY", cat[j]->d_name, de[x]->d_name));
226
226
			if (just_pkgname) {
227
			if (just_pkgname) {
227
				if (dups_only) {
228
				if (dups_only) {
228
					pkgname = atom_explode(de[x]->d_name);
229
					pkgname = atom_explode(de[x]->d_name);
Lines 241-249 int qlist_main(int argc, char **argv) Link Here
241
						slot = grab_vdb_item("SLOT", cat[j]->d_name, de[x]->d_name);
242
						slot = grab_vdb_item("SLOT", cat[j]->d_name, de[x]->d_name);
242
243
243
					/* display it */
244
					/* display it */
244
					printf("%s%s/%s%s%s%s%s%s%s", BOLD, cat[j]->d_name, BLUE,
245
					printf("%s%s/%s%s%s%s%s%s%s%s%s", BOLD, cat[j]->d_name, BLUE,
245
					       (pkgname ? pkgname->PN : de[x]->d_name), NORM,
246
					       (pkgname ? pkgname->PN : de[x]->d_name), NORM,
246
						YELLOW, slot ? " ": "", slot ? slot : "", NORM);
247
						YELLOW, overlay,
248
						RED, slot ? " ": "", slot ? slot : "", NORM);
247
					puts(umapstr(show_umap, cat[j]->d_name, de[x]->d_name));
249
					puts(umapstr(show_umap, cat[j]->d_name, de[x]->d_name));
248
				}
250
				}
249
				if (pkgname)
251
				if (pkgname)
Lines 253-259 int qlist_main(int argc, char **argv) Link Here
253
					continue;
255
					continue;
254
			}
256
			}
255
257
256
			snprintf(buf, sizeof(buf), "%s%s/%s/%s/CONTENTS", portroot, portvdb,
258
			snprintf(buf, sizeof(buf), "%s/%s/%s/CONTENTS", portvdb,
257
			         cat[j]->d_name, de[x]->d_name);
259
			         cat[j]->d_name, de[x]->d_name);
258
260
259
			if (verbose > 1)
261
			if (verbose > 1)
Lines 311-319 int qlist_main(int argc, char **argv) Link Here
311
				char *slot = NULL;
313
				char *slot = NULL;
312
				if (show_slots)
314
				if (show_slots)
313
					slot = (char *) grab_vdb_item("SLOT", (const char *) atom->CATEGORY, (const char *) atom->P);
315
					slot = (char *) grab_vdb_item("SLOT", (const char *) atom->CATEGORY, (const char *) atom->P);
314
				printf("%s%s/%s%s%s%s%s%s%s", BOLD, atom->CATEGORY, BLUE,
316
				printf("%s%s/%s%s%s%s%s%s%s%s%s", BOLD, atom->CATEGORY, BLUE,
315
					(verbose ? atom->P : atom->PN), NORM,
317
					(verbose ? atom->P : atom->PN), NORM,
316
					YELLOW, slot ? " " : "", slot ? slot : "", NORM);
318
					YELLOW, overlay,
319
					RED, slot ? " " : "", slot ? slot : "", NORM);
317
				puts(umapstr(show_umap, atom->CATEGORY, atom->P));
320
				puts(umapstr(show_umap, atom->CATEGORY, atom->P));
318
			}
321
			}
319
			atom_implode(atom);
322
			atom_implode(atom);
(-)portage-utils-20070115.new/qlop.c (-90 / +226 lines)
Lines 21-31 Link Here
21
# include <sys/time.h>
21
# include <sys/time.h>
22
#endif
22
#endif
23
23
24
#define QLOP_DEFAULT_LOGFILE "/var/log/emerge.log"
24
#define QLOP_DEFAULT_LOGFILE "/var/log/paludis.log"
25
25
26
26
27
27
28
#define QLOP_FLAGS "gtluscf:F:H" COMMON_FLAGS
28
#define QLOP_FLAGS "gtluso:cf:F:H" COMMON_FLAGS
29
static struct option const qlop_long_opts[] = {
29
static struct option const qlop_long_opts[] = {
30
	{"gauge",     no_argument, NULL, 'g'},
30
	{"gauge",     no_argument, NULL, 'g'},
31
	{"time",      no_argument, NULL, 't'},
31
	{"time",      no_argument, NULL, 't'},
Lines 33-38 static struct option const qlop_long_opt Link Here
33
	{"list",      no_argument, NULL, 'l'},
33
	{"list",      no_argument, NULL, 'l'},
34
	{"unlist",    no_argument, NULL, 'u'},
34
	{"unlist",    no_argument, NULL, 'u'},
35
	{"sync",      no_argument, NULL, 's'},
35
	{"sync",      no_argument, NULL, 's'},
36
	{"overlay",   a_argument,  NULL, 'o'},
36
	{"current",   no_argument, NULL, 'c'},
37
	{"current",   no_argument, NULL, 'c'},
37
	{"logfile",    a_argument, NULL, 'f'},
38
	{"logfile",    a_argument, NULL, 'f'},
38
	COMMON_LONG_OPTS
39
	COMMON_LONG_OPTS
Lines 44-49 static const char *qlop_opts_help[] = { Link Here
44
	"Show merge history",
45
	"Show merge history",
45
	"Show unmerge history",
46
	"Show unmerge history",
46
	"Show sync history",
47
	"Show sync history",
48
	"Do only consider the <arg> repository",
47
	"Show current emerging packages",
49
	"Show current emerging packages",
48
	"Read emerge logfile instead of " QLOP_DEFAULT_LOGFILE,
50
	"Read emerge logfile instead of " QLOP_DEFAULT_LOGFILE,
49
	COMMON_OPTS_HELP
51
	COMMON_OPTS_HELP
Lines 79-108 static const char *chop_ctime(time_t t) Link Here
79
	return ctime_out;
81
	return ctime_out;
80
}
82
}
81
83
82
unsigned long show_merge_times(char *package, const char *logfile, int average, char human_readable);
84
unsigned long show_merge_times(char *package, const short repo, const char repo_search[], const char *logfile, int average, char human_readable);
83
unsigned long show_merge_times(char *package, const char *logfile, int average, char human_readable)
85
unsigned long show_merge_times(char *package, const short repo, const char repo_search[], const char *logfile, int average, char human_readable)
84
{
86
{
85
	FILE *fp;
87
	FILE *fp;
86
	char cat[126], buf[2][BUFSIZ];
88
	char catPN[BUFSIZ], buf[2][BUFSIZ], matched;
87
	char *pkg, *p;
89
	char *p, *q;
88
	unsigned long count, merge_time;
90
	unsigned long count, merge_time;
89
	time_t t[2];
91
	time_t t[2];
90
	depend_atom *atom;
92
	depend_atom *atom,*search;
93
	int l;
94
	long pos;
91
95
92
	t[0] = t[1] = 0UL;
96
	t[0] = t[1] = 0UL;
93
	count = merge_time = 0;
97
	count = merge_time = 0;
94
	cat[0] = 0;
98
	matched = 0;
99
	pos = 0;
95
100
96
	if ((p = strchr(package, '/')) != NULL) {
101
	if ((search = atom_explode(package)) == NULL )
97
		pkg = p + 1;
102
		err("%s is not a valid atom", package);
98
		strncpy(cat, package, sizeof(cat));
103
	if (!search->CATEGORY && !search->PN && !search->OVERLAY)
99
		if ((p = strchr(cat, '/')) != NULL)
104
		err("You need to specify at least an overlay, a category, or a package name");
100
			*p = 0;
101
	} else {
102
		pkg = package;
103
	}
104
105
105
	DBG("Searching for %s in %s\n", pkg, logfile);
106
	DBG("Searching for %s in %s\n", package, logfile);
106
107
107
	if ((fp = fopen(logfile, "r")) == NULL) {
108
	if ((fp = fopen(logfile, "r")) == NULL) {
108
		warnp("Could not open logfile '%s'", logfile);
109
		warnp("Could not open logfile '%s'", logfile);
Lines 110-116 unsigned long show_merge_times(char *pac Link Here
110
	}
111
	}
111
112
112
	while ((fgets(buf[0], sizeof(buf[0]), fp)) != NULL) {
113
	while ((fgets(buf[0], sizeof(buf[0]), fp)) != NULL) {
113
		if (strstr(buf[0], pkg) == NULL)
114
		if (matched) {
115
			matched = 0;
116
			continue;
117
		}
118
		/* len( time:{starting,finished} install of package ) = 41 */
119
		if (search->CATEGORY && !strstr(&buf[0][40], search->CATEGORY))
120
			continue;
121
122
		if (search->PN && !strstr(&buf[0][40], search->PN))
123
			continue;
124
125
		if (search->OVERLAY && !strstr(&buf[0][40], search->OVERLAY))
114
			continue;
126
			continue;
115
127
116
		if ((p = strchr(buf[0], '\n')) != NULL)
128
		if ((p = strchr(buf[0], '\n')) != NULL)
Lines 121-200 unsigned long show_merge_times(char *pac Link Here
121
		t[0] = atol(buf[0]);
133
		t[0] = atol(buf[0]);
122
		strcpy(buf[1], p + 1);
134
		strcpy(buf[1], p + 1);
123
		rmspace(buf[1]);
135
		rmspace(buf[1]);
124
		if ((strncmp(buf[1], ">>> emerge (", 12)) == 0) {
136
		if ((strncmp(buf[1], "starting install of package", 26)) == 0) {
125
			char matched = 0;
137
			p = &buf[1][28];
126
			if ((p = strchr(buf[1], ')')) == NULL)
138
			if (repo && !strstr(p, repo_search))
127
				continue;
139
				continue;
128
			*p = 0;
140
129
			strcpy(buf[0], p + 1);
141
			if ((q = strchr(p, ' ')) == NULL)
130
			rmspace(buf[0]);
131
			if ((p = strchr(buf[0], ' ')) == NULL)
132
				continue;
142
				continue;
133
			*p = 0;
143
			*q = 0;
144
145
			strcpy(buf[0], p);
146
			rmspace(buf[0]);
134
			if ((atom = atom_explode(buf[0])) == NULL)
147
			if ((atom = atom_explode(buf[0])) == NULL)
135
				continue;
148
				continue;
136
149
137
			if (*cat) {
150
			if (search->CATEGORY && strcmp(atom->CATEGORY, search->CATEGORY)) {
138
				if ((strcmp(cat, atom->CATEGORY) == 0) && (strcmp(pkg, atom->PN) == 0))
151
				atom_implode(atom);
139
					matched = 1;
152
				continue;
140
			} else if (strcmp(pkg, atom->PN) == 0)
153
			}
141
				matched = 1;
154
155
			if (search->PN && *search->PN && strcmp(atom->PN, search->PN)) {
156
				atom_implode(atom);
157
				continue;
158
			}
159
160
			if (search->PV && strcmp(atom->PV, search->PV)) {
161
				atom_implode(atom);
162
				continue;
163
			}
164
165
			if (search->PR_int && atom->PR_int!=search->PR_int) {
166
				atom_implode(atom);
167
				continue;
168
			}
169
170
			if (search->OVERLAY && strcmp(atom->OVERLAY, search->OVERLAY)) {
171
				atom_implode(atom);
172
				continue;
173
			}
174
			pos = ftell(fp);
175
			matched = 1;
142
176
143
			if (matched) {
177
			if (matched) {
144
				while ((fgets(buf[0], sizeof(buf[0]), fp)) != NULL) {
178
				/* In case of simultaneous install, we search the corresponding */
179
				/* "finished install of package" pkg up to 20 lines after the 'starting line' */
180
				l=0;
181
				snprintf(catPN, sizeof(catPN), "%s/%s-%s::%s", atom->CATEGORY, atom->PN, (atom->PR_int ? atom->PVR : atom->PV), atom->OVERLAY);
182
				while ((fgets(buf[0], sizeof(buf[0]), fp)) != NULL && l++ < 20) {
183
					if ((p = strchr(buf[0],':')) == NULL)
184
						continue;
185
					p = p+2;
186
187
					/* Stop the search in case the package is already being reinstalled even in a different version/revision */
188
					if (!strncmp(p, "starting", 8) && strcmp(p+28, catPN))
189
						break;
190
191
					if (strncmp(p, "finished install of package", 26) != 0)
192
						continue;
193
					if (!strcmp(p+28, catPN))
194
						continue;
195
145
					if ((p = strchr(buf[0], '\n')) != NULL)
196
					if ((p = strchr(buf[0], '\n')) != NULL)
146
						*p = 0;
197
						*p = 0;
147
					if ((p = strchr(buf[0], ':')) == NULL)
198
					if ((p = strchr(buf[0], ':')) == NULL)
148
						continue;
199
						*p = 0;
149
					*p = 0;
150
					t[1] = atol(buf[0]);
200
					t[1] = atol(buf[0]);
151
					strcpy(buf[1], p + 1);
201
					strcpy(buf[1], p + 1);
152
					rmspace(buf[1]);
202
					rmspace(buf[1]);
153
					if (*buf[1] == '*')
203
154
						break;
204
					if (!average) {
155
					if ((strncmp(buf[1], "::: completed emerge (", 22)) == 0) {
205
						strcpy(buf[1], "");
156
						if (!average) {
206
						if (verbose)
157
							strcpy(buf[1], "");
207
							snprintf(buf[1], sizeof(buf[1]), "-%s%s::%s ", (atom->PR_int ? atom->PVR : atom->PV), YELLOW, atom->OVERLAY);
158
							if (verbose) {
208
159
								if (atom->PR_int)
209
						printf("%s%s/%s%s%s%s: %s: ", GREEN, atom->CATEGORY, BLUE, atom->PN, buf[1], NORM, chop_ctime(t[0]));
160
									snprintf(buf[1], sizeof(buf[1]), "-%s-r%i", atom->PV,  atom->PR_int);
210
						if (human_readable)
161
								else
211
							print_seconds_for_earthlings(t[1] - t[0]);
162
									snprintf(buf[1], sizeof(buf[1]), "-%s", atom->PV);
212
						else
163
							}
213
							printf("%s%lu%s seconds", GREEN, (t[1] - t[0]), NORM);
164
							printf("%s%s%s%s: %s: ", BLUE, atom->PN, buf[1], NORM, chop_ctime(t[0]));
214
						puts("");
165
							if (human_readable)
166
								print_seconds_for_earthlings(t[1] - t[0]);
167
							else
168
								printf("%s%lu%s seconds", GREEN, (t[1] - t[0]), NORM);
169
							puts("");
170
						}
171
						merge_time += (t[1] - t[0]);
172
						count++;
173
						break;
174
					}
215
					}
216
					merge_time += (t[1] - t[0]);
217
					count++;
218
					break;
219
175
				}
220
				}
176
			}
221
			}
177
			atom_implode(atom);
222
			atom_implode(atom);
223
			/* time to go back where we were */
224
			fseek(fp, pos, SEEK_SET);
178
		}
225
		}
179
	}
226
	}
180
	fclose(fp);
227
	fclose(fp);
181
	if (count == 0)
228
	if (count == 0)
182
		return 0;
229
		return 0;
183
	if (average == 1) {
230
	if (average == 1) {
184
		printf("%s%s%s: ", BLUE, pkg, NORM);
231
		printf("%s%s%s%s%s%s%s%s%s%s%s : ", GREEN, (search->CATEGORY? search->CATEGORY : ""), (search->CATEGORY ? "/": ""),
232
					BLUE, search->PN, (search->PV ? "-" : ""), (search->PV ? (search->PR_int ? search->PVR : search->PV) : ""),
233
					YELLOW, (search->OVERLAY ? "::" : ""), (search->OVERLAY ? search->OVERLAY : ""), NORM);
185
		if (human_readable)
234
		if (human_readable)
186
			print_seconds_for_earthlings(merge_time / count);
235
			print_seconds_for_earthlings(merge_time / count);
187
		else
236
		else
188
			printf("%s%lu%s seconds average", GREEN, merge_time / count, NORM);
237
			printf("%s%lu%s seconds", GREEN, merge_time / count, NORM);
189
		printf(" for %s%lu%s merges\n", GREEN, count, NORM);
238
		printf(" average for %s%lu%s merges%s", GREEN, count, NORM, (verbose ? ", for a total time of " : ""));
239
240
		if (verbose) {
241
			if (human_readable)
242
				print_seconds_for_earthlings(merge_time);
243
			else
244
				printf("%s%lu%s seconds", GREEN, merge_time, NORM);
245
		}
246
		fputc('\n', stdout);
190
	} else {
247
	} else {
191
		printf("%s%s%s: %s%lu%s times\n", BLUE, pkg, NORM, GREEN, count, NORM);
248
		printf("%s%s%s%s%s%s%s%s%s%s%s : %s%lu%s times%s", GREEN, (search->CATEGORY ? search->CATEGORY : ""), (search->CATEGORY ? "/": ""),
249
							BLUE, (search->PN ? search->PN : ""),  (search->PV ? "-" : ""), (search->PV ? (search->PR_int ? search->PVR : search->PV) : ""),
250
							YELLOW, (search->OVERLAY ? "::" : ""), (search->OVERLAY ? search->OVERLAY : ""),
251
							NORM, GREEN, count, NORM,
252
							(verbose ? ", for a total time of " : ""));
253
		if (verbose) {
254
			if (human_readable)
255
				print_seconds_for_earthlings(merge_time);
256
			else
257
				printf("%s%lu%s seconds", GREEN, merge_time, NORM);
258
		}
259
		fputc('\n', stdout);
192
	}
260
	}
261
	atom_implode(search);
193
	return 0;
262
	return 0;
194
}
263
}
195
264
196
void show_emerge_history(char listflag, int argc, char **argv, const char *logfile);
265
void show_emerge_history(char listflag, const short repo, const char repo_search[], int argc, char **argv, const char *logfile);
197
void show_emerge_history(char listflag, int argc, char **argv, const char *logfile)
266
void show_emerge_history(char listflag, const short repo, const char repo_search[], int argc, char **argv, const char *logfile)
198
{
267
{
199
	FILE *fp;
268
	FILE *fp;
200
	char buf[BUFSIZ], merged;
269
	char buf[BUFSIZ], merged;
Lines 222-244 void show_emerge_history(char listflag, Link Here
222
		if ((p = strchr(buf, ':')) == NULL)
291
		if ((p = strchr(buf, ':')) == NULL)
223
			continue;
292
			continue;
224
		*p = 0;
293
		*p = 0;
225
		q = p + 3;
294
		q = p + 2;
226
295
227
		t = (time_t) atol(buf);
296
		t = (time_t) atol(buf);
228
297
229
		if ((listflag & QLOP_LIST) && !strncmp(q, "::: completed emerge (", 22)) {
298
		if ((listflag & QLOP_LIST) && !strncmp(q, "finished install of package", 25)) {
230
			merged = 1;
299
			merged = 1;
231
			if ((p = strchr(q, ')')) == NULL)
300
			p = strstr(q, "package");
232
				continue;
301
			q = p + 1;
233
			q = p + 2;
234
			if ((p = strchr(q, ' ')) == NULL)
302
			if ((p = strchr(q, ' ')) == NULL)
235
				continue;
303
				continue;
236
			*p = 0;
304
			q = p + 1;
237
		} else if ((listflag & QLOP_UNLIST) && !strncmp(q, ">>> unmerge success: ", 21)) {
305
			if (repo) {
306
				if ((p = strstr(q, "::")) && strncmp(p+2, repo_search, sizeof(repo_search)))
307
					continue;
308
			}
309
		} else if ((listflag & QLOP_UNLIST) && !strncmp(q, "finished uninstall of package", 29)) {
238
			merged = 0;
310
			merged = 0;
239
			if ((p = strchr(q, ':')) == NULL)
311
			p = strstr(q, "package");
312
			q = p + 1;
313
			if ((p = strchr(q, ' ')) == NULL)
240
				continue;
314
				continue;
241
			q = p + 2;
315
			q = p + 1;
316
			if ((p = strchr(p, ':')) != NULL)
317
				*p = 0;
242
		}
318
		}
243
		else
319
		else
244
			continue;
320
			continue;
Lines 258-265 void show_emerge_history(char listflag, Link Here
258
	fclose(fp);
334
	fclose(fp);
259
}
335
}
260
336
261
void show_sync_history(const char *logfile);
337
void show_sync_history(const char *logfile, const short repo, char repo_search[]);
262
void show_sync_history(const char *logfile)
338
void show_sync_history(const char *logfile, const short repo, char repo_search[])
263
{
339
{
264
	FILE *fp;
340
	FILE *fp;
265
	char buf[BUFSIZ];
341
	char buf[BUFSIZ];
Lines 274-280 void show_sync_history(const char *logfi Link Here
274
	while ((fgets(buf, sizeof(buf), fp)) != NULL) {
350
	while ((fgets(buf, sizeof(buf), fp)) != NULL) {
275
		if (strlen(buf) < 35)
351
		if (strlen(buf) < 35)
276
			continue;
352
			continue;
277
		if (strncmp(buf+12, "=== Sync completed with", 23) != 0)
353
		if (strncmp(buf+12, "finished sync", 13) != 0)
354
			continue;
355
356
		if (repo && strstr(buf, repo_search) == NULL)
278
			continue;
357
			continue;
279
358
280
		if ((p = strchr(buf, '\n')) != NULL)
359
		if ((p = strchr(buf, '\n')) != NULL)
Lines 282-294 void show_sync_history(const char *logfi Link Here
282
		if ((p = strchr(buf, ':')) == NULL)
361
		if ((p = strchr(buf, ':')) == NULL)
283
			continue;
362
			continue;
284
		*p = 0;
363
		*p = 0;
285
		q = p+2;
364
		q = p+1;
286
365
287
		t = (time_t)atol(buf);
366
		t = (time_t)atol(buf);
288
367
289
		if ((p = strstr(q, "with")) == NULL)
368
		if ((p = strstr(q, "repository")) == NULL)
290
			continue;
369
			continue;
291
		q = p + 5;
370
		q = p + 11;
292
371
293
		printf("%s >>> %s%s%s\n", chop_ctime(t), GREEN, q, NORM);
372
		printf("%s >>> %s%s%s\n", chop_ctime(t), GREEN, q, NORM);
294
	}
373
	}
Lines 304-313 void show_current_emerge(void) Link Here
304
	pid_t pid;
383
	pid_t pid;
305
	char buf[BUFSIZE], bufstat[300];
384
	char buf[BUFSIZE], bufstat[300];
306
	char path[50];
385
	char path[50];
307
	char *p, *q;
386
	char *p, *q, *cat, *pnv;
308
	unsigned long long start_time = 0;
387
	unsigned long long start_time = 0;
309
	double uptime_secs;
388
	double uptime_secs;
310
	time_t start_date;
389
	time_t start_date;
390
	overlay_t *overlay_tmp;
311
391
312
	if ((proc = opendir("/proc")) == NULL) {
392
	if ((proc = opendir("/proc")) == NULL) {
313
		warnp("Could not open /proc");
393
		warnp("Could not open /proc");
Lines 319-333 void show_current_emerge(void) Link Here
319
		if ((pid = (pid_t)atol(de->d_name)) == 0)
399
		if ((pid = (pid_t)atol(de->d_name)) == 0)
320
			continue;
400
			continue;
321
401
322
		/* portage renames the cmdline so the package name is first */
323
		snprintf(path, sizeof(path), "/proc/%i/cmdline", pid);
402
		snprintf(path, sizeof(path), "/proc/%i/cmdline", pid);
324
		if (!eat_file(path, buf, sizeof(buf)))
403
		if (!eat_file(path, buf, sizeof(buf)))
325
			continue;
404
			continue;
326
405
327
		if (buf[0] == '[' && (p = strchr(buf, ']')) != NULL && strstr(buf, "sandbox") != NULL) {
406
		if (! strncmp(buf, "sandbox", 7)) {
328
			*p = '\0';
407
			/*			  0123456789012345678 */
329
			p = buf+1;
408
			if (!(p = strstr(&buf[8],"paludis/ebuild.bash")))
330
			q = p + strlen(p) + 1;
409
				continue;
410
411
			q = p + 20;
412
			if (*q != '/')
413
				continue;
414
415
			/*
416
			 * ex: /var/paludis/repositories/local/category/package_name/package_name_version.ebuild
417
			 * expected:
418
			 *     q			       cat     0	     pnv
419
			 */
420
			if (q == (pnv=strrchr(q, '/')))
421
				continue;
422
			*pnv = 0;
423
			pnv++;
424
			if (q == (cat=strrchr(q, '/')))
425
				continue;
426
			*cat = 0;
427
			if (q == (cat=strrchr(q, '/')))
428
				continue;
429
			*cat = 0;
430
			cat++;
431
			overlay_tmp=first_overlay;
432
			do {
433
				if (!strcmp(q, overlay_tmp->path))
434
					break;
435
			} while ((overlay_tmp=overlay_tmp->next));
436
437
			if (NULL == overlay_tmp)
438
				continue;
331
439
332
			/* open the stat file to figure out how long we have been running */
440
			/* open the stat file to figure out how long we have been running */
333
			snprintf(path, sizeof(path), "/proc/%i/stat", pid);
441
			snprintf(path, sizeof(path), "/proc/%i/stat", pid);
Lines 356-365 void show_current_emerge(void) Link Here
356
			/* figure out when this thing started and then show it */
464
			/* figure out when this thing started and then show it */
357
			start_date = time(0) - (uptime_secs - (start_time / HZ));
465
			start_date = time(0) - (uptime_secs - (start_time / HZ));
358
			printf(
466
			printf(
359
				" %s*%s %s%s%s\n"
467
				" %s*%s %s::%s%s%s/%s%s\n"
360
				"     started: %s%s%s\n"
468
				"     started: %s%s%s\n"
361
				"     elapsed: ", /*%s%llu%s seconds\n",*/
469
				"     elapsed: ", /*%s%llu%s seconds\n",*/
362
				BOLD, NORM, BLUE, p, NORM,
470
				BOLD, YELLOW, overlay_tmp->name, NORM, BLUE, cat, pnv, NORM,
363
				GREEN, chop_ctime(start_date), NORM);
471
				GREEN, chop_ctime(start_date), NORM);
364
			print_seconds_for_earthlings(uptime_secs - (start_time / HZ));
472
			print_seconds_for_earthlings(uptime_secs - (start_time / HZ));
365
			puts(NORM);
473
			puts(NORM);
Lines 380-385 void show_current_emerge(void) Link Here
380
	char *p, *q;
488
	char *p, *q;
381
	time_t start_date = 0;
489
	time_t start_date = 0;
382
490
491
	/* this would need to be written for paludis, but I don't really know *BSD */
492
	warn("You need to adapt the show_current_emerge(void) function for __FreeBSD__\n"
493
		"this may be trivial, just do as in the __linux__ one, but as I can't test it, I didn't make it");
494
383
	if (! (kd = kvm_open("/dev/null", "/dev/null", "/dev/null", O_RDONLY, "kvm_open"))) {
495
	if (! (kd = kvm_open("/dev/null", "/dev/null", "/dev/null", O_RDONLY, "kvm_open"))) {
384
		warnp("Could not open kvm: %s", kvm_geterr(kd));
496
		warnp("Could not open kvm: %s", kvm_geterr(kd));
385
		return;
497
		return;
Lines 433-444 int qlop_main(int argc, char **argv) Link Here
433
	int i, average = 1;
545
	int i, average = 1;
434
	char do_time, do_list, do_unlist, do_sync, do_current, do_human_readable = 0;
546
	char do_time, do_list, do_unlist, do_sync, do_current, do_human_readable = 0;
435
	char *opt_logfile;
547
	char *opt_logfile;
548
	short repo;
549
	char repo_search[64];
436
	const char *logfile = QLOP_DEFAULT_LOGFILE;
550
	const char *logfile = QLOP_DEFAULT_LOGFILE;
551
	overlay_t *overlay_tmp;
437
552
438
	DBG("argc=%d argv[0]=%s argv[1]=%s",
553
	DBG("argc=%d argv[0]=%s argv[1]=%s",
439
		argc, argv[0], argc > 1 ? argv[1] : "NULL?");
554
		argc, argv[0], argc > 1 ? argv[1] : "NULL?");
440
555
441
	opt_logfile = NULL;
556
	opt_logfile = NULL;
557
	repo = 0;
558
	repo_search[0] = 0;
442
	do_time = do_list = do_unlist = do_sync = do_current = 0;
559
	do_time = do_list = do_unlist = do_sync = do_current = 0;
443
560
444
	while ((i = GETOPT_LONG(QLOP, qlop, "")) != -1) {
561
	while ((i = GETOPT_LONG(QLOP, qlop, "")) != -1) {
Lines 448-454 int qlop_main(int argc, char **argv) Link Here
448
			case 't': do_time = 1; break;
565
			case 't': do_time = 1; break;
449
			case 'l': do_list = 1; break;
566
			case 'l': do_list = 1; break;
450
			case 'u': do_unlist = 1; break;
567
			case 'u': do_unlist = 1; break;
451
			case 's': do_sync = 1; break;
568
			case 's':
569
				if (do_sync) err("Only use -s or -S once");
570
				do_sync = 1;
571
				break;
572
			case 'o':
573
				repo = 1;
574
				strncpy(repo_search, optarg, sizeof(repo_search));
575
				break;
452
			case 'c': do_current = 1; break;
576
			case 'c': do_current = 1; break;
453
			case 'g': do_time = 1; average = 0; break;
577
			case 'g': do_time = 1; average = 0; break;
454
			case 'H': do_human_readable = 1; break;
578
			case 'H': do_human_readable = 1; break;
Lines 458-463 int qlop_main(int argc, char **argv) Link Here
458
				break;
582
				break;
459
		}
583
		}
460
	}
584
	}
585
	if (repo) {
586
		overlay_tmp = first_overlay;
587
		do {
588
			if (!strncmp(overlay_tmp->name, repo_search, sizeof(overlay_tmp->name)))
589
				break;
590
		} while ((overlay_tmp=overlay_tmp->next));
591
		if (NULL == overlay_tmp)
592
			err("%s : Unknown overlay, try 'q --ls-overlays'", repo_search);
593
	}
594
461
	if (!do_list && !do_unlist && !do_time && !do_sync && !do_current)
595
	if (!do_list && !do_unlist && !do_time && !do_sync && !do_current)
462
		qlop_usage(EXIT_FAILURE);
596
		qlop_usage(EXIT_FAILURE);
463
	if (opt_logfile != NULL)
597
	if (opt_logfile != NULL)
Lines 467-485 int qlop_main(int argc, char **argv) Link Here
467
	argv += optind;
601
	argv += optind;
468
602
469
	if (do_list && do_unlist)
603
	if (do_list && do_unlist)
470
		show_emerge_history(QLOP_LIST | QLOP_UNLIST, argc, argv, logfile);
604
		show_emerge_history(QLOP_LIST | QLOP_UNLIST, repo, repo_search,argc, argv, logfile);
471
	else if (do_list)
605
	else if (do_list)
472
		show_emerge_history(QLOP_LIST, argc, argv, logfile);
606
		show_emerge_history(QLOP_LIST, repo, repo_search, argc, argv, logfile);
473
	else if (do_unlist)
607
	else if (do_unlist)
474
		show_emerge_history(QLOP_UNLIST, argc, argv, logfile);
608
		show_emerge_history(QLOP_UNLIST, repo, repo_search, argc, argv, logfile);
475
	if (do_current)
609
	if (do_current)
476
		show_current_emerge();
610
		show_current_emerge();
477
	if (do_sync)
611
	if (do_sync)
478
		show_sync_history(logfile);
612
		show_sync_history(logfile, repo, repo_search);
479
613
480
	if (do_time) {
614
	if (do_time) {
481
		for (i = 0; i < argc; ++i)
615
		for (i = 0; i < argc; ++i)
482
			show_merge_times(argv[i], logfile, average, do_human_readable);
616
			show_merge_times(argv[i], repo, repo_search, logfile, average, do_human_readable);
483
	}
617
	}
484
618
485
	if (opt_logfile) free(opt_logfile);
619
	if (opt_logfile) free(opt_logfile);
Lines 490-492 int qlop_main(int argc, char **argv) Link Here
490
#else
624
#else
491
DEFINE_APPLET_STUB(qlop)
625
DEFINE_APPLET_STUB(qlop)
492
#endif
626
#endif
627
/* vim: set noet sts=8 sw=8 : */
628
(-)portage-utils-20070115.new/qsearch.c (-4 / +4 lines)
Lines 100-106 int qsearch_main(int argc, char **argv) Link Here
100
	}
100
	}
101
101
102
	last[0] = 0;
102
	last[0] = 0;
103
	fp = fopen(initialize_flat(search_cache), "r");
103
	fp = fopen(initialize_flat(search_cache, 0), "r");
104
	if (!fp)
104
	if (!fp)
105
		return 1;
105
		return 1;
106
106
Lines 137-143 int qsearch_main(int argc, char **argv) Link Here
137
						if (chdir(cur_overlay->path) != 0) {
137
						if (chdir(cur_overlay->path) != 0) {
138
							warnp("chdir to '%s' failed", cur_overlay->path);
138
							warnp("chdir to '%s' failed", cur_overlay->path);
139
							myerror = 1;
139
							myerror = 1;
140
							continue;
141
						} else
140
						} else
142
							bad_overlay = 0;
141
							bad_overlay = 0;
143
						break;
142
						break;
Lines 145-151 int qsearch_main(int argc, char **argv) Link Here
145
						if (chdir(cur_overlay->cache) != 0) {
144
						if (chdir(cur_overlay->cache) != 0) {
146
							warnp("chdir to '%s' failed, skipping the %s repository", cur_overlay->cache, cur_overlay->name);
145
							warnp("chdir to '%s' failed, skipping the %s repository", cur_overlay->cache, cur_overlay->name);
147
							myerror = 1;
146
							myerror = 1;
148
							continue;
149
						} else
147
						} else
150
							bad_overlay = 0;
148
							bad_overlay = 0;
151
						break;
149
						break;
Lines 154-160 int qsearch_main(int argc, char **argv) Link Here
154
					myerror = 1;
152
					myerror = 1;
155
				strncpy(overlay_name, p+2, sizeof(overlay_name));
153
				strncpy(overlay_name, p+2, sizeof(overlay_name));
156
			}
154
			}
157
		} else
155
		} else 
158
			myerror++;
156
			myerror++;
159
157
160
		if (myerror) {
158
		if (myerror) {
Lines 271-273 no_cache_ebuild_match: Link Here
271
#else
269
#else
272
DEFINE_APPLET_STUB(qsearch)
270
DEFINE_APPLET_STUB(qsearch)
273
#endif
271
#endif
272
/* vim: set noet sts=8 sw=8 : */
273
(-)portage-utils-20070115.new/qsize.c (-8 / +9 lines)
Lines 68-77 int qsize_main(int argc, char **argv) Link Here
68
	if ((argc == optind) && !search_all)
68
	if ((argc == optind) && !search_all)
69
		qsize_usage(EXIT_FAILURE);
69
		qsize_usage(EXIT_FAILURE);
70
70
71
	if (chdir(portroot))
71
	if (chdir(portvdb))
72
		errp("could not chdir(%s) for ROOT", portroot);
72
		errp("could not chdir(%s) for VDB", portvdb);
73
73
74
	if (chdir(portvdb) != 0 || (dir = opendir(".")) == NULL)
74
	if ((dir = opendir(".")) == NULL)
75
		return EXIT_FAILURE;
75
		return EXIT_FAILURE;
76
76
77
	num_all_bytes = num_all_files = num_all_nonfiles = 0;
77
	num_all_bytes = num_all_files = num_all_nonfiles = 0;
Lines 91-99 int qsize_main(int argc, char **argv) Link Here
91
91
92
			/* see if this cat/pkg is requested */
92
			/* see if this cat/pkg is requested */
93
			if (!search_all) {
93
			if (!search_all) {
94
				snprintf(buf, sizeof(buf), "%s/%s::%s", dentry->d_name,
95
					 de->d_name, grab_vdb_item("REPOSITORY", dentry->d_name, de->d_name));
94
				for (i = optind; i < argc; ++i) {
96
				for (i = optind; i < argc; ++i) {
95
					snprintf(buf, sizeof(buf), "%s/%s", dentry->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 103-109 int qsize_main(int argc, char **argv) Link Here
103
					continue;
103
					continue;
104
			}
104
			}
105
105
106
			snprintf(buf, sizeof(buf), "%s%s/%s/%s/CONTENTS", portroot, portvdb,
106
			snprintf(buf, sizeof(buf), "%s/%s/%s/CONTENTS", 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;
Lines 128-135 int qsize_main(int argc, char **argv) Link Here
128
			num_all_files += num_files;
128
			num_all_files += num_files;
129
			num_all_nonfiles += num_nonfiles;
129
			num_all_nonfiles += num_nonfiles;
130
			if (!summary_only) {
130
			if (!summary_only) {
131
				printf("%s%s/%s%s%s: %lu files, %lu non-files, ", BOLD,
131
				printf("%s%s/%s%s%s::%s%s : %lu files, %lu non-files, ", BOLD,
132
				       basename(dentry->d_name), BLUE, de->d_name, NORM,
132
				       basename(dentry->d_name), BLUE, de->d_name, 
133
				       YELLOW, grab_vdb_item("REPOSITORY", dentry->d_name, de->d_name), NORM,
133
				       (unsigned long)num_files,
134
				       (unsigned long)num_files,
134
				       (unsigned long)num_nonfiles);
135
				       (unsigned long)num_nonfiles);
135
				if (disp_units)
136
				if (disp_units)
(-)portage-utils-20070115.new/quse.c (-1 / +3 lines)
Lines 305-311 int quse_main(int argc, char **argv) Link Here
305
	if (idx == -1)
305
	if (idx == -1)
306
		return quse_describe_flag(optind, repo, repo_search, argc, argv);
306
		return quse_describe_flag(optind, repo, repo_search, argc, argv);
307
307
308
	initialize_ebuild_flat();	/* sets our pwd to $PORTDIR */
308
	initialize_ebuild_flat(0);	/* sets our pwd to $PORTDIR */
309
309
310
	search_len = strlen(search_vars[idx]);
310
	search_len = strlen(search_vars[idx]);
311
	assert(search_len < sizeof(buf0));
311
	assert(search_len < sizeof(buf0));
Lines 523-525 int quse_main(int argc, char **argv) Link Here
523
#else
523
#else
524
DEFINE_APPLET_STUB(quse)
524
DEFINE_APPLET_STUB(quse)
525
#endif
525
#endif
526
/* vim: set noet sts=8 sw=8 : */
527

Return to bug 154405