summaryrefslogtreecommitdiff
path: root/Property
diff options
context:
space:
mode:
Diffstat (limited to 'Property')
-rw-r--r--Property/Apt.hs11
-rw-r--r--Property/Cmd.hs7
-rw-r--r--Property/JoeySites.hs22
3 files changed, 36 insertions, 4 deletions
diff --git a/Property/Apt.hs b/Property/Apt.hs
index 5c0a32c3..b89fb30b 100644
--- a/Property/Apt.hs
+++ b/Property/Apt.hs
@@ -76,22 +76,25 @@ installed ps = check (isInstallable ps) go
go = runApt $ [Param "-y", Param "install"] ++ map Param ps
removed :: [Package] -> Property
-removed ps = check (or <$> isInstalled ps) go
+removed ps = check (or <$> isInstalled' ps) go
`describe` (unwords $ "apt removed":ps)
where
go = runApt $ [Param "-y", Param "remove"] ++ map Param ps
isInstallable :: [Package] -> IO Bool
isInstallable ps = do
- l <- isInstalled ps
+ l <- isInstalled' ps
return $ any (== False) l && not (null l)
+isInstalled :: Package -> IO Bool
+isInstalled p = (== [True]) <$> isInstalled' [p]
+
{- Note that the order of the returned list will not always
- correspond to the order of the input list. The number of items may
- even vary. If apt does not know about a package at all, it will not
- be included in the result list. -}
-isInstalled :: [Package] -> IO [Bool]
-isInstalled ps = catMaybes . map parse . lines
+isInstalled' :: [Package] -> IO [Bool]
+isInstalled' ps = catMaybes . map parse . lines
<$> readProcess "apt-cache" ("policy":ps)
where
parse l
diff --git a/Property/Cmd.hs b/Property/Cmd.hs
index b29a12b3..0a4a5ba4 100644
--- a/Property/Cmd.hs
+++ b/Property/Cmd.hs
@@ -1,10 +1,12 @@
module Property.Cmd (
cmdProperty,
cmdProperty',
+ scriptProperty,
module Utility.SafeCommand
) where
import Control.Applicative
+import Data.List
import Types
import Utility.Monad
@@ -26,3 +28,8 @@ cmdProperty' cmd params env = Property desc $ do
showp (Params s) = s
showp (Param s) = s
showp (File s) = s
+
+scriptProperty :: [String] -> Property
+scriptProperty script = cmdProperty "sh" [Param "-c", Param shellcmd]
+ where
+ shellcmd = intercalate " && " script
diff --git a/Property/JoeySites.hs b/Property/JoeySites.hs
new file mode 100644
index 00000000..35d51095
--- /dev/null
+++ b/Property/JoeySites.hs
@@ -0,0 +1,22 @@
+{- Specific configuation for Joey Hess's sites. Probably not useful to
+ - others except as an example. -}
+
+module Property.JoeySites where
+
+import Common
+import qualified Property.Apt as Apt
+
+oldUseNetshellBox :: Property
+oldUseNetshellBox = check (not <$> Apt.isInstalled "oldusenet") $
+ propertyList ("olduse.net shellbox")
+ [ Apt.installed (words "build-essential git ghc libghc-strptime-dev libghc-hamlet-dev libghc-ifelse-dev libghc-hxt-dev libghc-utf8-string-dev libghc-missingh-dev libghc-sha-dev")
+ `describe` "olduse.net build deps"
+ , scriptProperty
+ [ "git clone git://olduse.net/ /root/tmp/oldusenet/source"
+ , "cd /root/tmp/oldusenet/source/"
+ , "dpkg-buildpackage -us -uc"
+ , "dpkg -i ../oldusenet*.deb || true"
+ , "apt-get -f install" -- dependencies
+ , "rm -rf /root/tmp/oldusenet"
+ ] `describe` "olduse.net built"
+ ]