From e92a9774fa49f61fd7b08527c0550615e0df1a20 Mon Sep 17 00:00:00 2001
From: Ramakrishnan Muthukrishnan <ram@acano.com>
Date: Wed, 2 Sep 2015 10:14:06 +0530
Subject: [PATCH] OS-X package: add a preinstall script and copy the manpage
 into /etc/manpaths.d.

The preinstall script detects previous installation and removes it.

Author: Ramakrishnan Muthukrishnan <ram@leastauthority.com>
---
 misc/build_helpers/osx/scripts/postinstall |  7 ++++++-
 misc/build_helpers/osx/scripts/preinstall  | 13 +++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)
 create mode 100755 misc/build_helpers/osx/scripts/preinstall

diff --git a/misc/build_helpers/osx/scripts/postinstall b/misc/build_helpers/osx/scripts/postinstall
index aefc4fd3..48042618 100755
--- a/misc/build_helpers/osx/scripts/postinstall
+++ b/misc/build_helpers/osx/scripts/postinstall
@@ -1,3 +1,8 @@
 #!/bin/bash
 
-echo "/Applications/tahoe.app/bin" >> /etc/paths.d/tahoe
+PWD=`pwd`
+
+echo "/Applications/tahoe.app/bin/" >> /etc/paths.d/tahoe
+
+# copy the manpage into /etc/manpaths.d/
+echo "/Applications/tahoe.app/docs/man/" >> /etc/manpaths.d/tahoe
diff --git a/misc/build_helpers/osx/scripts/preinstall b/misc/build_helpers/osx/scripts/preinstall
new file mode 100755
index 00000000..b96aafe6
--- /dev/null
+++ b/misc/build_helpers/osx/scripts/preinstall
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+if [ -d /Applications/tahoe.app ]; then
+    rm -r /Applications/tahoe.app
+fi
+
+if [ -f /etc/paths.d/tahoe ]; then
+    rm /etc/paths.d/tahoe
+fi
+
+if [ -f /etc/manpaths.d/tahoe.1 ]; then
+    rm /etc/manpaths.d/tahoe.1
+fi
\ No newline at end of file
-- 
2.45.2