Gentoo Archives: gentoo-commits

From: Fabian Groffen <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage-utils:master commit in: /
Date: Sun, 28 Apr 2019 18:10:44
Message-Id: 1556475013.512b29304c7ddb1ea979631937f8d93bb4a2392a.grobian@gentoo
1 commit: 512b29304c7ddb1ea979631937f8d93bb4a2392a
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Sun Apr 28 18:10:13 2019 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Sun Apr 28 18:10:13 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=512b2930
7
8 qpkg: use libq/cache
9
10 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
11
12 qpkg.c | 53 +++++++++++++++++++----------------------------------
13 1 file changed, 19 insertions(+), 34 deletions(-)
14
15 diff --git a/qpkg.c b/qpkg.c
16 index 9942184..af8df37 100644
17 --- a/qpkg.c
18 +++ b/qpkg.c
19 @@ -124,11 +124,27 @@ qpkg_clean_dir(char *dirp, set *vdb)
20 return num_all_bytes;
21 }
22
23 +static int
24 +qpkg_cb(cache_pkg_ctx *pkg_ctx, void *priv)
25 +{
26 + set *vdb = (set *)priv;
27 + depend_atom *atom;
28 + char buf[_Q_PATH_MAX];
29 +
30 + snprintf(buf, sizeof(buf), "%s/%s", pkg_ctx->cat_ctx->name, pkg_ctx->name);
31 + atom = atom_explode(buf);
32 + if (atom == NULL)
33 + return 0;
34 +
35 + vdb = add_set(buf, vdb);
36 +
37 + return 1;
38 +}
39 +
40 /* figure out what dirs we want to process for cleaning and display results. */
41 static int
42 qpkg_clean(char *dirp)
43 {
44 - FILE *fp;
45 int i, count;
46 size_t disp_units = 0;
47 uint64_t num_all_bytes;
48 @@ -146,39 +162,8 @@ qpkg_clean(char *dirp)
49 size_t n;
50 const char *overlay;
51
52 - array_for_each(overlays, n, overlay) {
53 - /* FIXME: use libq/cache here */ continue;
54 -
55 - size_t buflen;
56 - char *buf;
57 -
58 - buf = NULL;
59 - while (getline(&buf, &buflen, fp) != -1) {
60 - char *name, *p;
61 - if ((p = strrchr(buf, '.')) == NULL)
62 - continue;
63 - *p = 0;
64 - if ((p = strrchr(buf, '/')) == NULL)
65 - continue;
66 - *p = 0;
67 - name = p + 1;
68 - if ((p = strrchr(buf, '/')) == NULL)
69 - continue;
70 - *p = 0;
71 - /* these strcat() are safe. the name is extracted from
72 - * buf already. */
73 - strcat(buf, "/");
74 - strcat(buf, name);
75 -
76 - /* num_all_bytes will be off when pretend and eclean are
77 - * enabled together */
78 - /* vdb = del_set(buf, vdb, &i); */
79 - vdb = add_set(buf, vdb);
80 - }
81 -
82 - free(buf);
83 - fclose(fp);
84 - }
85 + array_for_each(overlays, n, overlay)
86 + cache_foreach_pkg(portroot, overlay, qpkg_cb, vdb, NULL);
87 }
88
89 num_all_bytes = qpkg_clean_dir(dirp, vdb);