b9 0.5.7 → 0.5.8
raw patch · 7 files changed
+56/−13 lines, 7 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ B9.ArtifactGenerator: getAssemblyOutputFiles :: ArtifactAssembly -> [FilePath]
+ B9.ArtifactGeneratorImpl: getArtifactOutputFiles :: ArtifactGenerator -> Either String [FilePath]
+ B9.Content.Generator: FromString :: String -> Content
+ B9.DiskImages: getImageDestinationOutputFiles :: ImageTarget -> [FilePath]
Files
- b9.cabal +1/−1
- src/lib/B9.hs +1/−1
- src/lib/B9/ArtifactGenerator.hs +17/−0
- src/lib/B9/ArtifactGeneratorImpl.hs +10/−0
- src/lib/B9/Content/AST.hs +9/−9
- src/lib/B9/Content/Generator.hs +6/−2
- src/lib/B9/DiskImages.hs +12/−0
b9.cabal view
@@ -1,5 +1,5 @@ name: b9-version: 0.5.7+version: 0.5.8 synopsis: A tool and library for building virtual machine images.
src/lib/B9.hs view
@@ -1,4 +1,4 @@-{-| B9 is a library and build tool with primitive operations to run a+{-| B9 is a library and build tool with primitive operations to rmrun a build script inside a virtual machine and to create and convert virtual machine image files as well as related ISO and VFAT disk images for e.g. cloud-init configuration sources.
src/lib/B9/ArtifactGenerator.hs view
@@ -15,12 +15,14 @@ ,instanceIdKey ,buildIdKey ,buildDateKey+ ,getAssemblyOutputFiles ) where import Data.Data import Data.Monoid -- hiding ((<>)) import Control.Applicative+import System.FilePath ((<.>), (</>)) import B9.DiskImages import B9.Vm@@ -183,6 +185,21 @@ data CloudInitType = CI_ISO | CI_VFAT | CI_DIR deriving (Read, Show, Typeable, Data, Eq)++-- | Return the files that the artifact assembly consist of.+getAssemblyOutputFiles :: ArtifactAssembly -> [FilePath]+getAssemblyOutputFiles (VmImages ts _) =+ concatMap getImageDestinationOutputFiles ts+getAssemblyOutputFiles (CloudInit ts o) =+ concatMap (getCloudInitOutputFiles o) ts+ where+ getCloudInitOutputFiles baseName t+ | t == CI_ISO = [baseName <.> "iso"]+ | t == CI_VFAT = [baseName <.> "vfat"]+ | t == CI_DIR = [baseName </> "meta-data"+ ,baseName </> "user-data"]++-- * QuickCheck instances instance Arbitrary ArtifactGenerator where arbitrary = oneof [ Sources <$> halfSize arbitrary <*> halfSize arbitrary
src/lib/B9/ArtifactGeneratorImpl.hs view
@@ -33,6 +33,16 @@ import Text.Printf import Text.Show.Pretty (ppShow) +-- | Return a list of relative paths for the /local/ files to be generated+-- by the ArtifactGenerator. This excludes 'Shared' and Transient image targets.+getArtifactOutputFiles :: ArtifactGenerator -> Either String [FilePath]+getArtifactOutputFiles g =+ concatMap getAssemblyOutputFiles+ <$> map takeAssembly+ <$> evalArtifactGenerator undefined undefined [] g+ where+ takeAssembly (IG _ _ a) = a+ -- | Run an artifact generator to produce the artifacts. assemble :: ArtifactGenerator -> B9 [AssembledArtifact] assemble artGen = do
src/lib/B9/Content/AST.hs view
@@ -5,15 +5,15 @@ files containing parsable syntactic structures, such as most configuration files do. -Imagine you would want to create a cloud-init 'user-data' file from a set-of 'user-data' snippets which each are valid 'user-data' files in yaml syntax-and e.g. a 'writefiles' section. Now the goal is, for b9 to be able to merge-these snippets into one, such that all writefiles sections are combined into-a single writefile section. Another example is OTP/Erlang sys.config files.-This type class is the greatest commonon denominator of types describing a-syntax that can be parsed, concatenated e.g. like in the above example and-rendered. The actual concatenation operation is the append from Monoid,-i.e. like monoid but without the need for an empty element.+Imagine you would want to create a cloud-init 'user-data' file from a set of+'user-data' snippets which each are valid 'user-data' files in yaml syntax and+e.g. a 'write_files' section. Now the goal is, for b9 to be able to merge these+snippets into one, such that all writefiles sections are combined into a single+writefile section. Another example is OTP/Erlang sys.config files. This type+class is the greatest commonon denominator of types describing a syntax that can+be parsed, concatenated e.g. like in the above example and rendered. The actual+concatenation operation is the append from Monoid, i.e. like monoid but without+the need for an empty element. -} module B9.Content.AST ( ConcatableSyntax (..)
src/lib/B9/Content/Generator.hs view
@@ -7,23 +7,27 @@ import B9.Content.AST import B9.Content.ErlangPropList-import B9.Content.YamlObject import B9.Content.StringTemplate+import B9.Content.YamlObject+import qualified Data.ByteString.Char8 as B import Test.QuickCheck import B9.QCUtil data Content = RenderErlang (AST Content ErlangPropList) | RenderYaml (AST Content YamlObject)+ | FromString String | FromTextFile SourceFile deriving (Read, Show, Typeable, Eq) instance Arbitrary Content where arbitrary = oneof [FromTextFile <$> smaller arbitrary ,RenderErlang <$> smaller arbitrary- ,RenderYaml <$> smaller arbitrary]+ ,RenderYaml <$> smaller arbitrary+ ,FromString <$> smaller arbitrary] instance CanRender Content where render (RenderErlang ast) = encodeSyntax <$> fromAST ast render (RenderYaml ast) = encodeSyntax <$> fromAST ast render (FromTextFile s) = readTemplateFile s+ render (FromString str) = return (B.pack str)
src/lib/B9/DiskImages.hs view
@@ -92,6 +92,18 @@ type Mounted a = (a, MountPoint) +-- | Return the files generated for a local or a live image; shared and transient images+-- are treated like they have no ouput files because the output files are manged+-- by B9.+getImageDestinationOutputFiles :: ImageTarget -> [FilePath]+getImageDestinationOutputFiles (ImageTarget d _ _) =+ case d of+ LiveInstallerImage liName liPath _ ->+ let path = liPath </> "machines" </> liName </> "disks" </> "raw"+ in [path </> "0.raw", path </> "0.size", path </> "VERSION"]+ LocalFile (Image lfPath _ _) _ -> [lfPath]+ _ -> []+ itImageDestination :: ImageTarget -> ImageDestination itImageDestination (ImageTarget d _ _) = d