module Azubi.Module.Installable where
import Azubi.Core.Model
import Azubi.Module.Runable
class Installable a where
installed :: a -> State
class Updatable a where
uptodate :: a -> State
data Ebuild = Ebuild String
instance Installable Ebuild where
installed (Ebuild package) = State
[Check "eix" ["--exact", "--nocolor", "--installed", package] (Just $ "check if package " ++ package ++ " is installed")]
[Run "emerge" [package] (Just $ "installing " ++ package)]
Nothing
instance Updatable Ebuild where
uptodate (Ebuild package) = States [AlwaysYes]
[ installed (Ebuild package)
, State
[Not $ Check "eix" ["--upgrade-", "--nocolor", package] Nothing]
[Run "emerge" [package] (Just $ "upgrade " ++ package)]
Nothing
]
Nothing
type RepoUrl = String
data Git = Git RepoUrl Path
instance Installable Git where
installed (Git repository path) = State
[FolderExists path]
[Run "git"
["clone"
, repository
, path]
(Just $ "cloning " ++ repository ++ " to " ++ path)]
Nothing
instance Updatable Git where
uptodate (Git repo path) =
States [AlwaysYes]
[ installed (Git repo path )
, run (Always "git" ["--work-tree=" ++ path, "pull"])
]
Nothing