Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 67130 - Adding fixed symlinks in /usr/share/doc/ for important doc dirs
Summary: Adding fixed symlinks in /usr/share/doc/ for important doc dirs
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Enhancement/Feature Requests (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
: 83272 143628 498588 916479 (view as bug list)
Depends on:
Blocks: 147007
  Show dependency tree
 
Reported: 2004-10-11 11:46 UTC by TGL
Modified: 2023-10-29 11:51 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
eclass/doc-symlink.eclass (doc-symlink.eclass,2.36 KB, text/plain)
2004-10-11 11:48 UTC, TGL
Details
python-docs-2.3.4.ebuild--doc-symlink.patch (python-docs-2.3.4.ebuild--doc-symlink.patch,721 bytes, patch)
2004-10-11 11:51 UTC, TGL
Details | Diff
ebuild.sh--htmldoclink_feature.patch (ebuild.sh--htmldoclink_feature.patch,1011 bytes, patch)
2004-10-12 11:18 UTC, TGL
Details | Diff
ebuild.sh--doc_symlink.patch (ebuild.sh--doc_symlink.patch,968 bytes, patch)
2004-10-21 16:17 UTC, TGL
Details | Diff
HEAD--doc_symlink.patch (HEAD--doc_symlink.patch,1004 bytes, patch)
2005-03-24 11:42 UTC, TGL
Details | Diff
HEAD--doc_symlink.patch (HEAD--doc_symlink.patch,1.05 KB, patch)
2005-07-31 04:27 UTC, TGL
Details | Diff
portage-2.0-20051024-doc_symlink.patch (portage-2.0-20051024-doc_symlink.patch,1013 bytes, patch)
2005-10-27 04:29 UTC, TGL
Details | Diff
portage-2.0-20051024-doc_symlink-man.patch (portage-2.0-20051024-doc_symlink-man.patch,1.03 KB, patch)
2005-10-27 04:31 UTC, TGL
Details | Diff
portage-2.0-20051024-doc_symlink-cnf.patch (portage-2.0-20051024-doc_symlink-cnf.patch,12.38 KB, patch)
2005-10-27 04:32 UTC, TGL
Details | Diff
portage-2.0-20051024-doc_symlink-man.patch (portage-2.0-20051024-doc_symlink-man.patch,1.56 KB, patch)
2005-10-27 04:43 UTC, TGL
Details | Diff
portage-2.1_pre7-doc_symlink.patch (portage-2.1_pre7-doc_symlink.patch,958 bytes, patch)
2006-04-08 09:09 UTC, TGL
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description TGL 2004-10-11 11:46:42 UTC
Ebuilds that install documentation usually do it in /usr/share/doc/${PF}.  Since this path changes with every version or revision bumps, this policy makes difficult to keep up-to-date bookmarks to useful local documentation (like programming languages reference manuals for instance).

I suggest that such ebuilds create a symlink that would not move on each bump.  By default, for non-slotted ebuilds, it would be:
  /usr/share/doc/${PN} --> ${PF}/${DOCDESTREE}
And for slotted ebuilds:
  /usr/share/doc/${PN}-${SLOT} --> ${PF}/${DOCDESTREE}

For instance, the dev-python/python-docs-2.3.4 ebuild would install this symlink:
  /usr/share/doc/python-docs-2.3 --> python-docs-2.3.4/html
That would allow users to bookmark their local python docs on "file:///usr/share/doc/python-docs-2.3/index.html" and have this bookmark still correct after an update to a future python 2.3.5. 

Despite I understand that this is more a matter of policy than code, I've implemented a simple eclass that provides a function that creates such symlinks, and is meant to be used at the end of src_install().

Reproducible: Always
Steps to Reproduce:
Comment 1 TGL 2004-10-11 11:48:19 UTC
Created attachment 41564 [details]
eclass/doc-symlink.eclass
Comment 2 TGL 2004-10-11 11:51:18 UTC
Created attachment 41565 [details, diff]
python-docs-2.3.4.ebuild--doc-symlink.patch

Example of how to use this eclass. Once applied, the python-docs ebuild will
install this symlink:
/usr/share/doc/python-docs-2.3 -> python-docs-2.3.4/html
Comment 3 TGL 2004-10-12 11:17:01 UTC
Something I forgot to talk about is the possibility to implement this feature at portage level instead of eclass/ebuilds level. 

Actually, what I first wrote was a patch that was adding a "docsymlink" portage FEATURES flag that was forcing creation of a "/usr/share/doc/${PN}[-${SLOT}] -> ${PF}" for every package that was installing a /usr/share/doc/${PF} directory. I've used it for a few weeks, but that was introducing to much noise in /usr/share/doc for something that is completly useless for 95% of the packages. 

Hence I've wrote the eclass, to allow packagers to decide when the symlink should be created. But the drawback is that it relies on ebuild modifications, that may never happen.

An alternative would be the following: at portage level, create a doc symlink for packages that install some HTML documentation, if a given FEATURES flag is set. I will attach a patch for ebuild.sh that implements that. Detection of HTML documentation is just a test of existence of an "html" subdir in the doc dir: it seems to be enough in most cases, but if needed that could be improved.

Pros:
 - no need to modify ebuilds
 - won't affect users that dont set the FEATURES flag

Cons:
 - can't be as reliable as the per-ebuild implementation
 - may create conflicts in case both cat-foo/pkg-name and cat-bar/pkg-name install some html docs
Comment 4 TGL 2004-10-12 11:18:43 UTC
Created attachment 41631 [details, diff]
ebuild.sh--htmldoclink_feature.patch

The patch described in comment #3.
Comment 5 Marius Mauch (RETIRED) gentoo-dev 2004-10-12 11:57:10 UTC
random notes: I'd prefer if those symlinks would go into a subdir and I don't like adding another FEATURE for it. The symlinks wouldn't take much space and if they are in a subdir they don't clutter the /usr/share/doc listing.
Comment 6 SpanKY gentoo-dev 2004-10-12 15:11:20 UTC
maybe something like /usr/share/doc/perm/ ... then the symlinks would just point to ../${PF}
Comment 7 TGL 2004-10-21 16:17:41 UTC
Created attachment 42383 [details, diff]
ebuild.sh--doc_symlink.patch

Here is a modified version of the ebuild.sh patch. 
 - there is no more FEATURES flag.
 - the symlinks location depends on the DOC_SYMLINKS_DIR variable. I've set it
to "/usr/share/doc/symlinks" in my make.conf. If not set, then no symlink will
be created.
 - an $HTMLDOC_DIR var can be used in ebuilds to force making a symlink on a
dir that is not one of the standard (ie., {$PF,$P}/{html,HTML}) /usr/share/doc
subdir.
Comment 8 TGL 2005-03-24 11:42:51 UTC
Created attachment 54376 [details, diff]
HEAD--doc_symlink.patch

Same patch for portage HEAD (code moved from ebuild.sh to
default-functions.sh).
Comment 9 Jason Stubbs (RETIRED) gentoo-dev 2005-07-28 07:24:59 UTC
Putting a hold on feature requests for portage as they are drowning out the 
bugs. Most of these features should be available in the next major version of 
portage. But for the time being, they are just drowning out the major bugs and 
delaying the next version's progress. 
 
Any bugs that contain patches and any bugs for etc-update or dispatch-conf can 
be reopened. Sorry, I'm just not good enough with bugzilla. ;) 
Comment 10 TGL 2005-07-28 08:46:39 UTC
Reopening since this one is trivial and comes with a patch i've been using for
months with no issue.
Comment 11 Jason Stubbs (RETIRED) gentoo-dev 2005-07-31 00:30:10 UTC
How are SLOTs handled? 
Comment 12 TGL 2005-07-31 02:10:53 UTC
The link name is "$PN" when "$SLOT" is 0 or null, and "$PN-$SLOT" otherwise,
thus there should be no conflict beetween slotted packages. For instance, here i
have both a "python-docs-2.3" and a "python-docs-2.4" symlinks.

The only case of conflict i can think of is if 2 packages with same name in
different categories provide some html docs. I've never encountered that case,
but it's possible in theory. A way to avoid that would be to create th symlinks
in subdirs named by the category. I can add that if you think that's necessary.
Comment 13 Jason Stubbs (RETIRED) gentoo-dev 2005-07-31 03:27:51 UTC
Okay, I've taken a close look. I'm thinking that it would probably be better  
to do it in dodoc rather than having to modify all ebuilds. To cover the  
namespace collision possibility, maybe make another function to handle it?  
docalias perhaps. Was there ever a thread about this on -dev@g.o? 
 
However it's done, it should be within src_install() so that collision-protect 
plays properly. Using the DOC_SYMLINKS_DIR is good, by the way. It has the 
same feel as PORT_LOGDIR. Other than that, everything seems fine. 
Comment 14 TGL 2005-07-31 04:26:34 UTC
I've just made a test (of the last attached patch, the "no ebuild modification
needed" solution) with collision-protect enabled and two conflicting ebuilds:
same name, different category, both installing some html file, and both in
SLOT=0.  It happens that collision-protect didn't detect this conflict:

% emo port-teeeeest/docsymlink
<--snip-->
>>> Install docsymlink-1 into /var/tmp/portage/docsymlink-1/image/ category
port-teeeeest
 * Symlinking /usr/share/doc/symlinks/docsymlink to the HTML documentation
>>> Completed installing docsymlink-1 into /var/tmp/portage/docsymlink-1/image/

processing merge

* checking 1 files for package collisions
* spent 0.00 seconds checking for file collisions
>>> Merging port-teeeeest/docsymlink-1 to /
*** Adjusting ccache permissions for portage user...
overloading port_env_file setting to /var/tmp/portage/docsymlink-1/temp/environment
--- /usr/
--- /usr/share/
--- /usr/share/doc/
--- /usr/share/doc/symlinks/
>>> /usr/share/doc/docsymlink-1/
>>> /usr/share/doc/docsymlink-1/html/
>>> /usr/share/doc/docsymlink-1/html/foo.html
>>> /usr/share/doc/symlinks/docsymlink -> /usr/share/doc/docsymlink-1/html
<--snip-->

% emo port-test/docsymlink
<--snip-->
>>> Install docsymlink-2 into /var/tmp/portage/docsymlink-2/image/ category
port-test
 * Symlinking /usr/share/doc/symlinks/docsymlink to the HTML documentation
>>> Completed installing docsymlink-2 into /var/tmp/portage/docsymlink-2/image/

processing merge

* checking 1 files for package collisions
* spent 0.00 seconds checking for file collisions
>>> Merging port-test/docsymlink-2 to /
*** Adjusting ccache permissions for portage user...
overloading port_env_file setting to /var/tmp/portage/docsymlink-2/temp/environment
--- /usr/
--- /usr/share/
--- /usr/share/doc/
--- /usr/share/doc/symlinks/
>>> /usr/share/doc/docsymlink-2/
>>> /usr/share/doc/docsymlink-2/html/
>>> /usr/share/doc/docsymlink-2/html/foo.html
>>> /usr/share/doc/symlinks/docsymlink -> /usr/share/doc/docsymlink-2/html
<--snip-->

It seems that collision-protect doesn't handle symlinks, at least not those
pointing directories (that's what the "checking 1 files for package collisions"
seems to indicate too).  Is that expected behavior or a bug?

Anyway, i've modified the patch to add support for an optionnal DOC_SYMLINK_NAME
ebuild variable: if set, then it will be used to name the symlink instead of $PN
or $PN-$SLOT. That's enough to workaround such conflicts if they ever happen.
Comment 15 TGL 2005-07-31 04:27:43 UTC
Created attachment 64779 [details, diff]
HEAD--doc_symlink.patch
Comment 16 Jason Stubbs (RETIRED) gentoo-dev 2005-07-31 04:54:29 UTC
Ah, yes. I forgot that collision-protect presently ignores symlinks. But 
still, if we don't pretend that it does process symlinks it'll come back as a 
new bug later on. ;) 
Comment 17 Jason Stubbs (RETIRED) gentoo-dev 2005-10-16 08:23:59 UTC
*** Bug 83272 has been marked as a duplicate of this bug. ***
Comment 18 TGL 2005-10-27 04:29:49 UTC
Created attachment 71553 [details, diff]
portage-2.0-20051024-doc_symlink.patch

Updated patch for 2.0 SVN. No change but a code move from
ebuild-default-functions.sh back to ebuild.sh.
Comment 19 TGL 2005-10-27 04:31:14 UTC
Created attachment 71554 [details, diff]
portage-2.0-20051024-doc_symlink-man.patch

man/ebuild.5 documentation of the HTMLDOC_DIR variable (although rather few
package would actually need it i think)
Comment 20 TGL 2005-10-27 04:32:04 UTC
Created attachment 71555 [details, diff]
portage-2.0-20051024-doc_symlink-cnf.patch

cnf/make.conf* documentation of the DOC_SYMLINKS_DIR variable.
Comment 21 TGL 2005-10-27 04:43:01 UTC
Created attachment 71556 [details, diff]
portage-2.0-20051024-doc_symlink-man.patch

Oops, i had forgoten to document DOC_SYMLINK_NAME in the ebuild.5 patch.
Comment 22 TGL 2005-10-27 04:45:14 UTC
Okay, this patches are candidate for the next portage release round (2.0.54). I
think the feature is useful, and code is pretty trivial and non-intrusive.
Comment 23 TGL 2006-04-08 09:09:02 UTC
Created attachment 84208 [details, diff]
portage-2.1_pre7-doc_symlink.patch

rediffed for http://thread.gmane.org/gmane.linux.gentoo.devel/37295/focus=37295
Comment 24 Carsten Lohrke (RETIRED) gentoo-dev 2006-04-08 10:02:13 UTC
Is this really needed? I'd favor creating rss feeds from the documentation urls. don't know if some may think it vioates the KISS principle, but it would even allow to point to non-local documentation, instead installing it.
Comment 25 TGL 2006-04-08 10:56:44 UTC
(In reply to comment #24)
> Is this really needed?

Needed, no, sure, and i think it should stay optional. 
But after ~1.5 year of usage, i must say i still find it very convenient.  I have ~150 symlinks in my /usr/share/doc/symlinks directory, ~20 of which are bookmarked because i use them often enough. That's all i need and all i get.

> I'd favor creating rss feeds from the documentation urls. 

Sounds fun, but I'm not sure i understand how it would help my case. What i want is direct and simple access to my local documentation from my web browser (ie., bookmarks to some file:/// URLs that don't break on every revbump).

> it would even allow to point to non-local documentation, instead
> installing it.

I prefer to actually install the doc, because i code more when offline :)
And anyway, for online docs, i've never felt there was anything to improve:  the URLs are usualy not moving so often, thus i can already safely bookmark them, and i'm happy with that.

But maybe i just don't well understand your idea.


Oh, and just FYI, yet another approach is Ed Catmur's src_install hook for auto-generating devhelp books:
http://catmur.co.uk/svn/repos/gentoo/phase_hooks.d/post_src_install/
But i don't use devhelp myself, i prefer to have everything in my web browser.

(makes me think that i could convert my patch to a phase hook too though, it would be easier if some other people want to use it)
Comment 26 Fabian Neumann 2006-04-08 13:15:34 UTC
(In reply to comment #25)
> Oh, and just FYI, yet another approach is Ed Catmur's src_install hook for
> auto-generating devhelp books:
> http://catmur.co.uk/svn/repos/gentoo/phase_hooks.d/post_src_install/
> But i don't use devhelp myself, i prefer to have everything in my web browser.
> 
> (makes me think that i could convert my patch to a phase hook too though, it
> would be easier if some other people want to use it)

Portage phase hooks (never heard of them before) sound like a good place to put doc-symlink-functionality in. When will portage (stable) ship with phase hooks? (Google didn't tell me ;)

PS: Just for the record: auto-generation of a /usr/share/doc/index.html listing all found html-docs would be a nice add-on to this :)  (As mentioned here: http://article.gmane.org/gmane.linux.gentoo.devel/37296)
Comment 27 TGL 2006-04-08 14:56:29 UTC
(In reply to comment #26)
> Portage phase hooks (never heard of them before) sound like a good place 
> to put doc-symlink-functionality in.

Seeing how different is everyone opinions on what would be the right behavior for indexing html doc (symlinks, index.html, devhelp books, rss feed, etc.), I guess that yes, it belongs to hooks, so that it is really user-configurable.

For making symlinks as i do, it could be something like this (in /etc/portage/bashrc):

post_src_install() {
	# Where to put the symlinks?
	# - no category, everything in the same dir. Be aware that this may
	# lead to conflicts beetween homonym packages:
	#local symlink_dir="/usr/share/doc/symlinks"
	# - one subdir per category. Be aware that sometimes packages get 
	# moved from one category to another, so some symlinks may be moved 
	# by an update:
	local symlink_dir="/usr/share/doc/symlinks/${CATEGORY}"

	local mydocdir docdir
	for docdir in "${PF}/html" "${PF}/HTML" "${P}/html" "${P}/HTML" ; do
		[[ -d "${D}/usr/share/doc/${docdir}" ]] \
			&& mydocdir="/usr/share/doc/${docdir}" \
			&& break
	done
	if [[ -n "${mydocdir}" ]] ; then
		local symlink_name="${PN}"
		[[ -n "${SLOT}" ]] \
			&& [[ "${SLOT}" != "0" ]] \
			&& symlink_name="${PN}-${SLOT}"
		einfo "Symlinking ${symlink_dir}/${symlink_name} to the HTML doc"
		dodir "${symlink_dir}"
		dosym "${mydocdir}" "${symlink_dir}/${symlink_name}"
	fi
}

But sure, there is a drawback: ebuilds don't care about what people do in their phase hooks. It means that we can't expect they will ease the task of indexing their doc.  For instance, with my previos patch, they were able to force the symlink name by setting a $DOC_SYMLINK_NAME variable (needed to avoid conflicts, when two packages with the same name but from two different categories both install some HTML doc). With a non-standard (in phase hook) implementation, there is no more reason they set such a variable, and thus you have to create one subdir per category to avoid this conflicts (with the drawback explained in the function comments).

> When will portage (stable) ship with phase hooks?

I don't remember whether it exists in latest 2.0.*, but it is in 2.1_pre for sure. As to when 2.1 will become stable, i don't know, but this discussion may help getting an estimation:
http://thread.gmane.org/gmane.linux.gentoo.portage.devel/2002/focus=2002
Comment 28 Carsten Lohrke (RETIRED) gentoo-dev 2006-04-09 05:29:36 UTC
(In reply to comment #25)
> > I'd favor creating rss feeds from the documentation urls. 
> 
> Sounds fun, but I'm not sure i understand how it would help my case. What i
> want is direct and simple access to my local documentation from my web browser
> (ie., bookmarks to some file:/// URLs that don't break on every revbump).

I don't know what browser you are using, but that's exactly what I want, too. Firefox supports live bookmarks, which is reading bookmarks from a feed source. If you e.g. open kernel.org in Firefox and click on the orange icon, bottom right in  the status bar, you'll see. Just subfolders are not supported, so I did file
https://bugzilla.mozilla.org/show_bug.cgi?id=332095


> > it would even allow to point to non-local documentation, instead
> > installing it.
> 
> I prefer to actually install the doc, because i code more when offline :)
> And anyway, for online docs, i've never felt there was anything to improve: 
> the URLs are usualy not moving so often, thus i can already safely bookmark
> them, and i'm happy with that.

I didn't mean with non-local access it directly on the internet, but multi-user solutions, having a documentation server, instead installing the docs on every single workstation.


I thought about a little tool, so you can write

adddocfeed "name" category/package:slot" "one, two,... catchwords" "url"

in an ebuild, resulting in a few predefined feeds (whole doc tree, based on the catchwords,...?) as well as the possibility of user defined ones.
Comment 29 Jakub Moc (RETIRED) gentoo-dev 2006-08-12 00:51:27 UTC
*** Bug 143628 has been marked as a duplicate of this bug. ***
Comment 30 Marius Mauch (RETIRED) gentoo-dev 2007-01-10 06:19:00 UTC
Updated for trunk, using per-category dirs.
Comment 31 Zac Medico gentoo-dev 2007-01-11 04:14:38 UTC
Thanks.  This is in svn r5509 and has been released in 2.1.2_rc4-r8.
Comment 32 Jeroen Roovers (RETIRED) gentoo-dev 2014-01-20 01:30:41 UTC
*** Bug 498588 has been marked as a duplicate of this bug. ***
Comment 33 Ulrich Müller gentoo-dev 2023-10-29 11:51:57 UTC
*** Bug 916479 has been marked as a duplicate of this bug. ***