- # If this is a symlink, leave it alone.
- if ( ! -d "$tmp/usr/share/doc/$package" &&
- ! -l "$tmp/usr/share/doc/$package") {
- doit("install","-g",0,"-o",0,"-d","$tmp/usr/share/doc/$package");
+ if ($link_doc) {
+ # Make sure that the parent directory exists.
+ if (! -d "$tmp/usr/share/doc" && ! -l "$tmp/usr/share/doc") {
+ doit("install","-g",0,"-o",0,"-d","$tmp/usr/share/doc");
+ }
+ # Create symlink to another documentation directory if
+ # necessary.
+ if (! -d "$tmp/usr/share/doc/$package" &&
+ ! -l "$tmp/usr/share/doc/$package") {
+ doit("ln", "-sf", $dh{LINK_DOC}, "$tmp/usr/share/doc/$package");
+ # Policy says that if you make your documentation
+ # directory a symlink, then you have to depend on
+ # the target.
+ addsubstvar($package, "misc:Depends", $dh{LINK_DOC});
+ }
+ }
+ else {
+ ensure_docdir($package);