{-# OPTIONS_HADDOCK prune #-}
{-# LANGUAGE TypeFamilies #-}
module Propellor.Property.Sbuild (
UseCcache(..),
built,
update,
osDebianStandard,
keypairGenerated,
keypairInsecurelyGenerated,
usableBy,
userConfig,
) where
import Propellor.Base
import Propellor.Types.Core
import Propellor.Types.Info
import Propellor.Property.Debootstrap (extractSuite)
import qualified Propellor.Property.Apt as Apt
import qualified Propellor.Property.Ccache as Ccache
import qualified Propellor.Property.Chroot as Chroot
import qualified Propellor.Property.ConfFile as ConfFile
import qualified Propellor.Property.Debootstrap as Debootstrap
import qualified Propellor.Property.File as File
import qualified Propellor.Property.Schroot as Schroot
import qualified Propellor.Property.Reboot as Reboot
import qualified Propellor.Property.Localdir as Localdir
import qualified Propellor.Property.User as User
import Data.List
data UseCcache = UseCcache | NoCcache
built
:: UseCcache
-> Props metatypes
-> RevertableProperty (HasInfo + DebianLike) Linux
built :: forall metatypes.
UseCcache
-> Props metatypes
-> RevertableProperty
(HasInfo
+ MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
Linux
built UseCcache
cc Props metatypes
ps = case forall metatypes. Props metatypes -> Maybe System
schrootSystem Props metatypes
ps of
Maybe System
Nothing -> RevertableProperty
(HasInfo
+ MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
Linux
emitError
Just s :: System
s@(System Distribution
_ Architecture
arch) -> case System -> Maybe String
extractSuite System
s of
Maybe String
Nothing -> RevertableProperty
(HasInfo
+ MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
Linux
emitError
Just String
suite -> forall metatypes.
UseCcache
-> Props metatypes
-> String
-> String
-> RevertableProperty
(HasInfo
+ MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
Linux
built' UseCcache
cc Props metatypes
ps String
suite
(Architecture -> String
architectureToDebianArchString Architecture
arch)
where
schrootSystem :: Props metatypes -> Maybe System
schrootSystem :: forall metatypes. Props metatypes -> Maybe System
schrootSystem (Props [ChildProperty]
ps') = forall v. InfoVal v -> Maybe v
fromInfoVal forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall v. IsInfo v => Info -> v
fromInfo forall a b. (a -> b) -> a -> b
$
forall a. Monoid a => [a] -> a
mconcat (forall a b. (a -> b) -> [a] -> [b]
map forall p. IsProp p => p -> Info
getInfo [ChildProperty]
ps')
emitError :: RevertableProperty (HasInfo + DebianLike) Linux
emitError :: RevertableProperty
(HasInfo
+ MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
Linux
emitError = forall {k} (t :: k). SingI t => String -> Property (MetaTypes t)
impossible String
theError forall setupmetatypes undometatypes.
Property setupmetatypes
-> Property undometatypes
-> RevertableProperty setupmetatypes undometatypes
<!> forall {k} (t :: k). SingI t => String -> Property (MetaTypes t)
impossible String
theError
theError :: String
theError = String
"sbuild schroot does not specify suite and/or architecture"
built'
:: UseCcache
-> Props metatypes
-> String
-> String
-> RevertableProperty (HasInfo + DebianLike) Linux
built' :: forall metatypes.
UseCcache
-> Props metatypes
-> String
-> String
-> RevertableProperty
(HasInfo
+ MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
Linux
built' UseCcache
cc (Props [ChildProperty]
ps) String
suite String
arch = Property
(HasInfo
+ MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
provisioned forall setupmetatypes undometatypes.
Property setupmetatypes
-> Property undometatypes
-> RevertableProperty setupmetatypes undometatypes
<!> Property Linux
deleted
where
provisioned :: Property (HasInfo + DebianLike)
provisioned :: Property
(HasInfo
+ MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
provisioned = forall {k} (metatypes :: k).
SingI metatypes =>
String
-> Props (MetaTypes metatypes) -> Property (MetaTypes metatypes)
combineProperties String
desc forall a b. (a -> b) -> a -> b
$ Props UnixLike
props
forall {a} p (y :: [a]) (x :: [a]).
(IsProp p, MetaTypes y ~ GetMetaTypes p,
CheckCombinableNote x y (NoteFor ('Text "&"))) =>
Props (MetaTypes x) -> p -> Props (MetaTypes (Combine x y))
& Property UnixLike
cleanupOldConfig
forall {a} p (y :: [a]) (x :: [a]).
(IsProp p, MetaTypes y ~ GetMetaTypes p,
CheckCombinableNote x y (NoteFor ('Text "&"))) =>
Props (MetaTypes x) -> p -> Props (MetaTypes (Combine x y))
& Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
overlaysKernel
forall {a} p (y :: [a]) (x :: [a]).
(IsProp p, MetaTypes y ~ GetMetaTypes p,
CheckCombinableNote x y (NoteFor ('Text "&"))) =>
Props (MetaTypes x) -> p -> Props (MetaTypes (Combine x y))
& Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
preReqsInstalled
forall {a} p (y :: [a]) (x :: [a]).
(IsProp p, MetaTypes y ~ GetMetaTypes p,
CheckCombinableNote x y (NoteFor ('Text "&"))) =>
Props (MetaTypes x) -> p -> Props (MetaTypes (Combine x y))
& UseCcache
-> Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
ccacheMaybePrepared UseCcache
cc
forall {a} p (y :: [a]) (x :: [a]).
(IsProp p, MetaTypes y ~ GetMetaTypes p,
CheckCombinableNote x y (NoteFor ('Text "&"))) =>
Props (MetaTypes x) -> p -> Props (MetaTypes (Combine x y))
& Chroot -> RevertableProperty (HasInfo + Linux) Linux
Chroot.provisioned Chroot
schroot
forall {a} p (y :: [a]) (x :: [a]).
(IsProp p, MetaTypes y ~ GetMetaTypes p,
CheckCombinableNote x y (NoteFor ('Text "&"))) =>
Props (MetaTypes x) -> p -> Props (MetaTypes (Combine x y))
& String
-> String
-> Property
(MetaTypes
(Combine
(Combine
(Combine
(Combine
(Combine
(Combine
(Combine
(Combine
'[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD]
'[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD])
'[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD])
'[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD])
'[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD])
'[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD])
'[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
'[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD])
'[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD]))
conf String
suite String
arch
where
desc :: String
desc = String
"built sbuild schroot for " forall a. [a] -> [a] -> [a]
++ String
suiteArch
deleted :: Property Linux
deleted :: Property Linux
deleted = forall {k} (metatypes :: k).
SingI metatypes =>
String
-> Props (MetaTypes metatypes) -> Property (MetaTypes metatypes)
combineProperties String
desc forall a b. (a -> b) -> a -> b
$ Props UnixLike
props
forall {a} {k} (x :: [a]) (z :: [a]) (y :: k).
CheckCombinableNote x z (NoteFor ('Text "!")) =>
Props (MetaTypes x)
-> RevertableProperty (MetaTypes y) (MetaTypes z)
-> Props (MetaTypes (Combine x z))
! Chroot -> RevertableProperty (HasInfo + Linux) Linux
Chroot.provisioned Chroot
schroot
forall {a} {k} (x :: [a]) (z :: [a]) (y :: k).
CheckCombinableNote x z (NoteFor ('Text "!")) =>
Props (MetaTypes x)
-> RevertableProperty (MetaTypes y) (MetaTypes z)
-> Props (MetaTypes (Combine x z))
! RevertableProperty UnixLike UnixLike
compatSymlink
forall {a} p (y :: [a]) (x :: [a]).
(IsProp p, MetaTypes y ~ GetMetaTypes p,
CheckCombinableNote x y (NoteFor ('Text "&"))) =>
Props (MetaTypes x) -> p -> Props (MetaTypes (Combine x y))
& String -> Property UnixLike
File.notPresent String
schrootConf
where
desc :: String
desc = String
"no sbuild schroot for " forall a. [a] -> [a] -> [a]
++ String
suiteArch
conf :: String
-> String
-> Property
(MetaTypes
(Combine
(Combine
(Combine
(Combine
(Combine
(Combine
(Combine
(Combine
'[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD]
'[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD])
'[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD])
'[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD])
'[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD])
'[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD])
'[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
'[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD])
'[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD]))
conf String
suite' String
arch' = forall {k} (metatypes :: k).
SingI metatypes =>
String
-> Props (MetaTypes metatypes) -> Property (MetaTypes metatypes)
combineProperties String
"sbuild config file" forall a b. (a -> b) -> a -> b
$ Props UnixLike
props
forall {a} p (y :: [a]) (x :: [a]).
(IsProp p, MetaTypes y ~ GetMetaTypes p,
CheckCombinableNote x y (NoteFor ('Text "&"))) =>
Props (MetaTypes x) -> p -> Props (MetaTypes (Combine x y))
& String -> String -> Property UnixLike
pair String
"description" (String
suite' forall a. [a] -> [a] -> [a]
++ String
"/" forall a. [a] -> [a] -> [a]
++ String
arch' forall a. [a] -> [a] -> [a]
++ String
" autobuilder")
forall {a} p (y :: [a]) (x :: [a]).
(IsProp p, MetaTypes y ~ GetMetaTypes p,
CheckCombinableNote x y (NoteFor ('Text "&"))) =>
Props (MetaTypes x) -> p -> Props (MetaTypes (Combine x y))
& String -> String -> Property UnixLike
pair String
"groups" String
"root,sbuild"
forall {a} p (y :: [a]) (x :: [a]).
(IsProp p, MetaTypes y ~ GetMetaTypes p,
CheckCombinableNote x y (NoteFor ('Text "&"))) =>
Props (MetaTypes x) -> p -> Props (MetaTypes (Combine x y))
& String -> String -> Property UnixLike
pair String
"root-groups" String
"root,sbuild"
forall {a} p (y :: [a]) (x :: [a]).
(IsProp p, MetaTypes y ~ GetMetaTypes p,
CheckCombinableNote x y (NoteFor ('Text "&"))) =>
Props (MetaTypes x) -> p -> Props (MetaTypes (Combine x y))
& String -> String -> Property UnixLike
pair String
"profile" String
"sbuild"
forall {a} p (y :: [a]) (x :: [a]).
(IsProp p, MetaTypes y ~ GetMetaTypes p,
CheckCombinableNote x y (NoteFor ('Text "&"))) =>
Props (MetaTypes x) -> p -> Props (MetaTypes (Combine x y))
& String -> String -> Property UnixLike
pair String
"type" String
"directory"
forall {a} p (y :: [a]) (x :: [a]).
(IsProp p, MetaTypes y ~ GetMetaTypes p,
CheckCombinableNote x y (NoteFor ('Text "&"))) =>
Props (MetaTypes x) -> p -> Props (MetaTypes (Combine x y))
& String -> String -> Property UnixLike
pair String
"directory" String
schrootRoot
forall {a} p (y :: [a]) (x :: [a]).
(IsProp p, MetaTypes y ~ GetMetaTypes p,
CheckCombinableNote x y (NoteFor ('Text "&"))) =>
Props (MetaTypes x) -> p -> Props (MetaTypes (Combine x y))
& Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
unionTypeOverlay
forall {a} p (y :: [a]) (x :: [a]).
(IsProp p, MetaTypes y ~ GetMetaTypes p,
CheckCombinableNote x y (NoteFor ('Text "&"))) =>
Props (MetaTypes x) -> p -> Props (MetaTypes (Combine x y))
& Property UnixLike
aliasesLine
forall {a} p (y :: [a]) (x :: [a]).
(IsProp p, MetaTypes y ~ GetMetaTypes p,
CheckCombinableNote x y (NoteFor ('Text "&"))) =>
Props (MetaTypes x) -> p -> Props (MetaTypes (Combine x y))
& String -> String -> Property UnixLike
pair String
"command-prefix" (forall a. [a] -> [[a]] -> [a]
intercalate String
"," [String]
commandPrefix)
where
pair :: String -> String -> Property UnixLike
pair String
k String
v = String -> (String, String, String) -> Property UnixLike
ConfFile.containsIniSetting String
schrootConf
(String
suiteArch forall a. [a] -> [a] -> [a]
++ String
"-sbuild", String
k, String
v)
unionTypeOverlay :: Property DebianLike
unionTypeOverlay :: Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
unionTypeOverlay = forall {k} (metatypes :: k).
SingI metatypes =>
String
-> (OuterMetaTypesWitness metatypes -> Propellor Result)
-> Property (MetaTypes metatypes)
property' String
"add union-type = overlay" forall a b. (a -> b) -> a -> b
$ \OuterMetaTypesWitness
'[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish]
w ->
Propellor Bool
Schroot.usesOverlays forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Bool
usesOverlays ->
if Bool
usesOverlays
then forall (inner :: [MetaType]) (outer :: [MetaType]).
EnsurePropertyAllowed inner outer =>
OuterMetaTypesWitness outer
-> Property (MetaTypes inner) -> Propellor Result
ensureProperty OuterMetaTypesWitness
'[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish]
w forall a b. (a -> b) -> a -> b
$
String -> String -> Property UnixLike
pair String
"union-type" String
"overlay"
else Propellor Result
noChange
compatSymlink :: RevertableProperty UnixLike UnixLike
compatSymlink = String -> LinkTarget -> RevertableProperty UnixLike UnixLike
File.isSymlinkedTo
(String
"/etc/sbuild/chroot" String -> String -> String
</> String
suiteArch forall a. [a] -> [a] -> [a]
++ String
"-sbuild")
(String -> LinkTarget
File.LinkTarget String
schrootRoot)
aliasesLine :: Property UnixLike
aliasesLine :: Property UnixLike
aliasesLine = forall {k} (metatypes :: k).
SingI metatypes =>
String
-> (OuterMetaTypesWitness metatypes -> Propellor Result)
-> Property (MetaTypes metatypes)
property' String
"maybe set aliases line" forall a b. (a -> b) -> a -> b
$ \OuterMetaTypesWitness
'[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD]
w ->
String -> String -> Propellor Bool
sidHostArchSchroot String
suite String
arch forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Bool
isSidHostArchSchroot ->
if Bool
isSidHostArchSchroot
then forall (inner :: [MetaType]) (outer :: [MetaType]).
EnsurePropertyAllowed inner outer =>
OuterMetaTypesWitness outer
-> Property (MetaTypes inner) -> Propellor Result
ensureProperty OuterMetaTypesWitness
'[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD]
w forall a b. (a -> b) -> a -> b
$
String -> (String, String, String) -> Property UnixLike
ConfFile.containsIniSetting String
schrootConf
( String
suiteArch forall a. [a] -> [a] -> [a]
++ String
"-sbuild"
, String
"aliases"
, String
aliases
)
else forall (m :: * -> *) a. Monad m => a -> m a
return Result
NoChange
overlaysKernel :: Property DebianLike
overlaysKernel :: Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
overlaysKernel = forall {k} (metatypes :: k).
SingI metatypes =>
String
-> (OuterMetaTypesWitness metatypes -> Propellor Result)
-> Property (MetaTypes metatypes)
property' String
"reboot for union-type=overlay" forall a b. (a -> b) -> a -> b
$ \OuterMetaTypesWitness
'[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish]
w ->
Propellor Bool
Schroot.usesOverlays forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Bool
usesOverlays ->
if Bool
usesOverlays
then forall (inner :: [MetaType]) (outer :: [MetaType]).
EnsurePropertyAllowed inner outer =>
OuterMetaTypesWitness outer
-> Property (MetaTypes inner) -> Propellor Result
ensureProperty OuterMetaTypesWitness
'[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish]
w forall a b. (a -> b) -> a -> b
$
String
-> Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
Reboot.toKernelNewerThan String
"3.18"
else Propellor Result
noChange
cleanupOldConfig :: Property UnixLike
cleanupOldConfig :: Property UnixLike
cleanupOldConfig =
forall {k} (metatypes :: k).
SingI metatypes =>
String
-> (OuterMetaTypesWitness metatypes -> Propellor Result)
-> Property (MetaTypes metatypes)
property' String
"old sbuild module config cleaned up" forall a b. (a -> b) -> a -> b
$ \OuterMetaTypesWitness
'[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD]
w -> do
forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ forall (inner :: [MetaType]) (outer :: [MetaType]).
EnsurePropertyAllowed inner outer =>
OuterMetaTypesWitness outer
-> Property (MetaTypes inner) -> Propellor Result
ensureProperty OuterMetaTypesWitness
'[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish,
'Targeting 'OSArchLinux, 'Targeting 'OSFreeBSD]
w forall a b. (a -> b) -> a -> b
$
forall (p :: * -> *) i (m :: * -> *).
(Checkable p i, LiftPropellor m) =>
m Bool -> p i -> Property i
check (String -> IO Bool
doesFileExist String
fstab)
(String -> String -> Property UnixLike
File.lacksLine String
fstab String
aptCacheLine)
forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a.
MonadCatch m =>
m a -> m (Either IOException a)
tryIO forall a b. (a -> b) -> a -> b
$ String -> IO ()
removeDirectoryRecursive String
profile
forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ String -> IO ()
nukeFile String
schrootPiupartsConf
Propellor Result
noChange
where
fstab :: String
fstab = String
"/etc/schroot/sbuild/fstab"
profile :: String
profile = String
"/etc/schroot/piuparts"
schrootPiupartsConf :: String
schrootPiupartsConf = String
"/etc/schroot/chroot.d"
String -> String -> String
</> String
suiteArch forall a. [a] -> [a] -> [a]
++ String
"-piuparts-propellor"
schroot :: Chroot
schroot = forall metatypes.
DebootstrapConfig -> String -> Props metatypes -> Chroot
Chroot.debootstrapped DebootstrapConfig
Debootstrap.BuilddD
String
schrootRoot (forall metatypes. [ChildProperty] -> Props metatypes
Props [ChildProperty]
schrootProps)
schrootProps :: [ChildProperty]
schrootProps =
[ChildProperty]
ps forall a. [a] -> [a] -> [a]
++ [forall p. IsProp p => p -> ChildProperty
toChildProperty forall a b. (a -> b) -> a -> b
$ [String]
-> Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
Apt.installed [String
"eatmydata", String
"ccache"]
, forall p. IsProp p => p -> ChildProperty
toChildProperty forall a b. (a -> b) -> a -> b
$ Property UnixLike
Localdir.removed]
suiteArch :: String
suiteArch = String
suite forall a. [a] -> [a] -> [a]
++ String
"-" forall a. [a] -> [a] -> [a]
++ String
arch
schrootRoot :: String
schrootRoot = String
"/srv/chroot" String -> String -> String
</> String
suiteArch
schrootConf :: String
schrootConf = String
"/etc/schroot/chroot.d"
String -> String -> String
</> String
suiteArch forall a. [a] -> [a] -> [a]
++ String
"-sbuild-propellor"
aliases :: String
aliases = forall a. [a] -> [[a]] -> [a]
intercalate String
","
[ String
"sid"
, String
"rc-buggy"
, String
"experimental"
, String
"UNRELEASED"
, String
"UNRELEASED-"
forall a. [a] -> [a] -> [a]
++ String
arch
forall a. [a] -> [a] -> [a]
++ String
"-sbuild"
]
commandPrefix :: [String]
commandPrefix = case UseCcache
cc of
UseCcache
UseCcache -> String
"/var/cache/ccache-sbuild/sbuild-setup"forall a. a -> [a] -> [a]
:[String]
base
UseCcache
_ -> [String]
base
where
base :: [String]
base = [String
"eatmydata"]
osDebianStandard :: Property Debian
osDebianStandard :: Property Debian
osDebianStandard = forall {k} (metatypes :: k).
SingI metatypes =>
String
-> Props (MetaTypes metatypes) -> Property (MetaTypes metatypes)
propertyList String
"standard Debian sbuild properties" forall a b. (a -> b) -> a -> b
$ Props UnixLike
props
forall {a} p (y :: [a]) (x :: [a]).
(IsProp p, MetaTypes y ~ GetMetaTypes p,
CheckCombinableNote x y (NoteFor ('Text "&"))) =>
Props (MetaTypes x) -> p -> Props (MetaTypes (Combine x y))
& Property Debian
Apt.stdSourcesList
update :: Property DebianLike
update :: Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
update = Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
Apt.update forall x y. Combines x y => x -> y -> CombinedType x y
`before` Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
Apt.upgrade forall x y. Combines x y => x -> y -> CombinedType x y
`before` Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
Apt.autoRemove
aptCacheLine :: String
aptCacheLine :: String
aptCacheLine = String
"/var/cache/apt/archives /var/cache/apt/archives none rw,bind 0 0"
preReqsInstalled :: Property DebianLike
preReqsInstalled :: Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
preReqsInstalled = [String]
-> Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
Apt.installed [String
"piuparts", String
"autopkgtest", String
"lintian", String
"sbuild"]
usableBy :: User -> Property DebianLike
usableBy :: User
-> Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
usableBy User
u = User
-> Group
-> Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
User.hasGroup User
u (String -> Group
Group String
"sbuild") forall x y. Combines x y => x -> y -> CombinedType x y
`requires` Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
preReqsInstalled
keypairGenerated :: Property DebianLike
keypairGenerated :: Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
keypairGenerated = forall (p :: * -> *) i (m :: * -> *).
(Checkable p i, LiftPropellor m) =>
m Bool -> p i -> Property i
check (Bool -> Bool
not forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> IO Bool
doesFileExist String
secKeyFile) forall a b. (a -> b) -> a -> b
$ Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
go
forall x y. Combines x y => x -> y -> CombinedType x y
`requires` Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
preReqsInstalled
forall x y. Combines x y => x -> y -> CombinedType x y
`requires` String -> Property UnixLike
File.dirExists String
"/root/.gnupg"
where
go :: Property DebianLike
go :: Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
go = forall (p :: * -> *) (untightened :: [MetaType])
(tightened :: [MetaType]).
(TightenTargets p, TightenTargetsAllowed untightened tightened,
SingI tightened) =>
p (MetaTypes untightened) -> p (MetaTypes tightened)
tightenTargets forall a b. (a -> b) -> a -> b
$
String -> [String] -> UncheckedProperty UnixLike
cmdProperty String
"sbuild-update" [String
"--keygen"]
forall (p :: * -> *) i.
Checkable p i =>
p i -> Result -> Property i
`assume` Result
MadeChange
secKeyFile :: FilePath
secKeyFile :: String
secKeyFile = String
"/var/lib/sbuild/apt-keys/sbuild-key.sec"
keypairInsecurelyGenerated :: Property DebianLike
keypairInsecurelyGenerated :: Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
keypairInsecurelyGenerated = forall (p :: * -> *) i (m :: * -> *).
(Checkable p i, LiftPropellor m) =>
m Bool -> p i -> Property i
check (Bool -> Bool
not forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> IO Bool
doesFileExist String
secKeyFile) Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
go
where
go :: Property DebianLike
go :: Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
go = forall {k} (metatypes :: k).
SingI metatypes =>
String
-> Props (MetaTypes metatypes) -> Property (MetaTypes metatypes)
combineProperties String
"sbuild keyring insecurely generated" forall a b. (a -> b) -> a -> b
$ Props UnixLike
props
forall {a} p (y :: [a]) (x :: [a]).
(IsProp p, MetaTypes y ~ GetMetaTypes p,
CheckCombinableNote x y (NoteFor ('Text "&"))) =>
Props (MetaTypes x) -> p -> Props (MetaTypes (Combine x y))
& [String]
-> Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
Apt.installed [String
"rng-tools"]
forall {a} p (y :: [a]) (x :: [a]).
(IsProp p, MetaTypes y ~ GetMetaTypes p,
CheckCombinableNote x y (NoteFor ('Text "&"))) =>
Props (MetaTypes x) -> p -> Props (MetaTypes (Combine x y))
& String -> Property UnixLike
File.dirExists String
"/var/lib/sbuild/apt-keys"
forall {a} p (y :: [a]) (x :: [a]).
(IsProp p, MetaTypes y ~ GetMetaTypes p,
CheckCombinableNote x y (NoteFor ('Text "&"))) =>
Props (MetaTypes x) -> p -> Props (MetaTypes (Combine x y))
& User -> [String] -> UncheckedProperty UnixLike
userScriptProperty (String -> User
User String
"root")
[ String
"start-stop-daemon -q -K -R 10 -o -n rngd"
, String
"rngd -r /dev/urandom"
]
forall (p :: * -> *) i.
Checkable p i =>
p i -> Result -> Property i
`assume` Result
MadeChange
forall {a} p (y :: [a]) (x :: [a]).
(IsProp p, MetaTypes y ~ GetMetaTypes p,
CheckCombinableNote x y (NoteFor ('Text "&"))) =>
Props (MetaTypes x) -> p -> Props (MetaTypes (Combine x y))
& Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
keypairGenerated
forall {a} p (y :: [a]) (x :: [a]).
(IsProp p, MetaTypes y ~ GetMetaTypes p,
CheckCombinableNote x y (NoteFor ('Text "&"))) =>
Props (MetaTypes x) -> p -> Props (MetaTypes (Combine x y))
& User -> [String] -> UncheckedProperty UnixLike
userScriptProperty (String -> User
User String
"root")
[String
"kill $(cat /var/run/rngd.pid)"]
forall (p :: * -> *) i.
Checkable p i =>
p i -> Result -> Property i
`assume` Result
MadeChange
ccacheMaybePrepared :: UseCcache -> Property DebianLike
ccacheMaybePrepared :: UseCcache
-> Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
ccacheMaybePrepared UseCcache
cc = case UseCcache
cc of
UseCcache
UseCcache -> Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
ccachePrepared
UseCcache
NoCcache -> forall {k} (t :: k). SingI t => Property (MetaTypes t)
doNothing
ccachePrepared :: Property DebianLike
ccachePrepared :: Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
ccachePrepared = forall {k} (metatypes :: k).
SingI metatypes =>
String
-> Props (MetaTypes metatypes) -> Property (MetaTypes metatypes)
propertyList String
"sbuild group ccache configured" forall a b. (a -> b) -> a -> b
$ Props UnixLike
props
forall {a} p (y :: [a]) (x :: [a]).
(IsProp p, MetaTypes y ~ GetMetaTypes p,
CheckCombinableNote x y (NoteFor ('Text "&"))) =>
Props (MetaTypes x) -> p -> Props (MetaTypes (Combine x y))
& forall (p :: * -> *) i (m :: * -> *).
(Checkable p i, LiftPropellor m) =>
m Bool -> p i -> Property i
check (Bool -> Bool
not forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> IO Bool
doesDirectoryExist String
"/var/cache/ccache-sbuild")
(String
-> Limit
-> Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
Ccache.hasLimits String
"/var/cache/ccache-sbuild" (String -> Limit
Ccache.MaxSize String
"2G"))
forall x y. Combines x y => x -> y -> CombinedType x y
`before` Group
-> Limit
-> RevertableProperty
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
UnixLike
Ccache.hasCache (String -> Group
Group String
"sbuild") Limit
Ccache.NoLimit
forall {a} p (y :: [a]) (x :: [a]).
(IsProp p, MetaTypes y ~ GetMetaTypes p,
CheckCombinableNote x y (NoteFor ('Text "&"))) =>
Props (MetaTypes x) -> p -> Props (MetaTypes (Combine x y))
& String
"/etc/schroot/sbuild/fstab" String -> String -> Property UnixLike
`File.containsLine`
String
"/var/cache/ccache-sbuild /var/cache/ccache-sbuild none rw,bind 0 0"
forall p. IsProp p => p -> String -> p
`describe` String
"ccache mounted in sbuild schroots"
forall {a} p (y :: [a]) (x :: [a]).
(IsProp p, MetaTypes y ~ GetMetaTypes p,
CheckCombinableNote x y (NoteFor ('Text "&"))) =>
Props (MetaTypes x) -> p -> Props (MetaTypes (Combine x y))
& String
"/var/cache/ccache-sbuild/sbuild-setup" String -> [String] -> Property UnixLike
`File.hasContent`
[ String
"#!/bin/sh"
, String
""
, String
"export CCACHE_DIR=/var/cache/ccache-sbuild"
, String
"export CCACHE_UMASK=002"
, String
"export CCACHE_COMPRESS=1"
, String
"unset CCACHE_HARDLINK"
, String
"export PATH=\"/usr/lib/ccache:$PATH\""
, String
""
, String
"exec \"$@\""
]
forall {a} p (y :: [a]) (x :: [a]).
(IsProp p, MetaTypes y ~ GetMetaTypes p,
CheckCombinableNote x y (NoteFor ('Text "&"))) =>
Props (MetaTypes x) -> p -> Props (MetaTypes (Combine x y))
& String -> FileMode -> Property UnixLike
File.mode String
"/var/cache/ccache-sbuild/sbuild-setup"
([FileMode] -> FileMode
combineModes ([FileMode]
readModes forall a. [a] -> [a] -> [a]
++ [FileMode]
executeModes))
userConfig :: User -> Property DebianLike
userConfig :: User
-> Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
userConfig user :: User
user@(User String
u) = Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
go
forall x y. Combines x y => x -> y -> CombinedType x y
`requires` User
-> Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
usableBy User
user
forall x y. Combines x y => x -> y -> CombinedType x y
`requires` Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
preReqsInstalled
where
go :: Property DebianLike
go :: Property
(MetaTypes '[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish])
go = forall {k} (metatypes :: k).
SingI metatypes =>
String
-> (OuterMetaTypesWitness metatypes -> Propellor Result)
-> Property (MetaTypes metatypes)
property' (String
"~/.sbuildrc for " forall a. [a] -> [a] -> [a]
++ String
u) forall a b. (a -> b) -> a -> b
$ \OuterMetaTypesWitness
'[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish]
w -> do
String
h <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (User -> IO String
User.homedir User
user)
forall (inner :: [MetaType]) (outer :: [MetaType]).
EnsurePropertyAllowed inner outer =>
OuterMetaTypesWitness outer
-> Property (MetaTypes inner) -> Propellor Result
ensureProperty OuterMetaTypesWitness
'[ 'Targeting 'OSDebian, 'Targeting 'OSBuntish]
w forall a b. (a -> b) -> a -> b
$ String -> [String] -> Property UnixLike
File.hasContent (String
h String -> String -> String
</> String
".sbuildrc")
[ String
"$run_lintian = 1;"
, String
""
, String
"$run_piuparts = 1;"
, String
"$piuparts_opts = ["
, String
" '--no-eatmydata',"
, String
" '--schroot',"
, String
" '%r-%a-sbuild',"
, String
" '--fail-if-inadequate',"
, String
" ];"
, String
""
, String
"$run_autopkgtest = 1;"
, String
"$autopkgtest_root_args = \"\";"
, String
"$autopkgtest_opts = [\"--\", \"schroot\", \"%r-%a-sbuild\"];"
]
sidHostArchSchroot :: String -> String -> Propellor Bool
sidHostArchSchroot :: String -> String -> Propellor Bool
sidHostArchSchroot String
suite String
arch = do
Maybe System
maybeOS <- Propellor (Maybe System)
getOS
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ case Maybe System
maybeOS of
Maybe System
Nothing -> Bool
False
Just (System Distribution
_ Architecture
hostArch) ->
let hostArch' :: String
hostArch' = Architecture -> String
architectureToDebianArchString Architecture
hostArch
in String
suite forall a. Eq a => a -> a -> Bool
== String
"unstable" Bool -> Bool -> Bool
&& String
hostArch' forall a. Eq a => a -> a -> Bool
== String
arch