[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Dynamic registration of files to packages

Since many new features were recently added to dpkg, I wanted to
suggest a feature which I'd really like to see in Woody.  We all agree
that the package management system is one of the nicest features of
Debian.  It's very helpful to use dpkg to find out to which package a
file belongs (dpkg -S).  However, in many cases, prominent files (e.g.
/etc/hosts, /etc/passwd) don't belong to any package at all.  This
fact is confusing because the files must have been created somehow and
it decreases the usefulness of the packagement system.

Two examples illustrate this point:

 1. 'dpkg -S /etc/passwd' returns 'dpkg: /etc/passwd not found.'
    Further investigation shows that this file is created in the
    postinst script of the base-passwd package.


    if [ ! -e /etc/passwd ] ; then
    	cp /usr/share/base-passwd/passwd.master /etc/passwd

 2. % dpkg -S /usr/bin/yacc
    dpkg: /usr/bin/yacc not found.
    % ll /usr/bin/yacc
    lrwxrwxrwx    1 root     root           22 Jul 23 15:35 /usr/bin/yacc ->
    % ll /etc/alternatives/yacc
    lrwxrwxrwx    1 root     root           19 Jul 23 15:34
    /etc/alternatives/yacc -> /usr/bin/bison.yacc
    % dpkg -S /usr/bin/bison.yacc
    bison: /usr/bin/bison.yacc

In both cases, the files belong to a package in some way and still
'dpkg -S' doesn't show it.

I want all files in /etc to have a proper owner which is shown with
dpkg -S.  For this, a dynamic mechanism is needed to tell dpkg to
which package a file belongs.  This is needed because not all files
can be part of the package itself, but need to be created at a later
time (e.g. in a postinst script).

This fexible mechanism, dpkg-registerfile (or whatever it will be
called) should take two arguments: the file and the package to which the
file belongs.  The script could then, similarly to dpkg-divert, put the
information in /var/lib/dpkg (The script must also have the capability
to remove the information again in case a file is being deleted).  Of
course, dpkg has to be made aware of this.

The examples given above could easily be adapted to comply to this

 1. The postinst script of base-passwd should say:

    if [ ! -e /etc/passwd ] ; then
    	cp /usr/share/base-passwd/passwd.master /etc/passwd
    	dpkg-registerfile /etc/passwd base-passwd

 2. The solution for this example is to have update-alternatives
    call dpkg-registerfile

    Obviously, dpkg-registerfile must also be able to re-register a
    file or change the package a file belongs to because
    update-alternatives might change the situation.

I don't know how hard this would be to implement.  However, since
dpkg-divert does something similar, perhaps the necessary hooks
are in dpkg anyway.

How hard would it be to implement?
Martin Michlmayr

Attachment: pgpFxXLzGLVj4.pgp
Description: PGP signature

Reply to: