{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)
-}

module GI.OSTree.Objects.Sysroot
    ( 

-- * Exported types
    Sysroot(..)                             ,
    IsSysroot                               ,
    toSysroot                               ,
    noSysroot                               ,


 -- * Methods
-- ** cleanup #method:cleanup#
    SysrootCleanupMethodInfo                ,
    sysrootCleanup                          ,


-- ** deployTree #method:deployTree#
    SysrootDeployTreeMethodInfo             ,
    sysrootDeployTree                       ,


-- ** deploymentSetKargs #method:deploymentSetKargs#
    SysrootDeploymentSetKargsMethodInfo     ,
    sysrootDeploymentSetKargs               ,


-- ** deploymentSetMutable #method:deploymentSetMutable#
    SysrootDeploymentSetMutableMethodInfo   ,
    sysrootDeploymentSetMutable             ,


-- ** deploymentUnlock #method:deploymentUnlock#
    SysrootDeploymentUnlockMethodInfo       ,
    sysrootDeploymentUnlock                 ,


-- ** ensureInitialized #method:ensureInitialized#
    SysrootEnsureInitializedMethodInfo      ,
    sysrootEnsureInitialized                ,


-- ** getBootedDeployment #method:getBootedDeployment#
    SysrootGetBootedDeploymentMethodInfo    ,
    sysrootGetBootedDeployment              ,


-- ** getBootversion #method:getBootversion#
    SysrootGetBootversionMethodInfo         ,
    sysrootGetBootversion                   ,


-- ** getDeploymentDirectory #method:getDeploymentDirectory#
    SysrootGetDeploymentDirectoryMethodInfo ,
    sysrootGetDeploymentDirectory           ,


-- ** getDeploymentDirpath #method:getDeploymentDirpath#
    SysrootGetDeploymentDirpathMethodInfo   ,
    sysrootGetDeploymentDirpath             ,


-- ** getDeploymentOriginPath #method:getDeploymentOriginPath#
    sysrootGetDeploymentOriginPath          ,


-- ** getDeployments #method:getDeployments#
    SysrootGetDeploymentsMethodInfo         ,
    sysrootGetDeployments                   ,


-- ** getFd #method:getFd#
    SysrootGetFdMethodInfo                  ,
    sysrootGetFd                            ,


-- ** getMergeDeployment #method:getMergeDeployment#
    SysrootGetMergeDeploymentMethodInfo     ,
    sysrootGetMergeDeployment               ,


-- ** getPath #method:getPath#
    SysrootGetPathMethodInfo                ,
    sysrootGetPath                          ,


-- ** getRepo #method:getRepo#
    SysrootGetRepoMethodInfo                ,
    sysrootGetRepo                          ,


-- ** getSubbootversion #method:getSubbootversion#
    SysrootGetSubbootversionMethodInfo      ,
    sysrootGetSubbootversion                ,


-- ** initOsname #method:initOsname#
    SysrootInitOsnameMethodInfo             ,
    sysrootInitOsname                       ,


-- ** load #method:load#
    SysrootLoadMethodInfo                   ,
    sysrootLoad                             ,


-- ** loadIfChanged #method:loadIfChanged#
    SysrootLoadIfChangedMethodInfo          ,
    sysrootLoadIfChanged                    ,


-- ** lock #method:lock#
    SysrootLockMethodInfo                   ,
    sysrootLock                             ,


-- ** lockAsync #method:lockAsync#
    SysrootLockAsyncMethodInfo              ,
    sysrootLockAsync                        ,


-- ** lockFinish #method:lockFinish#
    SysrootLockFinishMethodInfo             ,
    sysrootLockFinish                       ,


-- ** new #method:new#
    sysrootNew                              ,


-- ** newDefault #method:newDefault#
    sysrootNewDefault                       ,


-- ** originNewFromRefspec #method:originNewFromRefspec#
    SysrootOriginNewFromRefspecMethodInfo   ,
    sysrootOriginNewFromRefspec             ,


-- ** prepareCleanup #method:prepareCleanup#
    SysrootPrepareCleanupMethodInfo         ,
    sysrootPrepareCleanup                   ,


-- ** simpleWriteDeployment #method:simpleWriteDeployment#
    SysrootSimpleWriteDeploymentMethodInfo  ,
    sysrootSimpleWriteDeployment            ,


-- ** tryLock #method:tryLock#
    SysrootTryLockMethodInfo                ,
    sysrootTryLock                          ,


-- ** unload #method:unload#
    SysrootUnloadMethodInfo                 ,
    sysrootUnload                           ,


-- ** unlock #method:unlock#
    SysrootUnlockMethodInfo                 ,
    sysrootUnlock                           ,


-- ** writeDeployments #method:writeDeployments#
    SysrootWriteDeploymentsMethodInfo       ,
    sysrootWriteDeployments                 ,


-- ** writeOriginFile #method:writeOriginFile#
    SysrootWriteOriginFileMethodInfo        ,
    sysrootWriteOriginFile                  ,




 -- * Properties
-- ** path #attr:path#
    SysrootPathPropertyInfo                 ,
    constructSysrootPath                    ,
    getSysrootPath                          ,
    sysrootPath                             ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import qualified GI.GLib.Structs.KeyFile as GLib.KeyFile
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Callbacks as Gio.Callbacks
import qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import qualified GI.Gio.Interfaces.File as Gio.File
import qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import {-# SOURCE #-} qualified GI.OSTree.Enums as OSTree.Enums
import {-# SOURCE #-} qualified GI.OSTree.Flags as OSTree.Flags
import {-# SOURCE #-} qualified GI.OSTree.Objects.Deployment as OSTree.Deployment
import {-# SOURCE #-} qualified GI.OSTree.Objects.Repo as OSTree.Repo

newtype Sysroot = Sysroot (ManagedPtr Sysroot)
foreign import ccall "ostree_sysroot_get_type"
    c_ostree_sysroot_get_type :: IO GType

instance GObject Sysroot where
    gobjectType _ = c_ostree_sysroot_get_type
    

class GObject o => IsSysroot o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError Sysroot a) =>
    IsSysroot a
#endif
instance IsSysroot Sysroot
instance GObject.Object.IsObject Sysroot

toSysroot :: IsSysroot o => o -> IO Sysroot
toSysroot = unsafeCastTo Sysroot

noSysroot :: Maybe Sysroot
noSysroot = Nothing

type family ResolveSysrootMethod (t :: Symbol) (o :: *) :: * where
    ResolveSysrootMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveSysrootMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveSysrootMethod "cleanup" o = SysrootCleanupMethodInfo
    ResolveSysrootMethod "deployTree" o = SysrootDeployTreeMethodInfo
    ResolveSysrootMethod "deploymentSetKargs" o = SysrootDeploymentSetKargsMethodInfo
    ResolveSysrootMethod "deploymentSetMutable" o = SysrootDeploymentSetMutableMethodInfo
    ResolveSysrootMethod "deploymentUnlock" o = SysrootDeploymentUnlockMethodInfo
    ResolveSysrootMethod "ensureInitialized" o = SysrootEnsureInitializedMethodInfo
    ResolveSysrootMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveSysrootMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveSysrootMethod "initOsname" o = SysrootInitOsnameMethodInfo
    ResolveSysrootMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveSysrootMethod "load" o = SysrootLoadMethodInfo
    ResolveSysrootMethod "loadIfChanged" o = SysrootLoadIfChangedMethodInfo
    ResolveSysrootMethod "lock" o = SysrootLockMethodInfo
    ResolveSysrootMethod "lockAsync" o = SysrootLockAsyncMethodInfo
    ResolveSysrootMethod "lockFinish" o = SysrootLockFinishMethodInfo
    ResolveSysrootMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveSysrootMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveSysrootMethod "originNewFromRefspec" o = SysrootOriginNewFromRefspecMethodInfo
    ResolveSysrootMethod "prepareCleanup" o = SysrootPrepareCleanupMethodInfo
    ResolveSysrootMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveSysrootMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveSysrootMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveSysrootMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveSysrootMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveSysrootMethod "simpleWriteDeployment" o = SysrootSimpleWriteDeploymentMethodInfo
    ResolveSysrootMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveSysrootMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveSysrootMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveSysrootMethod "tryLock" o = SysrootTryLockMethodInfo
    ResolveSysrootMethod "unload" o = SysrootUnloadMethodInfo
    ResolveSysrootMethod "unlock" o = SysrootUnlockMethodInfo
    ResolveSysrootMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveSysrootMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveSysrootMethod "writeDeployments" o = SysrootWriteDeploymentsMethodInfo
    ResolveSysrootMethod "writeOriginFile" o = SysrootWriteOriginFileMethodInfo
    ResolveSysrootMethod "getBootedDeployment" o = SysrootGetBootedDeploymentMethodInfo
    ResolveSysrootMethod "getBootversion" o = SysrootGetBootversionMethodInfo
    ResolveSysrootMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveSysrootMethod "getDeploymentDirectory" o = SysrootGetDeploymentDirectoryMethodInfo
    ResolveSysrootMethod "getDeploymentDirpath" o = SysrootGetDeploymentDirpathMethodInfo
    ResolveSysrootMethod "getDeployments" o = SysrootGetDeploymentsMethodInfo
    ResolveSysrootMethod "getFd" o = SysrootGetFdMethodInfo
    ResolveSysrootMethod "getMergeDeployment" o = SysrootGetMergeDeploymentMethodInfo
    ResolveSysrootMethod "getPath" o = SysrootGetPathMethodInfo
    ResolveSysrootMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveSysrootMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveSysrootMethod "getRepo" o = SysrootGetRepoMethodInfo
    ResolveSysrootMethod "getSubbootversion" o = SysrootGetSubbootversionMethodInfo
    ResolveSysrootMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveSysrootMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveSysrootMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveSysrootMethod t Sysroot, O.MethodInfo info Sysroot p) => O.IsLabelProxy t (Sysroot -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveSysrootMethod t Sysroot, O.MethodInfo info Sysroot p) => O.IsLabel t (Sysroot -> p) where
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

-- VVV Prop "path"
   -- Type: TInterface (Name {namespace = "Gio", name = "File"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Just False,Nothing)

getSysrootPath :: (MonadIO m, IsSysroot o) => o -> m Gio.File.File
getSysrootPath obj = liftIO $ checkUnexpectedNothing "getSysrootPath" $ getObjectPropertyObject obj "path" Gio.File.File

constructSysrootPath :: (IsSysroot o, Gio.File.IsFile a) => a -> IO (GValueConstruct o)
constructSysrootPath val = constructObjectPropertyObject "path" (Just val)

data SysrootPathPropertyInfo
instance AttrInfo SysrootPathPropertyInfo where
    type AttrAllowedOps SysrootPathPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint SysrootPathPropertyInfo = Gio.File.IsFile
    type AttrBaseTypeConstraint SysrootPathPropertyInfo = IsSysroot
    type AttrGetType SysrootPathPropertyInfo = Gio.File.File
    type AttrLabel SysrootPathPropertyInfo = "path"
    type AttrOrigin SysrootPathPropertyInfo = Sysroot
    attrGet _ = getSysrootPath
    attrSet _ = undefined
    attrConstruct _ = constructSysrootPath
    attrClear _ = undefined

instance O.HasAttributeList Sysroot
type instance O.AttributeList Sysroot = SysrootAttributeList
type SysrootAttributeList = ('[ '("path", SysrootPathPropertyInfo)] :: [(Symbol, *)])

sysrootPath :: AttrLabelProxy "path"
sysrootPath = AttrLabelProxy

type instance O.SignalList Sysroot = SysrootSignalList
type SysrootSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method Sysroot::new
-- method type : Constructor
-- Args : [Arg {argCName = "path", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Path to a system root directory, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "OSTree", name = "Sysroot"}))
-- throws : False
-- Skip return : False

foreign import ccall "ostree_sysroot_new" ostree_sysroot_new :: 
    Ptr Gio.File.File ->                    -- path : TInterface (Name {namespace = "Gio", name = "File"})
    IO (Ptr Sysroot)

{- |
/No description available in the introspection data./
-}
sysrootNew ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.File.IsFile a) =>
    Maybe (a)
    {- ^ /@path@/: Path to a system root directory, or 'Nothing' -}
    -> m Sysroot
    {- ^ __Returns:__ An accessor object for an system root located at /@path@/ -}
sysrootNew path = liftIO $ do
    maybePath <- case path of
        Nothing -> return nullPtr
        Just jPath -> do
            jPath' <- unsafeManagedPtrCastPtr jPath
            return jPath'
    result <- ostree_sysroot_new maybePath
    checkUnexpectedReturnNULL "sysrootNew" result
    result' <- (wrapObject Sysroot) result
    whenJust path touchManagedPtr
    return result'

-- method Sysroot::new_default
-- method type : Constructor
-- Args : []
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "OSTree", name = "Sysroot"}))
-- throws : False
-- Skip return : False

foreign import ccall "ostree_sysroot_new_default" ostree_sysroot_new_default :: 
    IO (Ptr Sysroot)

{- |
/No description available in the introspection data./
-}
sysrootNewDefault ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Sysroot
    {- ^ __Returns:__ An accessor for the current visible root \/ filesystem -}
sysrootNewDefault  = liftIO $ do
    result <- ostree_sysroot_new_default
    checkUnexpectedReturnNULL "sysrootNewDefault" result
    result' <- (wrapObject Sysroot) result
    return result'

-- method Sysroot::cleanup
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "Sysroot"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Sysroot", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Cancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_sysroot_cleanup" ostree_sysroot_cleanup :: 
    Ptr Sysroot ->                          -- self : TInterface (Name {namespace = "OSTree", name = "Sysroot"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Delete any state that resulted from a partially completed
transaction, such as incomplete deployments.
-}
sysrootCleanup ::
    (B.CallStack.HasCallStack, MonadIO m, IsSysroot a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@self@/: Sysroot -}
    -> Maybe (b)
    {- ^ /@cancellable@/: Cancellable -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
sysrootCleanup self cancellable = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ ostree_sysroot_cleanup self' maybeCancellable
        touchManagedPtr self
        whenJust cancellable touchManagedPtr
        return ()
     ) (do
        return ()
     )

data SysrootCleanupMethodInfo
instance (signature ~ (Maybe (b) -> m ()), MonadIO m, IsSysroot a, Gio.Cancellable.IsCancellable b) => O.MethodInfo SysrootCleanupMethodInfo a signature where
    overloadedMethod _ = sysrootCleanup

-- method Sysroot::deploy_tree
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "Sysroot"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Sysroot", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "osname", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "osname to use for merge deployment", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "revision", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Checksum to add", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "origin", argType = TInterface (Name {namespace = "GLib", name = "KeyFile"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Origin to use for upgrades", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "provided_merge_deployment", argType = TInterface (Name {namespace = "OSTree", name = "Deployment"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Use this deployment for merge path", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "override_kernel_argv", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Use these as kernel arguments; if %NULL, inherit options from provided_merge_deployment", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out_new_deployment", argType = TInterface (Name {namespace = "OSTree", name = "Deployment"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The new deployment path", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Cancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_sysroot_deploy_tree" ostree_sysroot_deploy_tree :: 
    Ptr Sysroot ->                          -- self : TInterface (Name {namespace = "OSTree", name = "Sysroot"})
    CString ->                              -- osname : TBasicType TUTF8
    CString ->                              -- revision : TBasicType TUTF8
    Ptr GLib.KeyFile.KeyFile ->             -- origin : TInterface (Name {namespace = "GLib", name = "KeyFile"})
    Ptr OSTree.Deployment.Deployment ->     -- provided_merge_deployment : TInterface (Name {namespace = "OSTree", name = "Deployment"})
    Ptr CString ->                          -- override_kernel_argv : TCArray True (-1) (-1) (TBasicType TUTF8)
    Ptr (Ptr OSTree.Deployment.Deployment) -> -- out_new_deployment : TInterface (Name {namespace = "OSTree", name = "Deployment"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Check out deployment tree with revision /@revision@/, performing a 3
way merge with /@providedMergeDeployment@/ for configuration.
-}
sysrootDeployTree ::
    (B.CallStack.HasCallStack, MonadIO m, IsSysroot a, OSTree.Deployment.IsDeployment b, Gio.Cancellable.IsCancellable c) =>
    a
    {- ^ /@self@/: Sysroot -}
    -> Maybe (T.Text)
    {- ^ /@osname@/: osname to use for merge deployment -}
    -> T.Text
    {- ^ /@revision@/: Checksum to add -}
    -> Maybe (GLib.KeyFile.KeyFile)
    {- ^ /@origin@/: Origin to use for upgrades -}
    -> Maybe (b)
    {- ^ /@providedMergeDeployment@/: Use this deployment for merge path -}
    -> Maybe ([T.Text])
    {- ^ /@overrideKernelArgv@/: Use these as kernel arguments; if 'Nothing', inherit options from provided_merge_deployment -}
    -> Maybe (c)
    {- ^ /@cancellable@/: Cancellable -}
    -> m (OSTree.Deployment.Deployment)
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
sysrootDeployTree self osname revision origin providedMergeDeployment overrideKernelArgv cancellable = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    maybeOsname <- case osname of
        Nothing -> return nullPtr
        Just jOsname -> do
            jOsname' <- textToCString jOsname
            return jOsname'
    revision' <- textToCString revision
    maybeOrigin <- case origin of
        Nothing -> return nullPtr
        Just jOrigin -> do
            jOrigin' <- unsafeManagedPtrGetPtr jOrigin
            return jOrigin'
    maybeProvidedMergeDeployment <- case providedMergeDeployment of
        Nothing -> return nullPtr
        Just jProvidedMergeDeployment -> do
            jProvidedMergeDeployment' <- unsafeManagedPtrCastPtr jProvidedMergeDeployment
            return jProvidedMergeDeployment'
    maybeOverrideKernelArgv <- case overrideKernelArgv of
        Nothing -> return nullPtr
        Just jOverrideKernelArgv -> do
            jOverrideKernelArgv' <- packZeroTerminatedUTF8CArray jOverrideKernelArgv
            return jOverrideKernelArgv'
    outNewDeployment <- allocMem :: IO (Ptr (Ptr OSTree.Deployment.Deployment))
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ ostree_sysroot_deploy_tree self' maybeOsname revision' maybeOrigin maybeProvidedMergeDeployment maybeOverrideKernelArgv outNewDeployment maybeCancellable
        outNewDeployment' <- peek outNewDeployment
        outNewDeployment'' <- (wrapObject OSTree.Deployment.Deployment) outNewDeployment'
        touchManagedPtr self
        whenJust origin touchManagedPtr
        whenJust providedMergeDeployment touchManagedPtr
        whenJust cancellable touchManagedPtr
        freeMem maybeOsname
        freeMem revision'
        mapZeroTerminatedCArray freeMem maybeOverrideKernelArgv
        freeMem maybeOverrideKernelArgv
        freeMem outNewDeployment
        return outNewDeployment''
     ) (do
        freeMem maybeOsname
        freeMem revision'
        mapZeroTerminatedCArray freeMem maybeOverrideKernelArgv
        freeMem maybeOverrideKernelArgv
        freeMem outNewDeployment
     )

data SysrootDeployTreeMethodInfo
instance (signature ~ (Maybe (T.Text) -> T.Text -> Maybe (GLib.KeyFile.KeyFile) -> Maybe (b) -> Maybe ([T.Text]) -> Maybe (c) -> m (OSTree.Deployment.Deployment)), MonadIO m, IsSysroot a, OSTree.Deployment.IsDeployment b, Gio.Cancellable.IsCancellable c) => O.MethodInfo SysrootDeployTreeMethodInfo a signature where
    overloadedMethod _ = sysrootDeployTree

-- method Sysroot::deployment_set_kargs
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "Sysroot"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Sysroot", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "deployment", argType = TInterface (Name {namespace = "OSTree", name = "Deployment"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A deployment", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "new_kargs", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Replace deployment's kernel arguments", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Cancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_sysroot_deployment_set_kargs" ostree_sysroot_deployment_set_kargs :: 
    Ptr Sysroot ->                          -- self : TInterface (Name {namespace = "OSTree", name = "Sysroot"})
    Ptr OSTree.Deployment.Deployment ->     -- deployment : TInterface (Name {namespace = "OSTree", name = "Deployment"})
    Ptr CString ->                          -- new_kargs : TCArray True (-1) (-1) (TBasicType TUTF8)
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Entirely replace the kernel arguments of /@deployment@/ with the
values in /@newKargs@/.
-}
sysrootDeploymentSetKargs ::
    (B.CallStack.HasCallStack, MonadIO m, IsSysroot a, OSTree.Deployment.IsDeployment b, Gio.Cancellable.IsCancellable c) =>
    a
    {- ^ /@self@/: Sysroot -}
    -> b
    {- ^ /@deployment@/: A deployment -}
    -> [T.Text]
    {- ^ /@newKargs@/: Replace deployment\'s kernel arguments -}
    -> Maybe (c)
    {- ^ /@cancellable@/: Cancellable -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
sysrootDeploymentSetKargs self deployment newKargs cancellable = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    deployment' <- unsafeManagedPtrCastPtr deployment
    newKargs' <- packZeroTerminatedUTF8CArray newKargs
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ ostree_sysroot_deployment_set_kargs self' deployment' newKargs' maybeCancellable
        touchManagedPtr self
        touchManagedPtr deployment
        whenJust cancellable touchManagedPtr
        mapZeroTerminatedCArray freeMem newKargs'
        freeMem newKargs'
        return ()
     ) (do
        mapZeroTerminatedCArray freeMem newKargs'
        freeMem newKargs'
     )

data SysrootDeploymentSetKargsMethodInfo
instance (signature ~ (b -> [T.Text] -> Maybe (c) -> m ()), MonadIO m, IsSysroot a, OSTree.Deployment.IsDeployment b, Gio.Cancellable.IsCancellable c) => O.MethodInfo SysrootDeploymentSetKargsMethodInfo a signature where
    overloadedMethod _ = sysrootDeploymentSetKargs

-- method Sysroot::deployment_set_mutable
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "Sysroot"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Sysroot", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "deployment", argType = TInterface (Name {namespace = "OSTree", name = "Deployment"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A deployment", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "is_mutable", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Whether or not deployment's files can be changed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_sysroot_deployment_set_mutable" ostree_sysroot_deployment_set_mutable :: 
    Ptr Sysroot ->                          -- self : TInterface (Name {namespace = "OSTree", name = "Sysroot"})
    Ptr OSTree.Deployment.Deployment ->     -- deployment : TInterface (Name {namespace = "OSTree", name = "Deployment"})
    CInt ->                                 -- is_mutable : TBasicType TBoolean
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
By default, deployment directories are not mutable.  This function
will allow making them temporarily mutable, for example to allow
layering additional non-OSTree content.
-}
sysrootDeploymentSetMutable ::
    (B.CallStack.HasCallStack, MonadIO m, IsSysroot a, OSTree.Deployment.IsDeployment b, Gio.Cancellable.IsCancellable c) =>
    a
    {- ^ /@self@/: Sysroot -}
    -> b
    {- ^ /@deployment@/: A deployment -}
    -> Bool
    {- ^ /@isMutable@/: Whether or not deployment\'s files can be changed -}
    -> Maybe (c)
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
sysrootDeploymentSetMutable self deployment isMutable cancellable = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    deployment' <- unsafeManagedPtrCastPtr deployment
    let isMutable' = (fromIntegral . fromEnum) isMutable
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ ostree_sysroot_deployment_set_mutable self' deployment' isMutable' maybeCancellable
        touchManagedPtr self
        touchManagedPtr deployment
        whenJust cancellable touchManagedPtr
        return ()
     ) (do
        return ()
     )

data SysrootDeploymentSetMutableMethodInfo
instance (signature ~ (b -> Bool -> Maybe (c) -> m ()), MonadIO m, IsSysroot a, OSTree.Deployment.IsDeployment b, Gio.Cancellable.IsCancellable c) => O.MethodInfo SysrootDeploymentSetMutableMethodInfo a signature where
    overloadedMethod _ = sysrootDeploymentSetMutable

-- method Sysroot::deployment_unlock
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "Sysroot"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Sysroot", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "deployment", argType = TInterface (Name {namespace = "OSTree", name = "Deployment"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Deployment", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "unlocked_state", argType = TInterface (Name {namespace = "OSTree", name = "DeploymentUnlockedState"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Transition to this unlocked state", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Cancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_sysroot_deployment_unlock" ostree_sysroot_deployment_unlock :: 
    Ptr Sysroot ->                          -- self : TInterface (Name {namespace = "OSTree", name = "Sysroot"})
    Ptr OSTree.Deployment.Deployment ->     -- deployment : TInterface (Name {namespace = "OSTree", name = "Deployment"})
    CUInt ->                                -- unlocked_state : TInterface (Name {namespace = "OSTree", name = "DeploymentUnlockedState"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Configure the target deployment /@deployment@/ such that it
is writable.  There are multiple modes, essentially differing
in whether or not any changes persist across reboot.

The @OSTREE_DEPLOYMENT_UNLOCKED_HOTFIX@ state is persistent
across reboots.
-}
sysrootDeploymentUnlock ::
    (B.CallStack.HasCallStack, MonadIO m, IsSysroot a, OSTree.Deployment.IsDeployment b, Gio.Cancellable.IsCancellable c) =>
    a
    {- ^ /@self@/: Sysroot -}
    -> b
    {- ^ /@deployment@/: Deployment -}
    -> OSTree.Enums.DeploymentUnlockedState
    {- ^ /@unlockedState@/: Transition to this unlocked state -}
    -> Maybe (c)
    {- ^ /@cancellable@/: Cancellable -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
sysrootDeploymentUnlock self deployment unlockedState cancellable = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    deployment' <- unsafeManagedPtrCastPtr deployment
    let unlockedState' = (fromIntegral . fromEnum) unlockedState
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ ostree_sysroot_deployment_unlock self' deployment' unlockedState' maybeCancellable
        touchManagedPtr self
        touchManagedPtr deployment
        whenJust cancellable touchManagedPtr
        return ()
     ) (do
        return ()
     )

data SysrootDeploymentUnlockMethodInfo
instance (signature ~ (b -> OSTree.Enums.DeploymentUnlockedState -> Maybe (c) -> m ()), MonadIO m, IsSysroot a, OSTree.Deployment.IsDeployment b, Gio.Cancellable.IsCancellable c) => O.MethodInfo SysrootDeploymentUnlockMethodInfo a signature where
    overloadedMethod _ = sysrootDeploymentUnlock

-- method Sysroot::ensure_initialized
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "Sysroot"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Sysroot", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Cancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_sysroot_ensure_initialized" ostree_sysroot_ensure_initialized :: 
    Ptr Sysroot ->                          -- self : TInterface (Name {namespace = "OSTree", name = "Sysroot"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Ensure that /@self@/ is set up as a valid rootfs, by creating
\/ostree\/repo, among other things.
-}
sysrootEnsureInitialized ::
    (B.CallStack.HasCallStack, MonadIO m, IsSysroot a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@self@/: Sysroot -}
    -> Maybe (b)
    {- ^ /@cancellable@/: Cancellable -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
sysrootEnsureInitialized self cancellable = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ ostree_sysroot_ensure_initialized self' maybeCancellable
        touchManagedPtr self
        whenJust cancellable touchManagedPtr
        return ()
     ) (do
        return ()
     )

data SysrootEnsureInitializedMethodInfo
instance (signature ~ (Maybe (b) -> m ()), MonadIO m, IsSysroot a, Gio.Cancellable.IsCancellable b) => O.MethodInfo SysrootEnsureInitializedMethodInfo a signature where
    overloadedMethod _ = sysrootEnsureInitialized

-- method Sysroot::get_booted_deployment
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "Sysroot"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Sysroot", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "OSTree", name = "Deployment"}))
-- throws : False
-- Skip return : False

foreign import ccall "ostree_sysroot_get_booted_deployment" ostree_sysroot_get_booted_deployment :: 
    Ptr Sysroot ->                          -- self : TInterface (Name {namespace = "OSTree", name = "Sysroot"})
    IO (Ptr OSTree.Deployment.Deployment)

{- |
/No description available in the introspection data./
-}
sysrootGetBootedDeployment ::
    (B.CallStack.HasCallStack, MonadIO m, IsSysroot a) =>
    a
    {- ^ /@self@/: Sysroot -}
    -> m OSTree.Deployment.Deployment
    {- ^ __Returns:__ The currently booted deployment, or 'Nothing' if none -}
sysrootGetBootedDeployment self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- ostree_sysroot_get_booted_deployment self'
    checkUnexpectedReturnNULL "sysrootGetBootedDeployment" result
    result' <- (newObject OSTree.Deployment.Deployment) result
    touchManagedPtr self
    return result'

data SysrootGetBootedDeploymentMethodInfo
instance (signature ~ (m OSTree.Deployment.Deployment), MonadIO m, IsSysroot a) => O.MethodInfo SysrootGetBootedDeploymentMethodInfo a signature where
    overloadedMethod _ = sysrootGetBootedDeployment

-- method Sysroot::get_bootversion
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "Sysroot"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "ostree_sysroot_get_bootversion" ostree_sysroot_get_bootversion :: 
    Ptr Sysroot ->                          -- self : TInterface (Name {namespace = "OSTree", name = "Sysroot"})
    IO Int32

{- |
/No description available in the introspection data./
-}
sysrootGetBootversion ::
    (B.CallStack.HasCallStack, MonadIO m, IsSysroot a) =>
    a
    -> m Int32
sysrootGetBootversion self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- ostree_sysroot_get_bootversion self'
    touchManagedPtr self
    return result

data SysrootGetBootversionMethodInfo
instance (signature ~ (m Int32), MonadIO m, IsSysroot a) => O.MethodInfo SysrootGetBootversionMethodInfo a signature where
    overloadedMethod _ = sysrootGetBootversion

-- method Sysroot::get_deployment_directory
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "Sysroot"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Sysroot", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "deployment", argType = TInterface (Name {namespace = "OSTree", name = "Deployment"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A deployment", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "File"}))
-- throws : False
-- Skip return : False

foreign import ccall "ostree_sysroot_get_deployment_directory" ostree_sysroot_get_deployment_directory :: 
    Ptr Sysroot ->                          -- self : TInterface (Name {namespace = "OSTree", name = "Sysroot"})
    Ptr OSTree.Deployment.Deployment ->     -- deployment : TInterface (Name {namespace = "OSTree", name = "Deployment"})
    IO (Ptr Gio.File.File)

{- |
/No description available in the introspection data./
-}
sysrootGetDeploymentDirectory ::
    (B.CallStack.HasCallStack, MonadIO m, IsSysroot a, OSTree.Deployment.IsDeployment b) =>
    a
    {- ^ /@self@/: Sysroot -}
    -> b
    {- ^ /@deployment@/: A deployment -}
    -> m Gio.File.File
    {- ^ __Returns:__ Path to deployment root directory -}
sysrootGetDeploymentDirectory self deployment = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    deployment' <- unsafeManagedPtrCastPtr deployment
    result <- ostree_sysroot_get_deployment_directory self' deployment'
    checkUnexpectedReturnNULL "sysrootGetDeploymentDirectory" result
    result' <- (wrapObject Gio.File.File) result
    touchManagedPtr self
    touchManagedPtr deployment
    return result'

data SysrootGetDeploymentDirectoryMethodInfo
instance (signature ~ (b -> m Gio.File.File), MonadIO m, IsSysroot a, OSTree.Deployment.IsDeployment b) => O.MethodInfo SysrootGetDeploymentDirectoryMethodInfo a signature where
    overloadedMethod _ = sysrootGetDeploymentDirectory

-- method Sysroot::get_deployment_dirpath
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "Sysroot"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Repo", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "deployment", argType = TInterface (Name {namespace = "OSTree", name = "Deployment"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A deployment", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "ostree_sysroot_get_deployment_dirpath" ostree_sysroot_get_deployment_dirpath :: 
    Ptr Sysroot ->                          -- self : TInterface (Name {namespace = "OSTree", name = "Sysroot"})
    Ptr OSTree.Deployment.Deployment ->     -- deployment : TInterface (Name {namespace = "OSTree", name = "Deployment"})
    IO CString

{- |
Note this function only returns a *relative* path - if you want
to access, it, you must either use fd-relative api such as @/openat()/@,
or concatenate it with the full 'GI.OSTree.Objects.Sysroot.sysrootGetPath'.
-}
sysrootGetDeploymentDirpath ::
    (B.CallStack.HasCallStack, MonadIO m, IsSysroot a, OSTree.Deployment.IsDeployment b) =>
    a
    {- ^ /@self@/: Repo -}
    -> b
    {- ^ /@deployment@/: A deployment -}
    -> m T.Text
    {- ^ __Returns:__ Path to deployment root directory, relative to sysroot -}
sysrootGetDeploymentDirpath self deployment = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    deployment' <- unsafeManagedPtrCastPtr deployment
    result <- ostree_sysroot_get_deployment_dirpath self' deployment'
    checkUnexpectedReturnNULL "sysrootGetDeploymentDirpath" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr self
    touchManagedPtr deployment
    return result'

data SysrootGetDeploymentDirpathMethodInfo
instance (signature ~ (b -> m T.Text), MonadIO m, IsSysroot a, OSTree.Deployment.IsDeployment b) => O.MethodInfo SysrootGetDeploymentDirpathMethodInfo a signature where
    overloadedMethod _ = sysrootGetDeploymentDirpath

-- method Sysroot::get_deployments
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "Sysroot"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Sysroot", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TPtrArray (TInterface (Name {namespace = "OSTree", name = "Deployment"})))
-- throws : False
-- Skip return : False

foreign import ccall "ostree_sysroot_get_deployments" ostree_sysroot_get_deployments :: 
    Ptr Sysroot ->                          -- self : TInterface (Name {namespace = "OSTree", name = "Sysroot"})
    IO (Ptr (GPtrArray (Ptr OSTree.Deployment.Deployment)))

{- |
/No description available in the introspection data./
-}
sysrootGetDeployments ::
    (B.CallStack.HasCallStack, MonadIO m, IsSysroot a) =>
    a
    {- ^ /@self@/: Sysroot -}
    -> m [OSTree.Deployment.Deployment]
    {- ^ __Returns:__ Ordered list of deployments -}
sysrootGetDeployments self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- ostree_sysroot_get_deployments self'
    checkUnexpectedReturnNULL "sysrootGetDeployments" result
    result' <- unpackGPtrArray result
    result'' <- mapM (newObject OSTree.Deployment.Deployment) result'
    unrefPtrArray result
    touchManagedPtr self
    return result''

data SysrootGetDeploymentsMethodInfo
instance (signature ~ (m [OSTree.Deployment.Deployment]), MonadIO m, IsSysroot a) => O.MethodInfo SysrootGetDeploymentsMethodInfo a signature where
    overloadedMethod _ = sysrootGetDeployments

-- method Sysroot::get_fd
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "Sysroot"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Sysroot", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "ostree_sysroot_get_fd" ostree_sysroot_get_fd :: 
    Ptr Sysroot ->                          -- self : TInterface (Name {namespace = "OSTree", name = "Sysroot"})
    IO Int32

{- |
Access a file descriptor that refers to the root directory of this
sysroot.  'GI.OSTree.Objects.Sysroot.sysrootLoad' must have been invoked prior to
calling this function.
-}
sysrootGetFd ::
    (B.CallStack.HasCallStack, MonadIO m, IsSysroot a) =>
    a
    {- ^ /@self@/: Sysroot -}
    -> m Int32
    {- ^ __Returns:__ A file descriptor valid for the lifetime of /@self@/ -}
sysrootGetFd self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- ostree_sysroot_get_fd self'
    touchManagedPtr self
    return result

data SysrootGetFdMethodInfo
instance (signature ~ (m Int32), MonadIO m, IsSysroot a) => O.MethodInfo SysrootGetFdMethodInfo a signature where
    overloadedMethod _ = sysrootGetFd

-- method Sysroot::get_merge_deployment
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "Sysroot"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Sysroot", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "osname", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Operating system group", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "OSTree", name = "Deployment"}))
-- throws : False
-- Skip return : False

foreign import ccall "ostree_sysroot_get_merge_deployment" ostree_sysroot_get_merge_deployment :: 
    Ptr Sysroot ->                          -- self : TInterface (Name {namespace = "OSTree", name = "Sysroot"})
    CString ->                              -- osname : TBasicType TUTF8
    IO (Ptr OSTree.Deployment.Deployment)

{- |
Find the deployment to use as a configuration merge source; this is
the first one in the current deployment list which matches osname.
-}
sysrootGetMergeDeployment ::
    (B.CallStack.HasCallStack, MonadIO m, IsSysroot a) =>
    a
    {- ^ /@self@/: Sysroot -}
    -> Maybe (T.Text)
    {- ^ /@osname@/: Operating system group -}
    -> m OSTree.Deployment.Deployment
    {- ^ __Returns:__ Configuration merge deployment -}
sysrootGetMergeDeployment self osname = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    maybeOsname <- case osname of
        Nothing -> return nullPtr
        Just jOsname -> do
            jOsname' <- textToCString jOsname
            return jOsname'
    result <- ostree_sysroot_get_merge_deployment self' maybeOsname
    checkUnexpectedReturnNULL "sysrootGetMergeDeployment" result
    result' <- (wrapObject OSTree.Deployment.Deployment) result
    touchManagedPtr self
    freeMem maybeOsname
    return result'

data SysrootGetMergeDeploymentMethodInfo
instance (signature ~ (Maybe (T.Text) -> m OSTree.Deployment.Deployment), MonadIO m, IsSysroot a) => O.MethodInfo SysrootGetMergeDeploymentMethodInfo a signature where
    overloadedMethod _ = sysrootGetMergeDeployment

-- method Sysroot::get_path
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "Sysroot"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "File"}))
-- throws : False
-- Skip return : False

foreign import ccall "ostree_sysroot_get_path" ostree_sysroot_get_path :: 
    Ptr Sysroot ->                          -- self : TInterface (Name {namespace = "OSTree", name = "Sysroot"})
    IO (Ptr Gio.File.File)

{- |
/No description available in the introspection data./
-}
sysrootGetPath ::
    (B.CallStack.HasCallStack, MonadIO m, IsSysroot a) =>
    a
    -> m Gio.File.File
    {- ^ __Returns:__ Path to rootfs -}
sysrootGetPath self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- ostree_sysroot_get_path self'
    checkUnexpectedReturnNULL "sysrootGetPath" result
    result' <- (newObject Gio.File.File) result
    touchManagedPtr self
    return result'

data SysrootGetPathMethodInfo
instance (signature ~ (m Gio.File.File), MonadIO m, IsSysroot a) => O.MethodInfo SysrootGetPathMethodInfo a signature where
    overloadedMethod _ = sysrootGetPath

-- method Sysroot::get_repo
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "Sysroot"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Sysroot", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out_repo", argType = TInterface (Name {namespace = "OSTree", name = "Repo"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Repository in sysroot @self", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Cancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_sysroot_get_repo" ostree_sysroot_get_repo :: 
    Ptr Sysroot ->                          -- self : TInterface (Name {namespace = "OSTree", name = "Sysroot"})
    Ptr (Ptr OSTree.Repo.Repo) ->           -- out_repo : TInterface (Name {namespace = "OSTree", name = "Repo"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Retrieve the OSTree repository in sysroot /@self@/.
-}
sysrootGetRepo ::
    (B.CallStack.HasCallStack, MonadIO m, IsSysroot a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@self@/: Sysroot -}
    -> Maybe (b)
    {- ^ /@cancellable@/: Cancellable -}
    -> m (OSTree.Repo.Repo)
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
sysrootGetRepo self cancellable = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    outRepo <- allocMem :: IO (Ptr (Ptr OSTree.Repo.Repo))
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ ostree_sysroot_get_repo self' outRepo maybeCancellable
        outRepo' <- peek outRepo
        outRepo'' <- (wrapObject OSTree.Repo.Repo) outRepo'
        touchManagedPtr self
        whenJust cancellable touchManagedPtr
        freeMem outRepo
        return outRepo''
     ) (do
        freeMem outRepo
     )

data SysrootGetRepoMethodInfo
instance (signature ~ (Maybe (b) -> m (OSTree.Repo.Repo)), MonadIO m, IsSysroot a, Gio.Cancellable.IsCancellable b) => O.MethodInfo SysrootGetRepoMethodInfo a signature where
    overloadedMethod _ = sysrootGetRepo

-- method Sysroot::get_subbootversion
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "Sysroot"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "ostree_sysroot_get_subbootversion" ostree_sysroot_get_subbootversion :: 
    Ptr Sysroot ->                          -- self : TInterface (Name {namespace = "OSTree", name = "Sysroot"})
    IO Int32

{- |
/No description available in the introspection data./
-}
sysrootGetSubbootversion ::
    (B.CallStack.HasCallStack, MonadIO m, IsSysroot a) =>
    a
    -> m Int32
sysrootGetSubbootversion self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- ostree_sysroot_get_subbootversion self'
    touchManagedPtr self
    return result

data SysrootGetSubbootversionMethodInfo
instance (signature ~ (m Int32), MonadIO m, IsSysroot a) => O.MethodInfo SysrootGetSubbootversionMethodInfo a signature where
    overloadedMethod _ = sysrootGetSubbootversion

-- method Sysroot::init_osname
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "Sysroot"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Sysroot", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "osname", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Name group of operating system checkouts", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Cancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_sysroot_init_osname" ostree_sysroot_init_osname :: 
    Ptr Sysroot ->                          -- self : TInterface (Name {namespace = "OSTree", name = "Sysroot"})
    CString ->                              -- osname : TBasicType TUTF8
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Initialize the directory structure for an \"osname\", which is a
group of operating system deployments, with a shared @\/var@.  One
is required for generating a deployment.
-}
sysrootInitOsname ::
    (B.CallStack.HasCallStack, MonadIO m, IsSysroot a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@self@/: Sysroot -}
    -> T.Text
    {- ^ /@osname@/: Name group of operating system checkouts -}
    -> Maybe (b)
    {- ^ /@cancellable@/: Cancellable -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
sysrootInitOsname self osname cancellable = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    osname' <- textToCString osname
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ ostree_sysroot_init_osname self' osname' maybeCancellable
        touchManagedPtr self
        whenJust cancellable touchManagedPtr
        freeMem osname'
        return ()
     ) (do
        freeMem osname'
     )

data SysrootInitOsnameMethodInfo
instance (signature ~ (T.Text -> Maybe (b) -> m ()), MonadIO m, IsSysroot a, Gio.Cancellable.IsCancellable b) => O.MethodInfo SysrootInitOsnameMethodInfo a signature where
    overloadedMethod _ = sysrootInitOsname

-- method Sysroot::load
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "Sysroot"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Sysroot", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Cancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_sysroot_load" ostree_sysroot_load :: 
    Ptr Sysroot ->                          -- self : TInterface (Name {namespace = "OSTree", name = "Sysroot"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Load deployment list, bootversion, and subbootversion from the
rootfs /@self@/.
-}
sysrootLoad ::
    (B.CallStack.HasCallStack, MonadIO m, IsSysroot a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@self@/: Sysroot -}
    -> Maybe (b)
    {- ^ /@cancellable@/: Cancellable -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
sysrootLoad self cancellable = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ ostree_sysroot_load self' maybeCancellable
        touchManagedPtr self
        whenJust cancellable touchManagedPtr
        return ()
     ) (do
        return ()
     )

data SysrootLoadMethodInfo
instance (signature ~ (Maybe (b) -> m ()), MonadIO m, IsSysroot a, Gio.Cancellable.IsCancellable b) => O.MethodInfo SysrootLoadMethodInfo a signature where
    overloadedMethod _ = sysrootLoad

-- method Sysroot::load_if_changed
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "Sysroot"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out_changed", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_sysroot_load_if_changed" ostree_sysroot_load_if_changed :: 
    Ptr Sysroot ->                          -- self : TInterface (Name {namespace = "OSTree", name = "Sysroot"})
    CInt ->                                 -- out_changed : TBasicType TBoolean
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
/No description available in the introspection data./
-}
sysrootLoadIfChanged ::
    (B.CallStack.HasCallStack, MonadIO m, IsSysroot a, Gio.Cancellable.IsCancellable b) =>
    a
    -> Bool
    -> Maybe (b)
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
sysrootLoadIfChanged self outChanged cancellable = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    let outChanged' = (fromIntegral . fromEnum) outChanged
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ ostree_sysroot_load_if_changed self' outChanged' maybeCancellable
        touchManagedPtr self
        whenJust cancellable touchManagedPtr
        return ()
     ) (do
        return ()
     )

data SysrootLoadIfChangedMethodInfo
instance (signature ~ (Bool -> Maybe (b) -> m ()), MonadIO m, IsSysroot a, Gio.Cancellable.IsCancellable b) => O.MethodInfo SysrootLoadIfChangedMethodInfo a signature where
    overloadedMethod _ = sysrootLoadIfChanged

-- method Sysroot::lock
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "Sysroot"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Self", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_sysroot_lock" ostree_sysroot_lock :: 
    Ptr Sysroot ->                          -- self : TInterface (Name {namespace = "OSTree", name = "Sysroot"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Acquire an exclusive multi-process write lock for /@self@/.  This call
blocks until the lock has been acquired.  The lock is not
reentrant.

Release the lock with 'GI.OSTree.Objects.Sysroot.sysrootUnlock'.  The lock will also
be released if /@self@/ is deallocated.
-}
sysrootLock ::
    (B.CallStack.HasCallStack, MonadIO m, IsSysroot a) =>
    a
    {- ^ /@self@/: Self -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
sysrootLock self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    onException (do
        _ <- propagateGError $ ostree_sysroot_lock self'
        touchManagedPtr self
        return ()
     ) (do
        return ()
     )

data SysrootLockMethodInfo
instance (signature ~ (m ()), MonadIO m, IsSysroot a) => O.MethodInfo SysrootLockMethodInfo a signature where
    overloadedMethod _ = sysrootLock

-- method Sysroot::lock_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "Sysroot"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Self", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Cancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Callback", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "User data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "ostree_sysroot_lock_async" ostree_sysroot_lock_async :: 
    Ptr Sysroot ->                          -- self : TInterface (Name {namespace = "OSTree", name = "Sysroot"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
An asynchronous version of 'GI.OSTree.Objects.Sysroot.sysrootLock'.
-}
sysrootLockAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsSysroot a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@self@/: Self -}
    -> Maybe (b)
    {- ^ /@cancellable@/: Cancellable -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: Callback -}
    -> m ()
sysrootLockAsync self cancellable callback = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    ostree_sysroot_lock_async self' maybeCancellable maybeCallback userData
    touchManagedPtr self
    whenJust cancellable touchManagedPtr
    return ()

data SysrootLockAsyncMethodInfo
instance (signature ~ (Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsSysroot a, Gio.Cancellable.IsCancellable b) => O.MethodInfo SysrootLockAsyncMethodInfo a signature where
    overloadedMethod _ = sysrootLockAsync

-- method Sysroot::lock_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "Sysroot"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Self", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Result", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_sysroot_lock_finish" ostree_sysroot_lock_finish :: 
    Ptr Sysroot ->                          -- self : TInterface (Name {namespace = "OSTree", name = "Sysroot"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Call when 'GI.OSTree.Objects.Sysroot.sysrootLockAsync' is ready.
-}
sysrootLockFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsSysroot a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@self@/: Self -}
    -> b
    {- ^ /@result@/: Result -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
sysrootLockFinish self result_ = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result_' <- unsafeManagedPtrCastPtr result_
    onException (do
        _ <- propagateGError $ ostree_sysroot_lock_finish self' result_'
        touchManagedPtr self
        touchManagedPtr result_
        return ()
     ) (do
        return ()
     )

data SysrootLockFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsSysroot a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo SysrootLockFinishMethodInfo a signature where
    overloadedMethod _ = sysrootLockFinish

-- method Sysroot::origin_new_from_refspec
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "Sysroot"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "refspec", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A refspec", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "KeyFile"}))
-- throws : False
-- Skip return : False

foreign import ccall "ostree_sysroot_origin_new_from_refspec" ostree_sysroot_origin_new_from_refspec :: 
    Ptr Sysroot ->                          -- self : TInterface (Name {namespace = "OSTree", name = "Sysroot"})
    CString ->                              -- refspec : TBasicType TUTF8
    IO (Ptr GLib.KeyFile.KeyFile)

{- |
/No description available in the introspection data./
-}
sysrootOriginNewFromRefspec ::
    (B.CallStack.HasCallStack, MonadIO m, IsSysroot a) =>
    a
    -> T.Text
    {- ^ /@refspec@/: A refspec -}
    -> m GLib.KeyFile.KeyFile
    {- ^ __Returns:__ A new config file which sets /@refspec@/ as an origin -}
sysrootOriginNewFromRefspec self refspec = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    refspec' <- textToCString refspec
    result <- ostree_sysroot_origin_new_from_refspec self' refspec'
    checkUnexpectedReturnNULL "sysrootOriginNewFromRefspec" result
    result' <- (wrapBoxed GLib.KeyFile.KeyFile) result
    touchManagedPtr self
    freeMem refspec'
    return result'

data SysrootOriginNewFromRefspecMethodInfo
instance (signature ~ (T.Text -> m GLib.KeyFile.KeyFile), MonadIO m, IsSysroot a) => O.MethodInfo SysrootOriginNewFromRefspecMethodInfo a signature where
    overloadedMethod _ = sysrootOriginNewFromRefspec

-- method Sysroot::prepare_cleanup
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "Sysroot"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Sysroot", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Cancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_sysroot_prepare_cleanup" ostree_sysroot_prepare_cleanup :: 
    Ptr Sysroot ->                          -- self : TInterface (Name {namespace = "OSTree", name = "Sysroot"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Like 'GI.OSTree.Objects.Sysroot.sysrootCleanup' in that it cleans up incomplete deployments
and old boot versions, but does NOT prune the repository.
-}
sysrootPrepareCleanup ::
    (B.CallStack.HasCallStack, MonadIO m, IsSysroot a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@self@/: Sysroot -}
    -> Maybe (b)
    {- ^ /@cancellable@/: Cancellable -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
sysrootPrepareCleanup self cancellable = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ ostree_sysroot_prepare_cleanup self' maybeCancellable
        touchManagedPtr self
        whenJust cancellable touchManagedPtr
        return ()
     ) (do
        return ()
     )

data SysrootPrepareCleanupMethodInfo
instance (signature ~ (Maybe (b) -> m ()), MonadIO m, IsSysroot a, Gio.Cancellable.IsCancellable b) => O.MethodInfo SysrootPrepareCleanupMethodInfo a signature where
    overloadedMethod _ = sysrootPrepareCleanup

-- method Sysroot::simple_write_deployment
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "sysroot", argType = TInterface (Name {namespace = "OSTree", name = "Sysroot"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Sysroot", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "osname", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "OS name", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "new_deployment", argType = TInterface (Name {namespace = "OSTree", name = "Deployment"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Prepend this deployment to the list", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "merge_deployment", argType = TInterface (Name {namespace = "OSTree", name = "Deployment"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Use this deployment for configuration merge", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "OSTree", name = "SysrootSimpleWriteDeploymentFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Flags controlling behavior", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Cancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_sysroot_simple_write_deployment" ostree_sysroot_simple_write_deployment :: 
    Ptr Sysroot ->                          -- sysroot : TInterface (Name {namespace = "OSTree", name = "Sysroot"})
    CString ->                              -- osname : TBasicType TUTF8
    Ptr OSTree.Deployment.Deployment ->     -- new_deployment : TInterface (Name {namespace = "OSTree", name = "Deployment"})
    Ptr OSTree.Deployment.Deployment ->     -- merge_deployment : TInterface (Name {namespace = "OSTree", name = "Deployment"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "OSTree", name = "SysrootSimpleWriteDeploymentFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Prepend /@newDeployment@/ to the list of deployments, commit, and
cleanup.  By default, all other deployments for the given /@osname@/
except the merge deployment and the booted deployment will be
garbage collected.

If 'GI.OSTree.Flags.SysrootSimpleWriteDeploymentFlagsRetain' is
specified, then all current deployments will be kept.

If 'GI.OSTree.Flags.SysrootSimpleWriteDeploymentFlagsNotDefault' is
specified, then instead of prepending, the new deployment will be
added right after the booted or merge deployment, instead of first.
-}
sysrootSimpleWriteDeployment ::
    (B.CallStack.HasCallStack, MonadIO m, IsSysroot a, OSTree.Deployment.IsDeployment b, OSTree.Deployment.IsDeployment c, Gio.Cancellable.IsCancellable d) =>
    a
    {- ^ /@sysroot@/: Sysroot -}
    -> Maybe (T.Text)
    {- ^ /@osname@/: OS name -}
    -> b
    {- ^ /@newDeployment@/: Prepend this deployment to the list -}
    -> Maybe (c)
    {- ^ /@mergeDeployment@/: Use this deployment for configuration merge -}
    -> [OSTree.Flags.SysrootSimpleWriteDeploymentFlags]
    {- ^ /@flags@/: Flags controlling behavior -}
    -> Maybe (d)
    {- ^ /@cancellable@/: Cancellable -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
sysrootSimpleWriteDeployment sysroot osname newDeployment mergeDeployment flags cancellable = liftIO $ do
    sysroot' <- unsafeManagedPtrCastPtr sysroot
    maybeOsname <- case osname of
        Nothing -> return nullPtr
        Just jOsname -> do
            jOsname' <- textToCString jOsname
            return jOsname'
    newDeployment' <- unsafeManagedPtrCastPtr newDeployment
    maybeMergeDeployment <- case mergeDeployment of
        Nothing -> return nullPtr
        Just jMergeDeployment -> do
            jMergeDeployment' <- unsafeManagedPtrCastPtr jMergeDeployment
            return jMergeDeployment'
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ ostree_sysroot_simple_write_deployment sysroot' maybeOsname newDeployment' maybeMergeDeployment flags' maybeCancellable
        touchManagedPtr sysroot
        touchManagedPtr newDeployment
        whenJust mergeDeployment touchManagedPtr
        whenJust cancellable touchManagedPtr
        freeMem maybeOsname
        return ()
     ) (do
        freeMem maybeOsname
     )

data SysrootSimpleWriteDeploymentMethodInfo
instance (signature ~ (Maybe (T.Text) -> b -> Maybe (c) -> [OSTree.Flags.SysrootSimpleWriteDeploymentFlags] -> Maybe (d) -> m ()), MonadIO m, IsSysroot a, OSTree.Deployment.IsDeployment b, OSTree.Deployment.IsDeployment c, Gio.Cancellable.IsCancellable d) => O.MethodInfo SysrootSimpleWriteDeploymentMethodInfo a signature where
    overloadedMethod _ = sysrootSimpleWriteDeployment

-- method Sysroot::try_lock
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "Sysroot"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Self", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out_acquired", argType = TBasicType TBoolean, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Whether or not the lock has been acquired", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_sysroot_try_lock" ostree_sysroot_try_lock :: 
    Ptr Sysroot ->                          -- self : TInterface (Name {namespace = "OSTree", name = "Sysroot"})
    Ptr CInt ->                             -- out_acquired : TBasicType TBoolean
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Try to acquire an exclusive multi-process write lock for /@self@/.  If
another process holds the lock, this function will return
immediately, setting /@outAcquired@/ to 'False', and returning 'True'
(and no error).

Release the lock with 'GI.OSTree.Objects.Sysroot.sysrootUnlock'.  The lock will also
be released if /@self@/ is deallocated.
-}
sysrootTryLock ::
    (B.CallStack.HasCallStack, MonadIO m, IsSysroot a) =>
    a
    {- ^ /@self@/: Self -}
    -> m (Bool)
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
sysrootTryLock self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    outAcquired <- allocMem :: IO (Ptr CInt)
    onException (do
        _ <- propagateGError $ ostree_sysroot_try_lock self' outAcquired
        outAcquired' <- peek outAcquired
        let outAcquired'' = (/= 0) outAcquired'
        touchManagedPtr self
        freeMem outAcquired
        return outAcquired''
     ) (do
        freeMem outAcquired
     )

data SysrootTryLockMethodInfo
instance (signature ~ (m (Bool)), MonadIO m, IsSysroot a) => O.MethodInfo SysrootTryLockMethodInfo a signature where
    overloadedMethod _ = sysrootTryLock

-- method Sysroot::unload
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "Sysroot"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Sysroot", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "ostree_sysroot_unload" ostree_sysroot_unload :: 
    Ptr Sysroot ->                          -- self : TInterface (Name {namespace = "OSTree", name = "Sysroot"})
    IO ()

{- |
Release any resources such as file descriptors referring to the
root directory of this sysroot.  Normally, those resources are
cleared by finalization, but in garbage collected languages that
may not be predictable.

This undoes the effect of @ostree_sysroot_load()@.
-}
sysrootUnload ::
    (B.CallStack.HasCallStack, MonadIO m, IsSysroot a) =>
    a
    {- ^ /@self@/: Sysroot -}
    -> m ()
sysrootUnload self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    ostree_sysroot_unload self'
    touchManagedPtr self
    return ()

data SysrootUnloadMethodInfo
instance (signature ~ (m ()), MonadIO m, IsSysroot a) => O.MethodInfo SysrootUnloadMethodInfo a signature where
    overloadedMethod _ = sysrootUnload

-- method Sysroot::unlock
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "Sysroot"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Self", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "ostree_sysroot_unlock" ostree_sysroot_unlock :: 
    Ptr Sysroot ->                          -- self : TInterface (Name {namespace = "OSTree", name = "Sysroot"})
    IO ()

{- |
Clear the lock previously acquired with 'GI.OSTree.Objects.Sysroot.sysrootLock'.  It
is safe to call this function if the lock has not been previously
acquired.
-}
sysrootUnlock ::
    (B.CallStack.HasCallStack, MonadIO m, IsSysroot a) =>
    a
    {- ^ /@self@/: Self -}
    -> m ()
sysrootUnlock self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    ostree_sysroot_unlock self'
    touchManagedPtr self
    return ()

data SysrootUnlockMethodInfo
instance (signature ~ (m ()), MonadIO m, IsSysroot a) => O.MethodInfo SysrootUnlockMethodInfo a signature where
    overloadedMethod _ = sysrootUnlock

-- method Sysroot::write_deployments
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "Sysroot"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Sysroot", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "new_deployments", argType = TPtrArray (TInterface (Name {namespace = "OSTree", name = "Deployment"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "List of new deployments", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Cancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_sysroot_write_deployments" ostree_sysroot_write_deployments :: 
    Ptr Sysroot ->                          -- self : TInterface (Name {namespace = "OSTree", name = "Sysroot"})
    Ptr (GPtrArray (Ptr OSTree.Deployment.Deployment)) -> -- new_deployments : TPtrArray (TInterface (Name {namespace = "OSTree", name = "Deployment"}))
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Assuming /@newDeployments@/ have already been deployed in place on
disk, atomically update bootloader configuration.
-}
sysrootWriteDeployments ::
    (B.CallStack.HasCallStack, MonadIO m, IsSysroot a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@self@/: Sysroot -}
    -> [OSTree.Deployment.Deployment]
    {- ^ /@newDeployments@/: List of new deployments -}
    -> Maybe (b)
    {- ^ /@cancellable@/: Cancellable -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
sysrootWriteDeployments self newDeployments cancellable = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    newDeployments' <- mapM unsafeManagedPtrCastPtr newDeployments
    newDeployments'' <- packGPtrArray newDeployments'
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ ostree_sysroot_write_deployments self' newDeployments'' maybeCancellable
        touchManagedPtr self
        mapM_ touchManagedPtr newDeployments
        whenJust cancellable touchManagedPtr
        unrefPtrArray newDeployments''
        return ()
     ) (do
        unrefPtrArray newDeployments''
     )

data SysrootWriteDeploymentsMethodInfo
instance (signature ~ ([OSTree.Deployment.Deployment] -> Maybe (b) -> m ()), MonadIO m, IsSysroot a, Gio.Cancellable.IsCancellable b) => O.MethodInfo SysrootWriteDeploymentsMethodInfo a signature where
    overloadedMethod _ = sysrootWriteDeployments

-- method Sysroot::write_origin_file
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "sysroot", argType = TInterface (Name {namespace = "OSTree", name = "Sysroot"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "System root", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "deployment", argType = TInterface (Name {namespace = "OSTree", name = "Deployment"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Deployment", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "new_origin", argType = TInterface (Name {namespace = "GLib", name = "KeyFile"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Origin content", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Cancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_sysroot_write_origin_file" ostree_sysroot_write_origin_file :: 
    Ptr Sysroot ->                          -- sysroot : TInterface (Name {namespace = "OSTree", name = "Sysroot"})
    Ptr OSTree.Deployment.Deployment ->     -- deployment : TInterface (Name {namespace = "OSTree", name = "Deployment"})
    Ptr GLib.KeyFile.KeyFile ->             -- new_origin : TInterface (Name {namespace = "GLib", name = "KeyFile"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Immediately replace the origin file of the referenced /@deployment@/
with the contents of /@newOrigin@/.  If /@newOrigin@/ is 'Nothing',
this function will write the current origin of /@deployment@/.
-}
sysrootWriteOriginFile ::
    (B.CallStack.HasCallStack, MonadIO m, IsSysroot a, OSTree.Deployment.IsDeployment b, Gio.Cancellable.IsCancellable c) =>
    a
    {- ^ /@sysroot@/: System root -}
    -> b
    {- ^ /@deployment@/: Deployment -}
    -> Maybe (GLib.KeyFile.KeyFile)
    {- ^ /@newOrigin@/: Origin content -}
    -> Maybe (c)
    {- ^ /@cancellable@/: Cancellable -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
sysrootWriteOriginFile sysroot deployment newOrigin cancellable = liftIO $ do
    sysroot' <- unsafeManagedPtrCastPtr sysroot
    deployment' <- unsafeManagedPtrCastPtr deployment
    maybeNewOrigin <- case newOrigin of
        Nothing -> return nullPtr
        Just jNewOrigin -> do
            jNewOrigin' <- unsafeManagedPtrGetPtr jNewOrigin
            return jNewOrigin'
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ ostree_sysroot_write_origin_file sysroot' deployment' maybeNewOrigin maybeCancellable
        touchManagedPtr sysroot
        touchManagedPtr deployment
        whenJust newOrigin touchManagedPtr
        whenJust cancellable touchManagedPtr
        return ()
     ) (do
        return ()
     )

data SysrootWriteOriginFileMethodInfo
instance (signature ~ (b -> Maybe (GLib.KeyFile.KeyFile) -> Maybe (c) -> m ()), MonadIO m, IsSysroot a, OSTree.Deployment.IsDeployment b, Gio.Cancellable.IsCancellable c) => O.MethodInfo SysrootWriteOriginFileMethodInfo a signature where
    overloadedMethod _ = sysrootWriteOriginFile

-- method Sysroot::get_deployment_origin_path
-- method type : MemberFunction
-- Args : [Arg {argCName = "deployment_path", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A deployment path", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "File"}))
-- throws : False
-- Skip return : False

foreign import ccall "ostree_sysroot_get_deployment_origin_path" ostree_sysroot_get_deployment_origin_path :: 
    Ptr Gio.File.File ->                    -- deployment_path : TInterface (Name {namespace = "Gio", name = "File"})
    IO (Ptr Gio.File.File)

{- |
/No description available in the introspection data./
-}
sysrootGetDeploymentOriginPath ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.File.IsFile a) =>
    a
    {- ^ /@deploymentPath@/: A deployment path -}
    -> m Gio.File.File
    {- ^ __Returns:__ Path to deployment origin file -}
sysrootGetDeploymentOriginPath deploymentPath = liftIO $ do
    deploymentPath' <- unsafeManagedPtrCastPtr deploymentPath
    result <- ostree_sysroot_get_deployment_origin_path deploymentPath'
    checkUnexpectedReturnNULL "sysrootGetDeploymentOriginPath" result
    result' <- (wrapObject Gio.File.File) result
    touchManagedPtr deploymentPath
    return result'