change name of buprepo

Instead of remote=, use buprepo=

Anyone already using bup will need to re-run git annex initremote.
This commit is contained in:
Joey Hess 2011-04-09 12:41:17 -04:00
parent 141e55ff11
commit c739c7d787
3 changed files with 35 additions and 29 deletions

View file

@ -33,26 +33,27 @@ import Ssh
remote :: RemoteType Annex remote :: RemoteType Annex
remote = RemoteType { remote = RemoteType {
typename = "bup", typename = "bup",
enumerate = findSpecialRemotes "bupremote", enumerate = findSpecialRemotes "buprepo",
generate = gen, generate = gen,
setup = bupSetup setup = bupSetup
} }
gen :: Git.Repo -> UUID -> Maybe (M.Map String String) -> Annex (Remote Annex) gen :: Git.Repo -> UUID -> Maybe (M.Map String String) -> Annex (Remote Annex)
gen r u c = do gen r u c = do
bupremote <- getConfig r "bupremote" (error "missing bupremote") buprepo <- getConfig r "buprepo" (error "missing buprepo")
cst <- remoteCost r (if bupLocal bupremote then semiCheapRemoteCost else expensiveRemoteCost) cst <- remoteCost r (if bupLocal buprepo then semiCheapRemoteCost else expensiveRemoteCost)
-- u' <- getBupUUID r u
return $ this cst bupremote return $ this cst buprepo u'
where where
this cst bupremote = Remote { this cst buprepo u' = Remote {
uuid = u, uuid = u',
cost = cst, cost = cst,
name = Git.repoDescribe r, name = Git.repoDescribe r,
storeKey = store r bupremote, storeKey = store r buprepo,
retrieveKeyFile = retrieve bupremote, retrieveKeyFile = retrieve buprepo,
removeKey = remove, removeKey = remove,
hasKey = checkPresent u, hasKey = checkPresent u',
hasKeyCheap = True, hasKeyCheap = True,
config = c config = c
} }
@ -60,7 +61,7 @@ gen r u c = do
bupSetup :: UUID -> M.Map String String -> Annex (M.Map String String) bupSetup :: UUID -> M.Map String String -> Annex (M.Map String String)
bupSetup u c = do bupSetup u c = do
-- verify configuration is sane -- verify configuration is sane
let bupremote = case M.lookup "remote" c of let buprepo = case M.lookup "remote" c of
Nothing -> error "Specify remote=" Nothing -> error "Specify remote="
Just r -> r Just r -> r
case M.lookup "encryption" c of case M.lookup "encryption" c of
@ -71,37 +72,37 @@ bupSetup u c = do
-- bup init will create the repository. -- bup init will create the repository.
-- (If the repository already exists, bup init again appears safe.) -- (If the repository already exists, bup init again appears safe.)
showNote "bup init" showNote "bup init"
ok <- bup "init" bupremote [] ok <- bup "init" buprepo []
unless ok $ error "bup init failed" unless ok $ error "bup init failed"
storeBupUUID u bupremote storeBupUUID u buprepo
-- The bup remote is stored in git config, as well as this remote's -- The buprepo is stored in git config, as well as this repo's
-- persistant state, so it can vary between hosts. -- persistant state, so it can vary between hosts.
gitConfigSpecialRemote u c "bupremote" bupremote gitConfigSpecialRemote u c "buprepo" buprepo
return $ M.delete "directory" c return $ M.delete "directory" c
bupParams :: String -> String -> [CommandParam] -> [CommandParam] bupParams :: String -> String -> [CommandParam] -> [CommandParam]
bupParams command bupremote params = bupParams command buprepo params =
(Param command) : [Param "-r", Param bupremote] ++ params (Param command) : [Param "-r", Param buprepo] ++ params
bup :: String -> String -> [CommandParam] -> Annex Bool bup :: String -> String -> [CommandParam] -> Annex Bool
bup command bupremote params = do bup command buprepo params = do
showProgress -- make way for bup output showProgress -- make way for bup output
liftIO $ boolSystem "bup" $ bupParams command bupremote params liftIO $ boolSystem "bup" $ bupParams command buprepo params
store :: Git.Repo -> String -> Key -> Annex Bool store :: Git.Repo -> String -> Key -> Annex Bool
store r bupremote k = do store r buprepo k = do
g <- Annex.gitRepo g <- Annex.gitRepo
let src = gitAnnexLocation g k let src = gitAnnexLocation g k
o <- getConfig r "bup-split-options" "" o <- getConfig r "bup-split-options" ""
let os = map Param $ words o let os = map Param $ words o
bup "split" bupremote $ os ++ [Param "-n", Param (show k), File src] bup "split" buprepo $ os ++ [Param "-n", Param (show k), File src]
retrieve :: String -> Key -> FilePath -> Annex Bool retrieve :: String -> Key -> FilePath -> Annex Bool
retrieve bupremote k f = do retrieve buprepo k f = do
let params = bupParams "join" bupremote [Param $ show k] let params = bupParams "join" buprepo [Param $ show k]
ret <- liftIO $ try $ do ret <- liftIO $ try $ do
-- pipe bup's stdout directly to file -- pipe bup's stdout directly to file
tofile <- openFile f WriteMode tofile <- openFile f WriteMode
@ -140,8 +141,8 @@ checkPresent u k = do
{- Store UUID in the annex.uuid setting of the bup repository. -} {- Store UUID in the annex.uuid setting of the bup repository. -}
storeBupUUID :: UUID -> FilePath -> Annex () storeBupUUID :: UUID -> FilePath -> Annex ()
storeBupUUID u bupremote = do storeBupUUID u buprepo = do
r <- liftIO $ bup2GitRemote bupremote r <- liftIO $ bup2GitRemote buprepo
if Git.repoIsUrl r if Git.repoIsUrl r
then do then do
showNote "storing uuid" showNote "storing uuid"
@ -157,6 +158,11 @@ storeBupUUID u bupremote = do
when (olduuid == "") $ when (olduuid == "") $
Git.run r' "config" [Param "annex.uuid", Param u] Git.run r' "config" [Param "annex.uuid", Param u]
{- Allow for bup repositories on removable media by checking
- local bup repositories -}
--getBupUUID :: UUID -> FilePath -> Annex ()
--getBupUUID u buprepo = do
{- Converts a bup remote path spec into a Git.Repo. There are some {- Converts a bup remote path spec into a Git.Repo. There are some
- differences in path representation between git and bup. -} - differences in path representation between git and bup. -}
bup2GitRemote :: FilePath -> IO Git.Repo bup2GitRemote :: FilePath -> IO Git.Repo

View file

@ -21,10 +21,10 @@ These parameters can be passed to `git annex initremote` to configure bup:
keys can be given access to a remote by rerunning initremote with keys can be given access to a remote by rerunning initremote with
the new key id. the new key id.
* `remote` - Required. This is passed to `bup` as the `--remote` * `buprepo` - Required. This is passed to `bup` as the `--remote`
to use to store data. To create the repository,`bup init` will be run. to use to store data. To create the repository,`bup init` will be run.
Example: "remote=example.com:/big/mybup" or "remote=/big/mybup" Example: "buprepo=example.com:/big/mybup" or "buprepo=/big/mybup"
(To use the default `~/.bup` repository on the local host, specify "remote=") (To use the default `~/.bup` repository on the local host, specify "buprepo=")
Options to pass to `bup split` when sending content to bup can also Options to pass to `bup split` when sending content to bup can also
be specified, by using `git config annex.bup-split-options`. This be specified, by using `git config annex.bup-split-options`. This

View file

@ -8,10 +8,10 @@ Here's how to create a bup remote, and describe it.
[[!template id=note text=""" [[!template id=note text="""
Instead of specifying a remote system, you could choose to make a bup Instead of specifying a remote system, you could choose to make a bup
remote that is only accessible on the current system, by passing remote that is only accessible on the current system, by passing
"remote=/big/mybup". "buprepo=/big/mybup".
"""]] """]]
# git annex initremote mybup type=bup encryption=none remote=example.com:/big/mybup # git annex initremote mybup type=bup encryption=none buprepo=example.com:/big/mybup
initremote bup (bup init) initremote bup (bup init)
Initialized empty Git repository in /big/mybup/ Initialized empty Git repository in /big/mybup/
ok ok