Commit Graph

60 Commits (d420d4114863fadc6458b489cff32b3d3ab61349)

Author SHA1 Message Date
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