summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Setup.hs2
-rw-r--r--fsmgr.cabal53
-rw-r--r--fsmgr.hs48
-rw-r--r--src/Crypto/Hash/Types/Digest/Read.hs20
-rw-r--r--stack.yaml5
6 files changed, 129 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3a5b475
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
.stack-work/
diff --git a/Setup.hs b/Setup.hs
new file mode 100644
index 0000000..9a994af
--- /dev/null
+++ b/Setup.hs
@@ -0,0 +1,2 @@
1import Distribution.Simple
2main = defaultMain
diff --git a/fsmgr.cabal b/fsmgr.cabal
new file mode 100644
index 0000000..06a6bdb
--- /dev/null
+++ b/fsmgr.cabal
@@ -0,0 +1,53 @@
1name: fsmgr
2version: 0.1.0.0
3-- description: Please see the README on GitHub at <https://github.com/afcady/fsmgr#readme>
4-- homepage: https://github.com/afcady/fsmgr#readme
5-- bug-reports: https://github.com/afcady/fsmgr/issues
6author: Andrew Cady
7maintainer: d@jerkface.net
8copyright: AllRightsReserved
9-- license-file: LICENSE
10build-type: Simple
11cabal-version: >= 1.10
12-- extra-source-files:
13-- ChangeLog.md
14-- README.md
15
16source-repository head
17 type: git
18 location: https://github.com/afcady/fsmgr
19
20library
21 exposed-modules:
22 Crypto.Hash.Types.Digest.Read
23 other-modules:
24 Paths_fsmgr
25 hs-source-dirs:
26 src
27 build-depends:
28 base >=4.7 && <5, rebase, optparse-applicative, typed-process,
29 directory, filepath, yaml, lens, lens-aeson, cryptonite, memory, basement
30 default-language: Haskell2010
31
32executable fsmgr
33 main-is: fsmgr.hs
34 other-modules:
35 Paths_fsmgr
36 ghc-options: -threaded -rtsopts -with-rtsopts=-N -W -Wall
37 build-depends:
38 base >=4.7 && <5, rebase, optparse-applicative, typed-process,
39 directory, filepath, yaml, lens, lens-aeson, cryptonite, memory, basement, fsmgr
40 default-language: Haskell2010
41
42-- test-suite fsmgr-test
43-- type: exitcode-stdio-1.0
44-- main-is: Spec.hs
45-- other-modules:
46-- Paths_fsmgr
47-- hs-source-dirs:
48-- test
49-- ghc-options: -threaded -rtsopts -with-rtsopts=-N
50-- build-depends:
51-- base >=4.7 && <5
52-- , fsmgr
53-- default-language: Haskell2010
diff --git a/fsmgr.hs b/fsmgr.hs
new file mode 100644
index 0000000..3c5e72f
--- /dev/null
+++ b/fsmgr.hs
@@ -0,0 +1,48 @@
1{-# LANGUAGE InstanceSigs #-}
2{-# LANGUAGE NoImplicitPrelude #-}
3{-# LANGUAGE PartialTypeSignatures #-}
4module Main where
5import Rebase.Prelude hiding (hash)
6
7import Crypto.Hash
8import Crypto.Hash.Types.Digest.Read ()
9
10{-
11
12Basic idea is to have a fs.yaml that specifies the build procedure. Analogous to
13stack.yaml, it should specify everything (every source) directly or indirectly.
14
15We want to make new images from CoW copies of old ones. We want to build these
16things incrementally, but still end up with something that will be reproducible
17from scratch.
18
19Anyway, what we'll have is a list of packages, which will be unpacked first.
20Then a list of debconf values, which will be applied. Then we will have the rest
21of the other, slower changes to the image (including dpkg --configure -a). Some
22changes can be assumed to produce the same results out of order. Oh right, and
23the zeroeth step is to generate the empty (or just initial) filesystem image.
24The initial filesystem image, if nonempty, is specified by filename (otherwise,
25by size), while the hash of the configuration determines the output filename.
26
27
28-}
29
30newtype DebconfConfig = DebconfConfig Text deriving (Show, Read, Eq, Ord)
31newtype Package = Package Text deriving (Show, Read, Eq, Ord)
32data Patch = Patch deriving (Show, Read)
33
34sha1 :: ByteString -> Digest SHA1
35sha1 = hash
36
37data DiskImageConfig = DiskImageConfig {
38 initialImage :: Either Integer (Digest SHA1)
39, unpacked :: Set Package
40, debconfConfig :: DebconfConfig
41, configured :: Set Package
42, patched :: [Patch]
43} deriving (Show, Read)
44
45
46
47main :: IO ()
48main = return ()
diff --git a/src/Crypto/Hash/Types/Digest/Read.hs b/src/Crypto/Hash/Types/Digest/Read.hs
new file mode 100644
index 0000000..f371f30
--- /dev/null
+++ b/src/Crypto/Hash/Types/Digest/Read.hs
@@ -0,0 +1,20 @@
1{-# OPTIONS_GHC -fno-warn-orphans #-}
2{-# LANGUAGE InstanceSigs #-}
3{-# LANGUAGE NoImplicitPrelude #-}
4{-# LANGUAGE PartialTypeSignatures #-}
5{-# LANGUAGE ViewPatterns #-}
6module Crypto.Hash.Types.Digest.Read where
7import Rebase.Prelude hiding (hash)
8
9import Crypto.Hash
10import Data.ByteArray.Encoding
11import qualified Rebase.Data.Text as Text
12
13instance HashAlgorithm a =>
14 Read (Digest a) where
15 readsPrec :: Int -> (String -> [(Digest a, String)])
16 readsPrec _ (Text.encodeUtf8 . Text.pack -> bytes) =
17 toList $ (flip (,) "") <$> (digestFromByteString =<< baseConv bytes)
18 where
19 baseConv :: ByteString -> Maybe (ByteString)
20 baseConv = listToMaybe . toList . convertFromBase Base16
diff --git a/stack.yaml b/stack.yaml
new file mode 100644
index 0000000..c7632a6
--- /dev/null
+++ b/stack.yaml
@@ -0,0 +1,5 @@
1resolver: lts-11.13
2packages:
3- .
4extra-deps:
5- rebase-1.2.4