-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A tool and library for building virtual machine images. -- @package b9 @version 0.2.4 -- | Utility module to extract a primary partition from an MBR partition on -- a raw image file. module B9.MBR getPartition :: Int -> FilePath -> IO (Word64, Word64) data PrimaryPartition PrimaryPartition :: !Word8 -> !CHS -> !Word8 -> !CHS -> !Word32 -> !Word32 -> PrimaryPartition primPartStatus :: PrimaryPartition -> !Word8 primPartChsStart :: PrimaryPartition -> !CHS primPartPartType :: PrimaryPartition -> !Word8 primPartChsEnd :: PrimaryPartition -> !CHS primPartLbaStart :: PrimaryPartition -> !Word32 primPartSectors :: PrimaryPartition -> !Word32 data MBR MBR :: !PrimaryPartition -> !PrimaryPartition -> !PrimaryPartition -> !PrimaryPartition -> MBR mbrPart1 :: MBR -> !PrimaryPartition mbrPart2 :: MBR -> !PrimaryPartition mbrPart3 :: MBR -> !PrimaryPartition mbrPart4 :: MBR -> !PrimaryPartition data CHS CHS :: !Word8 -> !Word8 -> !Word8 -> CHS chsH :: CHS -> !Word8 chs_CUpper2_S :: CHS -> !Word8 chs_CLower8 :: CHS -> !Word8 instance Show CHS instance Show PrimaryPartition instance Show MBR -- | Function to find the file offsets of primary partitions in raw disk -- images. Currently only MBR partitions are supported. See MBR module B9.PartitionTable getPartition :: Int -> FilePath -> IO (Word64, Word64, Word64) -- | Some QuickCheck utility functions. module B9.QCUtil arbitraryEnv :: Arbitrary a => Gen [(String, a)] halfSize :: Gen a -> Gen a smaller :: Gen a -> Gen a arbitraryFilePath :: Gen FilePath arbitraryLetter :: Gen Char arbitraryLetterUpper :: Gen Char arbitraryLetterLower :: Gen Char arbitraryDigit :: Gen Char -- | Erlang term parser and pretty printer. module B9.Content.ErlTerms -- | Parse a subset of valid Erlang terms. It parses no maps and binaries -- are restricted to either empty binaries or binaries with a string. The -- input encoding must be restricted to ascii compatible 8-bit characters -- (e.g. latin-1 or UTF8). parseErlTerm :: String -> ByteString -> Either String SimpleErlangTerm -- | Convert an abstract Erlang term to a pretty byte string preserving the -- encoding. renderErlTerm :: SimpleErlangTerm -> ByteString -- | Simplified Erlang term representation. data SimpleErlangTerm ErlString :: String -> SimpleErlangTerm ErlFloat :: Double -> SimpleErlangTerm ErlNatural :: Integer -> SimpleErlangTerm ErlAtom :: String -> SimpleErlangTerm ErlChar :: Char -> SimpleErlangTerm ErlBinary :: String -> SimpleErlangTerm ErlList :: [SimpleErlangTerm] -> SimpleErlangTerm ErlTuple :: [SimpleErlangTerm] -> SimpleErlangTerm arbitraryErlSimpleAtom :: Gen SimpleErlangTerm arbitraryErlString :: Gen SimpleErlangTerm arbitraryErlNumber :: Gen SimpleErlangTerm arbitraryErlNatural :: Gen SimpleErlangTerm arbitraryErlFloat :: Gen SimpleErlangTerm arbitraryErlNameChar :: Gen Char instance Typeable SimpleErlangTerm instance Eq SimpleErlangTerm instance Ord SimpleErlangTerm instance Read SimpleErlangTerm instance Show SimpleErlangTerm instance Data SimpleErlangTerm instance Arbitrary SimpleErlangTerm -- | Definition of Script and functions to convert Scripts to -- bash scripts. module B9.ShellScript -- | Convert script to bash-shell-script written to file -- and make file executable. writeSh :: FilePath -> Script -> IO () -- | Check if a script has the same effect as NoOP emptyScript :: Script -> Bool data CmdVerbosity Debug :: CmdVerbosity Verbose :: CmdVerbosity OnlyStdErr :: CmdVerbosity Quiet :: CmdVerbosity data Cwd Cwd :: FilePath -> Cwd NoCwd :: Cwd data User User :: String -> User NoUser :: User data Script In :: FilePath -> [Script] -> Script As :: String -> [Script] -> Script IgnoreErrors :: Bool -> [Script] -> Script Verbosity :: CmdVerbosity -> [Script] -> Script Begin :: [Script] -> Script Run :: FilePath -> [String] -> Script NoOP :: Script instance Typeable CmdVerbosity instance Typeable Script instance Show CmdVerbosity instance Read CmdVerbosity instance Data CmdVerbosity instance Eq CmdVerbosity instance Show Script instance Read Script instance Data Script instance Eq Script instance Show Cwd instance Read Cwd instance Show User instance Read User instance Show Cmd instance Read Cmd instance Monoid Script -- | Data types that describe all B9 relevant elements of virtual machine -- disk images. module B9.DiskImages -- | Build target for disk images. data ImageTarget ImageTarget :: ImageDestination -> ImageSource -> MountPoint -> ImageTarget -- | A mount point or NotMounted data MountPoint MountPoint :: FilePath -> MountPoint NotMounted :: MountPoint -- | The destination of an image. data ImageDestination Share :: String -> ImageType -> ImageResize -> ImageDestination LiveInstallerImage :: String -> FilePath -> ImageResize -> ImageDestination LocalFile :: Image -> ImageResize -> ImageDestination Transient :: ImageDestination -- | Specification of how the image to build is obtained. data ImageSource EmptyImage :: String -> FileSystem -> ImageType -> ImageSize -> ImageSource CopyOnWrite :: Image -> ImageSource SourceImage :: Image -> Partition -> ImageResize -> ImageSource From :: String -> ImageResize -> ImageSource data Partition NoPT :: Partition Partition :: Int -> Partition data Image Image :: FilePath -> ImageType -> FileSystem -> Image data ImageType Raw :: ImageType QCow2 :: ImageType Vmdk :: ImageType data FileSystem NoFileSystem :: FileSystem Ext4 :: FileSystem ISO9660 :: FileSystem VFAT :: FileSystem data ImageSize ImageSize :: Int -> SizeUnit -> ImageSize data SizeUnit B :: SizeUnit KB :: SizeUnit MB :: SizeUnit GB :: SizeUnit data ImageResize ResizeImage :: ImageSize -> ImageResize Resize :: ImageSize -> ImageResize ShrinkToMinimum :: ImageResize KeepSize :: ImageResize type Mounted a = (a, MountPoint) itImageDestination :: ImageTarget -> ImageDestination itImageMountPoint :: ImageTarget -> MountPoint isPartitioned :: Partition -> Bool getPartition :: Partition -> Int -- | Return the file name extension of an image file with a specific image -- format. imageFileExtension :: ImageType -> String changeImageFormat :: ImageType -> Image -> Image changeImageDirectory :: FilePath -> Image -> Image -- | SharedImage holds all data necessary to identify an image -- shared. data SharedImage SharedImage :: SharedImageName -> SharedImageDate -> SharedImageBuildId -> ImageType -> FileSystem -> SharedImage -- | Return the name of a shared image. siName :: SharedImage -> String -- | Shared images are orderd by name, build date and build id newtype SharedImageName SharedImageName :: String -> SharedImageName newtype SharedImageDate SharedImageDate :: String -> SharedImageDate newtype SharedImageBuildId SharedImageBuildId :: String -> SharedImageBuildId -- | Return the disk image of an sharedImage sharedImageImage :: SharedImage -> Image -- | Calculate the path to the text file holding the serialized -- SharedImage relative to the directory of shared images in a -- repository. sharedImageFileName :: SharedImage -> FilePath sharedImagesRootDirectory :: FilePath sharedImageFileExtension :: String instance Typeable MountPoint instance Typeable Partition instance Typeable ImageType instance Typeable FileSystem instance Typeable Image instance Typeable SizeUnit instance Typeable ImageSize instance Typeable ImageResize instance Typeable ImageSource instance Typeable ImageDestination instance Typeable ImageTarget instance Show MountPoint instance Read MountPoint instance Data MountPoint instance Eq MountPoint instance Eq Partition instance Show Partition instance Read Partition instance Data Partition instance Eq ImageType instance Read ImageType instance Data ImageType instance Show ImageType instance Eq FileSystem instance Show FileSystem instance Read FileSystem instance Data FileSystem instance Eq Image instance Show Image instance Read Image instance Data Image instance Eq SizeUnit instance Show SizeUnit instance Read SizeUnit instance Ord SizeUnit instance Data SizeUnit instance Eq ImageSize instance Show ImageSize instance Read ImageSize instance Data ImageSize instance Eq ImageResize instance Show ImageResize instance Read ImageResize instance Data ImageResize instance Show ImageSource instance Read ImageSource instance Data ImageSource instance Eq ImageSource instance Read ImageDestination instance Show ImageDestination instance Data ImageDestination instance Eq ImageDestination instance Read ImageTarget instance Show ImageTarget instance Data ImageTarget instance Eq ImageTarget instance Eq SharedImageName instance Ord SharedImageName instance Read SharedImageName instance Show SharedImageName instance Eq SharedImageDate instance Ord SharedImageDate instance Read SharedImageDate instance Show SharedImageDate instance Eq SharedImageBuildId instance Ord SharedImageBuildId instance Read SharedImageBuildId instance Show SharedImageBuildId instance Eq SharedImage instance Read SharedImage instance Show SharedImage instance Ord SharedImage -- | Data types describing the execution environment of virtual machine -- builds. ExecEnv, Resources and SharedDirectory -- describe how B9.LibVirtLXC should configure and execute build -- scripts, as defined in B9.ShellScript and B9.Vm. module B9.ExecEnv data ExecEnv ExecEnv :: String -> [Mounted Image] -> [SharedDirectory] -> Resources -> ExecEnv envName :: ExecEnv -> String envImageMounts :: ExecEnv -> [Mounted Image] envSharedDirectories :: ExecEnv -> [SharedDirectory] envResources :: ExecEnv -> Resources data Resources Resources :: RamSize -> Int -> CPUArch -> Resources maxMemory :: Resources -> RamSize cpuCount :: Resources -> Int cpuArch :: Resources -> CPUArch noResources :: Resources data SharedDirectory SharedDirectory :: FilePath -> MountPoint -> SharedDirectory SharedDirectoryRO :: FilePath -> MountPoint -> SharedDirectory SharedSources :: MountPoint -> SharedDirectory data CPUArch X86_64 :: CPUArch I386 :: CPUArch data RamSize RamSize :: Int -> SizeUnit -> RamSize AutomaticRamSize :: RamSize instance Typeable SharedDirectory instance Typeable CPUArch instance Typeable RamSize instance Typeable Resources instance Read SharedDirectory instance Show SharedDirectory instance Data SharedDirectory instance Eq SharedDirectory instance Read CPUArch instance Show CPUArch instance Data CPUArch instance Eq CPUArch instance Eq RamSize instance Read RamSize instance Show RamSize instance Ord RamSize instance Data RamSize instance Read Resources instance Show Resources instance Data Resources instance Monoid RamSize instance Monoid CPUArch instance Monoid Resources -- | Extensions to ConfigFile and utility functions for dealing with -- configuration in general and reading/writing files. module B9.ConfigUtils allOn :: (a -> Maybe Bool) -> a -> a -> Maybe Bool lastOn :: (a -> Maybe b) -> a -> a -> Maybe b data SystemPath Path :: FilePath -> SystemPath InHomeDir :: FilePath -> SystemPath InB9UserDir :: FilePath -> SystemPath InTempDir :: FilePath -> SystemPath resolve :: MonadIO m => SystemPath -> m FilePath ensureDir :: MonadIO m => FilePath -> m () readIniFile :: MonadIO m => SystemPath -> m ConfigParser getOptionM :: (Get_C a, Read a) => ConfigParser -> SectionSpec -> OptionSpec -> Maybe a getOption :: (Get_C a, Monoid a) => ConfigParser -> SectionSpec -> OptionSpec -> a getOptionOr :: (Get_C a, Read a) => ConfigParser -> SectionSpec -> OptionSpec -> a -> a data IniFileException IniFileException :: FilePath -> CPError -> IniFileException newtype UUID UUID :: (Word32, Word16, Word16, Word16, Word32, Word16) -> UUID randomUUID :: MonadIO m => m UUID tell :: (MonadIO m, Show a) => FilePath -> a -> m () consult :: (MonadIO m, Read a) => FilePath -> m a -- | Get all files from dir that is get ONLY files not directories getDirectoryFiles :: MonadIO m => FilePath -> m [FilePath] maybeConsult :: (MonadIO m, Read a) => Maybe FilePath -> a -> m a maybeConsultSystemPath :: (MonadIO m, Read a) => Maybe SystemPath -> a -> m a instance Typeable SystemPath instance Typeable ReaderException instance Typeable IniFileException instance Eq SystemPath instance Read SystemPath instance Show SystemPath instance Data SystemPath instance Show ReaderException instance Show IniFileException instance Read UUID instance Show UUID instance Eq UUID instance Ord UUID instance PrintfArg UUID instance Exception IniFileException instance Exception ReaderException -- | B9 has a concept of shared images. Images can be pulled and pushed -- to/from remote locations via rsync+ssh. B9 also maintains a local -- cache; the whole thing is supposed to be build-server-safe, that means -- no two builds shall interfere with each other. This is accomplished by -- refraining from automatic cache updates from/to remote repositories. module B9.Repository data RemoteRepo RemoteRepo :: String -> FilePath -> SshPrivKey -> SshRemoteHost -> SshRemoteUser -> RemoteRepo remoteRepoRepoId :: RemoteRepo -> String newtype RepoCache RepoCache :: FilePath -> RepoCache newtype SshPrivKey SshPrivKey :: FilePath -> SshPrivKey newtype SshRemoteHost SshRemoteHost :: (String, Int) -> SshRemoteHost newtype SshRemoteUser SshRemoteUser :: String -> SshRemoteUser -- | Initialize the local repository cache directory. initRepoCache :: MonadIO m => SystemPath -> m RepoCache -- | Initialize the repository; load the corresponding settings from the -- config file, check that the priv key exists and create the -- correspondig cache directory. initRemoteRepo :: MonadIO m => RepoCache -> RemoteRepo -> m RemoteRepo -- | Check for existance of priv-key and make it an absolute path. remoteRepoCheckSshPrivKey :: MonadIO m => RemoteRepo -> m RemoteRepo -- | Return the cache directory for a remote repository relative to the -- root cache dir. remoteRepoCacheDir :: RepoCache -> String -> FilePath -- | Return the local repository directory. localRepoDir :: RepoCache -> FilePath -- | Persist a repo to a configuration file. writeRemoteRepoConfig :: RemoteRepo -> ConfigParser -> Either CPError ConfigParser getConfiguredRemoteRepos :: ConfigParser -> [RemoteRepo] -- | Load a repository from a configuration file that has been written by -- writeRepositoryToB9Config. lookupRemoteRepo :: [RemoteRepo] -> String -> Maybe RemoteRepo instance Typeable RepoCache instance Typeable SshPrivKey instance Typeable SshRemoteHost instance Typeable SshRemoteUser instance Typeable RemoteRepo instance Read RepoCache instance Show RepoCache instance Data RepoCache instance Read SshPrivKey instance Show SshPrivKey instance Data SshPrivKey instance Read SshRemoteHost instance Show SshRemoteHost instance Data SshRemoteHost instance Read SshRemoteUser instance Show SshRemoteUser instance Data SshRemoteUser instance Read RemoteRepo instance Show RemoteRepo instance Data RemoteRepo -- | Utility functions bnased on Template to offer $var -- variable expansion in string throughout a B9 artifact. module B9.Content.StringTemplate subst :: [(String, String)] -> String -> String substE :: [(String, String)] -> String -> Either String String substEB :: [(String, String)] -> ByteString -> Either String ByteString substFile :: MonadIO m => [(String, String)] -> FilePath -> FilePath -> m () substPath :: [(String, String)] -> SystemPath -> SystemPath readTemplateFile :: (MonadIO m, MonadReader Environment m) => SourceFile -> m ByteString -- | A wrapper around a file path and a flag indicating if template -- variable expansion should be performed when reading the file contents. data SourceFile Source :: SourceFileConversion -> FilePath -> SourceFile data SourceFileConversion NoConversion :: SourceFileConversion ExpandVariables :: SourceFileConversion data Environment Environment :: [(String, String)] -> Environment withEnvironment :: [(String, String)] -> ReaderT Environment m a -> m a instance Typeable SourceFileConversion instance Typeable SourceFile instance Read SourceFileConversion instance Show SourceFileConversion instance Data SourceFileConversion instance Eq SourceFileConversion instance Read SourceFile instance Show SourceFile instance Data SourceFile instance Eq SourceFile instance Arbitrary SourceFile -- | Definition of VmScript an artifact encapsulating several -- virtual machines disk images that can be mounted in an execution -- environment like B9.LibVirtLXC. A VmScript is embedded -- by in an ArtifactGenerator. module B9.Vm -- | Describe a virtual machine, i.e. a set up disk images to create and a -- shell script to put things together. data VmScript VmScript :: CPUArch -> [SharedDirectory] -> Script -> VmScript NoVmScript :: VmScript substVmScript :: [(String, String)] -> VmScript -> VmScript instance Typeable VmScript instance Read VmScript instance Show VmScript instance Data VmScript instance Eq VmScript -- | B9 produces not only VM-Images but also text documents such as -- configuration files required by virtual machines. This module is about -- creating and merging 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. module B9.Content.AST class Semigroup a => ConcatableSyntax a decodeSyntax :: ConcatableSyntax a => FilePath -> ByteString -> Either String a encodeSyntax :: ConcatableSyntax a => a -> ByteString -- | Structure data into an abstract syntax tree class ConcatableSyntax a => ASTish a fromAST :: (ASTish a, CanRender c, Applicative m, Monad m, MonadIO m, MonadReader Environment m) => AST c a -> m a -- | A simple AST wrapper for merging embeded ASTs data AST c a ASTObj :: [(String, AST c a)] -> AST c a ASTArr :: [AST c a] -> AST c a ASTMerge :: [AST c a] -> AST c a ASTEmbed :: c -> AST c a ASTString :: String -> AST c a ASTParse :: SourceFile -> AST c a AST :: a -> AST c a -- | Things that produce byte strings. class CanRender c render :: (CanRender c, Functor m, Applicative m, MonadIO m, MonadReader Environment m) => c -> m ByteString instance Typeable AST instance (Read c, Read a) => Read (AST c a) instance (Show c, Show a) => Show (AST c a) instance (Data c, Data a) => Data (AST c a) instance (Eq c, Eq a) => Eq (AST c a) instance (Arbitrary c, Arbitrary a) => Arbitrary (AST c a) instance ConcatableSyntax ByteString -- | A wrapper around erlang and yaml syntax with a proplist-like behaviour -- in the ConcatableSyntax instances module B9.Content.ErlangPropList -- | A wrapper type around erlang terms with a Semigroup instance useful -- for combining sys.config files with OTP-application configurations in -- a list of the form of a proplist. data ErlangPropList ErlangPropList :: SimpleErlangTerm -> ErlangPropList instance Typeable ErlangPropList instance Read ErlangPropList instance Eq ErlangPropList instance Show ErlangPropList instance Data ErlangPropList instance ASTish ErlangPropList instance ConcatableSyntax ErlangPropList instance Semigroup ErlangPropList instance Arbitrary ErlangPropList -- | A wrapper around erlang and yaml syntax with a proplist-like behaviour -- in the ConcatableSyntax instances module B9.Content.YamlObject -- | A wrapper type around yaml values with a Semigroup instance useful for -- combining yaml documents describing system configuration like e.g. -- user-data. data YamlObject YamlObject :: Value -> YamlObject instance Eq YamlObject instance Arbitrary YamlObject instance ASTish YamlObject instance ConcatableSyntax YamlObject instance Semigroup YamlObject instance Show YamlObject instance Read YamlObject -- | The basic data structure that ties together syntax trees making them -- composable and addressable in B9 artifacts. module B9.Content.Generator data Content RenderErlang :: (AST Content ErlangPropList) -> Content RenderYaml :: (AST Content YamlObject) -> Content FromTextFile :: SourceFile -> Content instance Typeable Content instance Read Content instance Show Content instance Eq Content instance CanRender Content instance Arbitrary Content -- | Top-Level data types for B9 build artifacts. module B9.ArtifactGenerator -- | A single config generator specifies howto generate multiple output -- files/directories. It consists of a netsted set of variable bindings -- that are replaced inside the text files data ArtifactGenerator Sources :: [ArtifactSource] -> [ArtifactGenerator] -> ArtifactGenerator Let :: [(String, String)] -> [ArtifactGenerator] -> ArtifactGenerator LetX :: [(String, [String])] -> [ArtifactGenerator] -> ArtifactGenerator EachT :: [String] -> [[String]] -> [ArtifactGenerator] -> ArtifactGenerator Each :: [(String, [String])] -> [ArtifactGenerator] -> ArtifactGenerator Artifact :: InstanceId -> ArtifactAssembly -> ArtifactGenerator EmptyArtifact :: ArtifactGenerator -- | Explicit is better than implicit: Only files that have explicitly been -- listed will be included in any generated configuration. That's right: -- There's no "inlcude *.*". B9 will check that *all* files in the -- directory specified with FromDir are referred to by nested -- ArtifactSources. data ArtifactSource FromFile :: FilePath -> SourceFile -> ArtifactSource FromContent :: FilePath -> Content -> ArtifactSource SetPermissions :: Int -> Int -> Int -> [ArtifactSource] -> ArtifactSource FromDirectory :: FilePath -> [ArtifactSource] -> ArtifactSource IntoDirectory :: FilePath -> [ArtifactSource] -> ArtifactSource Concatenation :: FilePath -> [ArtifactSource] -> ArtifactSource newtype InstanceId IID :: String -> InstanceId data ArtifactTarget CloudInitTarget :: CloudInitType -> FilePath -> ArtifactTarget VmImagesTarget :: ArtifactTarget data CloudInitType CI_ISO :: CloudInitType CI_VFAT :: CloudInitType CI_DIR :: CloudInitType data ArtifactAssembly CloudInit :: [CloudInitType] -> FilePath -> ArtifactAssembly VmImages :: [ImageTarget] -> VmScript -> ArtifactAssembly data AssembledArtifact AssembledArtifact :: InstanceId -> [ArtifactTarget] -> AssembledArtifact instanceIdKey :: String buildIdKey :: String buildDateKey :: String instance Typeable InstanceId instance Typeable CloudInitType instance Typeable ArtifactTarget instance Typeable AssembledArtifact instance Typeable ArtifactAssembly instance Read ArtifactSource instance Show ArtifactSource instance Eq ArtifactSource instance Read InstanceId instance Show InstanceId instance Data InstanceId instance Eq InstanceId instance Read CloudInitType instance Show CloudInitType instance Data CloudInitType instance Eq CloudInitType instance Read ArtifactTarget instance Show ArtifactTarget instance Data ArtifactTarget instance Eq ArtifactTarget instance Read AssembledArtifact instance Show AssembledArtifact instance Data AssembledArtifact instance Eq AssembledArtifact instance Read ArtifactAssembly instance Show ArtifactAssembly instance Data ArtifactAssembly instance Eq ArtifactAssembly instance Read ArtifactGenerator instance Show ArtifactGenerator instance Eq ArtifactGenerator instance Arbitrary CloudInitType instance Arbitrary ArtifactAssembly instance Arbitrary InstanceId instance Arbitrary ArtifactSource instance Arbitrary ArtifactGenerator instance Monoid ArtifactGenerator -- | Static B9 configuration. Read, write and merge configurable -- properties. The properties are independent of specific build targets. module B9.B9Config data B9Config B9Config :: Maybe LogLevel -> Maybe FilePath -> Maybe FilePath -> Bool -> ExecEnvType -> Maybe FilePath -> BuildVariables -> Bool -> SystemPath -> Maybe String -> B9Config verbosity :: B9Config -> Maybe LogLevel logFile :: B9Config -> Maybe FilePath buildDirRoot :: B9Config -> Maybe FilePath keepTempDirs :: B9Config -> Bool execEnvType :: B9Config -> ExecEnvType profileFile :: B9Config -> Maybe FilePath envVars :: B9Config -> BuildVariables uniqueBuildDirs :: B9Config -> Bool repositoryCache :: B9Config -> SystemPath repository :: B9Config -> Maybe String defaultB9ConfigFile :: SystemPath defaultB9Config :: B9Config getB9ConfigFile :: MonadIO m => Maybe SystemPath -> m FilePath writeB9Config :: MonadIO m => (Maybe SystemPath) -> ConfigParser -> m () writeInitialB9Config :: MonadIO m => (Maybe SystemPath) -> B9Config -> ConfigParser -> m () readB9Config :: MonadIO m => (Maybe SystemPath) -> m ConfigParser parseB9Config :: ConfigParser -> Either String B9Config data LogLevel LogTrace :: LogLevel LogDebug :: LogLevel LogInfo :: LogLevel LogError :: LogLevel LogNothing :: LogLevel data ExecEnvType LibVirtLXC :: ExecEnvType type BuildVariables = [(String, String)] instance Eq ExecEnvType instance Show ExecEnvType instance Ord ExecEnvType instance Read ExecEnvType instance Eq LogLevel instance Show LogLevel instance Ord LogLevel instance Read LogLevel instance Show B9Config instance Monoid B9Config -- | Definition of the B9 monad. It encapsulates logging, very basic -- command execution profiling, a reader for the B9.B9Config and -- access to the current build id, the current build directory and the -- artifact to build. -- -- This module is used by the _effectful_ functions in this library. module B9.B9Monad data B9 a run :: ConfigParser -> B9Config -> B9 a -> IO a traceL :: String -> B9 () dbgL :: String -> B9 () infoL :: String -> B9 () errorL :: String -> B9 () getConfigParser :: B9 ConfigParser getConfig :: B9 B9Config getBuildId :: B9 FilePath getBuildDate :: B9 String getBuildDir :: B9 FilePath getExecEnvType :: B9 ExecEnvType getSelectedRemoteRepo :: B9 (Maybe RemoteRepo) getRemoteRepos :: B9 [RemoteRepo] getRepoCache :: B9 RepoCache cmd :: String -> B9 () instance Eq ProfilingEntry instance Show ProfilingEntry instance Functor B9 instance Applicative B9 instance Monad B9 instance MonadState BuildState B9 instance MonadIO B9 -- | Effectful functions executing shared image respository operations. See -- B9.Repository module B9.RepositoryIO -- | Find files which are in subDir and match glob in the -- repository cache. NOTE: This operates on the repository cache, but -- does not enforce a repository cache update. repoSearch :: FilePath -> FilePathGlob -> B9 [(Repository, [FilePath])] -- | Push a file from the cache to a remote repository pushToRepo :: RemoteRepo -> FilePath -> FilePath -> B9 () -- | Pull a file from a remote repository to cache pullFromRepo :: RemoteRepo -> FilePath -> FilePath -> B9 () -- | Push a file from the cache to a remote repository pullGlob :: FilePath -> FilePathGlob -> RemoteRepo -> B9 () data Repository Cache :: Repository Remote :: String -> Repository -- | Express a pattern for file paths, used when searching repositories. data FilePathGlob FileExtension :: String -> FilePathGlob instance Eq Repository instance Ord Repository instance Read Repository instance Show Repository -- | Effectful functions that create and convert disk image files. module B9.DiskImageBuilder -- | Create an image from an image source. The destination image must have -- a compatible image type and filesyste. The directory of the image MUST -- be present and the image file itself MUST NOT alredy exist. materializeImageSource :: ImageSource -> Image -> B9 () -- | Replace $... variables inside an ImageTarget substImageTarget :: [(String, String)] -> ImageTarget -> ImageTarget -- | Return all valid image types sorted by preference. preferredDestImageTypes :: ImageSource -> B9 [ImageType] preferredSourceImageTypes :: ImageDestination -> [ImageType] -- | Resolve an ImageSource to an Image. Note however that this -- source will may not exist as is the case for EmptyImage. resolveImageSource :: ImageSource -> B9 Image createDestinationImage :: Image -> ImageDestination -> B9 () -- | Resize an image, including the file system inside the image. resizeImage :: ImageResize -> Image -> B9 () -- | Import a disk image from some external source into the build directory -- if necessary convert the image. importImage :: Image -> Image -> B9 () -- | Export a disk image from the build directory; if necessary convert the -- image. exportImage :: Image -> Image -> B9 () -- | Export a disk image from the build directory; if necessary convert the -- image. exportAndRemoveImage :: Image -> Image -> B9 () -- | Convert an image in the build directory to another format and return -- the new image. convertImage :: Image -> Image -> B9 () -- | Publish an sharedImage made from an image and image meta data to the -- configured repository shareImage :: Image -> SharedImageName -> B9 SharedImage ensureAbsoluteImageDirExists :: Image -> IO Image -- | Publish the latest version of a shared image identified by name to the -- selected repository from the cache. pushSharedImageLatestVersion :: SharedImageName -> B9 () -- | Find shared images and the associated repos from two predicates. The -- result is the concatenated result of the sorted shared images -- satisfying imgPred. lookupSharedImages :: (Repository -> Bool) -> (SharedImage -> Bool) -> B9 [(Repository, SharedImage)] -- | Return a list of all existing sharedImages from cached repositories. getSharedImages :: B9 [(Repository, [SharedImage])] -- | Pull metadata files from all remote repositories. pullRemoteRepos :: B9 () -- | Pull the latest version of an image, either from the selected remote -- repo or from the repo that has the latest version. pullLatestImage :: SharedImageName -> B9 Bool -- | Implementation of an execution environment that uses "libvirt-lxc". module B9.LibVirtLXC runInEnvironment :: ExecEnv -> Script -> B9 Bool supportedImageTypes :: [ImageType] setDefaultConfig :: ConfigParser instance Read LXCGuestCapability instance Show LXCGuestCapability instance Read LibVirtLXCConfig instance Show LibVirtLXCConfig -- | Effectful functions to execute and build virtual machine images using -- an execution environment like e.g. libvirt-lxc. module B9.VmBuilder buildWithVm :: InstanceId -> [ImageTarget] -> FilePath -> VmScript -> B9 Bool -- | Mostly effectful functions to assemble artifacts. module B9.ArtifactGeneratorImpl -- | Run an artifact generator to produce the artifacts. assemble :: ArtifactGenerator -> B9 [AssembledArtifact] parseArtifactGenerator :: ArtifactGenerator -> CGParser () withArtifactSources :: [ArtifactSource] -> CGParser () -> CGParser () withBindings :: [(String, String)] -> CGParser () -> CGParser () addBindings :: [(String, String)] -> CGEnv -> CGEnv withXBindings :: [(String, [String])] -> CGParser () -> CGParser () eachBindingSetT :: ArtifactGenerator -> [String] -> [[String]] -> CGParser [[(String, String)]] eachBindingSet :: ArtifactGenerator -> [(String, [String])] -> CGParser [[(String, String)]] writeInstanceGenerator :: InstanceId -> ArtifactAssembly -> CGParser () -- | Monad for creating Instance generators. newtype CGParser a CGParser :: WriterT [InstanceGenerator CGEnv] (ReaderT CGEnv (Either CGError)) a -> CGParser a runCGParser :: CGParser a -> WriterT [InstanceGenerator CGEnv] (ReaderT CGEnv (Either CGError)) a data CGEnv CGEnv :: [(String, String)] -> [ArtifactSource] -> CGEnv agEnv :: CGEnv -> [(String, String)] agSources :: CGEnv -> [ArtifactSource] data InstanceGenerator e IG :: InstanceId -> e -> ArtifactAssembly -> InstanceGenerator e newtype CGError CGError :: String -> CGError cgError :: String -> CGParser a execCGParser :: CGParser () -> CGEnv -> Either CGError [InstanceGenerator CGEnv] execIGEnv :: InstanceGenerator CGEnv -> Either String (InstanceGenerator [SourceGenerator]) substAssembly :: [(String, String)] -> ArtifactAssembly -> ArtifactAssembly toSourceGen :: [(String, String)] -> ArtifactSource -> Either String [SourceGenerator] createAssembledArtifacts :: [InstanceGenerator [SourceGenerator]] -> B9 [AssembledArtifact] generateSources :: FilePath -> InstanceGenerator [SourceGenerator] -> B9 (InstanceGenerator FilePath) createTargets :: InstanceGenerator FilePath -> B9 AssembledArtifact generateUniqueIID :: InstanceId -> B9 InstanceId generateSourceTo :: FilePath -> SourceGenerator -> B9 () sgReadSourceFile :: [(String, String)] -> SourceFile -> B9 ByteString sgChangePerm :: FilePath -> SGPerm -> B9 () -- | Internal data type simplifying the rather complex source generation by -- bioling down ArtifactSources to a flat list of uniform -- SourceGenerators. data SourceGenerator SGConcat :: [(String, String)] -> SGSource -> SGPerm -> FilePath -> SourceGenerator data SGSource SGFiles :: [SourceFile] -> SGSource SGContent :: Content -> SGSource data SGType SGT :: SGType SGF :: SGType data SGPerm SGSetPerm :: (Int, Int, Int) -> SGPerm KeepPerm :: SGPerm sgGetFroms :: SourceGenerator -> [SourceFile] setSGPerm :: Int -> Int -> Int -> SourceGenerator -> Either String SourceGenerator setSGFromDirectory :: FilePath -> SourceGenerator -> SourceGenerator setSGToDirectory :: FilePath -> SourceGenerator -> SourceGenerator -- | Create the actual target, either just a mountpoint, or an ISO or VFAT -- image. createTarget :: InstanceId -> FilePath -> ArtifactAssembly -> B9 [ArtifactTarget] instance Typeable InstanceGenerator instance Typeable CGError instance Typeable SGType instance Typeable SGPerm instance Read CGEnv instance Show CGEnv instance Eq CGEnv instance Read e => Read (InstanceGenerator e) instance Show e => Show (InstanceGenerator e) instance Data e => Data (InstanceGenerator e) instance Eq e => Eq (InstanceGenerator e) instance Read CGError instance Show CGError instance Data CGError instance Eq CGError instance Error CGError instance Functor CGParser instance Applicative CGParser instance Monad CGParser instance MonadReader CGEnv CGParser instance MonadWriter [InstanceGenerator CGEnv] CGParser instance MonadError CGError CGParser instance Read SGSource instance Show SGSource instance Eq SGSource instance Read SGType instance Show SGType instance Data SGType instance Eq SGType instance Read SGPerm instance Show SGPerm instance Data SGPerm instance Eq SGPerm instance Read SourceGenerator instance Show SourceGenerator instance Eq SourceGenerator -- | Highest-level build functions and and B9-re-exports. module B9.Builder buildArtifacts :: ArtifactGenerator -> ConfigParser -> B9Config -> IO Bool -- | B9 is a library and build tool with primitive operations to run 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. -- -- This module re-exports the modules needed to build a tool around the -- library, e.g. see src/cli/Main.hs as an example. module B9 -- | Merge existingConfig with the configuration from the main b9 -- config file. If the file does not exists, a new config file with the -- given configuration will be written. The return value is a parser for -- the config file. Returning the raw config file parser allows modules -- unkown to B9Config to add their own values to the shared config -- file. configure :: MonadIO m => Maybe SystemPath -> B9Config -> m ConfigParser -- | Return the cabal package version of the B9 library. b9_version :: Version