Commit Graph

46 Commits

Author SHA1 Message Date
Alexey Tourbin
add6349fea system.h: moved AUTO_REALLOC from depends.h 2011-01-06 03:26:09 +03:00
Alexey Tourbin
523b00db6e depends.c (rpmRangesOverlap): avoid extra strcmp calls 2011-01-06 03:24:14 +03:00
c7167f0395 lib/depends.c (rpmRangesOverlap): optimize out unneeded calls to printDepend()
This optimization speeds up rpmRangesOverlap() by 10%.
2010-12-04 17:30:16 +00:00
Alexey Tourbin
3e9adcff64 depends.c (rpmRangesOverlap): added support for set-versions 2010-09-11 01:58:13 +04:00
Mikhail Efremov
f92be4b40e Added SELinux support
Mostly backported from rpm-4.8
2010-08-24 16:59:07 +00:00
Alexey Tourbin
0e2e506379 depends.c: do not check installed Conflicts against addedPackages names
In build.c:checkSpec(), build dependencies are checked by creating
a transaction, adding source header to the transaction and then running
rpmdepCheck().  Source headers have only BuildRequies and BuildConflicts
types of dependencies (no regular Requires and Conflicts).  Also, source
packages have no Provides, but they have NAMES.  When a self-conflicting
package is installed, its self conflict will be triggered by the source
package name.

To fix the problem, note that binary packages explicitly provide
their N=EVR among Provides; and source packages provides nothing,
even the name.  So the solution is as simple as not to check
the dependencies against package names.

Update: also, do not check installed Requires against erasedPackages names.
2010-08-22 03:20:50 +04:00
Alexey Tourbin
e8c5b7ad21 depends.c: permit self-conflicting packages
Only for the last two weeks or so, the issues has been raised twice.
By specifying "Provides: foo, Conflicts: foo", people expect that
other packages which provide "foo" will not be installed along with
the package.  What people don't anticipate is that the package will
conflict with itself, and will not be installed at all.  This is where
apt and rpm differ.  In apt, "conflicts may never self match".  In rpm,
Requires and Conflicts are handled in exactly the same way, except that
Requires should match, and Conflicts should not match (I call this
a symmetry).  Both can match against the package they come from.

So, to permit self-conflicting packages, I have to break the symmetry
and pass additional argument which indicates the type of dependency
being processed (either Requires or Conflicts).  The code is then
adjusted to discard self-matching Conflicts.

Obsoletes should be handled specially, too.  In tsSatisfiesDepend(),
I attempt to handle the Obsoletes case as well.  It is rather
unfortunate that, in rpmdepCheck(), Obsoletes are simply not checked
just yet.
2010-08-22 01:04:41 +04:00
Alexey Tourbin
682646a657 depends.c: made dbProvCache global (static __thread)
Passing this "implicit" argument from a toplevel API function
down to dbSatisfiesDepends() looks too ugly.
2010-08-19 00:37:23 +04:00
Alexey Tourbin
adce826c53 depends.c: better solution for dbProvCache dangling pointers without resorting to strdup 2010-08-18 14:28:08 +04:00
Alexey Tourbin
da0408ae20 Revert "depends.c (dbSatisfiesDepend): strdup dbProvCache keys (ALT#23811)"
This reverts commit c9b1f0e2ec.
2010-08-18 11:56:59 +04:00
Alexey Tourbin
c9b1f0e2ec depends.c (dbSatisfiesDepend): strdup dbProvCache keys (ALT#23811)
My previous assumption that strdup() was not needed for dbProvCache keys
was wrong.  The keys point to header memory, which is right.  However,
those are not only ts->addedPackages and ts->erasedPackages headers.
In checkDependent(), headers come from rpmdb and are disposed immediately
after the check.
2010-08-05 18:27:02 +04:00
Alexey Tourbin
7a1f3ed06d depends.c: provided actual dbProvCache implementation
Based on rpm.org 2e76d0e6 by Panu Matilainen:
> Add in-memory hash for caching rpmdb dependency lookups
> - worst case behavior for uncached dependency lookups can be disastrous,
>   eg > 35s vs < 1s on my laptop for trying to remove /bin/sh provider
> - we only bother caching rpmdb lookups, the other cases plenty fast already
> - using in-memory cache avoids nasty in vs out of chroot issues with
>   temporary db files, which otherwise were about as fast

However, we do not use full-blown printDepend-based caching (i.e.
we no longer cache depends with versions).  This is because, well,
dependency versions are likely to differ.  This is especially true
if we consider upcoming set-versions for soname symbols - hashing
symbol sets here will be just a waste of time and memory.  And so
now we cache satisfied/unsatisfied depends by just name.  Thus,
"yes" hit can be used immediately only for unversioned dependences.

Top 10 dependencies which will be handled by the cache:
$ rpm -qaR |grep -v rpmlib |grep -v = |sort |uniq -c |sort -n |tail
    245 /usr/lib/perl5/vendor_perl
    311 libm.so.6(GLIBC_2.2.5)(64bit)
    386 libpthread.so.0(GLIBC_2.2.5)(64bit)
    454 /lib64/ld-linux-x86-64.so.2
    548 libc.so.6(GLIBC_2.3)(64bit)
    587 /bin/sh
    828 libc.so.6(GLIBC_2.3.4)(64bit)
    906 libc.so.6(GLIBC_2.4)(64bit)
   1128 rtld(GNU_HASH)
   1140 libc.so.6(GLIBC_2.2.5)(64bit)
$

Top 10 dependencies which will not be handled by the cache:
$ rpm -qaR |grep -v rpmlib |grep -e = |sort |uniq -c |sort -n |tail
     13 python-base = 2.6.5-alt2
     14 mono(mscorlib) = 1.0
     15 qt4-common = 4.6.2-alt6
     16 mono(mscorlib) = 2.0
     18 mktemp >= 1:1.3.1
     20 koffice-common = 4:2.2.0-alt2
     20 perl-base >= 1:5.8.0
     23 alternatives >= 0:0.4
     49 libqt4-core >= 4.6.2
     54 perl-base >= 1:5.6.0
$

Here's a simple test to see if the cache works (using Panu's example -
trying to remove /bin/sh).

(before this change)
$ time LD_LIBRARY_PATH=$PWD/1 rpm -e --test sh 2>&1 |tail
        /bin/sh   is needed by groff-base-1.20.1-alt0.20091013
        /bin/sh   is needed by groff-base-1.20.1-alt0.20091013
        /bin/sh   is needed by groff-base-1.20.1-alt0.20091013
        /bin/sh   is needed by libgnome-sharp-2.24.1-alt1
        /bin/sh   is needed by kernel-image-std-def-2.6.32-alt15
        /bin/sh   is needed by kernel-image-std-def-2.6.32-alt15
        /bin/sh   is needed by kde4libs-4.4.5-alt1
        /bin/sh   is needed by kde4base-runtime-core-4.4.5-alt1
        /bin/sh   is needed by kde4base-konqueror-4.4.5-alt1
        /usr/lib/bash is needed by bash-builtin-lockf-0.3.1-alt1
rpm -e --test sh 2>&1  6.18s user 3.44s system 94% cpu 10.182 total
$

(after this change)
$ time LD_LIBRARY_PATH=$PWD/2 rpm -e --test sh 2>&1 |tail
        /bin/sh   is needed by groff-base-1.20.1-alt0.20091013
        /bin/sh   is needed by groff-base-1.20.1-alt0.20091013
        /bin/sh   is needed by groff-base-1.20.1-alt0.20091013
        /bin/sh   is needed by libgnome-sharp-2.24.1-alt1
        /bin/sh   is needed by kernel-image-std-def-2.6.32-alt15
        /bin/sh   is needed by kernel-image-std-def-2.6.32-alt15
        /bin/sh   is needed by kde4libs-4.4.5-alt1
        /bin/sh   is needed by kde4base-runtime-core-4.4.5-alt1
        /bin/sh   is needed by kde4base-konqueror-4.4.5-alt1
        /usr/lib/bash is needed by bash-builtin-lockf-0.3.1-alt1
rpm -e --test sh 2>&1  0.11s user 0.09s system 91% cpu 0.218 total
$
2010-07-12 11:39:27 +04:00
Alexey Tourbin
d35a165dc3 depends.c: pass dbProvCache parameter down to dbSatisfiesDepend
This is a bit ugly but this is probably still a bit better than
extending the ts structure.
2010-07-12 11:39:26 +04:00
Alexey Tourbin
945417c34f depends.c: updated for ts->erasedPackages 2010-07-12 11:39:25 +04:00
Alexey Tourbin
d392376ed7 depends.c: added initial support for ts->erasedPackages list
Before this change, only rpm headers for addedPackages were loaded
during transaction; for removedPackages, we only stored the list
of rpmdb header numbers (numeric instances).  With this change,
removedPackages' headers are getting loaded, too (the list is called
erasedPackages).  The reason is that, when a header is loaded,
it is possible to use pointers to point e.g. into header strings
without using strdup.  This might come useful as we try to reimplement
the depends cache.
2010-07-12 11:37:40 +04:00
Alexey Tourbin
83a71d080d depends.c: merged check{PackageSet,Dependent{Packages,Conflicts}} into checkDependent 2010-07-12 10:04:41 +04:00
Alexey Tourbin
fc5bc9b582 depends.c: renamed unsatisfiedDepend -> tsSatisfiesDepends, factored dbSatisfiesDepends
Based on rpm.org ccb545f0 "Refactor rpmdb lookups..." by Panu Matilainen.
2010-07-12 10:03:19 +04:00
Alexey Tourbin
c6943fb0f2 depends.c: further removed dying code 2010-07-12 10:01:55 +04:00
Alexey Tourbin
cf70d66c4e depends.c: disabled dbi-based dependency caching
Based on rpm.org 6bc5d870 by Panu Matilainen:
> Rip out dependency caching
> - it doesn't speed up things that much, is broken in some chroot
>   scenarios and is ugly ugly hardwired BDB hackery where it doesn't belong
2010-07-12 10:01:29 +04:00
Alexey Tourbin
3d98659409 depends.c: need to export printDepend() 2010-03-16 15:03:27 +03:00
Alexey Tourbin
797f0ff2a5 order.c: factored from depends.c 2010-03-16 15:03:23 +03:00
Alexey Tourbin
7f0aa5d96d al.c: optimize out rpmRangesOverlap call for unversioned dependencies 2009-10-04 12:44:40 +04:00
Alexey Tourbin
09751027bf al.c: removed extra arguments in alAllSatisfiesDepend 2009-10-04 12:44:38 +04:00
Alexey Tourbin
216526577b al.c: reimplemented alProvIndex, removed alMakeIndex() 2009-10-04 12:44:35 +04:00
Alexey Tourbin
5c8817985a al.c: factored from depends.c 2009-10-04 12:44:33 +04:00
Alexey Tourbin
d9e8ab64f5 depends.c: turned availableIndex.index into flexible array 2009-10-04 12:44:32 +04:00
Alexey Tourbin
f14e4a1fd9 depends.c: implemented automatic realloc 2009-10-04 12:44:30 +04:00
Alexey Tourbin
f9e7f3e6e0 depends.c: avoid expression dependent on evaluation order
In alAddPackage(), ts->addedPackages.list can be reallocated with
realloc().  So it is not safe to use ts->addedPackages.list in the
same expression.
2009-10-04 12:44:28 +04:00
Alexey Tourbin
55ef8cfed5 removed support for availablePackages/suggestedPackages 2009-10-01 04:38:09 +04:00
Alexey Tourbin
a15d548dec lib/depends.c: adjust provides check for versioned paths
(cherry picked from commit fb5f3e4c88)
2009-06-17 06:30:53 +04:00
Panu Matilainen
3dfb7d4b01 Remove artificial limit in dependency loop elimination attempts
- continue processing as long as progress can be made instead of artificial
  hardcoded magic "try ten times"

[rpm.org f39d2432f74bdc328ceafa8abc6cac517e02c73b]
2009-06-14 05:34:36 +04:00
Alexey Tourbin
aebc9a42dd removed prehistoric multilib support 2009-03-10 14:27:38 +03:00
Alexey Tourbin
b8767dceb1 depends.c: disabled tsort presentation order
This should facilitate library upgrades, e.g. glibc-prthread.
Consider that we upgrade gcc-* and glibc-* packages; and glibc
has new subpackage glibc-pthread (with libpthread and librt
shared libraries).

Old order was:
D: ========== tsorting packages (order, #predecessors, #succesors, tree, depth)
D:     0    0   14    0    0  glibc-preinstall-2.8.90-alt3
D:     1    1   21    0    1    glibc-core-2.8.90-alt3
D:     2    1    9    0    2      cpp4.3-4.3.2-alt5
D:     3    1    5    0    2      libgcc4.3-4.3.2-alt5
D:     4    2   13    0    3        glibc-pthread-2.8.90-alt3
D:     5    2   20    0    4          glibc-core-debug-2.8.90-alt3
D:     6    2   17    0    4          glibc-gconv-modules-2.8.90-alt3
D:     7    2   16    0    4          glibc-locales-2.8.90-alt3
D:     8    2   15    0    4          glibc-nss-2.8.90-alt3
D:     9    2   12    0    4          glibc-timezones-2.8.90-alt3
D:    10    2   11    0    4          glibc-utils-2.8.90-alt3
D:    11    2   10    0    5            iconv-2.8.90-alt3
D:    12    8   22    0    6              glibc-2.8.90-alt3
D:    13    4   19    0    7                glibc-devel-2.8.90-alt3
D:    14    1   18    0    8                  glibc-devel-static-2.8.90-alt3
D:    15    4    8    0    8                  gcc4.3-4.3.2-alt5
D:    16    1    4    0    2      libgfortran4.3-4.3.2-alt5
D:    17    2    3    0    3        libgfortran4.3-devel-4.3.2-alt5
D:    18    3    6    0    4          gcc4.3-fortran-4.3.2-alt5
D:    19    2    2    0    3        libstdc++4.3-4.3.2-alt5
D:    20    2    1    0    4          libstdc++4.3-devel-4.3.2-alt5
D: ========== successors only (presentation order)
D:    21    3    7    0    5            gcc4.3-c++-4.3.2-alt5

Note that #succesors value is actually changed using the package index
in the input list of packages (on the command line): earlier packages
have higher values.  This is called "successors from tsort are processed
in presentation order".  E.g. when choosing to upgrade between cpp4.3,
libgcc4.3, and libgfortran4.3, cpp4.3 gets upgraded first.  (The
collation is probably due to using shell glob on the command line.)

The problem is that, in cpp4.3 %post-script, some pthread-dependent
code might be called, and pthread shared library is simply mssing
at that point (after glibc-core upgrade and before glibc-pthread
install).

New order is:
D: ========== tsorting packages (order, #predecessors, #succesors, tree, depth)
D:     0    0    1    0    0  glibc-preinstall-2.8.90-alt3
D:     1    1   17    0    1    glibc-core-2.8.90-alt3
D:     2    1    3    0    2      libgcc4.3-4.3.2-alt5
D:     3    2    8    0    3        glibc-pthread-2.8.90-alt3
D:     4    2    2    0    4          glibc-gconv-modules-2.8.90-alt3
D:     5    2    2    0    4          glibc-nss-2.8.90-alt3
D:     6    2    1    0    5            iconv-2.8.90-alt3
D:     7    2    1    0    4          glibc-locales-2.8.90-alt3
D:     8    2    1    0    4          glibc-timezones-2.8.90-alt3
D:     9    2    1    0    4          glibc-utils-2.8.90-alt3
D:    10    8    1    0    5            glibc-2.8.90-alt3
D:    11    4    4    0    6              glibc-devel-2.8.90-alt3
D:    12    2    1    0    3        libstdc++4.3-4.3.2-alt5
D:    13    2    1    0    4          libstdc++4.3-devel-4.3.2-alt5
D:    14    1    1    0    2      cpp4.3-4.3.2-alt5
D:    15    4    2    0    3        gcc4.3-4.3.2-alt5
D:    16    1    1    0    2      libgfortran4.3-4.3.2-alt5
D:    17    2    1    0    3        libgfortran4.3-devel-4.3.2-alt5
D: ========== successors only (presentation order)
D:    18    2    0    0    4          glibc-core-debug-2.8.90-alt3
D:    19    1    0    0    7                glibc-devel-static-2.8.90-alt3
D:    20    3    0    0    4          gcc4.3-fortran-4.3.2-alt5
D:    21    3    0    0    4          gcc4.3-c++-4.3.2-alt5

Note that #succesors now indicates the number of immediate successors;
libgcc4.3 now has 3 immediate successors (glibc-pthread, gcc4.3, and
libstdc++4.3), while cpp4.3 and libgfortran4.3 have only one immediate
successor.

Also removed tools/rpmsort.c.

> The are various serial representations of a partially ordered set.
>
> The default is what I call "chainsaw", always emit the node that has
> the most children.  The "chainsaw" heuristic tries to emit nodes that
> are depended upon as early as possible to localize interactions
> amongst packages, but really should be
>     Always emit the node of the largest sub-tree.
> rather than the number of immediate children. I call this "buzzsaw".
>
> Anaconda has the constraint of changing cd's during install. So
> "presentation" ordering preserves the arrival ordering into a
> transaction set. Too bad that "presentation" ordering is often
> incorrect because of no loop analysis first.

https://lists.dulug.duke.edu/pipermail/rpm-devel/2005-June/000468.html
2008-11-10 05:21:23 +03:00
8787ee5d55 Fixed "type qualifiers ignored on function return type" issue. 2006-05-15 02:48:59 +04:00
3fa4258878 Backported epoch handling fix in psmStage() and rpmRunTransactions().
Fix package upgrades by introducing digest comparison.
Optionally honor buildtime during package upgrades.
2005-10-17 13:23:09 +00:00
adacd53a24 relocated headerNVR() from lib to rpmdb; added headerNEVRA() to rpmdb 2005-10-15 15:03:18 +00:00
6cb9a9a472 - lib/depends.c(rangeMatchesDepFlags,alAllSatisfiesDepend):
when using rpmRangesOverlap for versioned requires, ensure that
  provides are also versioned.
2004-01-22 12:43:59 +00:00
e13efb7549 reverted recent change 2004-01-22 11:56:33 +00:00
0d326d3a8d rpmRangesOverlap: If both A and B are an existence test, always overlap 2004-01-22 08:57:52 +00:00
4b6e05af60 rpmRangesOverlap: when both EVRs are non-existent or empty, overlap; otherwise use normal rpmEVRcmp algorithm 2004-01-21 15:11:03 +00:00
58e1dad6cc fixed compilation warnings 2003-11-24 18:59:03 +00:00
a6b602bd31 fix Requires(post,preun) problem 2003-07-09 17:21:28 +00:00
de25d1f6d1 Added a pair of new things to the query format:
the '>'-test, ':nothing' format variant and
	implemented '-q --changes-since=<e:v-r>' upon them.
2002-07-20 10:39:40 +00:00
db9590945c updated code to snapshot 2002-04-04 2002-04-05 08:04:32 +00:00
dee952c2f8 sync with rpm4 branch: include local headers 2002-03-25 22:02:39 +00:00
82a4763c66 Initial revision 2002-03-25 20:16:26 +00:00