diff options
| author | Joey Hess <joeyh@joeyh.name> | 2017-11-16 14:17:33 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2017-11-16 14:34:07 -0400 |
| commit | 22bad99dc00df153aaefe3b5445116b142294504 (patch) | |
| tree | 8594a4bd5c932de212395889922803f3fa0c8f04 /src/Propellor/Property/Qemu.hs | |
| parent | 5ff40b7d8501f3f7a537a049a2d0cdd14ff7b226 (diff) | |
Debootstrap.built now supports bootstrapping chroots for foreign OS's
This commit was sponsored by Ethan Aubin.
Diffstat (limited to 'src/Propellor/Property/Qemu.hs')
| -rw-r--r-- | src/Propellor/Property/Qemu.hs | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/Propellor/Property/Qemu.hs b/src/Propellor/Property/Qemu.hs new file mode 100644 index 00000000..4d9e8b1f --- /dev/null +++ b/src/Propellor/Property/Qemu.hs @@ -0,0 +1,47 @@ +module Propellor.Property.Qemu where + +import Propellor.Base +import qualified Propellor.Property.Apt as Apt + +-- | Installs qemu user mode emulation binaries, built statically, +-- which allow foreign binaries to run directly. +foreignBinariesEmulated :: RevertableProperty Linux Linux +foreignBinariesEmulated = (setup <!> cleanup) + `describe` "foreign binary emulation" + where + setup = Apt.installed p `pickOS` unsupportedOS + cleanup = Apt.removed p `pickOS` unsupportedOS + p = ["qemu-user-static"] + +-- | Removes qemu user mode emulation binary for the host CPU. +-- This binary is copied into a chroot by qemu-debootstrap, and is not +-- part of any package. +-- +-- Note that removing the binary will prevent using the chroot on the host +-- system. +removeHostEmulationBinary :: Property DebianLike +removeHostEmulationBinary = tightenTargets $ + scriptProperty ["rm -f /usr/bin/qemu-*-static"] + `assume` MadeChange + +-- | Check if the given System supports an Architecture. +-- +-- For example, on Debian, X86_64 supports X86_32, and vice-versa. +supportsArch :: System -> Architecture -> Bool +supportsArch (System os a) b + | a == b = True + | otherwise = case os of + Debian _ _ -> debianlike + Buntish _ -> debianlike + -- don't know about other OS's + _ -> False + where + debianlike = + let l = + [ (X86_64, X86_32) + , (ARMHF, ARMEL) + , (PPC, PPC64) + , (SPARC, SPARC64) + , (S390, S390X) + ] + in elem (a, b) l || elem (b, a) l |
