/usr/share/doc vs. /usr/doc transition, debate reopened
Thanks for reopening the debate, Chris.
I am (still) following it and I (still :) do not understand what is wrong
with the following'
debian-policy [PROPOSAL]: /usr/doc -> /usr/share/doc should be a symlink
I propose that the "transition" of /usr/doc to /usr/share/doc be done with
the following three changes to Policy:
1. REQUIRE that /usr/doc is a symlink to the FHS directory /usr/share/doc.
2. REQUIRE that packages
- DO NOT create both /usr/doc/P and /usr/share/doc/P,
- DO NOT depend on /usr/doc not being a symlink,
and file critical bugs against packages violating any of these.
3. REQUIRE that packages
- DO NOT use the path /usr/doc,
- STORE their documentation in /usr/share/doc/P,
and file normal bugs against packages violating any of these.
Change the base-files package in the following way:
A. Move all files in /usr/doc to /usr/share/doc.
B. Add /usr/sbin/fix-FHS-compliance (attached) and execute it in postinst:
As far as I can see everything will then work with the release-critical
parts being fixed and everything else migrating at its own pace.
Here are the advantages of this scheme:
* Completely transparent to users, packages, etc.
* Just one inode used.
* Potato will be FHS-compliant except for the non-authorized single symbolic
link, and the upgrade path is trivial with the script above.
* dpkg is not bothered by a directory which is a symbolic link when it does
not have to create it. (I already use the same idea locally for /usr/src
and it works flawlessly: dpkg manages directories inside /usr/src without
any problems.) Recall that
$ ls -dl /usr/src
lrwxrwxrwx 1 root root 22 Jun 16 1998 /usr/src -> share/src
$ test -d /usr/src && echo OK
OK
demonstrates that such a symbolic link is interpreted as a directory so
scripts etc. should work as usual unless they explicitly test for a
symbolic link (which is unlikely).
* Once no package depends on /usr/doc it can be quietly removed.
Best,
Kristoffer
PS. The script is called fix-FHS-compliance because it could eventually
include more than just the /usr/doc issue. --Kris
--
Kristoffer Høgsbro Rose, phd, prof.associé <http://www.ens-lyon.fr/~krisrose>
addr. LIP, Ecole Normale Supérieure de Lyon, 46 Allée d'Italie, F-69364 Lyon 7
phone +33(0)4 7272 8642, fax +33(0)4 7272 8080 <Kristoffer.Rose@ENS-Lyon.FR>
pgp f-p: A4D3 5BD7 3EC5 7CA2 924E D21D 126B B8E0 <krisrose@{debian,tug}.org>
--
#!/bin/bash
#
# Debian FHS migration script.
# Currently only ensures that /usr/doc has migrated to /usr/share/doc.
echo -n "Checking that /usr/doc -> share/doc is in place..."
# Exit quietly if /usr/doc is already the right symbolic link.
cd /usr
if [ -L doc ]
then
target="`ls -ld doc | sed -n 's/.* -> //p'`"
if [ "$target" = "share/doc" ]; then
echo "ok."
exit
fi
fi
# (The rest is only executed if we did not run already.)
# Check that /usr/share/doc exists.
if [ ! -d /usr/share/doc ]
then
echo "failed."
echo "Error: /usr/share/doc does not exist! Please reinstall base-files."
exit 1
fi
# Exit noisily if they are already identical (since the symlink is bad).
usrdocfiles=`ls -1 /usr/doc`
usrsharedocfiles=`ls -1 /usr/share/doc`
if [ "$usrdocfiles" = "$usrsharedocfiles" ]
&& diff -rq /usr/doc /usr/share/doc
then
echo "ok."
echo "Warning: /usr/doc and /usr/share/doc seem to be identical but"
echo " /usr/doc is not a relative symlink to share/doc."
echo " You should fix this."
exit
fi
# We must migrate (or fail).
echo "no."
echo -n "Migrating /usr/doc -> share/doc..."
# Fail noisily if /usr/doc is a mount point.
if mount | fgrep -q ' /usr/doc '
then
echo "failed."
echo "Error: /usr/doc is a mount point! Please undo that and rerun"
echo " the /usr/sbin/fix-FHS-compliance script."
exit 1
fi
# Check that there are no duplicates between the directories.
dups=""
for d in $usrdocfiles
do
dups="$dups"`expr " $usrsharedocfiles " : " $d "`
done
if [ -n "$dups" ]
then
echo "failed."
echo "Error: The following packages have files in both /usr/doc and
/usr/share/doc:"
echo " $dups"
echo " This should not happen and cannot be handled by this script."
echo " We propose you remove these buggy packages and rerun the"
echo " /usr/sbin/fix-FHS-compliance script."
exit 1
fi
# We have a go for migration! Copy /usr/doc/* to /usr/share/doc/*.
cd /usr/doc
for d in $usrdocfiles
do
cp -a $d /usr/share/doc/$d
done
# Check that all data was correctly copied or fail.
cd /usr/doc
for d in $usrdocfiles
do
if ! diff -rq $d /usr/share/doc/$d >/dev/null 2>&1
then
echo "failed."
echo "Error: Could not copy /usr/doc/* to /usr/share/doc/*."
echo -n "Cleaning up..."
cd /usr/share/doc
for d in $usrdocfiles
do
rm -fr $d
done
echo "done."
exit 1
fi
done
# Now remove the old /usr/doc directory and make the symlink.
cd /usr
rm -fr doc
if [ -d /usr/doc ]
then
echo "failed."
echo "Error: Could not remove /usr/doc!"
echo " Your system may be in a very bad state - sorry."
exit 1
fi
ln -s share/doc doc
if [ ! -L doc ]
then
echo "failed."
echo "Error: Could not create symlink /usr/doc -> share/doc!"
echo " Your system may be in a very bad state - sorry."
exit 1
fi
# We're done.
echo "done."
exit
Reply to: