[devel] [jbj на redhat.com]

Dmitry V. Levin =?iso-8859-1?q?ldv_=CE=C1_fandra=2Eorg?=
Вс Ноя 12 15:49:08 MSK 2000


Greetings!

Довольно любопытные рассуждения:

----- Forwarded message from Jeff Johnson <jbj на redhat.com> -----

Date: Sun, 12 Nov 2000 04:58:30 -0500
From: Jeff Johnson <jbj на redhat.com>

All --

> The package ordering algorithm in rpm is gonna change.
> 
> Here's a simple test to illustrate the need for the change (from
> bugzilla #12327):
> 
>     Assume the minimal 7.0 package manifest in /tmp/list
> 	/mnt/redhat/comps/dist/7.0/sparc/bash-2.04-11.sparc.rpm
> 	/mnt/redhat/comps/dist/7.0.2/sparc/glibc-2.1.94-1.sparc.rpm
> 	/mnt/redhat/comps/dist/7.0/sparc/mktemp-1.5-5.sparc.rpm
> 	/mnt/redhat/comps/dist/7.0/noarch/basesystem-7.0-2.noarch.rpm
> 	/mnt/redhat/comps/dist/7.0/noarch/setup-2.3.4-1.noarch.rpm
> 	/mnt/redhat/comps/dist/7.0/noarch/filesystem-2.0.7-1.noarch.rpm
> 	/mnt/redhat/comps/dist/7.0/sparc/libtermcap-2.0.8-25.sparc.rpm
> 	/mnt/redhat/comps/dist/7.0/noarch/termcap-11.0.1-3.noarch.rpm
> 
>     with database initialization as
> 	mkdir -p /tmp/ROOT/var/lib/rpm
> 	rpm --initdb /tmp/ROOT/var/lib/rpm
> 
>     This command "works"
> 	rpm -Uvh -r /tmp/ROOT `cat /tmp/list`
>     while this command
> 	rpm -Uvh -r /tmp/ROOT `tac /tmp/list`
>     fails with 
> 	loop in prerequisite chain: libtermcap bash libtermcap
> 
> The problem is that the current ordering algorithm, basically a very clever
> implementation of tsort, is sensitive to initial conditions, and the first
> command "happens" to snip a loop, while the second does not.
> 
> I've reimplemented a notso-clever tsort from Knuth V1, but there's one further
> twist. Since the only way out of a dependency loop is to snip the loop
> somewhere, rpm needs a hint about where to make the cut. The short term hack
> will be to cut dependency loops by removing all PreReq:'s in the loop.
> 
> If that seems counter-intuitive, you might consider the loop above:
> 	bash has
> 		Requires: libtermcap.so.2
> 	libtermcap has
> 		PreReq: /bin/sh
> Cutting on the PreReq: potentially breaks one package, libtermcap, while
> cutting on the Requires: may break an entire install (i.e. no /bin/sh).

Above is my original message.

OK, snipping on PreReq:'s was a counter-intuitive hack, now repaired in
rpm-4.0.1-0.7.

What is implemented now is that there is syntax to explicitly specify
the source of a Requires: dependency. If, for example, you use grep in %post,
then you as a packager would normally add
	PreReq: grep
in order to insure that grep was installed before attempted use by %postou
Now the same dependency can be expressed more precisely as
	Requires(post): grep

For completeness, here's the complete set of tokens that may be
added to Requires: as in the example above:
    "interp",         RPMSENSE_INTERP
    "prereq",         RPMSENSE_PREREQ
    "preun",          RPMSENSE_SCRIPT_PREUN
    "pre",            RPMSENSE_SCRIPT_PRE
    "postun",         RPMSENSE_SCRIPT_POSTUN
    "post",           RPMSENSE_SCRIPT_POST
    "rpmlib",         RPMSENSE_RPMLIB
    "verify",         RPMSENSE_SCRIPT_VERIFY

Ditto BuildRequires:
    "prep",           RPMSENSE_SCRIPT_PREP
    "build",          RPMSENSE_SCRIPT_BUILD
    "install",        RPMSENSE_SCRIPT_INSTALL
    "clean",          RPMSENSE_SCRIPT_CLEAN
but let's not go there (yet).

For giggles, you can also do stuff like
	Requires(pre,post): /bin/sh

By marking dependencies more precisely, rpm can distinguish between
an upgrade context (like the use of grep in %post above) and an installed
context (like the autogenerated Requires: in a package that includes a
script with #!/bin/sh), and that permits rpm to differentiate pre-requisites
from co-requisites while doing package ordering.

Here's what cures the libtermcap <-> bash loop:
	Requires(postun): /bin/sh
which, since the dependency is clearly not useful or necessary in determining
install ordering, is safely ignored.

In order to start flushing PreReq's everywhere, I've looked at all of
7.0/6.2/6.1/6.0/5.2 "everything install" ordering, and am able to order
packages successfully when given an alphabetically sorted list of
packages both forwards and backwards. That should catch most all the
loops, maybe not, we'll see.

At the moment, I've hacked dependency "white out" directly into rpmlib to
eliminate the following (new) package loops:

    This      needs     That	(i.e. is eliminated or there's a loop)
    ========================
    libtermcap		bash
    modutils		vixie-cron
    ypbind		yp-tools
    ghostscript-fonts	ghostscript
    /* 7.0 only */
    pango-gtkbeta-devel	pango-gtkbeta
    XFree86		Mesa
    compat-glibc	db2
    compat-glibc	db1
    pam			initscripts
    kernel		initscripts
    initscripts		sysklogd
    /* 6.2 */
    egcs-c++		libstdc++
    /* 6.1 */
    pilot-link-devel	pilot-link
    /* 5.2 */
    pam			pamconfig

Why are there new loops? Because my tsort is trying to use all of the
dependency info for ordering, while ewt's tsort ignored all Requires:
from added packages.

Except for the well known libtermcap <-> bash loop (which is just wrong),
all of the other dependencies are simply not needed in an upgrade context
to perform package ordering. Please note that the dependencies are not
removed, only ignored for the purposes of determining package ordering
during install, hence "white out".

While applying "white out" in rpmlib is a very, very, dirty hack, I believe
that the hack is expedient, as it's really gonna take a while to rebuild
all of the above packages, get the errata out, inform support, etc, and
I really, really, really don't want to be explaining pre-requisites and
co-requisites again, and again, and ...

Yes, the "white out" hack will be removed as soon as possible.

So what does this all mean? Basically not much, as it's gonna take at least
a year to flush PreReq's from legacy packaging. And, before you start adding
new-fangled syntax to packages, please remember that rpm will be auto-generating
fine-grained dependencies for %post et al scriptlets using the bash hack to
identify tokens used in an exec context within a shell script long before
the year is up. FWIW, what still needs doing is adding support for
	Requires: PATH(foo)
with semantics, essentially, of dependency is satisfied if foo exists
in $PATH, as scriptlets can and do use relative paths.

Off to figger how rpm-4.0.1 polluted the SBE compose (I believe that's
what happened) and what's going on with signing ...

Cheers

73 de Jeff

----- End forwarded message -----


Regards,
	Dmitry

+-------------------------------------------------------------------------+
Dmitry V. Levin     mailto://ldv@fandra.org
Software Engineer   PGP pubkey http://www.fandra.org/users/ldv/pgpkeys.html
IPLabs Linux Team   http://linux.iplabs.ru
Fandra Project      http://www.fandra.org
+-------------------------------------------------------------------------+
UNIX is user friendly. It's just very selective about who it's friends are.
----------- следующая часть -----------
Было удалено вложение не в текстовом формате...
Имя     : =?iso-8859-1?q?=CF=D4=D3=D5=D4=D3=D4=D7=D5=C5=D4?=
Тип     : application/pgp-signature
Размер  : 232 байтов
Описание: =?iso-8859-1?q?=CF=D4=D3=D5=D4=D3=D4=D7=D5=C5=D4?=
Url     : <http://lists.altlinux.org/pipermail/devel/attachments/20001112/c8c4b571/attachment-0001.bin>


Подробная информация о списке рассылки Devel