Propellor 3.0 is a major new version with large changes to the API.
Property types have been improved to indicate what systems they target. This prevents using eg, Property FreeBSD on a Debian system.
This forum topic is to help users with the upgrade. Post comments if you're having trouble and Joey will get back to you.
Now, the transition guide as far as your config.hs goes:
Add
props
to host definitions.host name & foo & bar
Becomes
host name $ props & foo & bar
Similarly,
propertyList
andcombineProperties
needprops
to be used to combine together properties; they no longer accept lists of properties. (If you have such a list, usetoProps
.)- And similarly, Chroot, Docker, and Systemd container need
props
to be used to combine together the properies used inside them. - The
os
property is removed. Instead useosDebian
,osBuntish
, orosFreeBSD
. These tell the type checker the target OS of a host. - GHC needs
{-# LANGUAGE TypeOperators #-}
to use these fancy types. This is enabled by default for all modules in propellor.cabal. But if you are using propellor as a library, you may need to enable it manually.
Additional things you need to do if you've written your own properties:
- Change
Property NoInfo
toProperty UnixLike
- Change
Property HasInfo
toProperty (HasInfo + UnixLike)
- Change
RevertableProperty NoInfo
to
RevertableProperty UnixLike UnixLike
- Change
RevertableProperty HasInfo
to
RevertableProperty (HasInfo + UnixLike) UnixLike
- If you know a property only works on a particular OS, like
Debian
orFreeBSD
, use that instead ofUnixLike
. For example:Property Debian
- It's also possible make a property support a set of OS's, for example:
Property (Debian + FreeBSD)
- Removed
infoProperty
andsimpleProperty
constructors, instead useproperty
to construct a Property. Due to the polymorphic type returned by
property
, additional type signatures tend to be needed when using it. For example, this will fail to type check, because the type checker cannot guess what type you intend the intermediate propertygo
to have:foo :: Property UnixLike foo = go `requires` bar where go = property "foo" (return NoChange)
To fix, specify the type of go:
go :: Property UnixLike
ensureProperty
now needs to be passed a witness to the type of the property it's used in.foo = property desc $ ... ensureProperty bar
Becomes
foo = property' desc $ \w -> ... ensureProperty w bar
General purpose properties like cmdProperty have type
Property UnixLike
. When using that to run a command only available on Debian, you can tighten the type to only the OS that your more specific property works on. For example:upgraded :: Property Debian upgraded = tightenTargets (cmdProperty "apt-get" ["upgrade"])
Several utility functions have been renamed:
getInfo to fromInfo
propertyInfo to getInfo
propertyDesc to getDesc
propertyChildren to getChildren
Hello, I am trying to migrate this property
and when I compile it I get this error message
so my question is what is wrong with my code
There are a few things in your example that seem to reference other parts of your schroot module, which I don't have handy. But, I was able to add dummy versions of those (hopefully with close to the real types) and reproduce what looks like the same type errors.
Let's first deal with "type variable x is ambiguous". Because if the type checker cannot infer a type, the other errors are not likely to be useful.
So, the first of these involves the definition of
umount
, which usesproperty
. And like it says in the transition guide:So, write down the type of
umount
to fix this.Next thing that stuck out to me is that two places are using
toChildProperty
. I'm at a bit of a loss to why, this is a new function that's a bit of an implementation detail, documented as "Gets a ChildProperty representing the Property. You should not normally need to use this." And indeed, you do not need to use it here. I simply removed it, and the types lined up without it, hurrah!With those fixes, my version of the code is compiling.
Hope this helps!
BTW, looks like you also have a type error outside the code you showed, on line 98 of Sbuild.hs, which again looks to need the type of
property
to be explicitly specified to fix it.Thanks to your help I could convert my config.h... BUT now the compilation of my config.hs files eat all my RAM and faild after filling all the swap. I have a small computer i386 with only 700 Mo of RAM. Are you aware of this sort of "side effect" with 3.0.1 ?
Memory use did go up. Building with -O0 helped a lot for me, and it's doing ok on a 500 mb memory machine. So I recommend -O0 in your cabal file if you don't have that already.
I wrote down my memory benchmarks here: http://source.propellor.branchable.com/?p=source.git;a=commit;h=af7b2d61c0c7f9b4fe53d8f5d18b5426a93cbd7b