summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Assistant/Install.hs39
-rw-r--r--Assistant/Install/AutoStart.hs23
-rw-r--r--Build/InstallDesktopFile.hs19
-rwxr-xr-xui-macos/git-annex.app/Contents/MacOS/git-annex-webapp4
-rwxr-xr-xui-macos/git-annex.app/Contents/MacOS/runshell2
5 files changed, 62 insertions, 25 deletions
diff --git a/Assistant/Install.hs b/Assistant/Install.hs
index efcfbfe6e..b404bc4b6 100644
--- a/Assistant/Install.hs
+++ b/Assistant/Install.hs
@@ -7,26 +7,30 @@
module Assistant.Install where
+import Assistant.Common
+import Assistant.Install.AutoStart
+import Assistant.Ssh
import Locations.UserConfig
+import Utility.FileMode
import Utility.OSX
-import Utility.Path
import System.Posix.Env
-import System.Directory
{- The OSX git-annex.app does not have an installation process.
- So when it's run, it needs to set up autostarting of the assistant
- - daemon, as well as writing the programFile.
+ - daemon, as well as writing the programFile, and putting a
+ - git-annex-shell wrapper into ~/.ssh
-
- Note that this is done every time it's started, so if the user moves
- it around, the paths this sets up won't break.
-}
ensureInstalled :: IO ()
ensureInstalled = do
- e <- getEnv "OSX_GIT_ANNEX_APP_PROGRAM"
+ e <- getEnv "GIT_ANNEX_OSX_APP_BASE"
case e of
Nothing -> return ()
- Just program -> do
+ Just base -> do
+ let program = base ++ "/bin/git-annex"
programfile <- programFile
createDirectoryIfMissing True (parentDir programfile)
writeFile programfile program
@@ -34,12 +38,19 @@ ensureInstalled = do
autostartfile <- userAutoStart autoStartLabel
installAutoStart program autostartfile
-{- Installs an autostart plist file for OSX. -}
-installAutoStart :: FilePath -> FilePath -> IO ()
-installAutoStart command file = do
- createDirectoryIfMissing True (parentDir file)
- writeFile file $ genOSXAutoStartFile autoStartLabel command
- ["assistant", "--autostart"]
-
-autoStartLabel :: String
-autoStartLabel = "com.branchable.git-annex.assistant"
+ {- This shim is only updated if it doesn't
+ - already exist with the right content. This
+ - ensures that there's no race where it would have
+ - worked, but is unavailable due to being updated. -}
+ sshdir <- sshDir
+ let shim = sshdir </> "git-annex-shell"
+ let content = unlines
+ [ "#!/bin/sh"
+ , "set -e"
+ , "exec", base </> "runshell" ++ " git-annex-shell \"$@\""
+ ]
+ curr <- catchDefaultIO "" $ readFile shim
+ when (curr /= content) $ do
+ createDirectoryIfMissing True (parentDir shim)
+ writeFile shim content
+ modifyFileMode shim $ addModes [ownerExecuteMode]
diff --git a/Assistant/Install/AutoStart.hs b/Assistant/Install/AutoStart.hs
new file mode 100644
index 000000000..692774939
--- /dev/null
+++ b/Assistant/Install/AutoStart.hs
@@ -0,0 +1,23 @@
+{- Assistant OSX autostart file installation
+ -
+ - Copyright 2012 Joey Hess <joey@kitenet.net>
+ -
+ - Licensed under the GNU GPL version 3 or higher.
+ -}
+
+module Assistant.Install.AutoStart where
+
+import Utility.OSX
+import Utility.Path
+
+import System.Directory
+
+{- Installs an autostart plist file for OSX. -}
+installAutoStart :: FilePath -> FilePath -> IO ()
+installAutoStart command file = do
+ createDirectoryIfMissing True (parentDir file)
+ writeFile file $ genOSXAutoStartFile autoStartLabel command
+ ["assistant", "--autostart"]
+
+autoStartLabel :: String
+autoStartLabel = "com.branchable.git-annex.assistant"
diff --git a/Build/InstallDesktopFile.hs b/Build/InstallDesktopFile.hs
index 70c0033ee..bf1211bf4 100644
--- a/Build/InstallDesktopFile.hs
+++ b/Build/InstallDesktopFile.hs
@@ -16,7 +16,7 @@ import Utility.Path
import Utility.Monad
import Locations.UserConfig
import Utility.OSX
-import Assistant.OSX
+import Assistant.Install.AutoStart
import Control.Applicative
import System.Directory
@@ -97,16 +97,19 @@ installOSXAppFile appdir appfile mcontent = do
setFileMode dest mode
install :: FilePath -> IO ()
-install = do
+install command = do
#ifdef darwin_HOST_OS
- writeOSXDesktop
+ writeOSXDesktop command
#else
- writeFDODesktop
+ writeFDODesktop command
#endif
- unlessM isRoot $ do
- programfile <- inDestDir =<< programFile
- createDirectoryIfMissing True (parentDir programfile)
- writeFile programfile command
+ ifM isRoot
+ ( return ()
+ , do
+ programfile <- inDestDir =<< programFile
+ createDirectoryIfMissing True (parentDir programfile)
+ writeFile programfile command
+ )
main :: IO ()
main = getArgs >>= go
diff --git a/ui-macos/git-annex.app/Contents/MacOS/git-annex-webapp b/ui-macos/git-annex.app/Contents/MacOS/git-annex-webapp
index 7955bef15..565c3d1cb 100755
--- a/ui-macos/git-annex.app/Contents/MacOS/git-annex-webapp
+++ b/ui-macos/git-annex.app/Contents/MacOS/git-annex-webapp
@@ -12,8 +12,8 @@ fi
# If this is a standalone app, set a variable that git-annex can use to
# install itself.
if [ -e "$base/bin/git-annex" ]; then
- GIT_ANNEX_OSX_WEBAPP_PROGRAM="$base/bin/git-annex"
- export OSX_GIT_ANNEX_APP_PROGRAM
+ GIT_ANNEX_OSX_APP_BASE="$base"
+ export GIT_ANNEX_OSX_APP_BASE
fi
"$base/runshell" git-annex webapp "$@"
diff --git a/ui-macos/git-annex.app/Contents/MacOS/runshell b/ui-macos/git-annex.app/Contents/MacOS/runshell
index 78ba3bf0c..ade917686 100755
--- a/ui-macos/git-annex.app/Contents/MacOS/runshell
+++ b/ui-macos/git-annex.app/Contents/MacOS/runshell
@@ -47,7 +47,7 @@ export GIT_EXEC_PATH
if [ "$1" ]; then
cmd="$1"
shift 1
- "$cmd" "$@"
+ exec "$cmd" "$@"
else
$SHELL
fi