aboutsummaryrefslogtreecommitdiff
path: root/Annex/UUID.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-02-10 14:52:54 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-02-10 14:52:54 -0400
commit516d4899d3ea7e12ee9b408160b36190b8c2d3f2 (patch)
treead34ef74d632b07a20b6dec6850d5b9e4a14b289 /Annex/UUID.hs
parent9b7a1ea41832f30e4d2f707a02df34ccedfcb69f (diff)
Now uses the Haskell uuid library, rather than needing a uuid program.
Been meaning to do this for some time; Android port was last straw. Note that newer versions of the uuid library have a Data.UUID.V4 that generates random UUIDs slightly more cleanly, but Debian has an old version of the library, so I do it slightly round-about.
Diffstat (limited to 'Annex/UUID.hs')
-rw-r--r--Annex/UUID.hs15
1 files changed, 6 insertions, 9 deletions
diff --git a/Annex/UUID.hs b/Annex/UUID.hs
index b20d94125..c36861bbe 100644
--- a/Annex/UUID.hs
+++ b/Annex/UUID.hs
@@ -6,7 +6,7 @@
- UUIDs of remotes are cached in git config, using keys named
- remote.<name>.annex-uuid
-
- - Copyright 2010-2011 Joey Hess <joey@kitenet.net>
+ - Copyright 2010-2013 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
@@ -24,20 +24,17 @@ module Annex.UUID (
import Common.Annex
import qualified Git
import qualified Git.Config
-import qualified Build.SysConfig as SysConfig
import Config
+import qualified Data.UUID as U
+import System.Random
+
configkey :: ConfigKey
configkey = annexConfig "uuid"
-{- Generates a UUID. There is a library for this, but it's not packaged,
- - so use the command line tool. -}
+{- Generates a random UUID, that does not include the MAC address. -}
genUUID :: IO UUID
-genUUID = gen . lines <$> readProcess command params
- where
- gen [] = error $ "no output from " ++ command
- gen (l:_) = toUUID l
- (command:params) = words SysConfig.uuid
+genUUID = UUID . show <$> (randomIO :: IO U.UUID)
{- Get current repository's UUID. -}
getUUID :: Annex UUID