summary refs log tree commit diff
path: root/pkgs/build-support/setup-hooks/move-docs.sh
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-07-08 15:33:15 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-08-09 12:47:05 +0200
commita8fc68a5c02488a2228a1dc4984a3fa6351002eb (patch)
treeb902a06f1fb87856f53cd289627eed6252ac71f6 /pkgs/build-support/setup-hooks/move-docs.sh
parent9e31c66d1b4e71c5e09719931d77c794a9608acb (diff)
downloadnixpkgs-a8fc68a5c02488a2228a1dc4984a3fa6351002eb.tar
nixpkgs-a8fc68a5c02488a2228a1dc4984a3fa6351002eb.tar.gz
nixpkgs-a8fc68a5c02488a2228a1dc4984a3fa6351002eb.tar.bz2
nixpkgs-a8fc68a5c02488a2228a1dc4984a3fa6351002eb.tar.lz
nixpkgs-a8fc68a5c02488a2228a1dc4984a3fa6351002eb.tar.xz
nixpkgs-a8fc68a5c02488a2228a1dc4984a3fa6351002eb.tar.zst
nixpkgs-a8fc68a5c02488a2228a1dc4984a3fa6351002eb.zip
Move share/{man,info,doc} to the corresponding output
Diffstat (limited to 'pkgs/build-support/setup-hooks/move-docs.sh')
-rw-r--r--pkgs/build-support/setup-hooks/move-docs.sh50
1 files changed, 38 insertions, 12 deletions
diff --git a/pkgs/build-support/setup-hooks/move-docs.sh b/pkgs/build-support/setup-hooks/move-docs.sh
index b3b93193550..c819ee12a9c 100644
--- a/pkgs/build-support/setup-hooks/move-docs.sh
+++ b/pkgs/build-support/setup-hooks/move-docs.sh
@@ -1,24 +1,50 @@
-# This setup hook automatically moves $out/{man,doc,info} to
-# $out/share.
+# This setup hook moves $out/{man,doc,info} to $out/share; moves
+# $out/share/man to $man/share/man; and moves $out/share/doc to
+# $man/share/doc.
 
 preFixupHooks+=(_moveDocs)
 
-_moveDocs() {
+_moveToShare() {
     forceShare=${forceShare:=man doc info}
-    if [ -z "$forceShare" ]; then return; fi
+    if [ -z "$forceShare" -o -z "$out" ]; then return; fi
 
     for d in $forceShare; do
-        if [ -d "$prefix/$d" ]; then
-            if [ -d "$prefix/share/$d" ]; then
+        if [ -d "$out/$d" ]; then
+            if [ -d "$out/share/$d" ]; then
                 echo "both $d/ and share/$d/ exist!"
             else
-                echo "moving $prefix/$d to $prefix/share/$d"
-                mkdir -p $prefix/share
-                if [ -w $prefix/share ]; then
-                    mv $prefix/$d $prefix/share
-                    ln -s share/$d $prefix
-                fi
+                echo "moving $out/$d to $out/share/$d"
+                mkdir -p $out/share
+                mv $out/$d $out/share/
             fi
         fi
     done
 }
+
+_moveToOutput() {
+    local d="$1"
+    local dst="$2"
+    if [ -z "$dst" -a ! -e $dst/$d ]; then return; fi
+    local output
+    for output in $outputs; do
+        if [ "${!output}" = "$dst" ]; then continue; fi
+        if [ -d "${!output}/$d" ]; then
+            echo "moving ${!output}/$d to $dst/$d"
+            mkdir -p $dst/share
+            mv ${!output}/$d $dst/$d
+            break
+        fi
+    done
+}
+
+_moveDocs() {
+    _moveToShare
+    _moveToOutput share/man "$man"
+    _moveToOutput share/info "$info"
+    _moveToOutput share/doc "$doc"
+
+    # Remove empty share directory.
+    if [ -d "$out/share" ]; then
+        rmdir $out/share 2> /dev/null || true
+    fi
+}