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

Re: How are directories managed.



On Tue, 12 Apr 2011 17:43:10 +0530, harish badrinath
<harishbadrinath@gmail.com> wrote:
> On Tue, Apr 12, 2011 at 7:26 AM, Paul Elliott
> <pelliott@blackpatchpanel.com> wrote:
> > This may be a FAQ but I could not find the answer in the documentation:
> >
> > How are directories managed? When does a directory get deleted? What is
> > the lifetime of a directory? Is a directory owned by a specific package?
> >
> In case of apache2, config files present in /etc/apache2/ are "in"
> apache2.2-common package. Removing this package deletes /etc/apache2/
> and all files under it.

Not quite; for instance on this system:
% dlocate -S /etc/apache2 | cut -d: -f1 | sort | uniq
apache2.2-common
dhelp
libapache2-mod-dnssd
libapache2-mod-php5

All four of these packages provide files under /etc/apache2; in addition I've
also added files there (in /etc/apache2/sites-available). /etc/apache2 would
only be automatically removed if, at the time one of the above packages is
removed, the directory is empty.

> > Which packages are alowed to deposit files in a specific directory? What
> > exactly are the rules?
> 
> That is specified in the debian policy.

Right, and as far as I can see pretty much all that says is to follow the FHS,
and avoid attempting to create a directory with the same name as another
package's file or link.

> > If a package wants to put files in a directory, how does the package
> > "know" that the directory will live longer than the file?
> >
> You cant "put" files in a directory that does not exist. touch
> /etc/foo/bar would fail if foo does not exist. Also you cant delete a
> non empty directory, so a package can assume that directory will live
> longer than the file(s) that it contain.

Exactly. If a package declares a directory in its contents (as displayed by
"dpkg -L" for instance), dpkg will create that directory on installation and
remove it if it's empty (after deleting the package's files) on removal. If a
package creates a directory and/or files separately, for example in its
maintainer scripts, then removal has to be handled explicitly in the
maintainer scripts too.

More simply put, the answer to Paul's question is that if the package
declares that it contains the directory, then it can use it - if the package
needs to do something then by definition it's installed and the directory
will exist. (Notwithstanding manual intervention by the system administrator
or dpkg filters.)

Regards,

Stephen


Reply to: