
* unannex, uninit: Avoid committing after every file is unannexed, for massive speedup. * --notify-finish switch will cause desktop notifications after each file upload/download/drop completes (using the dbus Desktop Notifications Specification) * --notify-start switch will show desktop notifications when each file upload/download starts. * webapp: Automatically install Nautilus integration scripts to get and drop files. * tahoe: Pass -d parameter before subcommand; putting it after the subcommand no longer works with tahoe-lafs version 1.10. (Thanks, Alberto Berti) * forget --drop-dead: Avoid removing the dead remote from the trust.log, so that if git remotes for it still exist anywhere, git annex info will still know it's dead and not show it. * git-annex-shell: Make configlist automatically initialize a remote git repository, as long as a git-annex branch has been pushed to it, to simplify setup of remote git repositories, including via gitolite. * add --include-dotfiles: New option, perhaps useful for backups. * Version 5.20140227 broke creation of glacier repositories, not including the datacenter and vault in their configuration. This bug is fixed, but glacier repositories set up with the broken version of git-annex need to have the datacenter and vault set in order to be usable. This can be done using git annex enableremote to add the missing settings. For details, see http://git-annex.branchable.com/bugs/problems_with_glacier/ * Added required content configuration. * assistant: Improve ssh authorized keys line generated in local pairing or for a remote ssh server to set environment variables in an alternative way that works with the non-POSIX fish shell, as well as POSIX shells. # imported from the archive
131 lines
3.9 KiB
Haskell
131 lines
3.9 KiB
Haskell
{- Assistant installation
|
|
-
|
|
- Copyright 2012 Joey Hess <joey@kitenet.net>
|
|
-
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
-}
|
|
|
|
{-# LANGUAGE CPP #-}
|
|
|
|
module Assistant.Install where
|
|
|
|
import Assistant.Common
|
|
import Assistant.Install.AutoStart
|
|
import Config.Files
|
|
import Utility.FileMode
|
|
import Utility.Shell
|
|
import Utility.Tmp
|
|
import Utility.Env
|
|
import Utility.SshConfig
|
|
|
|
#ifdef darwin_HOST_OS
|
|
import Utility.OSX
|
|
#else
|
|
import Utility.FreeDesktop
|
|
import Assistant.Install.Menu
|
|
#endif
|
|
|
|
standaloneAppBase :: IO (Maybe FilePath)
|
|
standaloneAppBase = getEnv "GIT_ANNEX_APP_BASE"
|
|
|
|
{- The standalone 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, 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.
|
|
-
|
|
- Nautilus hook script installation is done even for packaged apps,
|
|
- since it has to go into the user's home directory.
|
|
-}
|
|
ensureInstalled :: IO ()
|
|
ensureInstalled = go =<< standaloneAppBase
|
|
where
|
|
go Nothing = installNautilus "git-annex"
|
|
go (Just base) = do
|
|
let program = base </> "git-annex"
|
|
programfile <- programFile
|
|
createDirectoryIfMissing True (parentDir programfile)
|
|
writeFile programfile program
|
|
|
|
#ifdef darwin_HOST_OS
|
|
autostartfile <- userAutoStart osxAutoStartLabel
|
|
#else
|
|
menufile <- desktopMenuFilePath "git-annex" <$> userDataDir
|
|
icondir <- iconDir <$> userDataDir
|
|
installMenu program menufile base icondir
|
|
autostartfile <- autoStartPath "git-annex" <$> userConfigDir
|
|
#endif
|
|
installAutoStart program autostartfile
|
|
|
|
{- This shim is only updated if it doesn't
|
|
- already exist with the right content. -}
|
|
sshdir <- sshDir
|
|
let shim = sshdir </> "git-annex-shell"
|
|
let runshell var = "exec " ++ base </> "runshell" ++
|
|
" git-annex-shell -c \"" ++ var ++ "\""
|
|
let content = unlines
|
|
[ shebang_local
|
|
, "set -e"
|
|
, "if [ \"x$SSH_ORIGINAL_COMMAND\" != \"x\" ]; then"
|
|
, runshell "$SSH_ORIGINAL_COMMAND"
|
|
, "else"
|
|
, runshell "$@"
|
|
, "fi"
|
|
]
|
|
|
|
curr <- catchDefaultIO "" $ readFileStrict shim
|
|
when (curr /= content) $ do
|
|
createDirectoryIfMissing True (parentDir shim)
|
|
viaTmp writeFile shim content
|
|
modifyFileMode shim $ addModes [ownerExecuteMode]
|
|
|
|
installNautilus program
|
|
|
|
installNautilus :: FilePath -> IO ()
|
|
#ifdef linux_HOST_OS
|
|
installNautilus program = do
|
|
scriptdir <- (\d -> d </> "nautilus" </> "scripts") <$> userDataDir
|
|
genscript scriptdir "get"
|
|
genscript scriptdir "drop"
|
|
where
|
|
genscript scriptdir action =
|
|
installscript (scriptdir </> scriptname action) $ unlines
|
|
[ shebang_local
|
|
, autoaddedcomment
|
|
, "exec " ++ program ++ " " ++ action ++ " --notify-start --notify-finish -- \"$@\""
|
|
]
|
|
scriptname action = "git-annex " ++ action
|
|
installscript f c = whenM (safetoinstallscript f) $ do
|
|
writeFile f c
|
|
modifyFileMode f $ addModes [ownerExecuteMode]
|
|
safetoinstallscript f = catchDefaultIO True $
|
|
elem autoaddedcomment . lines <$> readFileStrict f
|
|
autoaddedcomment = "# Automatically added by git-annex, do not edit. (To disable, chmod 600 this file.)"
|
|
#else
|
|
installNautilus _ = noop
|
|
#endif
|
|
|
|
{- Returns a cleaned up environment that lacks settings used to make the
|
|
- standalone builds use their bundled libraries and programs.
|
|
- Useful when calling programs not included in the standalone builds.
|
|
-
|
|
- For a non-standalone build, returns Nothing.
|
|
-}
|
|
cleanEnvironment :: IO (Maybe [(String, String)])
|
|
cleanEnvironment = clean <$> getEnvironment
|
|
where
|
|
clean env
|
|
| null vars = Nothing
|
|
| otherwise = Just $ catMaybes $ map (restoreorig env) env
|
|
| otherwise = Nothing
|
|
where
|
|
vars = words $ fromMaybe "" $
|
|
lookup "GIT_ANNEX_STANDLONE_ENV" env
|
|
restoreorig oldenv p@(k, _v)
|
|
| k `elem` vars = case lookup ("ORIG_" ++ k) oldenv of
|
|
(Just v')
|
|
| not (null v') -> Just (k, v')
|
|
_ -> Nothing
|
|
| otherwise = Just p
|