aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2015-02-23 19:21:25 -0500
committerMike Frysinger <vapier@gentoo.org>2015-02-23 19:21:25 -0500
commitf23fa9375a936d3d7d565175dfe39a2dd209d45e (patch)
tree7a1f9d9222cab63e157dec1688de9dac9c00a4c7
parentqmerge: pull atom up a level in the merge logic (diff)
downloadportage-utils-f23fa9375a936d3d7d565175dfe39a2dd209d45e.tar.gz
portage-utils-f23fa9375a936d3d7d565175dfe39a2dd209d45e.tar.bz2
portage-utils-f23fa9375a936d3d7d565175dfe39a2dd209d45e.zip
qmerge: parse the binpkg header first
This contains common details (like REPO) that are not repeated for every entry. We'll propagate that back out whenever we reset the Pkg state. Also seed the SLOT value with 0 every time. Its value is omitted when it is the default, so we have to do this ourselves.
-rw-r--r--qmerge.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/qmerge.c b/qmerge.c
index be28cb79..1bd860d9 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1675,13 +1675,40 @@ parse_packages(queue *todo)
char *buf, *p;
struct pkg_t Pkg;
depend_atom *pkg_atom;
+ char repo[sizeof(Pkg.REPO)];
fp = open_binpkg_index();
+ buf = NULL;
+ repo[0] = '\0';
+
+ /* First consume the header with the common data. */
+ while (getline(&buf, &buflen, fp) != -1) {
+ if (*buf == '\n')
+ break;
+
+ if ((p = strchr(buf, '\n')) != NULL)
+ *p = 0;
+ if ((p = strchr(buf, ':')) == NULL)
+ continue;
+ if (p[1] != ' ')
+ continue;
+ *p = 0;
+ p += 2;
+
+ switch (*buf) {
+ case 'R':
+ if (!strcmp(buf, "REPO"))
+ strncpy(repo, p, sizeof(repo));
+ break;
+ }
+ }
+
pkg_atom = NULL;
memset(&Pkg, 0, sizeof(Pkg));
+ strcpy(Pkg.SLOT, "0");
- buf = NULL;
+ /* Then walk all the package entries. */
while (getline(&buf, &buflen, fp) != -1) {
if (*buf == '\n') {
if (pkg_atom) {
@@ -1706,6 +1733,8 @@ parse_packages(queue *todo)
pkg_atom = NULL;
}
memset(&Pkg, 0, sizeof(Pkg));
+ strcpy(Pkg.SLOT, "0");
+ strcpy(Pkg.REPO, repo);
continue;
}