execute remote.<name>.annex-shell on remote, if set
It is useful to be able to specify an alternative git-annex-shell program to execute on the remote, e.g., to run a version not on the PATH. Use remote.<name>.annex-shell if specified, instead of the default "git-annex-shell" i.e., first so-named executable on the PATH.
This commit is contained in:
parent
5ed51e724e
commit
4eb72392b4
5 changed files with 26 additions and 9 deletions
|
@ -22,6 +22,7 @@ import Logs.UUID
|
||||||
import Logs.Trust
|
import Logs.Trust
|
||||||
import qualified Remote.Helper.Ssh as Ssh
|
import qualified Remote.Helper.Ssh as Ssh
|
||||||
import qualified Utility.Dot as Dot
|
import qualified Utility.Dot as Dot
|
||||||
|
import Types.GitConfig
|
||||||
|
|
||||||
-- a link from the first repository to the second (its remote)
|
-- a link from the first repository to the second (its remote)
|
||||||
data Link = Link Git.Repo Git.Repo
|
data Link = Link Git.Repo Git.Repo
|
||||||
|
@ -203,7 +204,9 @@ tryScan r
|
||||||
|
|
||||||
configlist = Ssh.onRemote r (pipedconfig, Nothing) "configlist" [] []
|
configlist = Ssh.onRemote r (pipedconfig, Nothing) "configlist" [] []
|
||||||
manualconfiglist = do
|
manualconfiglist = do
|
||||||
sshparams <- Ssh.toRepo r [Param sshcmd]
|
g <- fromRepo id
|
||||||
|
let c = extractRemoteGitConfig g (Git.repoDescribe r)
|
||||||
|
sshparams <- Ssh.toRepo r c [Param sshcmd]
|
||||||
liftIO $ pipedconfig "ssh" sshparams
|
liftIO $ pipedconfig "ssh" sshparams
|
||||||
where
|
where
|
||||||
sshcmd = cddir ++ " && " ++
|
sshcmd = cddir ++ " && " ++
|
||||||
|
|
|
@ -13,6 +13,7 @@ import System.Process
|
||||||
import Data.ByteString.Lazy.UTF8 (fromString)
|
import Data.ByteString.Lazy.UTF8 (fromString)
|
||||||
|
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
|
import Types.GitConfig
|
||||||
import Types.Remote
|
import Types.Remote
|
||||||
import Types.Key
|
import Types.Key
|
||||||
import Types.Creds
|
import Types.Creds
|
||||||
|
@ -223,7 +224,9 @@ storeBupUUID u buprepo = do
|
||||||
|
|
||||||
onBupRemote :: Git.Repo -> (FilePath -> [CommandParam] -> IO a) -> FilePath -> [CommandParam] -> Annex a
|
onBupRemote :: Git.Repo -> (FilePath -> [CommandParam] -> IO a) -> FilePath -> [CommandParam] -> Annex a
|
||||||
onBupRemote r a command params = do
|
onBupRemote r a command params = do
|
||||||
sshparams <- Ssh.toRepo r [Param $
|
g <- fromRepo id
|
||||||
|
let c = extractRemoteGitConfig g (Git.repoDescribe r)
|
||||||
|
sshparams <- Ssh.toRepo r c [Param $
|
||||||
"cd " ++ dir ++ " && " ++ unwords (command : toCommand params)]
|
"cd " ++ dir ++ " && " ++ unwords (command : toCommand params)]
|
||||||
liftIO $ a "ssh" sshparams
|
liftIO $ a "ssh" sshparams
|
||||||
where
|
where
|
||||||
|
|
|
@ -26,10 +26,8 @@ import Config
|
||||||
{- Generates parameters to ssh to a repository's host and run a command.
|
{- Generates parameters to ssh to a repository's host and run a command.
|
||||||
- Caller is responsible for doing any neccessary shellEscaping of the
|
- Caller is responsible for doing any neccessary shellEscaping of the
|
||||||
- passed command. -}
|
- passed command. -}
|
||||||
toRepo :: Git.Repo -> [CommandParam] -> Annex [CommandParam]
|
toRepo :: Git.Repo -> RemoteGitConfig -> [CommandParam] -> Annex [CommandParam]
|
||||||
toRepo r sshcmd = do
|
toRepo r c sshcmd = do
|
||||||
g <- fromRepo id
|
|
||||||
let c = extractRemoteGitConfig g (Git.repoDescribe r)
|
|
||||||
let opts = map Param $ remoteAnnexSshOptions c
|
let opts = map Param $ remoteAnnexSshOptions c
|
||||||
let host = fromMaybe (error "bad ssh url") $ Git.Url.hostuser r
|
let host = fromMaybe (error "bad ssh url") $ Git.Url.hostuser r
|
||||||
params <- sshCachingOptions (host, Git.Url.port r) opts
|
params <- sshCachingOptions (host, Git.Url.port r) opts
|
||||||
|
@ -41,16 +39,19 @@ git_annex_shell :: Git.Repo -> String -> [CommandParam] -> [(Field, String)] ->
|
||||||
git_annex_shell r command params fields
|
git_annex_shell r command params fields
|
||||||
| not $ Git.repoIsUrl r = return $ Just (shellcmd, shellopts ++ fieldopts)
|
| not $ Git.repoIsUrl r = return $ Just (shellcmd, shellopts ++ fieldopts)
|
||||||
| Git.repoIsSsh r = do
|
| Git.repoIsSsh r = do
|
||||||
|
g <- fromRepo id
|
||||||
|
let c = extractRemoteGitConfig g (Git.repoDescribe r)
|
||||||
u <- getRepoUUID r
|
u <- getRepoUUID r
|
||||||
sshparams <- toRepo r [Param $ sshcmd u ]
|
sshparams <- toRepo r c [Param $ sshcmd u c]
|
||||||
return $ Just ("ssh", sshparams)
|
return $ Just ("ssh", sshparams)
|
||||||
| otherwise = return Nothing
|
| otherwise = return Nothing
|
||||||
where
|
where
|
||||||
dir = Git.repoPath r
|
dir = Git.repoPath r
|
||||||
shellcmd = "git-annex-shell"
|
shellcmd = "git-annex-shell"
|
||||||
shellopts = Param command : File dir : params
|
shellopts = Param command : File dir : params
|
||||||
sshcmd u = unwords $
|
sshcmd u c = unwords $
|
||||||
shellcmd : map shellEscape (toCommand shellopts) ++
|
fromMaybe shellcmd (remoteAnnexShell c)
|
||||||
|
: map shellEscape (toCommand shellopts) ++
|
||||||
uuidcheck u ++
|
uuidcheck u ++
|
||||||
map shellEscape (toCommand fieldopts)
|
map shellEscape (toCommand fieldopts)
|
||||||
uuidcheck NoUUID = []
|
uuidcheck NoUUID = []
|
||||||
|
|
|
@ -119,6 +119,7 @@ data RemoteGitConfig = RemoteGitConfig
|
||||||
|
|
||||||
{- These settings are specific to particular types of remotes
|
{- These settings are specific to particular types of remotes
|
||||||
- including special remotes. -}
|
- including special remotes. -}
|
||||||
|
, remoteAnnexShell :: Maybe String
|
||||||
, remoteAnnexSshOptions :: [String]
|
, remoteAnnexSshOptions :: [String]
|
||||||
, remoteAnnexRsyncOptions :: [String]
|
, remoteAnnexRsyncOptions :: [String]
|
||||||
, remoteAnnexRsyncUploadOptions :: [String]
|
, remoteAnnexRsyncUploadOptions :: [String]
|
||||||
|
@ -151,6 +152,7 @@ extractRemoteGitConfig r remotename = RemoteGitConfig
|
||||||
, remoteAnnexAvailability = getmayberead "availability"
|
, remoteAnnexAvailability = getmayberead "availability"
|
||||||
, remoteAnnexBare = getmaybebool "bare"
|
, remoteAnnexBare = getmaybebool "bare"
|
||||||
|
|
||||||
|
, remoteAnnexShell = getmaybe "shell"
|
||||||
, remoteAnnexSshOptions = getoptions "ssh-options"
|
, remoteAnnexSshOptions = getoptions "ssh-options"
|
||||||
, remoteAnnexRsyncOptions = getoptions "rsync-options"
|
, remoteAnnexRsyncOptions = getoptions "rsync-options"
|
||||||
, remoteAnnexRsyncDownloadOptions = getoptions "rsync-download-options"
|
, remoteAnnexRsyncDownloadOptions = getoptions "rsync-download-options"
|
||||||
|
|
|
@ -1493,6 +1493,14 @@ Here are all the supported configuration settings.
|
||||||
The command will only be run once *all* running git-annex processes
|
The command will only be run once *all* running git-annex processes
|
||||||
are finished using the remote.
|
are finished using the remote.
|
||||||
|
|
||||||
|
* `remote.<name>.annex-shell`
|
||||||
|
|
||||||
|
Specify an alternative git-annex-shell executable on the remote
|
||||||
|
instead of looking for "git-annex-shell" on the PATH.
|
||||||
|
|
||||||
|
This is useful if the git-annex-shell program is outside the PATH
|
||||||
|
or has a non-standard name.
|
||||||
|
|
||||||
* `remote.<name>.annex-ignore`
|
* `remote.<name>.annex-ignore`
|
||||||
|
|
||||||
If set to `true`, prevents git-annex
|
If set to `true`, prevents git-annex
|
||||||
|
|
Loading…
Reference in a new issue