Bug 1113233 - rpmbuild doesn't mark %{_pkgdocdir}/<package> as %doc
Summary: rpmbuild doesn't mark %{_pkgdocdir}/<package> as %doc
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: rpm
Version: 28
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: ---
Assignee: Packaging Maintenance Team
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-06-25 17:08 UTC by Ralf Corsepius
Modified: 2018-03-29 09:52 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-03-29 09:52:24 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Ralf Corsepius 2014-06-25 17:08:11 UTC
Description of problem:
rpmbuild doesn't mark %{_pkgdocdir}/<package> as %doc

Instead, it treats these dirs as ordinary directories.
I am not sure if this behavior is an oversight or intentional.

Version-Release number of selected component (if applicable):
rpm-4.11.2-2.fc20.x86_64

How reproducible:
Always.

Steps to Reproduce:
1. build an arbitrary rpm from its spec
2. rpm -qdp <binary-rpm>


Actual results:
rpm -qd doesn't list /usr/share/doc/<package>

Expected results:
Cf. above. 

I am not sure, if this is a bug, oversight or intentional behavior, nor whether it is desired. The current behavior at least seems to be consistent with the antique rpms on CentOS{5,6}

Comment 1 Panu Matilainen 2014-06-26 07:06:10 UTC
As explained in bug 1113236, %{_pkgdocdir} as such is in no way special to rpm.
The actual issue here is whether directories can be %doc (or %config for that matter), and the bit has been explicitly stripped from directories in rpm since as far back as 1998.

The way it is now keeps things conceptually simple: a directory in itself is never documentation, nor configuration etc, it is merely a container which can hold files, files which then can be documentation, configuration and whatever. 
And of course one can argue that a directory containing only documentation should be considered documentation in itself. I've briefly considered it a couple of times but I haven't seen any real reason to change the historical behavior. I could be convinced to reconsider, but there would need to be some actual reason and associated benefits.

Comment 2 Ralf Corsepius 2014-06-26 07:52:27 UTC
The background of this BZ is me trying to find a work-round to 
https://bugzilla.redhat.com/show_bug.cgi?id=1113236
in particuliar, to find an answer to "how to manually package /usr/share/doc/<package>" in a spec-file. 

So far, my conclusion of combining these BZs is:

All packages, which are not using %doc <relative file> and are installing docs into %{_pkgdocdir} directly, are required to contain
%files
%dir %{_pkgdocdir}
%doc %{_pkgdocdir}/<file>
...

If your answer to this BZ would have told me /usr/share/doc/<package> was supposed to be marked %doc, then my conclusion would have been
%files
%dir %doc %{_pkgdocdir}
%doc %{_pkgdocdir}/<file>
...

I haven't checked yet, the cases of 
%files
%{_pkgdocdir}

and (Which also may be tempting to use}

%files
%doc %{_pkgdocdir}

Is my conclusion correct?

Comment 3 Panu Matilainen 2014-06-26 08:26:52 UTC
Right. Makes me wonder if Fedora's guidelines are somehow overcomplicated or plain wrong here (I need to check on that later). For manually packaging /usr/share/doc/<package>, all you need is

%files
/usr/share/doc/<package>

...or %{_pkgdocdir} in Fedora. Incidentally that's exactly what rpm internally does with non-absolute %doc, apart from actually copying the files there. 
No need to mark the contents as %doc as that is automatically done because its in %__docdir_path, and directories cannot be %doc even if marked as such, so these two procuce the exact same results:

%files
%{_pkgdocdir}

%files
%doc %{_pkgdocdir}

Comment 4 Ralf Corsepius 2014-06-26 10:35:10 UTC
(In reply to Panu Matilainen from comment #3)
> Right. Makes me wonder if Fedora's guidelines are somehow overcomplicated or
> plain wrong here (I need to check on that later).
I am not sure, either. IMO, they definitely need some overhaul.

ATM, I am leaning towards proposing a rule which mandates packages to own all dirs below %{_pkgdocdir}, similar to the packaging rules for perl-modules, because such a restrictive packaging rule would render detecting missing ownerships much easier (rpmlint?)

Right now, we allow "parent" packages to own docdirs, which renders it easy to miss missing directory ownerships (c.f. below), and difficult to check for correctness (Neither rpmlint nor koji/Fedora QA complains about these).

> For manually packaging
> /usr/share/doc/<package>, all you need is
> 
> %files
> /usr/share/doc/<package>
> 
> ...or %{_pkgdocdir} in Fedora. Incidentally that's exactly what rpm
> internally does with non-absolute %doc, apart from actually copying the
> files there. 
ACK, so far. 

FWIW: The actual origin of this and the other BZ was me investigating some %_pkgdocdir-change related F21FTBFSes. As a side-effect of this I found a larger number of sub-packages, which do correctly own %{_pkgdocdir}.
Therefore, I was mentioning the explicit %dir %{_pkgdocdir}.

Some examples:

# rpm -qlp g/gumbo-parser-1.0-0.4.20131204git87b99f2.fc21.x86_64.rpm 
/usr/lib64/libgumbo.so.1
/usr/lib64/libgumbo.so.1.0.0
/usr/share/doc/gumbo-parser/COPYING

=> Unowned /usr/share/doc/gumbo-parser/

This package directly installs into %{_pkgdocdir} and doesn't use relative %doc <file>.

# rpm -qlp c/copr-doc-1.26-2.fc21.noarch.rpm
/usr/share/doc/copr/python-doc
...

# rpm -q --requires -p c/copr-doc-1.26-2.fc21.noarch.rpm
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(PayloadIsXz) <= 5.2-1
== No dep on a package providing /usr/share/doc/copr

=> Unowned /usr/share/doc/copr/

You can easily find many more (100s?) similar cases in the repos.

> No need to mark the contents as %doc as that is automatically done because
> its in %__docdir_path, and directories cannot be %doc even if marked as
> such, so these two procuce the exact same results:
> 
> %files
> %{_pkgdocdir}
> 
> %files
> %doc %{_pkgdocdir}
OK.

Comment 5 Jaroslav Reznik 2015-03-03 16:03:59 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 22 development cycle.
Changing version to '22'.

More information and reason for this action is here:
https://fedoraproject.org/wiki/Fedora_Program_Management/HouseKeeping/Fedora22

Comment 6 Fedora End Of Life 2016-07-19 20:05:34 UTC
Fedora 22 changed to end-of-life (EOL) status on 2016-07-19. Fedora 22 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 7 Sergio Basto 2018-01-24 23:52:54 UTC
> %files
> %doc %{_pkgdocdir}

No, %doc copy from %_builddir to the proper location [1]  .
Maybe you want %docdir which the propose is mark files as docfiles, but I didn't find any thing relative to %docdir except in GAP packaging [2] . 


[1] https://fedoraproject.org/wiki/Packaging:Guidelines#Documentation
(...)
Marking a relative path with %doc in the %files section will cause RPM to copy the referenced file or directory from %_builddir to the proper location 

[2]
https://fedoraproject.org/wiki/Packaging:GAP#Documentation

Comment 8 Sergio Basto 2018-01-26 03:28:23 UTC
May I reopen this report? we miss %docdir macro documentation , what we should do when documentation is not /usr/doc and is in /use/share/packagename/ ?

Comment 9 Fedora End Of Life 2018-02-20 15:21:51 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 28 development cycle.
Changing version to '28'.

Comment 10 Panu Matilainen 2018-03-29 09:52:24 UTC
(In reply to Sergio Monteiro Basto from comment #7)
> > %files
> > %doc %{_pkgdocdir}
> 
> No, %doc copy from %_builddir to the proper location [1]  .

No. %doc only copies if the argument is a relative path. With an absolute path such as %{_pkgdocdir}, it simply means marking this item as documentation (but since a directory is not documentation I guess it doesn't do anything here). This has always been the case, %doc with relative paths being known as "a special doc".

(In reply to Sergio Monteiro Basto from comment #8)
> May I reopen this report? we miss %docdir macro documentation , what we
> should do when documentation is not /usr/doc and is in
> /use/share/packagename/ ?

Move the documentation to where it belongs?

As for %docdir documentation, it's documented in Maximum RPM:
http://ftp.rpm.org/max-rpm/s1-rpm-inside-files-list-directives.html

If you want Fedora packaging guideline on it's use, an rpm bug is the wrong place for it, talk to FPC instead.

NOTABUG as explained early on in the comments - directories are never documentation in rpm, only their content can be.


Note You need to log in before you can comment on or make changes to this bug.