From 9d208dd855d2181f0369da5f81f0c8ceceac7c8d Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Mon, 22 Nov 2010 19:30:09 -0300 Subject: [PATCH] qpkg: added parsing and recording of Provides data - pkg.h (enum flags): new flags QPKG_PROVIDED to indicate that the package is only a provision, not an installable package - fixup.h, fixup.c (complete_provisions): search for provisions that do not have a real package associated with them, create a package for them, and mark it as QPKG_PROVIDED - qpkg.c (do_fixups): invoke complete_provisions - pkg.h (struct pkg): add list of (virtual or real) packages a given package provides - pkg.c (new_pkg): initialize pkg->provides - pkg.c (free_pkg): deallocate pkg->provides - gobble.c (gobble_buf): parse the list of packages a package provides - TODO: updated status of Provides support --- qpkg/TODO | 3 +++ qpkg/fixup.c | 11 +++++++++++ qpkg/fixup.h | 1 + qpkg/gobble.c | 9 +++++++-- qpkg/pkg.c | 3 ++- qpkg/pkg.h | 4 +++- qpkg/qpkg.c | 1 + 7 files changed, 28 insertions(+), 4 deletions(-) diff --git a/qpkg/TODO b/qpkg/TODO index a6c1c99..2b34941 100644 --- a/qpkg/TODO +++ b/qpkg/TODO @@ -6,6 +6,9 @@ Still left to do - handle Provides: + Update: Provides data is now parsed and properly integrated in the + package database, but not yet used to resolve prerequisites. + - sort prerequisites such that they can be installed in the specified order - consider Architecture: diff --git a/qpkg/fixup.c b/qpkg/fixup.c index a9f481b..09d2b3a 100644 --- a/qpkg/fixup.c +++ b/qpkg/fixup.c @@ -42,3 +42,14 @@ void sort_versions(void) (*b)->more = tmp; } } + + +void complete_provisions(void) +{ + struct jrb *n; + + for (n = jrb_first(packages->root); n != jrb_nil(packages->root); + n = jrb_next(n)) + if (!n->val) + new_pkg(n)->flags |= QPKG_PROVIDED; +} diff --git a/qpkg/fixup.h b/qpkg/fixup.h index 7671fe7..caf41ed 100644 --- a/qpkg/fixup.h +++ b/qpkg/fixup.h @@ -14,5 +14,6 @@ #define FIXUP_H void sort_versions(void); +void complete_provisions(void); #endif /* !FIXUP_H */ diff --git a/qpkg/gobble.c b/qpkg/gobble.c index 307f80b..4cbc782 100644 --- a/qpkg/gobble.c +++ b/qpkg/gobble.c @@ -321,8 +321,13 @@ architecture: goto skip_data; provides: - /* @@@ later */ - goto skip_data; + anchor = &pkg->provides; + /* + * There should never be a version in the provisions, so it's a bit + * wasteful to use a structure that has a version field. But then, code + * reuse is nice, too. + */ + goto list_with_version; status: pkg->flags |= QPKG_INSTALLED; diff --git a/qpkg/pkg.c b/qpkg/pkg.c index 8fe4511..669f14d 100644 --- a/qpkg/pkg.c +++ b/qpkg/pkg.c @@ -30,7 +30,7 @@ struct pkg *new_pkg(struct jrb *jrb) jrb->val = pkg; pkg->version = NULL; pkg->arch = NULL; - pkg->conflicts = pkg->depends = NULL; + pkg->conflicts = pkg->depends = pkg->provides = NULL; pkg->filename = NULL; pkg->flags = 0; pkg->mark = 0; @@ -55,5 +55,6 @@ void free_pkg(struct pkg *pkg) { free_refs(pkg->conflicts); free_refs(pkg->depends); + free_refs(pkg->provides); free(pkg); } diff --git a/qpkg/pkg.h b/qpkg/pkg.h index d00f19c..b104dcc 100644 --- a/qpkg/pkg.h +++ b/qpkg/pkg.h @@ -19,8 +19,9 @@ enum flags { - /* parse-time flags */ + /* parse-time and fixup-time flags */ QPKG_INSTALLED = 1 << 0, /* installed on target */ + QPKG_PROVIDED = 1 << 1, /* virtual package */ /* run-time flags */ QPKG_ADDING = 1 << 10, /* resolving dependencies */ @@ -47,6 +48,7 @@ struct pkg { const char *arch; struct ref *conflicts; struct ref *depends; + struct ref *provides; const char *filename; int flags; /* see enum flags */ struct pkg *more; diff --git a/qpkg/qpkg.c b/qpkg/qpkg.c index e0a8027..182cfd7 100644 --- a/qpkg/qpkg.c +++ b/qpkg/qpkg.c @@ -121,6 +121,7 @@ static void find_prereq(const char *name, const char *version) static void do_fixups(void) { sort_versions(); + complete_provisions(); }