Gentoo Archives: gentoo-commits

From: Mike Frysinger <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage-utils:master commit in: /
Date: Thu, 26 Nov 2015 10:39:32
Message-Id: 1448534209.cb952155e5a9b5d3af533a9d46c561fee47c22f9.vapier@gentoo
1 commit: cb952155e5a9b5d3af533a9d46c561fee47c22f9
2 Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
3 AuthorDate: Thu Nov 26 10:36:49 2015 +0000
4 Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
5 CommitDate: Thu Nov 26 10:36:49 2015 +0000
6 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=cb952155
7
8 cache: support multiple overlays
9
10 This isn't terribly useful as-is since all callers still assume only
11 a single cache exists (portdir). But we can cut utils over now.
12
13 URL: https://bugs.gentoo.org/553260
14
15 main.c | 36 +++++++++++++++++++++---------------
16 qsearch.c | 2 +-
17 2 files changed, 22 insertions(+), 16 deletions(-)
18
19 diff --git a/main.c b/main.c
20 index 8c7403b..10af2db 100644
21 --- a/main.c
22 +++ b/main.c
23 @@ -934,7 +934,7 @@ int filter_hidden(const struct dirent *dentry)
24 }
25
26 static const char *
27 -initialize_flat(int cache_type, bool force)
28 +initialize_flat(const char *overlay, int cache_type, bool force)
29 {
30 struct dirent **category, **pn, **eb;
31 struct stat st;
32 @@ -945,7 +945,7 @@ initialize_flat(int cache_type, bool force)
33 int frac, secs, count;
34 FILE *fp;
35
36 - xasprintf(&cache_file, "%s/dep/%s/%s", portedb, portdir,
37 + xasprintf(&cache_file, "%s/dep/%s/%s", portedb, overlay,
38 (cache_type == CACHE_EBUILD ? ".ebuild.x" : ".metadata.x"));
39
40 /* If we aren't forcing a regen, make sure the file is somewhat sane. */
41 @@ -960,22 +960,22 @@ initialize_flat(int cache_type, bool force)
42
43 count = frac = secs = 0;
44
45 - int portdir_fd, subdir_fd;
46 - portdir_fd = open(portdir, O_RDONLY|O_CLOEXEC|O_PATH);
47 + int overlay_fd, subdir_fd;
48 + overlay_fd = open(overlay, O_RDONLY|O_CLOEXEC|O_PATH);
49
50 if (cache_type == CACHE_METADATA) {
51 - subdir_fd = openat(portdir_fd, portcachedir_md5, O_RDONLY|O_CLOEXEC);
52 + subdir_fd = openat(overlay_fd, portcachedir_md5, O_RDONLY|O_CLOEXEC);
53 if (subdir_fd == -1) {
54 - subdir_fd = openat(portdir_fd, portcachedir_pms, O_RDONLY|O_CLOEXEC);
55 + subdir_fd = openat(overlay_fd, portcachedir_pms, O_RDONLY|O_CLOEXEC);
56 if (subdir_fd == -1) {
57 - warnp("could not read md5 or pms cache dirs in %s", portdir);
58 + warnp("could not read md5 or pms cache dirs in %s", overlay);
59 goto ret;
60 }
61 portcachedir_type = CACHE_METADATA_PMS;
62 } else
63 portcachedir_type = CACHE_METADATA_MD5;
64 } else
65 - subdir_fd = portdir_fd;
66 + subdir_fd = overlay_fd;
67
68 if ((fp = fopen(cache_file, "we")) == NULL) {
69 warnfp("opening cache failed: %s", cache_file);
70 @@ -1056,22 +1056,28 @@ initialize_flat(int cache_type, bool force)
71
72 warn("Finished %u entries in %d.%06d seconds", count, secs, frac);
73 if (secs > 120)
74 - warn("You should consider using the noatime mount option for PORTDIR='%s' if it's not already enabled", portdir);
75 + warn("You should consider using the noatime mount option for '%s' if it's not already enabled", overlay);
76 ret:
77 close(subdir_fd);
78 - if (subdir_fd != portdir_fd)
79 - close(portdir_fd);
80 + if (subdir_fd != overlay_fd)
81 + close(overlay_fd);
82 return cache_file;
83 }
84 -#define initialize_ebuild_flat() initialize_flat(CACHE_EBUILD, false)
85 -#define initialize_metadata_flat() initialize_flat(CACHE_METADATA, false)
86 +#define initialize_ebuild_flat() initialize_flat(portdir, CACHE_EBUILD, false)
87 +#define initialize_metadata_flat() initialize_flat(portdir, CACHE_METADATA, false)
88
89 void reinitialize_as_needed(void)
90 {
91 + size_t n;
92 + const char *overlay;
93 +
94 if (reinitialize)
95 - initialize_flat(CACHE_EBUILD, true);
96 + array_for_each(overlays, n, overlay)
97 + initialize_flat(overlay, CACHE_EBUILD, true);
98 +
99 if (reinitialize_metacache)
100 - initialize_flat(CACHE_METADATA, true);
101 + array_for_each(overlays, n, overlay)
102 + initialize_flat(overlay, CACHE_METADATA, true);
103 }
104
105 typedef struct {
106
107 diff --git a/qsearch.c b/qsearch.c
108 index baaed37..427580d 100644
109 --- a/qsearch.c
110 +++ b/qsearch.c
111 @@ -69,7 +69,7 @@ int qsearch_main(int argc, char **argv)
112 search_me = argv[optind];
113 }
114 last[0] = 0;
115 - fp = fopen(initialize_flat(search_cache, false), "r");
116 + fp = fopen(initialize_flat(portdir, search_cache, false), "r");
117 if (!fp)
118 return 1;