Commit Graph

150 Commits (d0edeec8fb8fa5abee8b3065cea5e4882d0c51c4)

Author SHA1 Message Date
Timo Teräs aec93ee730 db: unify handling of special packages
make cache a special kind of repository, and automatically cache
special packages (virtual packages, or ones installed from command
line). add test cases for handling virtual packages. fixes #1617.
2013-05-30 08:48:32 +03:00
Timo Teräs 84bfef1a6b solver: increase score fields to 32-bits (from 16-bits)
We are having so many packages that they might overflow otherwise.
"ERROR: Preference overflow" was already reported.
2013-04-29 14:14:57 +03:00
Timo Teräs 72cd34cf81 solver: remove backjumping by name
It is incorrect optimization causing valid solutions to be skipped.
Any performance it might've gained, should be fixed by reintroduction
of the minimum penalty logic added in previous commit.
2013-01-28 15:34:09 +02:00
Timo Teräs cb98b55b7e solver: reintroduce minimum penalty logic
Basic per-name per-package specific scoring added.
2013-01-28 15:31:34 +02:00
Timo Teräs 528156a9fa solver: do not backtrack over "exclude none"
Otherwise we can return no solution at all instead of partially
satisfied solution (and give proper error message).
2013-01-22 16:23:16 +02:00
Timo Teräs 93bd305713 solver: simplify strength evaluation in constraint handling 2013-01-21 15:37:23 +02:00
Timo Teräs 2a194f3e7b solver: check if solution is not found at all
This is an internal error.
2013-01-21 09:12:44 +02:00
Timo Teräs b960759daa solver: fix reset of last_touched to zero 2013-01-18 16:21:38 +02:00
Timo Teräs cb15b31b79 solver: some code clean ups 2013-01-18 16:20:55 +02:00
Natanael Copa 3c40070752 solver: build fix for debug print on x86_64
use %zu for size_t
2013-01-18 14:46:25 +01:00
Timo Teräs 86a7338575 solver: fix name assignment logic to not mess up internal state
Should get rid of error messages like:
ERROR: Saved_score {4/0/0,74} != score {6/0/0,74}
2013-01-18 11:38:31 +02:00
Timo Teräs 832dfed637 solver: fix package prefence calculation a bit 2012-11-04 12:13:19 +02:00
Timo Teräs 16b70566bf solver: additional backjumping scheme
Enabled when all attempts to satisfy a name failed, we know that we
can ignore all decisions until we find a decision affecting the name
we wanted to satisfy.
2012-10-08 15:22:06 +03:00
Timo Teräs 01d0e4c408 solver: optimize backjumping
to be functional when backtracking
2012-10-08 12:25:43 +03:00
Timo Teräs 831bce5cf9 solver: properly calculate decision "strength" with provides 2012-10-08 11:50:52 +03:00
Timo Teräs dec409c6d4 solver: fix back jumping once more 2012-10-05 17:26:53 +03:00
Timo Teräs bc7e8f5da8 solver: record dependency apk_name in apk_decision
We can't just use the primary name, as that would mess up
backtracking. We need to record the name which caused the name
to get considered - that way the right last_touched_decision is
used on backtracking.
2012-10-05 15:48:12 +03:00
Timo Teräs 4dd8c58df9 solver: various fixes
* push_decision expects to always get the package primary 'name'
   as apk_name. ASSERT that and fix problem cases.
   (though - this might need to be reverted, and store the non
    primary name in apk_decision instead to accomodate for better
    backtracking optimizations)
 * fix error reporting of virtual package names
 * make 'assign_name' errors soft. the incorrect packages just are
   no longer consider instead of aborting whole calculation.
 * fix backtracking of virtual packages that are not depended
   directly
2012-10-03 15:07:31 +03:00
Natanael Copa 081155c438 solver: improve assert error messages
Print name of package and void double "ERROR"
2012-10-03 09:16:28 +02:00
Natanael Copa 00958d9207 solver: fix compile with -Werror on 64bit 2012-10-03 09:04:35 +02:00
Timo Teräs 43850a126b apk: implement --progress-fd to write progress to a specified fd 2012-09-20 15:12:15 +03:00
Timo Teräs bbba72c694 solver: fix install_if triggers on cyclic and early deps 2012-04-27 09:13:11 +03:00
Timo Teräs 29c7fb359e solver: fix backtracking with install_if dependencies 2012-04-27 08:47:20 +03:00
Timo Teräs 7458e4d3f4 solver: fix a type from previous commit 2012-03-31 23:31:43 +03:00
Timo Teräs a57db1bba0 solver: fix installation of non-repository packages 2012-03-31 23:27:15 +03:00
Timo Teräs 5ae0206d0b solver: properly set allowed flag for installed packages 2012-03-01 15:17:58 +02:00
Timo Teräs 3e429a8100 solver: rename some fields 2012-02-29 13:15:10 +02:00
Timo Teräs 2f66295fc7 solver: merge apk_name_state to apk_name
apk_name_state is now quite small; and we avoid overhead of two
pointers (+ malloc overhead) when we just make it part of apk_name.
It also fixes some problems (that got introduced) where apk_name_state
was not allocated.
2012-02-29 11:26:12 +02:00
Timo Teräs f27f194d92 solver, test: make conflicts unconditional
Solver will now never report partial solution where a conflict
constraint is not satisfied. The is because with --force we might
install the partial solution; and if conflicted packages were to
be installed we might have extra trouble.
2012-02-29 08:53:43 +02:00
Timo Teräs ef53dd52c5 solver: ask confirmation in interactive mode only if there's changes 2012-02-28 11:32:39 +02:00
Timo Teräs c7bd973367 solver: do not consider non-allowed packages in main loop
Instead cache the allowed pinning decision, and use it. Update
install decision heuristic to also use this cached information.
2012-02-28 11:27:56 +02:00
Timo Teräs 2655d27ea1 solver: consider provided names also for preference
ref #574
2012-02-28 11:27:17 +02:00
Timo Teräs 179b453ab7 solver: fix conflicting provides detection
ref #574
2012-02-28 10:28:39 +02:00
Timo Teräs 536c21979b solver: allow multiple packages with same virtual provides
ref #574
2012-02-28 09:39:35 +02:00
Timo Teräs b7a22e555f solver, test: implements more provides things, add tests
ref #574
2012-02-27 16:35:04 +02:00
Timo Teräs 1074c4d326 solver: have most inherited things per-package and clean ups
Required for provides support as package might be pulled in via
non-primary package name. This allows relatively easily to pass
through inherited flags via the provided names. ref #574.
2012-02-27 10:26:30 +02:00
Timo Teräs f0f2029eb1 solver: remove minimum penalty logic
Reasoning:
- it is less useful now that we do not do common dependency merging
- provides support would make the required logic overly complicated
- callgrind reports that depending on the case it can improve or
  decrease performance (the overhead pays off only in some cases);
  the difference is not large either way
2012-02-27 08:29:35 +02:00
Timo Teräs 12bdec38a3 solver, dot: elementary provides fixes
implementation is still not near finished, but now at least it
can handle it to a minimum degree. many cases are not done right
yet, though. ref #574.
2012-02-24 18:29:30 +02:00
Timo Teräs 99145e2c0d all: introduce apk_provides and use it in apk_name
in preparation for provides support. implements also some
dependency satisfaction helper routines.

ref #574.
2012-02-24 16:31:40 +02:00
Timo Teräs 97d44b5a00 solver: unallowed pinning is worse than changing installed package 2012-02-24 16:27:51 +02:00
Timo Teräs d420d41148 solver: non preferred actions are worse then non preferred pinning
Otherwise we might start to change packages unexpectedly when not
upgrading. This also fixes some other things the solver might've
decided to do.

Add also few test cases to detect bad behaviour.
2012-02-24 11:13:31 +02:00
Timo Teräs 4676c5d63a test: improve pinning tests 2012-02-24 08:42:40 +02:00
Timo Teräs 1bb2fa7862 solver: fix output of broken dependencies 2012-02-23 22:05:33 +02:00
Timo Teräs a9a84215c7 solver: report size difference in kibi- or mebibytes 2012-02-23 16:02:03 +02:00
Timo Teräs d633746892 solver: lock early names that have only single option left
care is needed to get the score right.
2012-02-22 13:09:51 +02:00
Timo Teräs 93a0f0b3cc solver: lazily update name state in main loop 2012-02-22 12:59:46 +02:00
Timo Teräs b9f3db2158 solver: handle fix/reinstall better
In case someone did "fix --force" for package for which we have no
APK available, we would uninstall the package instead of silently
ignoring the request. This could mean worse things.

So now we just consider unavailable packages a bad deal for reinstall
requests. And will downgrade if necessary. But if we really don't
have any APK available, we just skip the request but report it.
2012-02-22 10:31:07 +02:00
Timo Teräs a7500a9df5 solver: transitive dependency requiring
If n+1 packages depend A, and A depend on B. Add n+1 dependencies
to B. Otherwise if someone conflicts B, B might be left out.

Leaving package unassigned is no longer a non-preferred action,
this fixes the final test case that was failing.

And with --force we might even install that scenario.
Add also some debug checks.
2012-02-22 09:43:47 +02:00
Timo Teräs 955153eac2 solver: remove dependency merging; it's not worth it
callgrind says it's more overhead than improvement. back jumping
effectively prunes all bad trees. but can be added later if it
becomes needed; due to e.g. provides support.
2012-02-22 09:08:14 +02:00
Timo Teräs bf82e2e5fd db, solver, io: scan cache items at startup
It is faster to just scan the cache directory for existing packages
at startup than trying to faccessat() them on demand. It also makes
quite a few parts of the code more readable and simpler.
2012-02-22 08:45:40 +02:00
Timo Teräs 568d57336d solver: make apk_score a 64-bit int for speed 2012-02-21 11:01:21 +02:00
Timo Teräs c18e159185 solver: remove unneeded flag 2012-02-21 10:36:26 +02:00
Timo Teräs 6f237d9149 solver: implement backwards jumping and various other optimizations 2012-02-21 09:19:24 +02:00
Timo Teräs 6ae573887d solver: rewrite backtracking and scoring system
* properly do absolute scoring now, the previous scoring where
  preference could get reduced could have caused incorrect early
  pruning of search tree

* backtracking is now separated from package state, and first
  branching point is the decision if a name is left unassigned
  or if something _has_ to be assigned. this allows multiple future
  search tree optimizations like handling of common dependencies
  early.

* merge common dependency names early to provide deeper forward
  checking.
2012-02-20 13:02:09 +02:00
Timo Teräs a9d526836e apk: fix some unharmful leaks reported by valgrind 2012-02-17 10:02:44 +02:00
Timo Teräs 15c920ab90 solver: get rid of saved score in backtracking
also, discover late if package is needed or not.
2012-02-17 09:43:14 +02:00
Timo Teräs 4bc8add78d solver: convert some package state flags to bitfields 2012-02-16 21:46:09 +02:00
Timo Teräs 706664c178 solver: name's unlocked chosen is always next package getting locked
Instead of "skipping" certain packages, we include them as-if required,
and at expansion time we decide if they actually need to be considered
for installation. This cleans up the expansion main loop a little bit
and makes the code work together better.
2012-02-16 21:35:05 +02:00
Timo Teräs b0c0b900db solver: rework internals a bit
* cleaned up little bit on the internal state machine
* the decision applying mechanism now aborts early to avoid work
  if we are approaching bad solution candidate
* package availability checking is now done on-demand; which
  could still be improved
2012-02-16 21:11:22 +02:00
Timo Teräs 53f8a36c1f solver: fix allowed pinning calculation 2012-02-16 11:45:54 +02:00
Timo Teräs 0800d7e050 solver: record repository tag, and flags in solution
name state could get overwritten later, so we can't use that when
generating the changeset.
2012-02-16 10:57:52 +02:00
Timo Teräs 7399f1950f solver: remove an unneeded name state variable 2012-02-16 08:28:08 +02:00
Timo Teräs 41fb3a4f9e solver, db: repository pinning improvements
* solver internally calculates now using tags; not repository masks
* installeddb now contains the tag name where the package came from
  -> we can now handle upgrades properly
* the pinning is still a preference, and not strictly enforced;
  versioned dependencies may overrule preference
2012-02-15 13:57:36 +02:00
Timo Teräs 0f89565099 solver: fix regression from "calculate branch minimum penalty early"
Forgot to reset per-name penalty when it got locked by apply_decision.
This also fine tunes compare_package_preference() to always prefer
packages specified on command line speeding up calculation certain
complicated solutions.
2012-01-20 10:39:38 +02:00
Timo Teräs b3df78ed03 solver, upgrade: properly detect missing repository tags
* upgrade needs explicit check so we don't try self-upgrade
   (which would print additional messages on screen)
 * add can fix problems, so check against the new world
 * merge the code in few places
2012-01-17 14:48:22 +02:00
Timo Teräs 64b03ab603 solver: fix change ordering of removed pages in relation to installed 2012-01-17 14:18:10 +02:00
Timo Teräs 12183024fd solver: calculate branch minimum penalty early
Previously we would cache the penalty when evaluating the final
solution, and adding that until we backtrack to first topology
position changing that penalty. However, we can just keep track
of minimum penalty based on name state, and add it. This allows
us to bail out early on bad branches because we know in advance
how things will turn out.
2012-01-17 14:18:02 +02:00
Timo Teräs 2ea61da9d9 add: make repository tag pinning stronger
Previously we would not upgrade just by doing "apk add foo@tag" if
foo was already installed. It required explicit '-u'. This allows
'apk add' to explicitly prefer the newly specified pinning.
2012-01-13 10:39:06 +02:00
Timo Teräs 30965aa867 solver: print repository tag when committing package changes 2012-01-12 11:33:04 +02:00
Timo Teräs f1de353b81 db, solver: refuse committing changes if there is missing tags 2012-01-12 10:42:27 +02:00
Timo Teräs 34756e6b87 solver: report number of (mega)bytes used 2011-12-27 14:06:03 +02:00
Timo Teräs d80536b750 solver: fix error detection for certain unsatisfiability cases
did not properly detect as error if name could not be satisfied
due to being available in tagged repository which is not enabled.
2011-11-23 14:35:54 +02:00
Timo Teräs 716ee9e223 solver: fix zero score comparison 2011-11-01 14:44:39 +02:00
Timo Teräs 078e8b00d8 solver: return changeset even for partial solutions
otherwise --force does might not work during boot.
2011-11-01 08:40:50 +02:00
Timo Teräs f13ec9cf5e solver: consider world dependencies to determining exit score 2011-11-01 08:29:24 +02:00
Timo Teräs 918807c45b solver: misc fixes
caused upgrading package X with "apk add path/to/x...apk" where
the package file was not in any repository to not work properly.
2011-10-31 16:51:53 +02:00
Timo Teräs cb5054e686 solver: fix indentation of package lists (in interactive mode)
broken in commit bfd53b59d2 (print: minor cleanup to indented writer).
2011-10-29 23:43:50 +03:00
Timo Teräs 500f8d4a7d solver, db: implement repository pinning
Improves /etc/apk/repositories format so you can say:
http://nl.alpinelinux.org/alpine/v2.3/main
@edge http://nl.alpinelinux.org/alpine/edge/main
@testing http://nl.alpinelinux.org/alpine/edge/testing

After which you can pin dependencies to these tags using:
 apk add stableapp newapp@edge bleedingapp@testing

Apk will now by default only use the untagged repositories,
but adding a tag to specific dependency:
 1. will prefer that tag for the name
 2. allowing pulling in dependencies from that tag (though,
    it prefers untagged packages to satisfy deps if possible)

fixes #575
2011-10-29 05:18:21 +03:00
Timo Teräs e682e6596c solver, pkg: implement versioned conflicts
One can now say in dependency "!foo<2" which means, that if foo is
installed, it needs to be >=2, but it's not a required dependency.
2011-10-24 10:16:40 -04:00
Timo Teräs afd854a3e2 solver: preference scoring
Should now choose packages better if the best available version
is uninstallable for some reason.
2011-10-14 21:01:43 +03:00
Timo Teräs 3f098e7d8c solver: return error code if things fail during package install 2011-09-28 14:04:02 +03:00
Timo Teräs f76535cb5e solver: evaluate penalty of unsatisfiable name early
this prunes the search tree considerably and fixes a speed
regression introduced in an earlier commit.
2011-09-28 08:39:52 +03:00
Timo Teräs 012bcbe41c solver: fix backtracking
We need to refresh all name states after backtracking as options
that were excluding due to topology ordering might have become
available.
2011-09-22 13:09:23 +03:00
Timo Teräs 51999c97da solver: inheritable solver flags
allow per-name solver flags to be inheritable, and use them in
self-upgrade, add -u  and the fix applet. this gives more familiar
behaviour for the upgrades.
2011-09-16 17:10:50 +03:00
Timo Teräs cca6a7e332 solver: fix sorting when solver is used multiple times within run
namely this fixes apk upgrade without --no-self-upgrade when
the solver is called twice.
2011-09-15 09:49:25 +03:00
Timo Teräs 803f55ece5 solver: make state pointers completely internal
the only bit of information needed in solver commit is the "hard"
topology sorting information for trigger ordering. fixes a bug in
"apk del" which uses the state pointers to do intermediate
calculations between solution solving and commit.
2011-09-14 16:48:28 +03:00
Timo Teräs e34d2ed5fd solver, db: run triggers in dependency order
fixes #738
2011-09-14 11:30:35 +03:00
Timo Teräs f51aa6d42d upgrade: reimplement self-upgrade (after solver merge) 2011-09-14 10:57:51 +03:00
Timo Teräs 1817b0a3c3 all: update copyright year statement 2011-09-13 11:53:01 +03:00
Timo Teräs c6d9962d81 solver: add per-name specific flags, and fix the fix applet 2011-09-13 11:47:34 +03:00
Timo Teräs bfd53b59d2 print: minor cleanup to indented writer 2011-09-09 20:06:10 +03:00
Timo Teräs 4bf13c3d9a del: fix recursive deletion and messages (after solver merge)
Deduce the world dependencies to remove locally, and same for the
additional messages about packages not deleted.
2011-09-09 19:41:19 +03:00
Timo Teräs a5a7021658 applets: start using solver code
still todo:
  - 'fix' is missing
  - 'del -R' does not work
  - 'upgrade' does not do self-upgrade first

... and a lot of testing.
2011-09-09 16:32:31 +03:00
Timo Teräs 0e24207c2e solver: report 'complete' solutions with errors
Allow to select packages that conflict in case we are looking for
errors. This allows 'add --force' to install (on boot) the set of
packages with minimum conflicts.
2011-09-05 11:04:00 +03:00
Timo Teräs 1fb1afc5c2 solver: reintroduce install_if support
* each package name has two sorting positions, one which causes
   install_if triggers to be run, and other for bulk dependencies
 * fix also inverted ordering of package installations
2011-08-18 13:08:27 +03:00
Timo Teräs 48d368e7d5 solver: move topology sorting to solver code
this allows quite some optimizations to running time and memory
requirements.
2011-08-05 14:34:58 +03:00
Timo Teräs a5146f1b6c solver: generate proper error messages
* the solver no longer does look-ahead locking of names
   (could be possibly optimized later); instead names are now
   always ordered strictly to properly detect the package names
   which are unsolveable
 * basic error tests added, so we can see the most likely problem
   in dependencies easily
2011-08-01 16:21:47 +03:00
Timo Teräs 1a04425fad solver: don't consider package that we can't have
Packages that need (re-)installation but which are not available,
are excluded now properly.
2011-07-27 22:10:44 +03:00
Timo Teräs ad45a6de17 solver: permutate each preferred solution first
The first found solution is the most preferred one then.
2011-07-27 20:45:38 +03:00
Timo Teräs 79b53d4d76 solver: new package selection logic (which is not yet used)
* basic code for a backtracking, forward checking dependency satisfier
 * works better when there are tricky dependencies to solve
   (when can't just upgrade everything to most preferred versions)
 * the new code always evaluates all of 'world' constraints
   (old code just does incremental updates based on heuristics)
 * is probably somewhat slower than old code (probably unnoticeable
   difference in most cases)
 * makes easier to write support for provides and repository pinning
 * test applet and a bunch of test cases added which uses the new code
 * from the old feature set install_if is not yet implemented
2011-07-26 17:08:43 +03:00