summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Schroot.hs
diff options
context:
space:
mode:
authorJoey Hess2016-05-23 11:19:21 -0400
committerJoey Hess2016-05-23 11:19:21 -0400
commit96b92edc63a6754f6574325a700b2f1ebea59c59 (patch)
tree92e394ee1862015e207f26413a87d77dd8225b24 /src/Propellor/Property/Schroot.hs
parent7024be7db4021f059380afde9a0f48b99d456bf4 (diff)
parent83c65ad3b4dc3c3c54a0c2c99bf7566739a4a01a (diff)
Merge remote-tracking branch 'spwhitton/sbuild'
Diffstat (limited to 'src/Propellor/Property/Schroot.hs')
-rw-r--r--src/Propellor/Property/Schroot.hs42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/Propellor/Property/Schroot.hs b/src/Propellor/Property/Schroot.hs
new file mode 100644
index 00000000..c53ce4f1
--- /dev/null
+++ b/src/Propellor/Property/Schroot.hs
@@ -0,0 +1,42 @@
+-- | Maintainer: Sean Whitton <spwhitton@spwhitton.name>
+
+module Propellor.Property.Schroot where
+
+import Propellor.Base
+import qualified Propellor.Property.File as File
+import qualified Propellor.Property.Apt as Apt
+
+import Utility.FileMode
+
+-- | Configure schroot such that all schroots with @union-type=overlay@ in their
+-- configuration will run their overlays in a tmpfs.
+--
+-- Shell script from <https://wiki.debian.org/sbuild>.
+overlaysInTmpfs :: Property DebianLike
+overlaysInTmpfs = go `requires` installed
+ where
+ f = "/etc/schroot/setup.d/04tmpfs"
+ go :: Property UnixLike
+ go = f `File.hasContent`
+ [ "#!/bin/sh"
+ , ""
+ , "set -e"
+ , ""
+ , ". \"$SETUP_DATA_DIR/common-data\""
+ , ". \"$SETUP_DATA_DIR/common-functions\""
+ , ". \"$SETUP_DATA_DIR/common-config\""
+ , ""
+ , ""
+ , "if [ $STAGE = \"setup-start\" ]; then"
+ , " mount -t tmpfs overlay /var/lib/schroot/union/overlay"
+ , "elif [ $STAGE = \"setup-recover\" ]; then"
+ , " mount -t tmpfs overlay /var/lib/schroot/union/overlay"
+ , "elif [ $STAGE = \"setup-stop\" ]; then"
+ , " umount -f /var/lib/schroot/union/overlay"
+ , "fi"
+ ]
+ `onChange` (f `File.mode` (combineModes (readModes ++ executeModes)))
+ `describe` "schroot overlays in tmpfs"
+
+installed :: Property DebianLike
+installed = Apt.installed ["schroot"]