only enable SHA backends that configure finds support for
This commit is contained in:
parent
70a6eb6d73
commit
a3daac8a8b
12 changed files with 57 additions and 89 deletions
|
@ -26,7 +26,8 @@ module Backend (
|
|||
fsckKey,
|
||||
lookupFile,
|
||||
chooseBackends,
|
||||
keyBackend
|
||||
keyBackend,
|
||||
lookupBackendName
|
||||
) where
|
||||
|
||||
import Control.Monad.State
|
||||
|
|
|
@ -5,13 +5,14 @@
|
|||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
||||
module Backend.SHA (genBackend) where
|
||||
module Backend.SHA (backends) where
|
||||
|
||||
import Control.Monad.State
|
||||
import Data.String.Utils
|
||||
import System.Cmd.Utils
|
||||
import System.IO
|
||||
import System.Directory
|
||||
import Data.Maybe
|
||||
|
||||
import qualified Backend.File
|
||||
import BackendTypes
|
||||
|
@ -21,16 +22,31 @@ import Locations
|
|||
import Content
|
||||
import Types
|
||||
import Utility
|
||||
import qualified SysConfig
|
||||
|
||||
type SHASize = Int
|
||||
|
||||
-- Constructor for Backends using a given SHASize.
|
||||
genBackend :: SHASize -> Backend Annex
|
||||
genBackend size = Backend.File.backend
|
||||
{ name = shaName size
|
||||
, getKey = keyValue size
|
||||
, fsckKey = Backend.File.checkKey $ checkKeyChecksum size
|
||||
}
|
||||
backends :: [Backend Annex]
|
||||
-- order is slightly significant; want sha1 first ,and more general
|
||||
-- sizes earlier
|
||||
backends = catMaybes $ map genBackend [1, 256, 512, 224, 384]
|
||||
|
||||
genBackend :: SHASize -> Maybe (Backend Annex)
|
||||
genBackend size
|
||||
| supported size = Just b
|
||||
| otherwise = Nothing
|
||||
where
|
||||
b = Backend.File.backend
|
||||
{ name = shaName size
|
||||
, getKey = keyValue size
|
||||
, fsckKey = Backend.File.checkKey $ checkKeyChecksum size
|
||||
}
|
||||
supported 1 = SysConfig.sha1sum
|
||||
supported 256 = SysConfig.sha256sum
|
||||
supported 224 = SysConfig.sha224sum
|
||||
supported 384 = SysConfig.sha384sum
|
||||
supported 512 = SysConfig.sha512sum
|
||||
supported _ = False
|
||||
|
||||
shaName :: SHASize -> String
|
||||
shaName size = "SHA" ++ show size
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
{- git-annex "SHA1" backend
|
||||
-
|
||||
- Copyright 2011 Joey Hess <joey@kitenet.net>
|
||||
-
|
||||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
||||
module Backend.SHA1 (backend) where
|
||||
|
||||
import Types
|
||||
import Backend.SHA
|
||||
|
||||
backend :: Backend Annex
|
||||
backend = genBackend 1
|
|
@ -1,14 +0,0 @@
|
|||
{- git-annex "SHA224" backend
|
||||
-
|
||||
- Copyright 2011 Joey Hess <joey@kitenet.net>
|
||||
-
|
||||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
||||
module Backend.SHA224 (backend) where
|
||||
|
||||
import Types
|
||||
import Backend.SHA
|
||||
|
||||
backend :: Backend Annex
|
||||
backend = genBackend 224
|
|
@ -1,14 +0,0 @@
|
|||
{- git-annex "SHA384" backend
|
||||
-
|
||||
- Copyright 2011 Joey Hess <joey@kitenet.net>
|
||||
-
|
||||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
||||
module Backend.SHA384 (backend) where
|
||||
|
||||
import Types
|
||||
import Backend.SHA
|
||||
|
||||
backend :: Backend Annex
|
||||
backend = genBackend 384
|
|
@ -1,14 +0,0 @@
|
|||
{- git-annex "SHA512" backend
|
||||
-
|
||||
- Copyright 2011 Joey Hess <joey@kitenet.net>
|
||||
-
|
||||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
||||
module Backend.SHA512 (backend) where
|
||||
|
||||
import Types
|
||||
import Backend.SHA
|
||||
|
||||
backend :: Backend Annex
|
||||
backend = genBackend 512
|
|
@ -5,7 +5,7 @@
|
|||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
||||
module Backend.URL (backend) where
|
||||
module Backend.URL (backends) where
|
||||
|
||||
import Control.Monad.State (liftIO)
|
||||
import Data.String.Utils
|
||||
|
@ -15,6 +15,9 @@ import BackendTypes
|
|||
import Utility
|
||||
import Messages
|
||||
|
||||
backends :: [Backend Annex]
|
||||
backends = [backend]
|
||||
|
||||
backend :: Backend Annex
|
||||
backend = Backend {
|
||||
name = "URL",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
||||
module Backend.WORM (backend) where
|
||||
module Backend.WORM (backends) where
|
||||
|
||||
import Control.Monad.State
|
||||
import System.FilePath
|
||||
|
@ -22,6 +22,9 @@ import Content
|
|||
import Messages
|
||||
import Types
|
||||
|
||||
backends :: [Backend Annex]
|
||||
backends = [backend]
|
||||
|
||||
backend :: Backend Annex
|
||||
backend = Backend.File.backend {
|
||||
name = "WORM",
|
||||
|
|
|
@ -9,21 +9,13 @@ module BackendList (allBackends) where
|
|||
|
||||
-- When adding a new backend, import it here and add it to the list.
|
||||
import qualified Backend.WORM
|
||||
import qualified Backend.SHA1
|
||||
import qualified Backend.SHA256
|
||||
import qualified Backend.SHA512
|
||||
import qualified Backend.SHA224
|
||||
import qualified Backend.SHA384
|
||||
import qualified Backend.SHA
|
||||
import qualified Backend.URL
|
||||
import Types
|
||||
|
||||
allBackends :: [Backend Annex]
|
||||
allBackends =
|
||||
[ Backend.WORM.backend
|
||||
, Backend.SHA1.backend
|
||||
, Backend.SHA256.backend
|
||||
, Backend.SHA512.backend
|
||||
, Backend.SHA224.backend
|
||||
, Backend.SHA384.backend
|
||||
, Backend.URL.backend
|
||||
allBackends = concat
|
||||
[ Backend.WORM.backends
|
||||
, Backend.SHA.backends
|
||||
, Backend.URL.backends
|
||||
]
|
||||
|
|
|
@ -16,7 +16,7 @@ To build and use git-annex, you will need:
|
|||
(or uuidgen from util-linux)
|
||||
* `xargs`: <http://savannah.gnu.org/projects/findutils/>
|
||||
* `rsync`: <http://rsync.samba.org/>
|
||||
* `sha1sum`: <ftp://ftp.gnu.org/gnu/coreutils/>
|
||||
* `sha1sum`: <ftp://ftp.gnu.org/gnu/coreutils/> (optional, but recommended)
|
||||
* Then just [[download]] git-annex and run: `make; make install`
|
||||
|
||||
([Ikiwiki](http://ikiwiki.info) is needed to build the documentation,
|
||||
|
|
|
@ -7,7 +7,7 @@ sudo port install pcre
|
|||
sudo cabal install pcre-light
|
||||
sudo cabal install quickcheck
|
||||
|
||||
# this will enable the gnu tools, (to give sha224sum etc..., it does not override the BSD userland)
|
||||
# optional: this will enable the gnu tools, (to give sha224sum etc..., it does not override the BSD userland)
|
||||
export PATH=$PATH:/opt/local/libexec/gnubin
|
||||
|
||||
git clone git://git.kitenet.net/git-annex
|
||||
|
|
23
test.hs
23
test.hs
|
@ -37,8 +37,8 @@ import qualified UUID
|
|||
import qualified Trust
|
||||
import qualified Remotes
|
||||
import qualified Content
|
||||
import qualified Backend.SHA1
|
||||
import qualified Backend.WORM
|
||||
import qualified BackendList
|
||||
import qualified Backend
|
||||
import qualified Command.DropUnused
|
||||
|
||||
main :: IO ()
|
||||
|
@ -121,7 +121,7 @@ test_add = "git-annex add" ~: TestList [basic, sha1dup]
|
|||
test_setkey :: Test
|
||||
test_setkey = "git-annex setkey/fromkey" ~: TestCase $ inmainrepo $ do
|
||||
writeFile tmp $ content sha1annexedfile
|
||||
r <- annexeval $ BackendTypes.getKey Backend.SHA1.backend tmp
|
||||
r <- annexeval $ BackendTypes.getKey backendSHA1 tmp
|
||||
let sha1 = BackendTypes.keyName $ fromJust r
|
||||
git_annex "setkey" ["-q", "--backend", "SHA1", "--key", sha1, tmp] @? "setkey failed"
|
||||
git_annex "fromkey" ["-q", "--backend", "SHA1", "--key", sha1, sha1annexedfile] @? "fromkey failed"
|
||||
|
@ -405,8 +405,8 @@ test_migrate = "git-annex migrate" ~: TestList [t False, t True]
|
|||
@? "migrate annexedfile failed"
|
||||
annexed_present annexedfile
|
||||
annexed_present sha1annexedfile
|
||||
checkbackend annexedfile Backend.SHA1.backend
|
||||
checkbackend sha1annexedfile Backend.SHA1.backend
|
||||
checkbackend annexedfile backendSHA1
|
||||
checkbackend sha1annexedfile backendSHA1
|
||||
|
||||
-- check that reversing a migration works
|
||||
writeFile ".gitattributes" $ "* annex.backend=WORM"
|
||||
|
@ -416,8 +416,8 @@ test_migrate = "git-annex migrate" ~: TestList [t False, t True]
|
|||
@? "migrate annexedfile failed"
|
||||
annexed_present annexedfile
|
||||
annexed_present sha1annexedfile
|
||||
checkbackend annexedfile Backend.WORM.backend
|
||||
checkbackend sha1annexedfile Backend.WORM.backend
|
||||
checkbackend annexedfile backendWORM
|
||||
checkbackend sha1annexedfile backendWORM
|
||||
|
||||
where
|
||||
checkbackend file expected = do
|
||||
|
@ -682,3 +682,12 @@ changecontent f = writeFile f $ changedcontent f
|
|||
|
||||
changedcontent :: FilePath -> String
|
||||
changedcontent f = (content f) ++ " (modified)"
|
||||
|
||||
backendSHA1 :: Types.Backend Types.Annex
|
||||
backendSHA1 = backend_ "SHA1"
|
||||
|
||||
backendWORM :: Types.Backend Types.Annex
|
||||
backendWORM = backend_ "WORM"
|
||||
|
||||
backend_ :: String -> Types.Backend Types.Annex
|
||||
backend_ name = Backend.lookupBackendName BackendList.allBackends name
|
||||
|
|
Loading…
Reference in a new issue