try Apple AArch64 again
[cabal.git] / cabal-dev-scripts / src / GenValidateDockerfile.hs
blob61ed1eda13abdac72aab3e175af0b626e40b0f6c
1 {-# LANGUAGE DeriveGeneric #-}
2 {-# LANGUAGE ScopedTypeVariables #-}
3 module Main (main) where
5 import Control.Exception (SomeException (..), catch, displayException)
6 import GHC.Generics (Generic)
7 import System.Environment (getArgs)
8 import System.Exit (exitFailure)
10 import qualified Data.Map as Map
11 import qualified Zinza as Z
13 withIO :: (String -> FilePath -> FilePath -> IO a) -> IO a
14 withIO k = do
15 args <- getArgs
16 case args of
17 [version,src,tgt]
18 -> k version src tgt `catch` \(SomeException e) -> do
19 putStrLn $ "Exception: " ++ displayException e
20 exitFailure
21 _ -> do
22 putStrLn "Usage cabal run ... version"
23 exitFailure
25 main :: IO ()
26 main = withIO $ \version src tgt -> do
27 render <- Z.parseAndCompileTemplateIO src
28 case Map.lookup version params of
29 Just z -> do
30 contents <- render z
31 writeFile tgt contents
33 Nothing -> do
34 putStrLn $ "Unknown version " ++ version
35 exitFailure
37 -------------------------------------------------------------------------------
38 -- Params
39 -------------------------------------------------------------------------------
41 params :: Map.Map String Z
42 params = Map.fromList
43 [ pair "8.10.4" $ Z "ghc-8.10.4" "8.10.4-bionic" False True False True ""
44 , pair "8.8.4" $ Z "ghc-8.8.4" "8.8.4-bionic" False True False True "--doctest --solver-benchmarks --complete-hackage"
45 , pair "8.6.5" $ Z "ghc-8.6.5" "8.6.5-bionic" False True False True ""
46 , pair "8.4.4" $ Z "ghc-8.4.4" "8.4.4-bionic" False True False True ""
47 , pair "8.2.2" $ Z "ghc-8.2.2" "8.2.2-bionic" True True False True ""
49 where
50 pair = (,)
52 -------------------------------------------------------------------------------
53 -- Data
54 -------------------------------------------------------------------------------
56 data Z = Z
57 { zGhc :: String
58 , zImage :: String
59 , zParsecCompat :: Bool
60 , zHasTransformers :: Bool
61 , zNeedsDynamic :: Bool
62 , zClient :: Bool
63 , zArgs :: String
65 deriving (Generic)
67 instance Z.Zinza Z where
68 toType = Z.genericToTypeSFP
69 toValue = Z.genericToValueSFP
70 fromValue = Z.genericFromValueSFP