public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-11-26 10:39 99% Mike Frysinger
  0 siblings, 0 replies; 1+ results
From: Mike Frysinger @ 2015-11-26 10:39 UTC (permalink / raw
  To: gentoo-commits

commit:     cb952155e5a9b5d3af533a9d46c561fee47c22f9
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu Nov 26 10:36:49 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Nov 26 10:36:49 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=cb952155

cache: support multiple overlays

This isn't terribly useful as-is since all callers still assume only
a single cache exists (portdir).  But we can cut utils over now.

URL: https://bugs.gentoo.org/553260

 main.c    | 36 +++++++++++++++++++++---------------
 qsearch.c |  2 +-
 2 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/main.c b/main.c
index 8c7403b..10af2db 100644
--- a/main.c
+++ b/main.c
@@ -934,7 +934,7 @@ int filter_hidden(const struct dirent *dentry)
 }
 
 static const char *
-initialize_flat(int cache_type, bool force)
+initialize_flat(const char *overlay, int cache_type, bool force)
 {
 	struct dirent **category, **pn, **eb;
 	struct stat st;
@@ -945,7 +945,7 @@ initialize_flat(int cache_type, bool force)
 	int frac, secs, count;
 	FILE *fp;
 
-	xasprintf(&cache_file, "%s/dep/%s/%s", portedb, portdir,
+	xasprintf(&cache_file, "%s/dep/%s/%s", portedb, overlay,
 		(cache_type == CACHE_EBUILD ? ".ebuild.x" : ".metadata.x"));
 
 	/* If we aren't forcing a regen, make sure the file is somewhat sane. */
@@ -960,22 +960,22 @@ initialize_flat(int cache_type, bool force)
 
 	count = frac = secs = 0;
 
-	int portdir_fd, subdir_fd;
-	portdir_fd = open(portdir, O_RDONLY|O_CLOEXEC|O_PATH);
+	int overlay_fd, subdir_fd;
+	overlay_fd = open(overlay, O_RDONLY|O_CLOEXEC|O_PATH);
 
 	if (cache_type == CACHE_METADATA) {
-		subdir_fd = openat(portdir_fd, portcachedir_md5, O_RDONLY|O_CLOEXEC);
+		subdir_fd = openat(overlay_fd, portcachedir_md5, O_RDONLY|O_CLOEXEC);
 		if (subdir_fd == -1) {
-			subdir_fd = openat(portdir_fd, portcachedir_pms, O_RDONLY|O_CLOEXEC);
+			subdir_fd = openat(overlay_fd, portcachedir_pms, O_RDONLY|O_CLOEXEC);
 			if (subdir_fd == -1) {
-				warnp("could not read md5 or pms cache dirs in %s", portdir);
+				warnp("could not read md5 or pms cache dirs in %s", overlay);
 				goto ret;
 			}
 			portcachedir_type = CACHE_METADATA_PMS;
 		} else
 			portcachedir_type = CACHE_METADATA_MD5;
 	} else
-		subdir_fd = portdir_fd;
+		subdir_fd = overlay_fd;
 
 	if ((fp = fopen(cache_file, "we")) == NULL) {
 		warnfp("opening cache failed: %s", cache_file);
@@ -1056,22 +1056,28 @@ initialize_flat(int cache_type, bool force)
 
 	warn("Finished %u entries in %d.%06d seconds", count, secs, frac);
 	if (secs > 120)
-		warn("You should consider using the noatime mount option for PORTDIR='%s' if it's not already enabled", portdir);
+		warn("You should consider using the noatime mount option for '%s' if it's not already enabled", overlay);
 ret:
 	close(subdir_fd);
-	if (subdir_fd != portdir_fd)
-		close(portdir_fd);
+	if (subdir_fd != overlay_fd)
+		close(overlay_fd);
 	return cache_file;
 }
-#define initialize_ebuild_flat() initialize_flat(CACHE_EBUILD, false)
-#define initialize_metadata_flat() initialize_flat(CACHE_METADATA, false)
+#define initialize_ebuild_flat() initialize_flat(portdir, CACHE_EBUILD, false)
+#define initialize_metadata_flat() initialize_flat(portdir, CACHE_METADATA, false)
 
 void reinitialize_as_needed(void)
 {
+	size_t n;
+	const char *overlay;
+
 	if (reinitialize)
-		initialize_flat(CACHE_EBUILD, true);
+		array_for_each(overlays, n, overlay)
+			initialize_flat(overlay, CACHE_EBUILD, true);
+
 	if (reinitialize_metacache)
-		initialize_flat(CACHE_METADATA, true);
+		array_for_each(overlays, n, overlay)
+			initialize_flat(overlay, CACHE_METADATA, true);
 }
 
 typedef struct {

diff --git a/qsearch.c b/qsearch.c
index baaed37..427580d 100644
--- a/qsearch.c
+++ b/qsearch.c
@@ -69,7 +69,7 @@ int qsearch_main(int argc, char **argv)
 		search_me = argv[optind];
 	}
 	last[0] = 0;
-	fp = fopen(initialize_flat(search_cache, false), "r");
+	fp = fopen(initialize_flat(portdir, search_cache, false), "r");
 	if (!fp)
 		return 1;
 


^ permalink raw reply related	[relevance 99%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2015-11-26 10:39 99% [gentoo-commits] proj/portage-utils:master commit in: / Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox