From Fedora Project Wiki
No edit summary
No edit summary
 
(7 intermediate revisions by one other user not shown)
Line 3: Line 3:
Your package should own all of the files that are installed as part of the %install process.  Packages must not own files already owned by other packages. The rule of thumb here is that the first package to be installed  should own the files that other packages may rely upon. This means, for example, that no package in Fedora should ever share ownership with any of the files owned by the <code>filesystem</code> or <code>man</code> package. If you feel that you have a good reason to own a file or that another package owns, then please present that at package review time.
Your package should own all of the files that are installed as part of the %install process.  Packages must not own files already owned by other packages. The rule of thumb here is that the first package to be installed  should own the files that other packages may rely upon. This means, for example, that no package in Fedora should ever share ownership with any of the files owned by the <code>filesystem</code> or <code>man</code> package. If you feel that you have a good reason to own a file or that another package owns, then please present that at package review time.


Directory ownership is a little more complex than file ownership.  Although the rule of thumb is the same: own all the directories you create but none of the directories of packages you depend on, there are several instances where it's desirable for multiple packages to own a directory. Here are examples that describe how to handle most cases of directory ownership.
Directory ownership is a little more complex than file ownership.  Although the rule of thumb is the same: own all the directories you create but none of the directories of packages you depend on, there are several instances where it's desirable for multiple packages to own a directory.  
 
In all cases we are guarding against unowned directories being present on a system.  Please see [[Packaging:UnownedDirectories]] for the details.
 
{{admon/important|Note on multiple ownership| Note that when co-owning directories, you <b>must</b> ensure that the ownership and permissions on the directory match in all packages that own it.}}
 
{{admon/important|Note on directories| If a directory is explicitly required by packages in Fedora (such as <code>/usr/lib/mozilla/plugins</code>), only one package should own it, so that dependency solving is deterministic.}}
 
Here are examples that describe how to handle most cases of directory ownership.


=== The directory is wholly contained in your package, or involves core functionality of your package. ===
=== The directory is wholly contained in your package, or involves core functionality of your package. ===
Line 9: Line 17:
An example:
An example:
<pre>
<pre>
gnucash places many file under the /usr/share/gnucash directory
gnucash places many files under the /usr/share/gnucash directory
</pre>
</pre>


Solution: the <code>gnucash</code> package should own the <code>/usr/share/gnucash</code> directory
Solution: the <code>gnucash</code> package should own the <code>/usr/share/gnucash</code> directory
=== The package places files in many directories that are part of a larger environment's infrastructure. ===
An example:
<pre>
kdeutils places files in (among other places)
/usr/share/applications/kde4
/usr/share/kde4/apps
/usr/share/kde4/services
</pre>
Solution: the infrastructure directories above should be placed in a <code>kde-filesystem</code> package, and <code>kdeutils</code> should <code>Require:</code> the <code>kde-filesystem</code> package.


=== The directory is also owned by a package implementing required functionality of your package. ===
=== The directory is also owned by a package implementing required functionality of your package. ===
Line 23: Line 43:
</pre>
</pre>


Solution: the <code>pam</code> package should own the <code>/etc/pam.d</code> directory, and <code>gdm</code> should <code>Require:</code> the <code>pam</code> package
Solution: the <code>pam</code> package should own the <code>/etc/pam.d</code> directory, and <code>gdm</code> should <code>Require:</code> the <code>pam</code> package.


=== The directory is also owned by a package implementing optional functionality of your package. ===
=== Multiple packages own files in a common directory but none of them needs to require the others. ===


An example:
An example:


<pre>
<pre>
bash-completion owns the /etc/bash_completion.d directory
bash-completion owns the /etc/bash_completion.d directory and uses the files placed there to configure itself.
git places files into /etc/bash_completion.d
git places files into /etc/bash_completion.d
bzr places files into /etc/bash_completion.d
</pre>
</pre>


Solution: Both packages should own the <code>/etc/bash_completion.d</code> directory, as bash-completion is optional functionality and the installation of git should not force the installation of bash-completion.
Solution: Both the git and bzr packages should own the /etc/bash_completion.d directory as bash-completion is optional functionality and the installation of git or bzr should not force the installation of bash-completion.
{{admon/important|Rule of Thumb|When determining whether this exception applies, packagers and reviewers should ask this question: Do the files in this common directory enhance or add functionality to another package, where that other package is not necessary to be present for the primary functionality of this package?}}


=== The package you depend on to provide a directory may choose to own a different directory in a later version and your package will run unmodified with that later version. ===
=== The package you depend on to provide a directory may choose to own a different directory in a later version and your package will run unmodified with that later version. ===


One common example of this is a Perl module.  Assume ''perl-A-B'' depends on ''perl-A'' and installs files into /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/A/B.  The base Perl package guarantees that it will own /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi for as long as it remains compatible with version 5.8.8, but a future upgrade of the ''perl-A'' package may install into (and thus own) /usr/lib/perl5/vendor_perl/5.9.0/i386-linux-thread-multi/A.  So the ''perl-A-B'' package needs to own /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/A as well as /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/A/B in order to maintain proper ownership.
One common example of this is a Perl module.  Assume ''perl-A-B'' depends on ''perl-A'' and installs files into /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/A/B.  The base Perl package guarantees that it will own /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi for as long as it remains compatible with version 5.8.8, but a future upgrade of the ''perl-A'' package may install into (and thus own) /usr/lib/perl5/vendor_perl/5.9.0/i386-linux-thread-multi/A.  So the ''perl-A-B'' package needs to own /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/A as well as /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/A/B in order to maintain proper ownership.
=== Multiple packages have files in a common directory but none of them requires others. ===
An example:
<pre>
Foo-Animal-Emu puts files into /usr/share/Foo/Animal/Emu
Foo-Animal-Llama puts files into /usr/share/Foo/Animal/Llama
</pre>
Neither package depends on the other one. Neither package depends on any other package which owns the /usr/share/Foo/Animal/ directory.
Solution: In this case, each package must own the <code>/usr/share/Foo/Animal/</code> directory.
In all cases we are guarding against unowned directories being present on a system.  Please see [[Packaging:UnownedDirectories]] for the details. Note that when co-owning directories, you <b>must</b> ensure that the ownership and permissions on the directory match in all packages that own it.

Latest revision as of 16:58, 7 October 2009

File and Directory Ownership

Your package should own all of the files that are installed as part of the %install process. Packages must not own files already owned by other packages. The rule of thumb here is that the first package to be installed should own the files that other packages may rely upon. This means, for example, that no package in Fedora should ever share ownership with any of the files owned by the filesystem or man package. If you feel that you have a good reason to own a file or that another package owns, then please present that at package review time.

Directory ownership is a little more complex than file ownership. Although the rule of thumb is the same: own all the directories you create but none of the directories of packages you depend on, there are several instances where it's desirable for multiple packages to own a directory.

In all cases we are guarding against unowned directories being present on a system. Please see Packaging:UnownedDirectories for the details.

Note on multiple ownership
Note that when co-owning directories, you must ensure that the ownership and permissions on the directory match in all packages that own it.
Note on directories
If a directory is explicitly required by packages in Fedora (such as /usr/lib/mozilla/plugins), only one package should own it, so that dependency solving is deterministic.

Here are examples that describe how to handle most cases of directory ownership.

The directory is wholly contained in your package, or involves core functionality of your package.

An example:

gnucash places many files under the /usr/share/gnucash directory

Solution: the gnucash package should own the /usr/share/gnucash directory

The package places files in many directories that are part of a larger environment's infrastructure.

An example:

kdeutils places files in (among other places)
 /usr/share/applications/kde4
 /usr/share/kde4/apps
 /usr/share/kde4/services

Solution: the infrastructure directories above should be placed in a kde-filesystem package, and kdeutils should Require: the kde-filesystem package.

The directory is also owned by a package implementing required functionality of your package.

An example:

pam owns the /etc/pam.d directory
gdm places files into /etc/pam.d

Solution: the pam package should own the /etc/pam.d directory, and gdm should Require: the pam package.

Multiple packages own files in a common directory but none of them needs to require the others.

An example:

bash-completion owns the /etc/bash_completion.d directory and uses the files placed there to configure itself.
git places files into /etc/bash_completion.d
bzr places files into /etc/bash_completion.d

Solution: Both the git and bzr packages should own the /etc/bash_completion.d directory as bash-completion is optional functionality and the installation of git or bzr should not force the installation of bash-completion.

Rule of Thumb
When determining whether this exception applies, packagers and reviewers should ask this question: Do the files in this common directory enhance or add functionality to another package, where that other package is not necessary to be present for the primary functionality of this package?

The package you depend on to provide a directory may choose to own a different directory in a later version and your package will run unmodified with that later version.

One common example of this is a Perl module. Assume perl-A-B depends on perl-A and installs files into /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/A/B. The base Perl package guarantees that it will own /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi for as long as it remains compatible with version 5.8.8, but a future upgrade of the perl-A package may install into (and thus own) /usr/lib/perl5/vendor_perl/5.9.0/i386-linux-thread-multi/A. So the perl-A-B package needs to own /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/A as well as /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/A/B in order to maintain proper ownership.