diff options
author | Joey Hess <joey@kitenet.net> | 2012-09-26 16:50:04 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-09-26 16:50:04 -0400 |
commit | c9f341bd303a2d7b58eb0a7f6b596b7b1d7948bd (patch) | |
tree | 4f9097afb1cb69f1ba9653f6a90cb26ad0ddc090 /Assistant/Install.hs | |
parent | cb1913e6cddfa090bda8b860d9b4129d83cf2c83 (diff) |
make the standalone OSX app automatically install itself when run
Diffstat (limited to 'Assistant/Install.hs')
-rw-r--r-- | Assistant/Install.hs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/Assistant/Install.hs b/Assistant/Install.hs new file mode 100644 index 000000000..efcfbfe6e --- /dev/null +++ b/Assistant/Install.hs @@ -0,0 +1,45 @@ +{- Assistant installation + - + - Copyright 2012 Joey Hess <joey@kitenet.net> + - + - Licensed under the GNU GPL version 3 or higher. + -} + +module Assistant.Install where + +import Locations.UserConfig +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. + - + - 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" + case e of + Nothing -> return () + Just program -> do + programfile <- programFile + createDirectoryIfMissing True (parentDir programfile) + writeFile programfile program + + 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" |