diff options
author | Andrew Cady <d@jerkface.net> | 2018-07-09 01:36:11 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2018-07-09 01:36:11 -0400 |
commit | 4e831c33b6360b6957c68adf50c9ecb932900b15 (patch) | |
tree | 1d299d86168650b1c721b238e9b78ffd0065365f /fsmgr.hs | |
parent | 019a2a64ffd8286f2f272199bedca1d62589764a (diff) |
begin config file parser
Diffstat (limited to 'fsmgr.hs')
-rw-r--r-- | fsmgr.hs | 24 |
1 files changed, 20 insertions, 4 deletions
@@ -1,11 +1,16 @@ | |||
1 | {-# LANGUAGE TypeApplications #-} | ||
1 | {-# LANGUAGE InstanceSigs #-} | 2 | {-# LANGUAGE InstanceSigs #-} |
2 | {-# LANGUAGE NoImplicitPrelude #-} | 3 | {-# LANGUAGE NoImplicitPrelude #-} |
4 | {-# LANGUAGE OverloadedStrings #-} | ||
3 | {-# LANGUAGE PartialTypeSignatures #-} | 5 | {-# LANGUAGE PartialTypeSignatures #-} |
4 | module Main where | 6 | module Main where |
5 | import Rebase.Prelude hiding (hash) | 7 | import Rebase.Prelude hiding (hash, bool) |
6 | 8 | ||
7 | import Crypto.Hash | 9 | import Crypto.Hash |
8 | import Crypto.Hash.Types.Digest.Read () | 10 | import Crypto.Hash.Types.Digest.Read () |
11 | import Data.Yaml.Combinators | ||
12 | import qualified Rebase.Data.Set as Set | ||
13 | import qualified Rebase.Data.Vector as Vector | ||
9 | 14 | ||
10 | {- | 15 | {- |
11 | 16 | ||
@@ -35,14 +40,25 @@ sha1 :: ByteString -> Digest SHA1 | |||
35 | sha1 = hash | 40 | sha1 = hash |
36 | 41 | ||
37 | data DiskImageConfig = DiskImageConfig { | 42 | data DiskImageConfig = DiskImageConfig { |
38 | initialImage :: Either Integer (Digest SHA1) | 43 | initialImage :: Either Int Text -- :: Either Integer (Digest SHA1) |
39 | , unpacked :: Set Package | 44 | , unpacked :: Set Package |
40 | , debconfConfig :: DebconfConfig | 45 | , debconfConfig :: DebconfConfig |
41 | , configured :: Set Package | 46 | , configured :: Bool |
42 | , patched :: [Patch] | 47 | , patched :: Vector Text -- :: [Patch] |
43 | } deriving (Show, Read) | 48 | } deriving (Show, Read) |
44 | 49 | ||
50 | diskImageConfigParser :: Parser DiskImageConfig | ||
51 | diskImageConfigParser = object $ | ||
52 | DiskImageConfig | ||
53 | <$> field "initial-image" ((Left <$> integer) <> (Right <$> string)) | ||
54 | <*> (Set.fromList . toList . fmap f <$> (field "packages" (array string))) | ||
55 | <*> pure (DebconfConfig "") | ||
56 | <*> defaultField "configure" True bool | ||
57 | <*> ((fromMaybe Vector.empty) <$> (optField "patches" (array string))) | ||
45 | 58 | ||
59 | where | ||
60 | f :: Text -> Package | ||
61 | f = undefined | ||
46 | 62 | ||
47 | main :: IO () | 63 | main :: IO () |
48 | main = return () | 64 | main = return () |