Commit Graph

63 Commits

Author SHA1 Message Date
Werner Almesberger 326cd33967 qpkg/: committed some old changes (non-functional)
- TODO: various updates
- pkg.h (enum relop): marked rel_lt as deprecated
- prereq.c (resolve): instrumentation for chasing a dependencies bug
2011-07-23 11:45:24 -03:00
Werner Almesberger 6a3e471304 qpkg: added some field names and relational operators from Ubuntu
- gobble.c (gobble_buf): recognize (and ignore) the following fields:
  Bugs, Installed-Size, MD5sum, Origin, Original-Maintainer, SHA1, SHA256,
  Task.
- pkg.h (enum relop): added comments showing the respective symbol
- pkg.h (enum relop): added rel_gg (>>), rel_le (<=), and rel_ll (<<)
- gobble.c (gobble_buf): recognize >>, <=, and <<
- TODO: record progress in support beyond Jlime/OE
2010-11-22 22:48:28 -03:00
Werner Almesberger ab5df0a8d8 qpkg/test/bug-adding: found another manifestation of the same problem
This time, we even fail an assertion. Once again, it's because the state
changes are out of sync with the "under consideration" stack.
2010-11-22 21:49:50 -03:00
Werner Almesberger 068264ed61 qpkg: light cleanup of prereq.c:resolve and change forgotten in last commit
- prereq.c (resolve): do not consider installing virtual packages
  (forgotten in previous commit)
- prereq.c (resolve): renamed "next_dep" to "next_deps" to emphasize that
  this is a list
- prereq.c (resolve): use "break" instead of "return" to abandon a
  non-optimal path, so that we'll run future cleanup code
- prereq.c (resolve): fixed typos in explanation of QPKG_ADDING cleanup
- prereq.c (resolve): reference test/bug-adding in explanation
2010-11-22 21:18:33 -03:00
Werner Almesberger c95d064f9e qpkg/TODO: some open policy questions (cyclic dependencies and use of Provides) 2010-11-22 20:27:49 -03:00
Werner Almesberger 9d208dd855 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
2010-11-22 19:30:09 -03:00
Werner Almesberger bbf9c42bc8 qpkg: move "struct pkg" and its allocation from gobble.c and qpkg.h to pkg.[hc]
- Makefile (OBJS_qpkg): added pkg.o
- gobble.c (gobble_buf): moved "struct pkg" allocation to function new_pkg
  in pkg.c
- qpkg.h: moved "struct pkg" and subordinate structures to pkg.h
- pkg.h, pkg.c (new_pkg, free_pkg): provide package structure definition,
  allocation, and deallocation
- fixup.c, gobble.c, prereq.c, qpkg.c: include "pkg.h"
- gobble.c (finish_pkg): use free_pkg instead of just "free" to avoid
  leaking memory
2010-11-22 16:19:32 -03:00
Werner Almesberger 8d453d77c2 qpkg: test for the QPKG_ADDING leakage bug
- test/bug-adding: test if we get a false cyclic dependency because
  QPKG_ADDING isn't properly removed
- TODO: mention the problem
2010-11-22 09:28:34 -03:00
Werner Almesberger b89bcdfd93 qpkg: also consider conflicts introduced by package about to be added
- prereq.c (conflicts, resolve, prereq): renamed "conflicts" to
  "old_conflicts"
- prereq.c (new_conflicts, resolve, prereq): also test whether any of the
  conflicts of the package we're about to add matches an installed or
  considered package
- test/conflict, test/instconf: test for conflicts introduced by package
  about to be added
2010-11-22 06:52:53 -03:00
Werner Almesberger c44510ade1 qpkg: detect conflicts with installed packages
- prereq.c (installed_conflicts, free_conflicts, prereq): collect list of
  pre-existing conflicts in installed packages
- prereq.c (prereq): check if package being requested already conflicts
- test/instconf: regression test for conflicts with installed packages
- TODO: updated for full support of conflicts. Mention that we're not
  terribly efficient with handling conflicts.
2010-11-21 23:59:27 -03:00
Werner Almesberger be31904f5d qpkg: adding handling of conflicts (in progress)
- prereq.c (conflicts): detect conflicts
- prereq.c (prereq): pass list of conflicts of initial package
- test/conflict: regression test for basic conflict handling
- TODO: updated for partial implementation of conflicts
2010-11-21 23:24:44 -03:00
Werner Almesberger b181db5b9e qpkg: regression test for version preference
- test/verpref: test version preference (higher wins if there's a choice)
- TODO: updated for above change
2010-11-21 23:02:10 -03:00
Werner Almesberger c05e6d5dbb qpkg: sort package version list such that highest comes first
- Makefile (OBJS_qpkg): added fixup.o
- fixup.h, fixup.c (sort_versions): sort package versions
- qpkg.c (do_fixups, main): do fixups when done gobbling
- qpkg.h: need to include id.h to be self-contained
- test/sortver: test version sorting
2010-11-21 22:57:35 -03:00
Werner Almesberger b0c29c4d7a qpkg: improve "qpkg ... list"
- qpkg.c (list_all_packages): jrb indicates end-of-tree with pointer to
  jrb_nil(), not NULL
- qpkg.c (list_all_packages, list_one_package): use ID2PF
- qpkg.c (list_all_packages): iterate over versions
2010-11-21 22:50:42 -03:00
Werner Almesberger dd8bb6eecd qpkg: moved comp_versions from prereq.c to id.c
- id.c: added section titles
- prereq.c (comp_versions), id.h, id.c: moved comp_versions from prereq.c
  to id.c, to allow sharing with other code
2010-11-21 21:14:04 -03:00
Werner Almesberger a0c0e854cc qpkg: option -d to enable debugging at run time, and some cleanup
- prereq.c: added section titles
- prereq.c (debug), qpkg.h, qpkg.c: made variable "debug" global and moved
  it to qpkg.c
- qpkg.c (usage, main): new option -d to enable debugging
2010-11-21 20:55:25 -03:00
Werner Almesberger e1404bb6a2 qpkg/prereq.c (print_debug, resolve): moved debug output to separate function 2010-11-21 20:48:24 -03:00
Werner Almesberger 0bc4b6046b qpkg: added detection of cyclic dependencies
We define a cyclic dependency as the possibility (!) of the prerequisites
of a package X including a package that depends on X, and issue an error
if encountering such a situation.

Note that, if the dependencies of X can be resolved in a manner that does
not include the cyclic dependency, qpkg will still fail if it encounters
the cycle. Also note that qpkg (at least so far) does no perform an
exhaustive search to ferret out cyclic dependencies.

Furthermore, we don't consider that a cyclic dependency may not necessarily
imply a real life problem. E.g., if a package A contains elements X and
Y, with X needing package B, and the content of package B has a run-time
dependency on Y, the cyclic dependency between A and B would not exist
when considering its constituents. Since we don't have this information, we
just err on the side of caution.

- qpkg.h (enum flags): divide flags into categories (parse-time and
  run-time) and add flag QPKG_ADDING to mark packets whose dependencies we
  are processing
- prereq.c (resolve, prereq): track which packages we're tentatively
  considering for installation and detect cyclic dependencies
- test/cyclic: regression test for detection of cyclic dependencies
- TODO: updated with recent changes
2010-11-21 20:31:20 -03:00
Werner Almesberger 0229051f07 qpkg: change prerequisite resolution order to be fully depth-first
Until now, when considering adding a package, we processed its
dependencies after completing the current list of dependencies. E.g.,
if we had a package A that depended on B and C, B depended on D, and C
depended on E, then the sequence would have been A, B, C, ...

We now process the dependencies of a package immediately after
considering the package, so the sequence above would become A, B, D,
C, ...

The advantage of the new order is that it becomes easier to follow the
dependency tree, which will be beneficial for loop detection and for
ordering packages by installation order.

- prereq.c (resolve): change prerequisite resolution order such that the
  dependencies of the package being considered are processed immediately,
  instead of deferring them until the end of the current dependency list
- prereq.c (prereq): we can now pass the list of dependencies directly,
  without needing a list of lists element
- test/resorder: test resolution order
2010-11-21 17:34:17 -03:00
Werner Almesberger 6c66fa6053 qpkg: store dependencies and conflicts in file order
- gobble.c (gobble_buf): list_with_version reversed the order of the list
  items. It makes the behaviour of later algorithms more intuitive if we
  maintain the file order.
2010-11-21 15:56:55 -03:00
Werner Almesberger 9272f5057d qpkg/prereq.c (resolve): cleaned up the debugging output mechanism 2010-11-21 10:26:17 -03:00
Werner Almesberger 5a0444fd7e qpkg/prereq.c (prereq): removed confused false error avoidance
The original idea was to just copy "stack" (now called "installed") to
"best" when done. In this case, "best" would remain NULL if "install"
had no entries, which would then be interpreted as a failure to resolve
the prerequisites.

However, since we allocate a new list for "best" anyway, this concern
no longer exists, and we can also get rid of the contorted mechanism
that was designed to work around this problem. (It was never put into
action because I wanted to make a regression test for it first.)

- prereq.c (prereq): removed commented-out and nonsensical avoidance of
  false error
- test/prereq: added test case with no prerequisite
2010-11-21 10:22:37 -03:00
Werner Almesberger d0a1a9e82f qpkg: rearrange things in prereq.c to free the stack paradigm for other uses
- prereq.c (stack, epoch, push, pop, resolve, prereq): renamed to
  "installs"
- prereq.c (n_stack, stack_max, push, pop, resolve, prereq): changed
  "stack" to "install"
- prereq.c (push): renamed "push" to "append_install"
- prereq.c (pop): renamed "pop" to "backtrack"
2010-11-21 10:22:37 -03:00
Werner Almesberger 89223833f1 qpkg/qpkg.c: tighten detection of inconsistent use of Filename:
- qpkg/qpkg.c (find_prereq): instead of skipping nameless prerequisites,
  assert that these packages have a name
2010-11-21 08:19:28 -03:00
Werner Almesberger 2c953a5d1a qpkg: added regression test harness and a few tests
- Makefile (test, tests, valgrind): new targets to run regression tests
- test/Common: test harness (adapted from fped)
- test/minpkg: test minimum package definition
- test/prereq: test basic prerequisite queries
2010-11-21 04:32:04 -03:00
Werner Almesberger 83c716424f qpkg: perform sanity checks after parsing a package entry
- gobble.c (compact_pkg, gobble_buf): renamed compact_pkg to finish_pkg
- gobble.c (finish_pkg): check that the package has a version
- gobble.c (finish_pkg): check that the package has an architecture
- gobble.c (finish_pkg): check that the package either has a file name or
  is installed
2010-11-21 04:00:32 -03:00
Werner Almesberger f14c041e51 qpkg: record Architecture: tag
- qpkg.h (struct pkg): added "arch" field for the architecture
- gobble.c (gobble_buf): record the architecture
- gobble.c (gobble_buf): fail if trying to set the file name twice
- qpkg.c (main): initialize trees before doing anything else, so that the
  argument processing stays together
2010-11-21 03:53:19 -03:00
Werner Almesberger dd0ee66304 qpkg: give ID2S macro a more "offical" status
- prereq.c (ID2S), id.h (ID2PF): renamed ID2S to ID2PF and moved it to id.h
- prereq.c (push, satisfies, resolve): change ID2S to ID2PF
2010-11-21 03:25:53 -03:00
Werner Almesberger 44e4434b4c qpkg: towards "struct id" without jrb reference - change ID creation
- id.h, id.c (make_id): return a "struct jrb *", so that we have access to
  key and value
- gobble.c (ID, gobble_buf): adapt to above change
- gobble.c (compact_pkg, gobble_buf): keep the RB node reference instead
  of awkwardly regenerating it via pkg->id->jrb
2010-11-21 03:12:00 -03:00
Werner Almesberger 7058115a64 qpkg: towards "struct id" without jrb reference - change iteration and lookup
- id.h, id.c (first_id, next_id): removed
- qpkg.c (list_all_packages): use jrb_first/jrb_next instead of
  first_id/next_id
- id.h, id.c (find_id): return the RB tree node instead of the ID
- qpkg.c (list_one_package, find_prereq): adapted for above change
- id.h: explain the role of key and value
2010-11-21 03:11:54 -03:00
Werner Almesberger a63823e26a qpkg: turn pkg->installed into pkg->flags, allowing for future expansion
- qpkg.h (enum flags, struct pkg): replaced "installed" with "flags", one
  of them being QPKG_INSTALLED
- gobble.c (compact_pkg, gobble_buf), prereq.c (push, resolve): adapted
  for above change
2010-11-20 12:25:45 -03:00
Werner Almesberger 3d1ef02aba qpkg: added copyright headers and changed name to emphasize speediness
- Makefile, gobble.h, gobble.c, id.h, id.c, prereq.h, prereq.c, qpkg.h,
  qpkg.c, rbtest.c: added copyright header
- id.c: include jrb.h (for completeness)
- README: change name from "Query package databases" to "Quick package
  database query"
2010-11-20 07:29:18 -03:00
Werner Almesberger 07a4422641 qpkg/TODO: cleanup and added new task for consideration
- TODO: added section for tasks done
- TODO: search tree optimization is done
- TODO: added idea of supporting other database formats in the same family
2010-11-20 07:18:44 -03:00
Werner Almesberger 9481934c9a qpkg: Makefile cleanup and added OpenWRT target
- Makefile: added automatic dependenceies (needs SHELL = /bin/bash)
- Makefile: added non-verbose builds
- Makefile (jlime): set CC_normal instead of CC, so that also cross-builds
  can be non-verbose
- Makefile (openwrt): new target to cross-compile for OpenWRT with uClibc
- Makefile (spotless): added "spotless" target
- gobble.c: uClibc may not have posix_madvise, so replace it with a dummy
  if building for uClibc
2010-11-20 07:14:52 -03:00
Werner Almesberger 78006c51cc qpkg: added README and COPYING.GPLv2 2010-11-20 06:29:57 -03:00
Werner Almesberger 798209f883 qpkg/jrb.c: removed unnecessary inclusion of ctype.h and string.h 2010-11-19 22:32:39 -03:00
Werner Almesberger ed0281f306 qpkg/gobble.c (EXPECT): added variant that just skips over expected text
If the package database is sane, then we don't need to check that all
the field names match what we expect. This saves a few more CPU cycles.
However, if anything goes wrong, the consequences may be unpleasant.
Thus, we default to the slow but safe approach.
2010-11-19 22:29:19 -03:00
Werner Almesberger 03c5e4ffe7 qpkg: optimize duplicate lookup when inserting a new name
- jrb.h, jrb.c (jrb_find_or_insert): new function to look for a node and
  to insert a new one if not found
- id.c (make_id): use jrb_find_or_insert to avoid looking up new nodes
  twice
- TODO: report the improvement
2010-11-19 22:20:15 -03:00
Werner Almesberger 64c70e77f4 qpkg: use "val" field of jrb nodes instead of keeping one in "struct id"
- id.h (struct id), id.c (make_id): remove field "value"
- gobble.c (compact_pkg, gobble_buf), prereq.c (list_all_packages,
  list_one_package, find_prereq): use id->jrb->val instead of id->value
2010-11-19 22:02:42 -03:00
Werner Almesberger 0cc1dfc938 qpkg/Makefile (jlime): new target to build for the Ben under Jlime 2010-11-19 22:01:33 -03:00
Werner Almesberger a9f12d5666 qpkg: converted ID comparison from "struct id *" to "void *"
- id.h (struct tree, comp_id, make_tree), id.c (comp_id, make_tree):
  comparison function now takes "void *" (pointing to a "struct id")
  arguments instead of "struct id *", for compatibility with jrb
- id.c (comp_id, do_comp_id): added wrapper to convert "void *" back to
  "struct id *"
2010-11-19 21:53:43 -03:00
Werner Almesberger af27092667 qpkg/gobble.c (gobble_buf): initialize pkg->conflicts and pkg->depends 2010-11-19 21:53:43 -03:00
Werner Almesberger e1814ce372 qpkg: converted dumb binary trees to red-black trees (in progress)
This is a change of the underlying mechanism but it's not polished or
optimized yet. The compare functions haven't been updated, so they work
but produce compiler warnings because of type mismatches.

- Makefile (OBJS): added jrb.o
- id.h, id.c: use jrb instead of own dumb binary trees
- TODO: brag about the efficiency improvement
2010-11-19 21:53:38 -03:00
Werner Almesberger a8ed4dcb23 qpkg: use -Wmissing-prototypes
- Makefile (CFLAGS): use -Wmissing-prototypes
- jrb.c (lprev, rprev): made "static"
- prereq.c: include prereq.h
2010-11-19 20:51:49 -03:00
Werner Almesberger 47abebe364 qpkg: renamed "struct jrb_node" to "struct jrb" replaced JRB with "struct jrb *" 2010-11-19 20:48:49 -03:00
Werner Almesberger da7a6feb4b qpkg/jrb.c: reordered recolor and single_rotate and removed prototypes 2010-11-19 20:39:41 -03:00
Werner Almesberger c060b883a9 qpkg: mention in jrb-related files that they've been heavily edited 2010-11-19 20:37:29 -03:00
Werner Almesberger 7e641d2655 qpkg/jrb.[ch]: remove trailing spaces 2010-11-19 20:35:43 -03:00
Werner Almesberger a463773c12 qpkg: simplify jrb_delete_node and more whitespace cleanup
- jrb.c (recolor, jrb_delete_node, jrb_nblack, jrb_free_tree): add space
  to while(...
- jrb.c (jrb_delete_node): flatten deletion of internal node
- rbtest.c (main): add test of jrb_delete_node
2010-11-19 20:30:24 -03:00
Werner Almesberger 5a422a470d qpkg/jrb.c (mk_new_ext): converted from macro to function 2010-11-19 20:23:16 -03:00