View | Details | Raw Unified
Collapse All | Expand All

(-) portage-utils-20070115.new/applet-list (-4 lines)
 Lines 1-15    Link Here 
qatom
qatom
qcache
qcheck
qcheck
qdepends
qdepends
qfile
qfile
qglsa
qgrep
qgrep
qlist
qlist
qlop
qlop
qmerge
qpkg
qpkg
qpy
qsearch
qsearch
qsize
qsize
qtbz2
qtbz2
(-) portage-utils-20070115.new/applets.h (-7 / +7 lines)
 Lines 29-37   DECLARE_APPLET(qxpak) Link Here 
DECLARE_APPLET(qpkg)
DECLARE_APPLET(qpkg)
DECLARE_APPLET(qgrep)
DECLARE_APPLET(qgrep)
DECLARE_APPLET(qatom)
DECLARE_APPLET(qatom)
DECLARE_APPLET(qmerge)
DECLARE_APPLET(qmerge) /* disable */
DECLARE_APPLET(qcache)
DECLARE_APPLET(qcache) /* disable */
DECLARE_APPLET(qpy)
DECLARE_APPLET(qpy) /* disable */
DECLARE_APPLET(qglsa) /* disable */
DECLARE_APPLET(qglsa) /* disable */
#undef DECLARE_APPLET
#undef DECLARE_APPLET
 Lines 49-70   struct applet_t { Link Here 
	/* q must always be the first applet */
	/* q must always be the first applet */
	{"q",         q_main,         "<applet> <args>", "virtual applet"},
	{"q",         q_main,         "<applet> <args>", "virtual applet"},
	{"qatom",     qatom_main,     "<pkg>",           "split atom strings"},
	{"qatom",     qatom_main,     "<pkg>",           "split atom strings"},
	{"qcache",    qcache_main,    "<action> <args>", "search the metadata cache"},
	{"qcheck",    qcheck_main,    "<pkgname>",       "verify mtimes/digests"},
	{"qcheck",    qcheck_main,    "<pkgname>",       "verify mtimes/digests"},
	{"qdepends",  qdepends_main,  "<pkgname>",       "show dependency info"},
	{"qdepends",  qdepends_main,  "<pkgname>",       "show dependency info"},
	{"qfile",     qfile_main,     "<filename>",      "list all pkgs owning files"},
	{"qfile",     qfile_main,     "<filename>",      "list all pkgs owning files"},
	{"qglsa",     qglsa_main,     "<action> <list>", "check GLSAs against system"},
	{"qgrep",     qgrep_main,     "<misc args>",     "grep in ebuilds"},
	{"qgrep",     qgrep_main,     "<misc args>",     "grep in ebuilds"},
	{"qlist",     qlist_main,     "<pkgname>",       "list files owned by pkgname"},
	{"qlist",     qlist_main,     "<pkgname>",       "list files owned by pkgname"},
	{"qlop",      qlop_main,      "<pkgname>",       "emerge log analyzer"},
	{"qlop",      qlop_main,      "<pkgname>",       "emerge log analyzer"},
	{"qmerge",    qmerge_main,    "<pkgnames>",      "fetch and merge binary package"},
	{"qpkg",      qpkg_main,      "<misc args>",     "manipulate Gentoo binpkgs"},
	{"qpkg",      qpkg_main,      "<misc args>",     "manipulate Gentoo binpkgs"},
	{"qpy",      qpy_main,      "<misc args>",     "python interface"},
	{"qsearch",   qsearch_main,   "<regex>",         "search pkgname/desc"},
	{"qsearch",   qsearch_main,   "<regex>",         "search pkgname/desc"},
	{"qsize",     qsize_main,     "<pkgname>",       "calculate size usage"},
	{"qsize",     qsize_main,     "<pkgname>",       "calculate size usage"},
	{"qtbz2",     qtbz2_main,     "<misc args>",     "manipulate tbz2 packages"},
	{"qtbz2",     qtbz2_main,     "<misc args>",     "manipulate tbz2 packages"},
	{"quse",      quse_main,      "<useflag>",       "find pkgs using useflags"},
	{"quse",      quse_main,      "<useflag>",       "find pkgs using useflags"},
	{"qxpak",     qxpak_main,     "<misc args>",     "manipulate xpak archives"},
	{"qxpak",     qxpak_main,     "<misc args>",     "manipulate xpak archives"},
	{"qcache",    qcache_main,    "<action> <args>", NULL},		/* "search the metadata cache" */
	{"qglsa",     qglsa_main,     "<action> <list>", NULL},		/* "check GLSAs against system" */
	{"qmerge",    qmerge_main,    "<pkgnames>",      NULL},		/* "fetch and merge binary package" */
	{"qpy",       qpy_main,       "<misc args>",     NULL},		/* "python interface" */
	/* aliases for equery capatability */
	/* aliases for equery capatability */
(-) portage-utils-20070115.new/main.c (-102 / +223 lines)
 Lines 71-79   int rematch(const char *, const char *, Link Here 
static char *rmspace(char *);
static char *rmspace(char *);
void initialize_portage_env(void);
void initialize_portage_env(void);
void initialize_overlays (char portdir_overlay[]);
void initialize_overlays(void);
void initialize_ebuild_flat(void);
void reinitialize_ebuild_flat(short force);
void reinitialize_ebuild_flat(void);
void reinitialize_as_needed(void);
void reinitialize_as_needed(void);
void cleanup(void);
void cleanup(void);
int lookup_applet_idx(const char *);
int lookup_applet_idx(const char *);
 Lines 86-96   static int quiet = 0; Link Here 
static char pretend = 0;
static char pretend = 0;
static char reinitialize = 0;
static char reinitialize = 0;
static char reinitialize_metacache = 0;
static char reinitialize_metacache = 0;
static char portarch[20] = "";
/* static char portarch[20] = ""; */
static char portvdb[_Q_PATH_MAX] = "var/db/pkg";
static char portvdb[_Q_PATH_MAX] = "";
static char portcachedir[] = "metadata/cache";
static char cache_file_dir[_Q_PATH_MAX]="var/cache/paludis";
static char portroot[_Q_PATH_MAX] = "/";
static char metacache_file_dir[_Q_PATH_MAX]="var/cache/paludis/metadata";
static char config_protect[_Q_PATH_MAX] = "/etc/";
static char repocachedir[] = "metadata/cache";
static char portroot[_Q_PATH_MAX] = "";
/* static char config_protect[_Q_PATH_MAX] = "/etc/"; */
typedef struct overlay_t overlay_t;
typedef struct overlay_t overlay_t;
struct overlay_t {
struct overlay_t {
 Lines 101-111   struct overlay_t { Link Here 
};
};
static overlay_t *first_overlay = NULL;
static overlay_t *first_overlay = NULL;
/* temporary workaround ? */
static overlay_t *overlay_gentoo = NULL;
static overlay_t *overlay_gentoo = NULL;
char pkgdir[512] = "/usr/portage/packages/";
char pkgdir[512] = "/var/paludis/repositories/gentoo/packages/";
char port_tmpdir[512] = "/var/tmp/portage/";
char port_tmpdir[512] = "/var/tmp/paludis/";
char binhost[512] = PORTAGE_BINHOST;
char binhost[512] = PORTAGE_BINHOST;
char features[512] = "noman noinfo nodoc";
char features[512] = "noman noinfo nodoc";
 Lines 227-233   static void version_barf(const char *Id) Link Here 
# define VERSION "cvs"
# define VERSION "cvs"
#endif
#endif
	printf("portage-utils-%s: compiled on %s\n%s\n"
	printf("portage-utils-%s: compiled on %s\n%s\n"
	       "%s written for Gentoo by <solar and vapier @ gentoo.org>\n",
	       "%s written for Gentoo by <solar and vapier @ gentoo.org>\n"
	       "modified for overlay and paludis compatibility by samuelethiec @ hotmail.com\n",
	       VERSION, __DATE__, Id, argv0);
	       VERSION, __DATE__, Id, argv0);
	exit(EXIT_SUCCESS);
	exit(EXIT_SUCCESS);
}
}
 Lines 479-552   char *strincr_var(const char *name, char Link Here 
	return (char *) value;
	return (char *) value;
}
}
void initialize_overlays (char portdir_overlay[])
void initialize_overlays(void)
{
{
	short merror = 0;
 	short merror = 0, first = 1;
	char buf[BUFSIZE], file[_Q_PATH_MAX], *s, *p, *t;
	int i,j;
	overlay_t *cur_overlay;
 	char *s, *p, *t;
	FILE *repo_nameFP;
 	char buf[BUFSIZE], conffile[_Q_PATH_MAX], confdir[_Q_PATH_MAX], path[_Q_PATH_MAX];
	s = portdir_overlay;
	char location[_Q_PATH_MAX], write_cache[_Q_PATH_MAX], cache[_Q_PATH_MAX], format[32];
 	FILE *CONFFILE, *REPO_NAME;
 	DIR *CONFDIR;
 	struct dirent *f;
	struct stat statcache;
 	overlay_t *cur_overlay;
	struct {
		const char *name;
		const size_t name_len;
		char *value;
		const size_t value_len;
	} vars_to_read[] = {
		/* order is important */
		{"ROOT",	4,	portroot,	sizeof(portroot)},
		{"location",	8,	location,	sizeof(location)},
		{"write_cache",	11,	write_cache,	sizeof(write_cache)},
		{"cache",	5,	cache,		sizeof(cache)},
		{"format",	6,	format,		sizeof(format)}
	};
	first_overlay = xmalloc(sizeof(*first_overlay));
	first_overlay = xmalloc(sizeof(*first_overlay));
	cur_overlay = first_overlay;
  	cur_overlay = first_overlay;
	while (*s) {
 	snprintf(confdir, sizeof(confdir), "%s/etc/paludis/repositories", portroot);
		/* except on the first loop */
		if (s!=portdir_overlay) {
 	if (NULL == (CONFDIR = opendir(confdir)))
			cur_overlay->next = xmalloc (sizeof (*cur_overlay->next));
 		err("%s : could not open directory", confdir);
			cur_overlay = cur_overlay->next;
 	while ((f =  readdir(CONFDIR))) {
		location[0] = 0;
		cache[0] = 0;
		write_cache[0] = 0;
		format[0] = 0;
 		if (f->d_name[0] == '.')
 			continue;
 		snprintf(conffile, sizeof(conffile), "%s/%s", confdir, f->d_name);
 		if (NULL == (CONFFILE = fopen(conffile, "r")))
 			continue;
 		merror = 0;
 		while (fgets(buf, sizeof(buf), CONFFILE )) {
 			rmspace(buf);
 			if (*buf == '#' || *buf == '\0')
 				continue;
			for (i=1; i<ARR_SIZE(vars_to_read); ++i) {
				if (buf[vars_to_read[i].name_len] != '=' && buf[vars_to_read[i].name_len] != ' ')
					continue;
				if (strncmp(buf, vars_to_read[i].name, vars_to_read[i].name_len))
					continue;
				/* make sure we handle spaces between the varname, the =, and the value:
				 * VAR=val   VAR = val   VAR="val"
				 */
				s = buf + vars_to_read[i].name_len;
				if ((p = strchr(s, '=')) != NULL)
					s = p + 1;
				while (isspace(*s))
					++s;
				if (*s == '"' || *s == '\'') {
					++s;
					s[strlen(s)-1] = '\0';
				}
				strncpy(vars_to_read[i].value, s, vars_to_read[i].value_len);
			}
 		}
 		fclose(CONFFILE);
 		if (!format[0])
 			continue;
		/* delete trailing '/' */
		for (i=0; i<ARR_SIZE(vars_to_read); ++i) {
			if ((p = strrchr(vars_to_read[i].value, '/')) && (p+1) && *(p+1)==0)
				*p = 0;
		}
		}
		cur_overlay->next = NULL;
		if ((p=strchr(s,' ')))
		if (strncmp(format, "ebuild", sizeof(format)) && strncmp(format, "vdb", sizeof(format)))
			*p = 0;
			continue;
		snprintf(cur_overlay->path, sizeof(cur_overlay->path), "%s%s", (strcmp(portroot, "/") ? portroot : ""), s);
		/* if the path begins with a variable such as ${ROOT}, $ROOT, or $location and so on
		 * we try to replace it with its value */
		for (i=1; i<ARR_SIZE(vars_to_read); ++i) {
			path[0] = 0;
			if (vars_to_read[i].value[0] == '$') {
				p = strchr(vars_to_read[i].value, '/');
				*p = 0;
				if (vars_to_read[i].value[1]=='{' && *(p-1)=='}') {
					*(p-1) = 0;
					s = &vars_to_read[i].value[2];
				} else
					s = &vars_to_read[i].value[1];
				for (j=0; j<ARR_SIZE(vars_to_read); ++j)
					if (!strcmp(s, vars_to_read[j].name)) {
						strcpy(path, vars_to_read[j].value);
						break;
					}
		/* find the name for the overlay */
				/* put the slash back */
		snprintf(file, sizeof(file), "%s/profiles/repo_name", cur_overlay->path);
				*p = '/';
				strncat(path, p, sizeof(path));
				strcpy(vars_to_read[i].value, path);
			}
		}
		if ((repo_nameFP = fopen(file, "r"))) {
		/* vdb location defined in etc/paludis/repositories/installed.conf */
			if (!(fgets(buf, sizeof(buf),repo_nameFP)))
		if (!strcmp("installed.conf", f->d_name) && !strcmp("vdb", format)) {
				merror++;
			strncpy(portvdb, location, sizeof(portvdb));
			rmspace(buf);
			continue;
			if ((t = strchr(buf,'\n')))
		}
				*t = 0;
			strncpy(cur_overlay->name, buf, sizeof(cur_overlay->name));
			fclose(repo_nameFP);
 		if (!first) {
		} else
			cur_overlay->next = xmalloc(sizeof(*(cur_overlay->next)));
			merror++;
			cur_overlay = cur_overlay->next;
		if (merror) {
			/* delete trailing '/' */
			t = cur_overlay->path + strlen(cur_overlay->path) - 1;
			if (*t == '/')
				*t = 0;
			strncpy(file, cur_overlay->path, sizeof(file));
			strncpy(cur_overlay->name, basename(file), sizeof(cur_overlay->name));
			merror=0;
		}
		}
 		cur_overlay->next = NULL;
		cur_overlay->cache[0] = 0;
		if (!strncmp(cur_overlay->name, "gentoo", sizeof(cur_overlay->name))) {
		/* time to search for the overlay->name */
			snprintf(cur_overlay->cache, sizeof(cur_overlay->cache), "%s/%s", cur_overlay->path, portcachedir);
 		snprintf(conffile, sizeof(conffile), "%s/profiles/repo_name", location);
 		if (NULL != (REPO_NAME = fopen(conffile, "r"))) {
 			if (!(fgets(buf, sizeof(buf),REPO_NAME)))
 				merror++;
 			rmspace(buf);
 			if ((t = strchr(buf,'\n')))
  				*t = 0;
			strncpy(cur_overlay->name, buf, sizeof(cur_overlay->name));
 			fclose(REPO_NAME);
 		} else {
 			strcpy(cur_overlay->name, "x-");
			/* there is no trailing '/' */
			if ((p=strrchr(location,'/')))
				p = p+1;
			else
				p = location;
 			strncat(cur_overlay->name, p, sizeof(cur_overlay->name));
 		}
		if (!strcmp(cur_overlay->name, "gentoo"))
			overlay_gentoo = cur_overlay;
			overlay_gentoo = cur_overlay;
		} else
		strncpy(cur_overlay->path, location, sizeof(cur_overlay->path));
		if (!cache[0])
			snprintf(cache, sizeof(cache), "%s/%s", location, repocachedir);
		/* now we fill cur_overlay->cache */
		if (!strstr(cache, "/var/empty")) {
			if (stat(cache, &statcache) != -1 && S_ISDIR(statcache.st_mode))
				strcpy(cur_overlay->cache, cache);
			else {
				if (*write_cache) {
					snprintf(cache, sizeof(cache), "%s/%s", write_cache, cur_overlay->name);
					if (stat(cache, &statcache) != -1 && S_ISDIR(statcache.st_mode))
						strncpy(cur_overlay->cache, cache, sizeof(cur_overlay->cache));
					else
						strncpy(cur_overlay->cache, "/var/empty", sizeof(cur_overlay->cache));
				} else
					strncpy(cur_overlay->cache, "/var/empty", sizeof(cur_overlay->cache));
			}
 		} else
			strcpy(cur_overlay->cache, "/var/empty");
			strcpy(cur_overlay->cache, "/var/empty");
		if (p)
		/* once we get there we have at least done with the first overlay */
			s = p+1; /* because portdir_overlay has no trailing space */
		if (first)
		else
			first = 0;
			break;
	}
	}
 	closedir(CONFDIR);
}
}
void initialize_portage_env(void)
void initialize_portage_env(void)
{
{
	char nocolor = 0;
	char nocolor = 0;
	int i, f;
	int i;
	char *s;
	char tmp[_Q_PATH_MAX];
/*
	struct stat st;
	struct stat st;
	FILE *fp;
	FILE *fp;
	char tmp_portdir[_Q_PATH_MAX];
	char tmp_portdir[_Q_PATH_MAX];
 Lines 556-561   void initialize_portage_env(void) Link Here 
	char portdir_overlay[BUFSIZE] = "";
	char portdir_overlay[BUFSIZE] = "";
	const char *files[] = {portage_file, "/etc/make.globals", "/etc/make.conf"};
	const char *files[] = {portage_file, "/etc/make.globals", "/etc/make.conf"};
*/
	typedef enum { _Q_BOOL, _Q_STR, _Q_ISTR } var_types;
	typedef enum { _Q_BOOL, _Q_STR, _Q_ISTR } var_types;
	struct {
	struct {
 Lines 565-571   void initialize_portage_env(void) Link Here 
		char *value;
		char *value;
		const size_t value_len;
		const size_t value_len;
	} vars_to_read[] = {
	} vars_to_read[] = {
		{"ACCEPT_LICENSE",   14, _Q_STR,  accept_license, sizeof(accept_license)},
/*		{"ACCEPT_LICENSE",   14, _Q_STR,  accept_license, sizeof(accept_license)},
		{"INSTALL_MASK",     12, _Q_ISTR, install_mask,   sizeof(install_mask)},
		{"INSTALL_MASK",     12, _Q_ISTR, install_mask,   sizeof(install_mask)},
		{"ARCH",              4, _Q_STR,  portarch,       sizeof(portarch)},
		{"ARCH",              4, _Q_STR,  portarch,       sizeof(portarch)},
		{"CONFIG_PROTECT",   14, _Q_STR,  config_protect, sizeof(config_protect)},
		{"CONFIG_PROTECT",   14, _Q_STR,  config_protect, sizeof(config_protect)},
 Lines 576-588   void initialize_portage_env(void) Link Here 
		{"PORTAGE_BINHOST",  15, _Q_STR,  binhost,        sizeof(binhost)},
		{"PORTAGE_BINHOST",  15, _Q_STR,  binhost,        sizeof(binhost)},
		{"PORTAGE_TMPDIR",   14, _Q_STR,  port_tmpdir,    sizeof(port_tmpdir)},
		{"PORTAGE_TMPDIR",   14, _Q_STR,  port_tmpdir,    sizeof(port_tmpdir)},
		{"PKGDIR",            6, _Q_STR,  pkgdir,         sizeof(pkgdir)},
		{"PKGDIR",            6, _Q_STR,  pkgdir,         sizeof(pkgdir)},
*/
		{"ROOT",              4, _Q_STR,  portroot,       sizeof(portroot)}
		{"ROOT",              4, _Q_STR,  portroot,       sizeof(portroot)}
	};
	};
	if ((p = strchr(portroot, '/')) != NULL)
#if 0
		if (strlen(p) != 1)
			strncat(portroot, "/", sizeof(portroot));
	f = 0;
	f = 0;
	if (readlink("/etc/make.profile", profile, sizeof(profile)) == -1)
	if (readlink("/etc/make.profile", profile, sizeof(profile)) == -1)
		strcpy(profile, "/etc/make.profile");
		strcpy(profile, "/etc/make.profile");
 Lines 643-648   void initialize_portage_env(void) Link Here 
			f = 1;
			f = 1;
		}
		}
	} while (1);
	} while (1);
#endif
	/* finally, check the env */
	/* finally, check the env */
	for (i=0; i<ARR_SIZE(vars_to_read); ++i) {
	for (i=0; i<ARR_SIZE(vars_to_read); ++i) {
 Lines 671-682   void initialize_portage_env(void) Link Here 
	else
	else
		color_remap();
		color_remap();
	snprintf(tmp_portdir, sizeof(tmp_portdir), "%s/%s", (strcmp(portroot, "/") ? portroot : ""), portvdb);
	snprintf(tmp,sizeof(tmp),"%s/%s", portroot, cache_file_dir);
	strncpy(portvdb, tmp_portdir, sizeof(portvdb));
	strcpy(cache_file_dir, tmp);
	strincr_var("PORTDIR_OVERLAY", tmp_portdir, portdir_overlay, sizeof(portdir_overlay));
	snprintf(tmp,sizeof(tmp),"%s/%s", portroot, metacache_file_dir);
	strcpy(metacache_file_dir, tmp);
	/* now we initiliase the overlay chained list */
	/* now we initiliase the overlay chained list */
	initialize_overlays(portdir_overlay);
	initialize_overlays();
}
}
 Lines 694-702   int filter_hidden(const struct dirent *d Link Here 
}
}
#define CACHE_EBUILD_FILE (getenv("CACHE_EBUILD_FILE") ? getenv("CACHE_EBUILD_FILE") : ".ebuild.x")
#define CACHE_EBUILD_FILE (getenv("CACHE_EBUILD_FILE") ? getenv("CACHE_EBUILD_FILE") : ".ebuild.x")
#define CACHE_METADATA_FILE ".metadata.x"
#define CACHE_METADATA_FILE (getenv("CACHE_METADATA_FILE") ? getenv("CACHE_METADATA_FILE") : ".metadata.x")
const char *initialize_flat(int cache_type);
const char *initialize_flat(int cache_type, short force);
const char *initialize_flat(int cache_type)
const char *initialize_flat(int cache_type, short force)
{
{
	struct dirent **category, **pn, **eb;
	struct dirent **category, **pn, **eb;
	struct stat st;
	struct stat st;
 Lines 714-752   const char *initialize_flat(int cache_ty Link Here 
	cache_file = (cache_type == CACHE_EBUILD ? CACHE_EBUILD_FILE : CACHE_METADATA_FILE);
	cache_file = (cache_type == CACHE_EBUILD ? CACHE_EBUILD_FILE : CACHE_METADATA_FILE);
	/* SAM review without gentoo! */
 	if (cache_type == CACHE_METADATA) {
	if (cache_type == CACHE_METADATA) {
 		if (chdir(metacache_file_dir) != 0) {
		if (chdir(overlay_gentoo->cache) != 0) {
 			warnp("chdir to cache '%s' failed", metacache_file_dir);
			warnp("chdir to portage cache '%s' failed", overlay_gentoo->cache);
 			goto ret;
			goto ret;
 		}
		}
 	} else {
	} else {
 		if (chdir(cache_file_dir) != 0) {
		if (chdir(overlay_gentoo->path) != 0) {
 			warnp("chdir to '%s' failed", cache_file_dir);
			warnp("chdir to PORTDIR '%s' failed", overlay_gentoo->path);
 			goto ret;
			goto ret;
 		}
		}
	}
	}
	if ((stat(cache_file, &st)) != (-1))
	if ((stat(cache_file, &st)) != (-1)) {
		if (st.st_size == 0)
		if (force || st.st_size == 0)
			unlink(cache_file);
			unlink(cache_file);
		else
			goto ret;
	}
	/* assuming --sync is used with --delete this will get recreated after every merge */
	if (access(cache_file, R_OK) == 0)
		goto ret;
	if (!quiet)
	if (!quiet)
		warn("Updating ebuild %scache ... ", cache_type == CACHE_EBUILD ? "" : "meta");
		warn("Updating ebuild %scache ... ", cache_type == CACHE_EBUILD ? "" : "meta");
	unlink(cache_file);
	unlink(cache_file);
	if (errno != ENOENT) {
	if (errno != ENOENT) {
		/* SAM review without gentoo! */
		warnfp("unlinking '%s/%s' failed", (cache_type == CACHE_EBUILD ? cache_file_dir : metacache_file_dir), cache_file);
		warnfp("unlinking '%s/%s' failed", overlay_gentoo->path, cache_file);
		warn("define CACHE_METADATA_FILE and/or CACHE_EBUILD_FILE to use different cache file");
		goto ret;
		goto ret;
	}
	}
	/* SAM review without gentoo! */
	if ((fp = fopen(cache_file, "w")) == NULL) {
	if ((fp = fopen(cache_file, "w")) == NULL) {
		warnfp("opening '%s/%s' failed", (cache_type == CACHE_EBUILD ? overlay_gentoo->path : overlay_gentoo->cache), cache_file);
		warnfp("opening '%s/%s' failed", (cache_type == CACHE_EBUILD ? cache_file_dir : metacache_file_dir), cache_file);
		goto ret;
		goto ret;
	}
	}
 Lines 799-804   const char *initialize_flat(int cache_ty Link Here 
					break;
					break;
				case CACHE_METADATA:
				case CACHE_METADATA:
					if (S_ISREG(st.st_mode))
					if (S_ISREG(st.st_mode))
						count++;
						fprintf(fp, "%s::%s\n", de, cur_overlay->name);
						fprintf(fp, "%s::%s\n", de, cur_overlay->name);
					continue;
					continue;
					break;
					break;
 Lines 842-866   const char *initialize_flat(int cache_ty Link Here 
ret:
ret:
	return cache_file;
	return cache_file;
}
}
#define initialize_ebuild_flat() initialize_flat(CACHE_EBUILD)
#define initialize_ebuild_flat(force) initialize_flat(CACHE_EBUILD, force)
#define initialize_metadata_flat() initialize_flat(CACHE_METADATA)
#define initialize_metadata_flat(force) initialize_flat(CACHE_METADATA, force)
void reinitialize_ebuild_flat(void)
void reinitialize_ebuild_flat(short force)
{
{
	if ((chdir(first_overlay->path)) != 0) {
	if ((chdir(first_overlay->path)) != 0) {
		warnp("chdir to PORTDIR '%s' failed", first_overlay->path);
		warnp("chdir to PORTDIR '%s' failed", first_overlay->path);
		return;
		return;
	}
	}
	unlink(CACHE_EBUILD_FILE);
	unlink(CACHE_EBUILD_FILE);
	initialize_ebuild_flat();
	initialize_ebuild_flat(force);
}
}
void reinitialize_as_needed(void)
void reinitialize_as_needed(void)
{
{
	if (reinitialize)
	if (reinitialize)
		reinitialize_ebuild_flat();
		reinitialize_ebuild_flat(1);
	if (reinitialize_metacache)
	if (reinitialize_metacache)
		initialize_metadata_flat();
		initialize_metadata_flat(1);
}
}
typedef struct {
typedef struct {
 Lines 1039-1045   char *grab_vdb_item(const char *item, co Link Here 
	char *p;
	char *p;
	FILE *fp;
	FILE *fp;
	snprintf(buf, sizeof(buf), "%s%s/%s/%s/%s", portroot, portvdb, CATEGORY, PF, item);
	snprintf(buf, sizeof(buf), "%s/%s/%s/%s", portvdb, CATEGORY, PF, item);
	if ((fp = fopen(buf, "r")) == NULL)
	if ((fp = fopen(buf, "r")) == NULL)
		return NULL;
		return NULL;
	fgets(buf, sizeof(buf), fp);
	fgets(buf, sizeof(buf), fp);
 Lines 1070-1078   queue *get_vdb_atoms(void) Link Here 
	assert(chdir(savecwd) == 0);
	assert(chdir(savecwd) == 0);
	if (chdir(portroot) != 0)
		goto fuckit;
	if (chdir(portvdb) != 0)
	if (chdir(portvdb) != 0)
		goto fuckit;
		goto fuckit;
 Lines 1167-1169   int main(int argc, char **argv) Link Here 
}
}
#include "include_applets.h"
#include "include_applets.h"
/* vim: set noet sts=8 sw=8 : */
(-) portage-utils-20070115.new/man/qlop.1 (-1 / +6 lines)
 Lines 5-11   qlop \- emerge log analyzer Link Here 
.B qlop
.B qlop
\fI<pkgname>\fR
\fI<pkgname>\fR
.SH DESCRIPTION
.SH DESCRIPTION
Options: \fB\-[gtluscf:F:HvqChV]\fR
Options: \fB\-[gtluso:cf\fR:F:HvqChV]
.TP
.TP
\fB\-g\fR, \fB\-\-gauge\fR
\fB\-g\fR, \fB\-\-gauge\fR
* Gauge number of times a package has been merged
* Gauge number of times a package has been merged
 Lines 25-30   Options: \fB\-[gtluscf:F:HvqChV]\fR Link Here 
\fB\-s\fR, \fB\-\-sync\fR
\fB\-s\fR, \fB\-\-sync\fR
* Show sync history
* Show sync history
.TP
.TP
\fB\-o\fR, \fB\-\-overlay\fR
<arg>
.BR
* Only consider the <arg> overlay
.TP
\fB\-c\fR, \fB\-\-current\fR
\fB\-c\fR, \fB\-\-current\fR
* Show current emerging packages
* Show current emerging packages
.TP
.TP
(-) portage-utils-20070115.new/q.c (+2 lines)
 Lines 145-147   int q_main(int argc, char **argv) Link Here 
	return (func)(argc - 1, ++argv);
	return (func)(argc - 1, ++argv);
}
}
/* vim: set noet sts=8 sw=8 : */
(-) portage-utils-20070115.new/qfile.c (-5 lines)
 Lines 543-553   int qfile_main(int argc, char **argv) Link Here 
	if ((args_file == NULL) && (max_args != QFILE_DEFAULT_MAX_ARGS))
	if ((args_file == NULL) && (max_args != QFILE_DEFAULT_MAX_ARGS))
		warn("--max-args is only used when reading arguments from a file (with -f)");
		warn("--max-args is only used when reading arguments from a file (with -f)");
	if (chdir(portroot)) {
		warnp("could not chdir(%s) for ROOT", portroot);
		goto exit;
	}
	if (chdir(portvdb) != 0) {
	if (chdir(portvdb) != 0) {
		warnp("could not chdir(ROOT/%s) for installed packages database", portvdb);
		warnp("could not chdir(ROOT/%s) for installed packages database", portvdb);
		goto exit;
		goto exit;
(-) portage-utils-20070115.new/qfile.c.orig (-5 / +3 lines)
 Lines 600-615   int qfile_main(int argc, char **argv) Link Here 
		if (nb_of_queries < 0)
		if (nb_of_queries < 0)
			goto exit;
			goto exit;
		if (chdir(portroot)
		if (chdir(portvdb) != 0 || (dir = opendir(".")) == NULL) {
				|| chdir(portvdb) != 0
			warnp("could not chdir(%s) for installed packages database", portvdb);
				|| (dir = opendir(".")) == NULL) {
			warnp("could not chdir(ROOT/%s) for installed packages database", portvdb);
			goto exit;
			goto exit;
		}
		}
		/* Iteration over VDB categories */
		/* Iteration over VDB categories */
		while (nb_of_queries && (dentry = q_vdb_get_next_dir(dir))) {
		while (nb_of_queries && (dentry = q_vdb_get_next_dir(dir))) {
			snprintf(path, _Q_PATH_MAX, "%s/%s/%s", qfile_args->real_root, portvdb, dentry->d_name);
			snprintf(path, _Q_PATH_MAX, "%s/%s", portvdb, dentry->d_name);
			qfile(path, (assume_root_prefix ? root_prefix : NULL), qfile_args);
			qfile(path, (assume_root_prefix ? root_prefix : NULL), qfile_args);
		}
		}
(-) portage-utils-20070115.new/qgrep.c (-1 / +3 lines)
 Lines 90-96   int qgrep_main(int argc, char **argv) Link Here 
	if (argc == optind)
	if (argc == optind)
		qgrep_usage(EXIT_FAILURE);
		qgrep_usage(EXIT_FAILURE);
	initialize_ebuild_flat();	/* sets our pwd to $PORTDIR */
	initialize_ebuild_flat(0);	/* sets our pwd to $PORTDIR */
	if ((fp = fopen(CACHE_EBUILD_FILE, "r")) == NULL)
	if ((fp = fopen(CACHE_EBUILD_FILE, "r")) == NULL)
		return 1;
		return 1;
 Lines 191-193   int qgrep_main(int argc, char **argv) Link Here 
#else
#else
DEFINE_APPLET_STUB(qgrep)
DEFINE_APPLET_STUB(qgrep)
#endif
#endif
/* vim: set noet sts=8 sw=8 : */
(-) portage-utils-20070115.new/qlist.c (-10 / +13 lines)
 Lines 137-142   int qlist_main(int argc, char **argv) Link Here 
	char qlist_all = 0, just_pkgname = 0, dups_only = 0;
	char qlist_all = 0, just_pkgname = 0, dups_only = 0;
	char show_dir, show_obj, show_sym, show_slots, show_umap;
	char show_dir, show_obj, show_sym, show_slots, show_umap;
	struct dirent **de, **cat;
	struct dirent **de, **cat;
	char overlay[64];
	char buf[_Q_PATH_MAX];
	char buf[_Q_PATH_MAX];
	char swap[_Q_PATH_MAX];
	char swap[_Q_PATH_MAX];
	queue *sets = NULL;
	queue *sets = NULL;
 Lines 146-151   int qlist_main(int argc, char **argv) Link Here 
	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
	show_dir = show_obj = show_sym = show_slots = show_umap = 0;
	show_dir = show_obj = show_sym = show_slots = show_umap = 0;
	overlay[0] = 0;
	while ((i = GETOPT_LONG(QLIST, qlist, "")) != -1) {
	while ((i = GETOPT_LONG(QLIST, qlist, "")) != -1) {
		switch (i) {
		switch (i) {
 Lines 168-179   int qlist_main(int argc, char **argv) Link Here 
	if ((argc == optind) && (!just_pkgname))
	if ((argc == optind) && (!just_pkgname))
		qlist_usage(EXIT_FAILURE);
		qlist_usage(EXIT_FAILURE);
	if (chdir(portroot))
		errp("could not chdir(%s) for ROOT", portroot);
	if (chdir(portvdb) != 0)
	if (chdir(portvdb) != 0)
		return EXIT_FAILURE;
		errp("could not chdir(%s) for VDB", portvdb);
	if ((dfd = scandir(".", &cat, filter_hidden, alphasort)) < 0)
	if ((dfd = scandir(".", &cat, filter_hidden, alphasort)) < 0)
		return EXIT_FAILURE;
		return EXIT_FAILURE;
 Lines 223-228   int qlist_main(int argc, char **argv) Link Here 
			if ((i == argc) && (argc != optind))
			if ((i == argc) && (argc != optind))
				continue;
				continue;
			if (verbose>1)
				snprintf(overlay, sizeof(overlay), "::%s",grab_vdb_item("REPOSITORY", cat[j]->d_name, de[x]->d_name));
			if (just_pkgname) {
			if (just_pkgname) {
				if (dups_only) {
				if (dups_only) {
					pkgname = atom_explode(de[x]->d_name);
					pkgname = atom_explode(de[x]->d_name);
 Lines 241-249   int qlist_main(int argc, char **argv) Link Here 
						slot = grab_vdb_item("SLOT", cat[j]->d_name, de[x]->d_name);
						slot = grab_vdb_item("SLOT", cat[j]->d_name, de[x]->d_name);
					/* display it */
					/* display it */
					printf("%s%s/%s%s%s%s%s%s%s", BOLD, cat[j]->d_name, BLUE,
					printf("%s%s/%s%s%s%s%s%s%s%s%s", BOLD, cat[j]->d_name, BLUE,
					       (pkgname ? pkgname->PN : de[x]->d_name), NORM,
					       (pkgname ? pkgname->PN : de[x]->d_name), NORM,
						YELLOW, slot ? " ": "", slot ? slot : "", NORM);
						YELLOW, overlay,
						RED, slot ? " ": "", slot ? slot : "", NORM);
					puts(umapstr(show_umap, cat[j]->d_name, de[x]->d_name));
					puts(umapstr(show_umap, cat[j]->d_name, de[x]->d_name));
				}
				}
				if (pkgname)
				if (pkgname)
 Lines 253-259   int qlist_main(int argc, char **argv) Link Here 
					continue;
					continue;
			}
			}
			snprintf(buf, sizeof(buf), "%s%s/%s/%s/CONTENTS", portroot, portvdb,
			snprintf(buf, sizeof(buf), "%s/%s/%s/CONTENTS", portvdb,
			         cat[j]->d_name, de[x]->d_name);
			         cat[j]->d_name, de[x]->d_name);
			if (verbose > 1)
			if (verbose > 1)
 Lines 311-319   int qlist_main(int argc, char **argv) Link Here 
				char *slot = NULL;
				char *slot = NULL;
				if (show_slots)
				if (show_slots)
					slot = (char *) grab_vdb_item("SLOT", (const char *) atom->CATEGORY, (const char *) atom->P);
					slot = (char *) grab_vdb_item("SLOT", (const char *) atom->CATEGORY, (const char *) atom->P);
				printf("%s%s/%s%s%s%s%s%s%s", BOLD, atom->CATEGORY, BLUE,
				printf("%s%s/%s%s%s%s%s%s%s%s%s", BOLD, atom->CATEGORY, BLUE,
					(verbose ? atom->P : atom->PN), NORM,
					(verbose ? atom->P : atom->PN), NORM,
					YELLOW, slot ? " " : "", slot ? slot : "", NORM);
					YELLOW, overlay,
					RED, slot ? " " : "", slot ? slot : "", NORM);
				puts(umapstr(show_umap, atom->CATEGORY, atom->P));
				puts(umapstr(show_umap, atom->CATEGORY, atom->P));
			}
			}
			atom_implode(atom);
			atom_implode(atom);
(-) portage-utils-20070115.new/qlop.c (-90 / +226 lines)
 Lines 21-31    Link Here 
# include <sys/time.h>
# include <sys/time.h>
#endif
#endif
#define QLOP_DEFAULT_LOGFILE "/var/log/emerge.log"
#define QLOP_DEFAULT_LOGFILE "/var/log/paludis.log"
#define QLOP_FLAGS "gtluscf:F:H" COMMON_FLAGS
#define QLOP_FLAGS "gtluso:cf:F:H" COMMON_FLAGS
static struct option const qlop_long_opts[] = {
static struct option const qlop_long_opts[] = {
	{"gauge",     no_argument, NULL, 'g'},
	{"gauge",     no_argument, NULL, 'g'},
	{"time",      no_argument, NULL, 't'},
	{"time",      no_argument, NULL, 't'},
 Lines 33-38   static struct option const qlop_long_opt Link Here 
	{"list",      no_argument, NULL, 'l'},
	{"list",      no_argument, NULL, 'l'},
	{"unlist",    no_argument, NULL, 'u'},
	{"unlist",    no_argument, NULL, 'u'},
	{"sync",      no_argument, NULL, 's'},
	{"sync",      no_argument, NULL, 's'},
	{"overlay",   a_argument,  NULL, 'o'},
	{"current",   no_argument, NULL, 'c'},
	{"current",   no_argument, NULL, 'c'},
	{"logfile",    a_argument, NULL, 'f'},
	{"logfile",    a_argument, NULL, 'f'},
	COMMON_LONG_OPTS
	COMMON_LONG_OPTS
 Lines 44-49   static const char *qlop_opts_help[] = { Link Here 
	"Show merge history",
	"Show merge history",
	"Show unmerge history",
	"Show unmerge history",
	"Show sync history",
	"Show sync history",
	"Do only consider the <arg> repository",
	"Show current emerging packages",
	"Show current emerging packages",
	"Read emerge logfile instead of " QLOP_DEFAULT_LOGFILE,
	"Read emerge logfile instead of " QLOP_DEFAULT_LOGFILE,
	COMMON_OPTS_HELP
	COMMON_OPTS_HELP
 Lines 79-108   static const char *chop_ctime(time_t t) Link Here 
	return ctime_out;
	return ctime_out;
}
}
unsigned long show_merge_times(char *package, const char *logfile, int average, char human_readable);
unsigned long show_merge_times(char *package, const short repo, const char repo_search[], const char *logfile, int average, char human_readable);
unsigned long show_merge_times(char *package, const char *logfile, int average, char human_readable)
unsigned long show_merge_times(char *package, const short repo, const char repo_search[], const char *logfile, int average, char human_readable)
{
{
	FILE *fp;
	FILE *fp;
	char cat[126], buf[2][BUFSIZ];
	char catPN[BUFSIZ], buf[2][BUFSIZ], matched;
	char *pkg, *p;
	char *p, *q;
	unsigned long count, merge_time;
	unsigned long count, merge_time;
	time_t t[2];
	time_t t[2];
	depend_atom *atom;
	depend_atom *atom,*search;
	int l;
	long pos;
	t[0] = t[1] = 0UL;
	t[0] = t[1] = 0UL;
	count = merge_time = 0;
	count = merge_time = 0;
	cat[0] = 0;
	matched = 0;
	pos = 0;
	if ((p = strchr(package, '/')) != NULL) {
	if ((search = atom_explode(package)) == NULL )
		pkg = p + 1;
		err("%s is not a valid atom", package);
		strncpy(cat, package, sizeof(cat));
	if (!search->CATEGORY && !search->PN && !search->OVERLAY)
		if ((p = strchr(cat, '/')) != NULL)
		err("You need to specify at least an overlay, a category, or a package name");
			*p = 0;
	} else {
		pkg = package;
	}
	DBG("Searching for %s in %s\n", pkg, logfile);
	DBG("Searching for %s in %s\n", package, logfile);
	if ((fp = fopen(logfile, "r")) == NULL) {
	if ((fp = fopen(logfile, "r")) == NULL) {
		warnp("Could not open logfile '%s'", logfile);
		warnp("Could not open logfile '%s'", logfile);
 Lines 110-116   unsigned long show_merge_times(char *pac Link Here 
	}
	}
	while ((fgets(buf[0], sizeof(buf[0]), fp)) != NULL) {
	while ((fgets(buf[0], sizeof(buf[0]), fp)) != NULL) {
		if (strstr(buf[0], pkg) == NULL)
		if (matched) {
			matched = 0;
			continue;
		}
		/* len( time:{starting,finished} install of package ) = 41 */
		if (search->CATEGORY && !strstr(&buf[0][40], search->CATEGORY))
			continue;
		if (search->PN && !strstr(&buf[0][40], search->PN))
			continue;
		if (search->OVERLAY && !strstr(&buf[0][40], search->OVERLAY))
			continue;
			continue;
		if ((p = strchr(buf[0], '\n')) != NULL)
		if ((p = strchr(buf[0], '\n')) != NULL)
 Lines 121-200   unsigned long show_merge_times(char *pac Link Here 
		t[0] = atol(buf[0]);
		t[0] = atol(buf[0]);
		strcpy(buf[1], p + 1);
		strcpy(buf[1], p + 1);
		rmspace(buf[1]);
		rmspace(buf[1]);
		if ((strncmp(buf[1], ">>> emerge (", 12)) == 0) {
		if ((strncmp(buf[1], "starting install of package", 26)) == 0) {
			char matched = 0;
			p = &buf[1][28];
			if ((p = strchr(buf[1], ')')) == NULL)
			if (repo && !strstr(p, repo_search))
				continue;
				continue;
			*p = 0;
			strcpy(buf[0], p + 1);
			if ((q = strchr(p, ' ')) == NULL)
			rmspace(buf[0]);
			if ((p = strchr(buf[0], ' ')) == NULL)
				continue;
				continue;
			*p = 0;
			*q = 0;
			strcpy(buf[0], p);
			rmspace(buf[0]);
			if ((atom = atom_explode(buf[0])) == NULL)
			if ((atom = atom_explode(buf[0])) == NULL)
				continue;
				continue;
			if (*cat) {
			if (search->CATEGORY && strcmp(atom->CATEGORY, search->CATEGORY)) {
				if ((strcmp(cat, atom->CATEGORY) == 0) && (strcmp(pkg, atom->PN) == 0))
				atom_implode(atom);
					matched = 1;
				continue;
			} else if (strcmp(pkg, atom->PN) == 0)
			}
				matched = 1;
			if (search->PN && *search->PN && strcmp(atom->PN, search->PN)) {
				atom_implode(atom);
				continue;
			}
			if (search->PV && strcmp(atom->PV, search->PV)) {
				atom_implode(atom);
				continue;
			}
			if (search->PR_int && atom->PR_int!=search->PR_int) {
				atom_implode(atom);
				continue;
			}
			if (search->OVERLAY && strcmp(atom->OVERLAY, search->OVERLAY)) {
				atom_implode(atom);
				continue;
			}
			pos = ftell(fp);
			matched = 1;
			if (matched) {
			if (matched) {
				while ((fgets(buf[0], sizeof(buf[0]), fp)) != NULL) {
				/* In case of simultaneous install, we search the corresponding */
				/* "finished install of package" pkg up to 20 lines after the 'starting line' */
				l=0;
				snprintf(catPN, sizeof(catPN), "%s/%s-%s::%s", atom->CATEGORY, atom->PN, (atom->PR_int ? atom->PVR : atom->PV), atom->OVERLAY);
				while ((fgets(buf[0], sizeof(buf[0]), fp)) != NULL && l++ < 20) {
					if ((p = strchr(buf[0],':')) == NULL)
						continue;
					p = p+2;
					/* Stop the search in case the package is already being reinstalled even in a different version/revision */
					if (!strncmp(p, "starting", 8) && strcmp(p+28, catPN))
						break;
					if (strncmp(p, "finished install of package", 26) != 0)
						continue;
					if (!strcmp(p+28, catPN))
						continue;
					if ((p = strchr(buf[0], '\n')) != NULL)
					if ((p = strchr(buf[0], '\n')) != NULL)
						*p = 0;
						*p = 0;
					if ((p = strchr(buf[0], ':')) == NULL)
					if ((p = strchr(buf[0], ':')) == NULL)
						continue;
						*p = 0;
					*p = 0;
					t[1] = atol(buf[0]);
					t[1] = atol(buf[0]);
					strcpy(buf[1], p + 1);
					strcpy(buf[1], p + 1);
					rmspace(buf[1]);
					rmspace(buf[1]);
					if (*buf[1] == '*')
						break;
					if (!average) {
					if ((strncmp(buf[1], "::: completed emerge (", 22)) == 0) {
						strcpy(buf[1], "");
						if (!average) {
						if (verbose)
							strcpy(buf[1], "");
							snprintf(buf[1], sizeof(buf[1]), "-%s%s::%s ", (atom->PR_int ? atom->PVR : atom->PV), YELLOW, atom->OVERLAY);
							if (verbose) {
								if (atom->PR_int)
						printf("%s%s/%s%s%s%s: %s: ", GREEN, atom->CATEGORY, BLUE, atom->PN, buf[1], NORM, chop_ctime(t[0]));
									snprintf(buf[1], sizeof(buf[1]), "-%s-r%i", atom->PV,  atom->PR_int);
						if (human_readable)
								else
							print_seconds_for_earthlings(t[1] - t[0]);
									snprintf(buf[1], sizeof(buf[1]), "-%s", atom->PV);
						else
							}
							printf("%s%lu%s seconds", GREEN, (t[1] - t[0]), NORM);
							printf("%s%s%s%s: %s: ", BLUE, atom->PN, buf[1], NORM, chop_ctime(t[0]));
						puts("");
							if (human_readable)
								print_seconds_for_earthlings(t[1] - t[0]);
							else
								printf("%s%lu%s seconds", GREEN, (t[1] - t[0]), NORM);
							puts("");
						}
						merge_time += (t[1] - t[0]);
						count++;
						break;
					}
					}
					merge_time += (t[1] - t[0]);
					count++;
					break;
				}
				}
			}
			}
			atom_implode(atom);
			atom_implode(atom);
			/* time to go back where we were */
			fseek(fp, pos, SEEK_SET);
		}
		}
	}
	}
	fclose(fp);
	fclose(fp);
	if (count == 0)
	if (count == 0)
		return 0;
		return 0;
	if (average == 1) {
	if (average == 1) {
		printf("%s%s%s: ", BLUE, pkg, NORM);
		printf("%s%s%s%s%s%s%s%s%s%s%s : ", GREEN, (search->CATEGORY? search->CATEGORY : ""), (search->CATEGORY ? "/": ""),
					BLUE, search->PN, (search->PV ? "-" : ""), (search->PV ? (search->PR_int ? search->PVR : search->PV) : ""),
					YELLOW, (search->OVERLAY ? "::" : ""), (search->OVERLAY ? search->OVERLAY : ""), NORM);
		if (human_readable)
		if (human_readable)
			print_seconds_for_earthlings(merge_time / count);
			print_seconds_for_earthlings(merge_time / count);
		else
		else
			printf("%s%lu%s seconds average", GREEN, merge_time / count, NORM);
			printf("%s%lu%s seconds", GREEN, merge_time / count, NORM);
		printf(" for %s%lu%s merges\n", GREEN, count, NORM);
		printf(" average for %s%lu%s merges%s", GREEN, count, NORM, (verbose ? ", for a total time of " : ""));
		if (verbose) {
			if (human_readable)
				print_seconds_for_earthlings(merge_time);
			else
				printf("%s%lu%s seconds", GREEN, merge_time, NORM);
		}
		fputc('\n', stdout);
	} else {
	} else {
		printf("%s%s%s: %s%lu%s times\n", BLUE, pkg, NORM, GREEN, count, NORM);
		printf("%s%s%s%s%s%s%s%s%s%s%s : %s%lu%s times%s", GREEN, (search->CATEGORY ? search->CATEGORY : ""), (search->CATEGORY ? "/": ""),
							BLUE, (search->PN ? search->PN : ""),  (search->PV ? "-" : ""), (search->PV ? (search->PR_int ? search->PVR : search->PV) : ""),
							YELLOW, (search->OVERLAY ? "::" : ""), (search->OVERLAY ? search->OVERLAY : ""),
							NORM, GREEN, count, NORM,
							(verbose ? ", for a total time of " : ""));
		if (verbose) {
			if (human_readable)
				print_seconds_for_earthlings(merge_time);
			else
				printf("%s%lu%s seconds", GREEN, merge_time, NORM);
		}
		fputc('\n', stdout);
	}
	}
	atom_implode(search);
	return 0;
	return 0;
}
}
void show_emerge_history(char listflag, int argc, char **argv, const char *logfile);
void show_emerge_history(char listflag, const short repo, const char repo_search[], int argc, char **argv, const char *logfile);
void show_emerge_history(char listflag, int argc, char **argv, const char *logfile)
void show_emerge_history(char listflag, const short repo, const char repo_search[], int argc, char **argv, const char *logfile)
{
{
	FILE *fp;
	FILE *fp;
	char buf[BUFSIZ], merged;
	char buf[BUFSIZ], merged;
 Lines 222-244   void show_emerge_history(char listflag, Link Here 
		if ((p = strchr(buf, ':')) == NULL)
		if ((p = strchr(buf, ':')) == NULL)
			continue;
			continue;
		*p = 0;
		*p = 0;
		q = p + 3;
		q = p + 2;
		t = (time_t) atol(buf);
		t = (time_t) atol(buf);
		if ((listflag & QLOP_LIST) && !strncmp(q, "::: completed emerge (", 22)) {
		if ((listflag & QLOP_LIST) && !strncmp(q, "finished install of package", 25)) {
			merged = 1;
			merged = 1;
			if ((p = strchr(q, ')')) == NULL)
			p = strstr(q, "package");
				continue;
			q = p + 1;
			q = p + 2;
			if ((p = strchr(q, ' ')) == NULL)
			if ((p = strchr(q, ' ')) == NULL)
				continue;
				continue;
			*p = 0;
			q = p + 1;
		} else if ((listflag & QLOP_UNLIST) && !strncmp(q, ">>> unmerge success: ", 21)) {
			if (repo) {
				if ((p = strstr(q, "::")) && strncmp(p+2, repo_search, sizeof(repo_search)))
					continue;
			}
		} else if ((listflag & QLOP_UNLIST) && !strncmp(q, "finished uninstall of package", 29)) {
			merged = 0;
			merged = 0;
			if ((p = strchr(q, ':')) == NULL)
			p = strstr(q, "package");
			q = p + 1;
			if ((p = strchr(q, ' ')) == NULL)
				continue;
				continue;
			q = p + 2;
			q = p + 1;
			if ((p = strchr(p, ':')) != NULL)
				*p = 0;
		}
		}
		else
		else
			continue;
			continue;
 Lines 258-265   void show_emerge_history(char listflag, Link Here 
	fclose(fp);
	fclose(fp);
}
}
void show_sync_history(const char *logfile);
void show_sync_history(const char *logfile, const short repo, char repo_search[]);
void show_sync_history(const char *logfile)
void show_sync_history(const char *logfile, const short repo, char repo_search[])
{
{
	FILE *fp;
	FILE *fp;
	char buf[BUFSIZ];
	char buf[BUFSIZ];
 Lines 274-280   void show_sync_history(const char *logfi Link Here 
	while ((fgets(buf, sizeof(buf), fp)) != NULL) {
	while ((fgets(buf, sizeof(buf), fp)) != NULL) {
		if (strlen(buf) < 35)
		if (strlen(buf) < 35)
			continue;
			continue;
		if (strncmp(buf+12, "=== Sync completed with", 23) != 0)
		if (strncmp(buf+12, "finished sync", 13) != 0)
			continue;
		if (repo && strstr(buf, repo_search) == NULL)
			continue;
			continue;
		if ((p = strchr(buf, '\n')) != NULL)
		if ((p = strchr(buf, '\n')) != NULL)
 Lines 282-294   void show_sync_history(const char *logfi Link Here 
		if ((p = strchr(buf, ':')) == NULL)
		if ((p = strchr(buf, ':')) == NULL)
			continue;
			continue;
		*p = 0;
		*p = 0;
		q = p+2;
		q = p+1;
		t = (time_t)atol(buf);
		t = (time_t)atol(buf);
		if ((p = strstr(q, "with")) == NULL)
		if ((p = strstr(q, "repository")) == NULL)
			continue;
			continue;
		q = p + 5;
		q = p + 11;
		printf("%s >>> %s%s%s\n", chop_ctime(t), GREEN, q, NORM);
		printf("%s >>> %s%s%s\n", chop_ctime(t), GREEN, q, NORM);
	}
	}
 Lines 304-313   void show_current_emerge(void) Link Here 
	pid_t pid;
	pid_t pid;
	char buf[BUFSIZE], bufstat[300];
	char buf[BUFSIZE], bufstat[300];
	char path[50];
	char path[50];
	char *p, *q;
	char *p, *q, *cat, *pnv;
	unsigned long long start_time = 0;
	unsigned long long start_time = 0;
	double uptime_secs;
	double uptime_secs;
	time_t start_date;
	time_t start_date;
	overlay_t *overlay_tmp;
	if ((proc = opendir("/proc")) == NULL) {
	if ((proc = opendir("/proc")) == NULL) {
		warnp("Could not open /proc");
		warnp("Could not open /proc");
 Lines 319-333   void show_current_emerge(void) Link Here 
		if ((pid = (pid_t)atol(de->d_name)) == 0)
		if ((pid = (pid_t)atol(de->d_name)) == 0)
			continue;
			continue;
		/* portage renames the cmdline so the package name is first */
		snprintf(path, sizeof(path), "/proc/%i/cmdline", pid);
		snprintf(path, sizeof(path), "/proc/%i/cmdline", pid);
		if (!eat_file(path, buf, sizeof(buf)))
		if (!eat_file(path, buf, sizeof(buf)))
			continue;
			continue;
		if (buf[0] == '[' && (p = strchr(buf, ']')) != NULL && strstr(buf, "sandbox") != NULL) {
		if (! strncmp(buf, "sandbox", 7)) {
			*p = '\0';
			/*			  0123456789012345678 */
			p = buf+1;
			if (!(p = strstr(&buf[8],"paludis/ebuild.bash")))
			q = p + strlen(p) + 1;
				continue;
			q = p + 20;
			if (*q != '/')
				continue;
			/*
			 * ex: /var/paludis/repositories/local/category/package_name/package_name_version.ebuild
			 * expected:
			 *     q			       cat     0	     pnv
			 */
			if (q == (pnv=strrchr(q, '/')))
				continue;
			*pnv = 0;
			pnv++;
			if (q == (cat=strrchr(q, '/')))
				continue;
			*cat = 0;
			if (q == (cat=strrchr(q, '/')))
				continue;
			*cat = 0;
			cat++;
			overlay_tmp=first_overlay;
			do {
				if (!strcmp(q, overlay_tmp->path))
					break;
			} while ((overlay_tmp=overlay_tmp->next));
			if (NULL == overlay_tmp)
				continue;
			/* open the stat file to figure out how long we have been running */
			/* open the stat file to figure out how long we have been running */
			snprintf(path, sizeof(path), "/proc/%i/stat", pid);
			snprintf(path, sizeof(path), "/proc/%i/stat", pid);
 Lines 356-365   void show_current_emerge(void) Link Here 
			/* figure out when this thing started and then show it */
			/* figure out when this thing started and then show it */
			start_date = time(0) - (uptime_secs - (start_time / HZ));
			start_date = time(0) - (uptime_secs - (start_time / HZ));
			printf(
			printf(
				" %s*%s %s%s%s\n"
				" %s*%s %s::%s%s%s/%s%s\n"
				"     started: %s%s%s\n"
				"     started: %s%s%s\n"
				"     elapsed: ", /*%s%llu%s seconds\n",*/
				"     elapsed: ", /*%s%llu%s seconds\n",*/
				BOLD, NORM, BLUE, p, NORM,
				BOLD, YELLOW, overlay_tmp->name, NORM, BLUE, cat, pnv, NORM,
				GREEN, chop_ctime(start_date), NORM);
				GREEN, chop_ctime(start_date), NORM);
			print_seconds_for_earthlings(uptime_secs - (start_time / HZ));
			print_seconds_for_earthlings(uptime_secs - (start_time / HZ));
			puts(NORM);
			puts(NORM);
 Lines 380-385   void show_current_emerge(void) Link Here 
	char *p, *q;
	char *p, *q;
	time_t start_date = 0;
	time_t start_date = 0;
	/* this would need to be written for paludis, but I don't really know *BSD */
	warn("You need to adapt the show_current_emerge(void) function for __FreeBSD__\n"
		"this may be trivial, just do as in the __linux__ one, but as I can't test it, I didn't make it");
	if (! (kd = kvm_open("/dev/null", "/dev/null", "/dev/null", O_RDONLY, "kvm_open"))) {
	if (! (kd = kvm_open("/dev/null", "/dev/null", "/dev/null", O_RDONLY, "kvm_open"))) {
		warnp("Could not open kvm: %s", kvm_geterr(kd));
		warnp("Could not open kvm: %s", kvm_geterr(kd));
		return;
		return;
 Lines 433-444   int qlop_main(int argc, char **argv) Link Here 
	int i, average = 1;
	int i, average = 1;
	char do_time, do_list, do_unlist, do_sync, do_current, do_human_readable = 0;
	char do_time, do_list, do_unlist, do_sync, do_current, do_human_readable = 0;
	char *opt_logfile;
	char *opt_logfile;
	short repo;
	char repo_search[64];
	const char *logfile = QLOP_DEFAULT_LOGFILE;
	const char *logfile = QLOP_DEFAULT_LOGFILE;
	overlay_t *overlay_tmp;
	DBG("argc=%d argv[0]=%s argv[1]=%s",
	DBG("argc=%d argv[0]=%s argv[1]=%s",
		argc, argv[0], argc > 1 ? argv[1] : "NULL?");
		argc, argv[0], argc > 1 ? argv[1] : "NULL?");
	opt_logfile = NULL;
	opt_logfile = NULL;
	repo = 0;
	repo_search[0] = 0;
	do_time = do_list = do_unlist = do_sync = do_current = 0;
	do_time = do_list = do_unlist = do_sync = do_current = 0;
	while ((i = GETOPT_LONG(QLOP, qlop, "")) != -1) {
	while ((i = GETOPT_LONG(QLOP, qlop, "")) != -1) {
 Lines 448-454   int qlop_main(int argc, char **argv) Link Here 
			case 't': do_time = 1; break;
			case 't': do_time = 1; break;
			case 'l': do_list = 1; break;
			case 'l': do_list = 1; break;
			case 'u': do_unlist = 1; break;
			case 'u': do_unlist = 1; break;
			case 's': do_sync = 1; break;
			case 's':
				if (do_sync) err("Only use -s or -S once");
				do_sync = 1;
				break;
			case 'o':
				repo = 1;
				strncpy(repo_search, optarg, sizeof(repo_search));
				break;
			case 'c': do_current = 1; break;
			case 'c': do_current = 1; break;
			case 'g': do_time = 1; average = 0; break;
			case 'g': do_time = 1; average = 0; break;
			case 'H': do_human_readable = 1; break;
			case 'H': do_human_readable = 1; break;
 Lines 458-463   int qlop_main(int argc, char **argv) Link Here 
				break;
				break;
		}
		}
	}
	}
	if (repo) {
		overlay_tmp = first_overlay;
		do {
			if (!strncmp(overlay_tmp->name, repo_search, sizeof(overlay_tmp->name)))
				break;
		} while ((overlay_tmp=overlay_tmp->next));
		if (NULL == overlay_tmp)
			err("%s : Unknown overlay, try 'q --ls-overlays'", repo_search);
	}
	if (!do_list && !do_unlist && !do_time && !do_sync && !do_current)
	if (!do_list && !do_unlist && !do_time && !do_sync && !do_current)
		qlop_usage(EXIT_FAILURE);
		qlop_usage(EXIT_FAILURE);
	if (opt_logfile != NULL)
	if (opt_logfile != NULL)
 Lines 467-485   int qlop_main(int argc, char **argv) Link Here 
	argv += optind;
	argv += optind;
	if (do_list && do_unlist)
	if (do_list && do_unlist)
		show_emerge_history(QLOP_LIST | QLOP_UNLIST, argc, argv, logfile);
		show_emerge_history(QLOP_LIST | QLOP_UNLIST, repo, repo_search,argc, argv, logfile);
	else if (do_list)
	else if (do_list)
		show_emerge_history(QLOP_LIST, argc, argv, logfile);
		show_emerge_history(QLOP_LIST, repo, repo_search, argc, argv, logfile);
	else if (do_unlist)
	else if (do_unlist)
		show_emerge_history(QLOP_UNLIST, argc, argv, logfile);
		show_emerge_history(QLOP_UNLIST, repo, repo_search, argc, argv, logfile);
	if (do_current)
	if (do_current)
		show_current_emerge();
		show_current_emerge();
	if (do_sync)
	if (do_sync)
		show_sync_history(logfile);
		show_sync_history(logfile, repo, repo_search);
	if (do_time) {
	if (do_time) {
		for (i = 0; i < argc; ++i)
		for (i = 0; i < argc; ++i)
			show_merge_times(argv[i], logfile, average, do_human_readable);
			show_merge_times(argv[i], repo, repo_search, logfile, average, do_human_readable);
	}
	}
	if (opt_logfile) free(opt_logfile);
	if (opt_logfile) free(opt_logfile);
 Lines 490-492   int qlop_main(int argc, char **argv) Link Here 
#else
#else
DEFINE_APPLET_STUB(qlop)
DEFINE_APPLET_STUB(qlop)
#endif
#endif
/* vim: set noet sts=8 sw=8 : */
(-) portage-utils-20070115.new/qsearch.c (-4 / +4 lines)
 Lines 100-106   int qsearch_main(int argc, char **argv) Link Here 
	}
	}
	last[0] = 0;
	last[0] = 0;
	fp = fopen(initialize_flat(search_cache), "r");
	fp = fopen(initialize_flat(search_cache, 0), "r");
	if (!fp)
	if (!fp)
		return 1;
		return 1;
 Lines 137-143   int qsearch_main(int argc, char **argv) Link Here 
						if (chdir(cur_overlay->path) != 0) {
						if (chdir(cur_overlay->path) != 0) {
							warnp("chdir to '%s' failed", cur_overlay->path);
							warnp("chdir to '%s' failed", cur_overlay->path);
							myerror = 1;
							myerror = 1;
							continue;
						} else
						} else
							bad_overlay = 0;
							bad_overlay = 0;
						break;
						break;
 Lines 145-151   int qsearch_main(int argc, char **argv) Link Here 
						if (chdir(cur_overlay->cache) != 0) {
						if (chdir(cur_overlay->cache) != 0) {
							warnp("chdir to '%s' failed, skipping the %s repository", cur_overlay->cache, cur_overlay->name);
							warnp("chdir to '%s' failed, skipping the %s repository", cur_overlay->cache, cur_overlay->name);
							myerror = 1;
							myerror = 1;
							continue;
						} else
						} else
							bad_overlay = 0;
							bad_overlay = 0;
						break;
						break;
 Lines 154-160   int qsearch_main(int argc, char **argv) Link Here 
					myerror = 1;
					myerror = 1;
				strncpy(overlay_name, p+2, sizeof(overlay_name));
				strncpy(overlay_name, p+2, sizeof(overlay_name));
			}
			}
		} else
		} else 
			myerror++;
			myerror++;
		if (myerror) {
		if (myerror) {
 Lines 271-273   no_cache_ebuild_match: Link Here 
#else
#else
DEFINE_APPLET_STUB(qsearch)
DEFINE_APPLET_STUB(qsearch)
#endif
#endif
/* vim: set noet sts=8 sw=8 : */
(-) portage-utils-20070115.new/qsize.c (-8 / +9 lines)
 Lines 68-77   int qsize_main(int argc, char **argv) Link Here 
	if ((argc == optind) && !search_all)
	if ((argc == optind) && !search_all)
		qsize_usage(EXIT_FAILURE);
		qsize_usage(EXIT_FAILURE);
	if (chdir(portroot))
	if (chdir(portvdb))
		errp("could not chdir(%s) for ROOT", portroot);
		errp("could not chdir(%s) for VDB", portvdb);
	if (chdir(portvdb) != 0 || (dir = opendir(".")) == NULL)
	if ((dir = opendir(".")) == NULL)
		return EXIT_FAILURE;
		return EXIT_FAILURE;
	num_all_bytes = num_all_files = num_all_nonfiles = 0;
	num_all_bytes = num_all_files = num_all_nonfiles = 0;
 Lines 91-99   int qsize_main(int argc, char **argv) Link Here 
			/* see if this cat/pkg is requested */
			/* see if this cat/pkg is requested */
			if (!search_all) {
			if (!search_all) {
				snprintf(buf, sizeof(buf), "%s/%s::%s", dentry->d_name,
					 de->d_name, grab_vdb_item("REPOSITORY", dentry->d_name, de->d_name));
				for (i = optind; i < argc; ++i) {
				for (i = optind; i < argc; ++i) {
					snprintf(buf, sizeof(buf), "%s/%s", dentry->d_name,
					         de->d_name);
					if (rematch(argv[i], buf, REG_EXTENDED) == 0)
					if (rematch(argv[i], buf, REG_EXTENDED) == 0)
						break;
						break;
					if (rematch(argv[i], de->d_name, REG_EXTENDED) == 0)
					if (rematch(argv[i], de->d_name, REG_EXTENDED) == 0)
 Lines 103-109   int qsize_main(int argc, char **argv) Link Here 
					continue;
					continue;
			}
			}
			snprintf(buf, sizeof(buf), "%s%s/%s/%s/CONTENTS", portroot, portvdb,
			snprintf(buf, sizeof(buf), "%s/%s/%s/CONTENTS", portvdb,
			         dentry->d_name, de->d_name);
			         dentry->d_name, de->d_name);
			if ((fp = fopen(buf, "r")) == NULL)
			if ((fp = fopen(buf, "r")) == NULL)
				continue;
				continue;
 Lines 128-135   int qsize_main(int argc, char **argv) Link Here 
			num_all_files += num_files;
			num_all_files += num_files;
			num_all_nonfiles += num_nonfiles;
			num_all_nonfiles += num_nonfiles;
			if (!summary_only) {
			if (!summary_only) {
				printf("%s%s/%s%s%s: %lu files, %lu non-files, ", BOLD,
				printf("%s%s/%s%s%s::%s%s : %lu files, %lu non-files, ", BOLD,
				       basename(dentry->d_name), BLUE, de->d_name, NORM,
				       basename(dentry->d_name), BLUE, de->d_name, 
				       YELLOW, grab_vdb_item("REPOSITORY", dentry->d_name, de->d_name), NORM,
				       (unsigned long)num_files,
				       (unsigned long)num_files,
				       (unsigned long)num_nonfiles);
				       (unsigned long)num_nonfiles);
				if (disp_units)
				if (disp_units)
(-) portage-utils-20070115.new/quse.c (-1 / +3 lines)
 Lines 305-311   int quse_main(int argc, char **argv) Link Here 
	if (idx == -1)
	if (idx == -1)
		return quse_describe_flag(optind, repo, repo_search, argc, argv);
		return quse_describe_flag(optind, repo, repo_search, argc, argv);
	initialize_ebuild_flat();	/* sets our pwd to $PORTDIR */
	initialize_ebuild_flat(0);	/* sets our pwd to $PORTDIR */
	search_len = strlen(search_vars[idx]);
	search_len = strlen(search_vars[idx]);
	assert(search_len < sizeof(buf0));
	assert(search_len < sizeof(buf0));
 Lines 523-525   int quse_main(int argc, char **argv) Link Here 
#else
#else
DEFINE_APPLET_STUB(quse)
DEFINE_APPLET_STUB(quse)
#endif
#endif
/* vim: set noet sts=8 sw=8 : */