summaryrefslogtreecommitdiff
path: root/Portage/GHCCore.hs
blob: 5ebfeeca23e2f9ab5dec36548959e6e746693c5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536

-- Guess GHC version from packages depended upon.
module Portage.GHCCore
        ( minimumGHCVersionToBuildPackage
        , cabalFromGHC
        , finalizePackageDescription
        , platform
        , dependencySatisfiable
        ) where

import qualified Distribution.Compiler as DC
import qualified Distribution.Package as Cabal
import qualified Distribution.Version as Cabal
import Distribution.Version
import Distribution.Simple.PackageIndex
import Distribution.InstalledPackageInfo as IPI

import Distribution.PackageDescription
import Distribution.PackageDescription.Configuration
import Distribution.Compiler (CompilerId(..), CompilerFlavor(GHC))
import Distribution.System

import Distribution.Text

import Data.Maybe
import Data.List ( nub )

import Debug.Trace

-- ghcs tried in specified order.
-- It means that first ghc in this list is a minmum default.
ghcs :: [(DC.CompilerInfo, InstalledPackageIndex)]
ghcs = modern_ghcs
    where modern_ghcs  = [ghc741, ghc742, ghc761, ghc762, ghc782, ghc7101, ghc7102, ghc801, ghc802, ghc821, ghc843, ghc861, ghc863]

cabalFromGHC :: [Int] -> Maybe Cabal.Version
cabalFromGHC ver = lookup ver table
  where
  table = [ ([7,4,2],  Cabal.mkVersion [1,14,0])
          , ([7,6,1],  Cabal.mkVersion [1,16,0])
          , ([7,6,2],  Cabal.mkVersion [1,16,0])
          , ([7,8,2],  Cabal.mkVersion [1,18,1,3])
          , ([7,10,1], Cabal.mkVersion [1,22,2,0])
          , ([7,10,2], Cabal.mkVersion [1,22,4,0])
          , ([8,0,1],  Cabal.mkVersion [1,24,0,0])
          , ([8,0,2],  Cabal.mkVersion [1,24,2,0])
          , ([8,2,1],  Cabal.mkVersion [2,0,0,2])
          , ([8,4,3],  Cabal.mkVersion [2,2,0,1])
          , ([8,6,1],  Cabal.mkVersion [2,4,0,1])
          ]

platform :: Platform
platform = Platform X86_64 Linux

packageIsCore :: InstalledPackageIndex -> Cabal.PackageName -> Bool
packageIsCore index pn = not . null $ lookupPackageName index pn

packageIsCoreInAnyGHC :: Cabal.PackageName -> Bool
packageIsCoreInAnyGHC pn = any (flip packageIsCore pn) (map snd ghcs)

-- | Check if a dependency is satisfiable given a 'PackageIndex'
-- representing the core packages in a GHC version.
-- Packages that are not core will always be accepted, packages that are
-- core in any ghc must be satisfied by the 'PackageIndex'.
dependencySatisfiable :: InstalledPackageIndex -> Cabal.Dependency -> Bool
dependencySatisfiable pindex dep@(Cabal.Dependency pn _rang)
  | Cabal.unPackageName pn == "Win32" = False -- only exists on windows, not in linux
  | not . null $ lookupDependency pindex dep = True -- the package index satisfies the dep
  | packageIsCoreInAnyGHC pn = False -- some other ghcs support the dependency
  | otherwise = True -- the dep is not related with core packages, accept the dep

packageBuildableWithGHCVersion
  :: GenericPackageDescription
  -> FlagAssignment
  -> (DC.CompilerInfo, InstalledPackageIndex)
  -> Either [Cabal.Dependency] (PackageDescription, FlagAssignment)
packageBuildableWithGHCVersion pkg user_specified_fas (compiler_info, pkgIndex) = trace_failure $
  finalizePackageDescription user_specified_fas (dependencySatisfiable pkgIndex) platform compiler_info [] pkg
    where trace_failure v = case v of
              (Left deps) -> trace (unwords ["rejecting dep:" , show_compiler compiler_info
                                            , "as", show_deps deps
                                            , "were not found."
                                            ]
                                   ) v
              _           -> trace (unwords ["accepting dep:" , show_compiler compiler_info
                                            ]
                                   ) v
          show_deps = show . map display
          show_compiler (DC.CompilerInfo { DC.compilerInfoId = CompilerId GHC v }) = "ghc-" ++ display v
          show_compiler c = show c

-- | Given a 'GenericPackageDescription' it returns the miminum GHC version
-- to build a package, and a list of core packages to that GHC version.
minimumGHCVersionToBuildPackage :: GenericPackageDescription -> FlagAssignment -> Maybe ( DC.CompilerInfo
                                                                                        , [Cabal.PackageName]
                                                                                        , PackageDescription
                                                                                        , FlagAssignment
                                                                                        , InstalledPackageIndex)
minimumGHCVersionToBuildPackage gpd user_specified_fas =
  listToMaybe [ (cinfo, packageNamesFromPackageIndex pix, pkg_desc, picked_flags, pix)
              | g@(cinfo, pix) <- ghcs
              , Right (pkg_desc, picked_flags) <- return (packageBuildableWithGHCVersion gpd user_specified_fas g)]

mkIndex :: [Cabal.PackageIdentifier] -> InstalledPackageIndex
mkIndex pids = fromList
  [ emptyInstalledPackageInfo
      { sourcePackageId = pindex
      , exposed = True
      }
  | pindex@(Cabal.PackageIdentifier _name _version) <- pids ]

packageNamesFromPackageIndex :: InstalledPackageIndex -> [Cabal.PackageName]
packageNamesFromPackageIndex pix = nub $ map fst $ allPackagesByName pix

ghc :: [Int] -> DC.CompilerInfo
ghc nrs = DC.unknownCompilerInfo c_id DC.NoAbiTag
    where c_id = CompilerId GHC (mkVersion nrs)

ghc863 :: (DC.CompilerInfo, InstalledPackageIndex)
ghc863 = (ghc [8,6,3], mkIndex ghc863_pkgs)

ghc861 :: (DC.CompilerInfo, InstalledPackageIndex)
ghc861 = (ghc [8,6,1], mkIndex ghc861_pkgs)

ghc843 :: (DC.CompilerInfo, InstalledPackageIndex)
ghc843 = (ghc [8,4,3], mkIndex ghc843_pkgs)

ghc821 :: (DC.CompilerInfo, InstalledPackageIndex)
ghc821 = (ghc [8,2,1], mkIndex ghc821_pkgs)

ghc802 :: (DC.CompilerInfo, InstalledPackageIndex)
ghc802 = (ghc [8,0,2], mkIndex ghc802_pkgs)

ghc801 :: (DC.CompilerInfo, InstalledPackageIndex)
ghc801 = (ghc [8,0,1], mkIndex ghc801_pkgs)

ghc7102 :: (DC.CompilerInfo, InstalledPackageIndex)
ghc7102 = (ghc [7,10,2], mkIndex ghc7102_pkgs)

ghc7101 :: (DC.CompilerInfo, InstalledPackageIndex)
ghc7101 = (ghc [7,10,1], mkIndex ghc7101_pkgs)

ghc782 :: (DC.CompilerInfo, InstalledPackageIndex)
ghc782 = (ghc [7,8,2], mkIndex ghc782_pkgs)

ghc762 :: (DC.CompilerInfo, InstalledPackageIndex)
ghc762 = (ghc [7,6,2], mkIndex ghc762_pkgs)

ghc761 :: (DC.CompilerInfo, InstalledPackageIndex)
ghc761 = (ghc [7,6,1], mkIndex ghc761_pkgs)

ghc742 :: (DC.CompilerInfo, InstalledPackageIndex)
ghc742 = (ghc [7,4,2], mkIndex ghc742_pkgs)

ghc741 :: (DC.CompilerInfo, InstalledPackageIndex)
ghc741 = (ghc [7,4,1], mkIndex ghc741_pkgs)

-- | Non-upgradeable core packages
-- Source: http://haskell.org/haskellwiki/Libraries_released_with_GHC
--         and our binary tarballs (package.conf.d.initial subdir)


ghc863_pkgs :: [Cabal.PackageIdentifier]
ghc863_pkgs =
  [ p "array" [0,5,3,0]
  , p "base" [4,12,0,0]
  , p "binary" [0,8,6,0] -- used by libghc
  , p "bytestring" [0,10,8,2]
--  , p "Cabal" [2,4,0,1]  package is upgradeable
  , p "containers" [0,6,0,1]
  , p "deepseq" [1,4,4,0] -- used by time
  , p "directory" [1,3,3,0]
  , p "filepath" [1,4,2,1]
  , p "ghc-boot" [8,6,3] 
  , p "ghc-boot-th" [8,6,3] 
  , p "ghc-compact" [0,1,0,0]
  , p "ghc-prim" [0,5,3,0]
  , p "ghci" [8,6,3]
--  , p "haskeline" [0,7,4,3]  package is upgradeable
  , p "hpc" [0,6,0,3] -- used by libghc
  , p "integer-gmp" [1,0,2,0]
  --  , p "mtl" [2,2,2]  package is upgradeable(?)
  --  , p "parsec" [3,1,13,0]  package is upgradeable(?)
  , p "pretty" [1,1,3,6]
  , p "process" [1,6,3,0]
  --  , p "stm" [2,5,0,0]  package is upgradeable(?)
  , p "template-haskell" [2,14,0,0] -- used by libghc
  -- , p "terminfo" [0,4,1,2]
  -- , p "text" [1,2,3,1] dependency of Cabal library
  , p "time" [1,8,0,2] -- used by unix, directory, hpc, ghc. unsafe to upgrade
  , p "transformers" [0,5,5,0] -- used by libghc
  , p "unix" [2,7,2,2]
--  , p "xhtml" [3000,2,2,1]
  ]

ghc861_pkgs :: [Cabal.PackageIdentifier]
ghc861_pkgs =
  [ p "array" [0,5,2,0]
  , p "base" [4,12,0,0]
  , p "binary" [0,8,6,0] -- used by libghc
  , p "bytestring" [0,10,8,2]
--  , p "Cabal" [2,4,0,1]  package is upgradeable
  , p "containers" [0,6,0,1]
  , p "deepseq" [1,4,4,0] -- used by time
  , p "directory" [1,3,3,0]
  , p "filepath" [1,4,2,1]
  , p "ghc-boot" [8,6,1] 
  , p "ghc-boot-th" [8,6,1] 
  , p "ghc-compact" [0,1,0,0]
  , p "ghc-prim" [0,5,3,0]
  , p "ghci" [8,6,1]
--  , p "haskeline" [0,7,4,3]  package is upgradeable
  , p "hpc" [0,6,0,3] -- used by libghc
  , p "integer-gmp" [1,0,2,0]
  --  , p "mtl" [2,2,2]  package is upgradeable(?)
  --  , p "parsec" [3,1,13,0]  package is upgradeable(?)
  , p "pretty" [1,1,3,6]
  , p "process" [1,6,3,0]
  --  , p "stm" [2,5,0,0]  package is upgradeable(?)
  , p "template-haskell" [2,14,0,0] -- used by libghc
  -- , p "terminfo" [0,4,1,2]
  -- , p "text" [1,2,3,1] dependency of Cabal library
  , p "time" [1,8,0,2] -- used by unix, directory, hpc, ghc. unsafe to upgrade
  , p "transformers" [0,5,5,0] -- used by libghc
  , p "unix" [2,7,2,2]
--  , p "xhtml" [3000,2,2,1]
  ]

ghc843_pkgs :: [Cabal.PackageIdentifier]
ghc843_pkgs =
  [ p "array" [0,5,2,0]
  , p "base" [4,11,1,0]
  , p "binary" [0,8,5,1] -- used by libghc
  , p "bytestring" [0,10,8,2]
--  , p "Cabal" [2,2,0,1]  package is upgradeable
  , p "containers" [0,5,11,2]
  , p "deepseq" [1,4,3,0] -- used by time
  , p "directory" [1,3,1,5]
  , p "filepath" [1,4,2]
  , p "ghc-boot" [8,4,3]
  , p "ghc-boot-th" [8,4,3]
  , p "ghc-compact" [0,1,0,0]
  , p "ghc-prim" [0,5,2,0]
  , p "ghci" [8,4,3]
--  , p "haskeline" [0,7,4,2]  package is upgradeable
  , p "hpc" [0,6,0,3] -- used by libghc
  , p "integer-gmp" [1,0,2,0]
  --  , p "mtl" [2,2,2]  package is upgradeable(?)
  --  , p "parsec" [3,1,13,0]  package is upgradeable(?)
  , p "pretty" [1,1,3,6]
  , p "process" [1,6,3,0]
  --  , p "stm" [2,4,5,0]  package is upgradeable(?)
  , p "template-haskell" [2,13,0,0] -- used by libghc
  -- , p "terminfo" [0,4,1,1]
  -- , p "text" [1,2,3,0]
  , p "time" [1,8,0,2] -- used by unix, directory, hpc, ghc. unsafe to upgrade
  , p "transformers" [0,5,5,0] -- used by libghc
  , p "unix" [2,7,2,2]
--  , p "xhtml" [3000,2,2,1]
  ]

ghc821_pkgs :: [Cabal.PackageIdentifier]
ghc821_pkgs =
  [ p "array" [0,5,2,0]
  , p "base" [4,10,0,0]
  , p "binary" [0,8,5,1] -- used by libghc
  , p "bytestring" [0,10,8,2]
--  , p "Cabal" [2,0,0,2]  package is upgradeable
  , p "containers" [0,5,10,2]
  , p "deepseq" [1,4,3,0] -- used by time
  , p "directory" [1,3,0,2]
  , p "filepath" [1,4,1,2]
  , p "ghc-boot" [8,2,1]
  , p "ghc-boot-th" [8,2,1]
  , p "ghc-compact" [0,1,0,0]
  , p "ghc-prim" [0,5,1,0]
  , p "ghci" [8,2,1]
--  , p "haskeline" [0,7,4,0]  package is upgradeable
  , p "hoopl" [3,10,2,2] -- used by libghc
  , p "hpc" [0,6,0,3] -- used by libghc
  , p "integer-gmp" [1,0,1,0]
  , p "pretty" [1,1,3,3]
  , p "process" [1,6,1,0]
  , p "template-haskell" [2,12,0,0] -- used by libghc
  -- , p "terminfo" [0,4,1,0]
  , p "time" [1,8,0,2] -- used by unix, directory, hpc, ghc. unsafe to upgrade
  , p "transformers" [0,5,2,0] -- used by libghc
  , p "unix" [2,7,2,2]
--  , p "xhtml" [3000,2,2]
  ]

ghc802_pkgs :: [Cabal.PackageIdentifier]
ghc802_pkgs =
  [ p "array" [0,5,1,1]
  , p "base" [4,9,1,0]
  , p "binary" [0,8,3,0] -- used by libghc
  , p "bytestring" [0,10,8,1]
--  , p "Cabal" [1,24,2,0]  package is upgradeable
  , p "containers" [0,5,7,1]
  , p "deepseq" [1,4,2,0] -- used by time
  , p "directory" [1,3,0,0]
  , p "filepath" [1,4,1,1]
  , p "ghc-boot" [8,0,2]
  , p "ghc-boot-th" [8,0,2]
  , p "ghc-prim" [0,5,0,0]
  , p "ghci" [8,0,2]
--  , p "haskeline" [0,7,3,0]  package is upgradeable
  , p "hoopl" [3,10,2,1] -- used by libghc
  , p "hpc" [0,6,0,3] -- used by libghc
  , p "integer-gmp" [1,0,0,1]
  , p "pretty" [1,1,3,3]
  , p "process" [1,4,3,0]
  , p "template-haskell" [2,11,1,0] -- used by libghc
  -- , p "terminfo" [0,4,0,2]
  , p "time" [1,6,0,1] -- used by unix, directory, hpc, ghc. unsafe to upgrade
  , p "transformers" [0,5,2,0] -- used by libghc
  , p "unix" [2,7,2,1]
--  , p "xhtml" [3000,2,1]
  ]

ghc801_pkgs :: [Cabal.PackageIdentifier]
ghc801_pkgs =
  [ p "array" [0,5,1,1]
  , p "base" [4,9,0,0]
  , p "binary" [0,8,3,0] -- used by libghc
  , p "bytestring" [0,10,8,0]
--  , p "Cabal" [1,24,0,0]  package is upgradeable
  , p "containers" [0,5,7,1]
  , p "deepseq" [1,4,2,0] -- used by time
  , p "directory" [1,2,6,2]
  , p "filepath" [1,4,1,0]
  , p "ghc-boot" [8,0,1]
  , p "ghc-prim" [0,5,0,0]
  , p "ghci" [8,0,1]
  , p "hoopl" [3,10,2,1] -- used by libghc
  , p "hpc" [0,6,0,3] -- used by libghc
  , p "integer-gmp" [1,0,0,1]
  , p "pretty" [1,1,3,3]
  , p "process" [1,4,2,0]
  , p "template-haskell" [2,11,0,0] -- used by libghc
  -- , p "terminfo" [0,4,0,2]
  , p "time" [1,6,0,1] -- used by unix, directory, hpc, ghc. unsafe to upgrade
  , p "transformers" [0,5,2,0] -- used by libghc
  , p "unix" [2,7,2,0]
--  , p "xhtml" [3000,2,1]
  ]

ghc7102_pkgs :: [Cabal.PackageIdentifier]
ghc7102_pkgs =
  [ p "array" [0,5,1,0]
  , p "base" [4,8,1,0]
  , p "binary" [0,7,3,0] -- used by libghc
  , p "bytestring" [0,10,6,0]
--  , p "Cabal" [1,18,1,3]  package is upgradeable
  , p "containers" [0,5,6,2]
  , p "deepseq" [1,4,1,1] -- used by time
  , p "directory" [1,2,2,0]
  , p "filepath" [1,4,0,0]
  , p "ghc-prim" [0,4,0,0]
  -- , p "haskell2010" [1,1,2,0] -- stopped shipping in 7.10, deprecated
  -- , p "haskell98" [2,0,0,3] -- stopped shipping in 7.10, deprecated
  , p "hoopl" [3,10,1,0] -- used by libghc
  , p "hpc" [0,6,0,2] -- used by libghc
  , p "integer-gmp" [1,0,0,0]
  -- , p "old-locale" [1,0,0,6] -- stopped shipping in 7.10, deprecated
  -- , p "old-time" [1,1,0,2] -- stopped shipping in 7.10, deprecated
  , p "pretty" [1,1,2,0]
  , p "process" [1,2,3,0]
  , p "template-haskell" [2,10,0,0] -- used by libghc
  , p "time" [1,5,0,1] -- used by haskell98, unix, directory, hpc, ghc. unsafe to upgrade
  , p "transformers" [0,4,2,0] -- used by libghc
  , p "unix" [2,7,1,0]
  ]

ghc7101_pkgs :: [Cabal.PackageIdentifier]
ghc7101_pkgs =
  [ p "array" [0,5,1,0]
  , p "base" [4,8,0,0]
  , p "binary" [0,7,3,0] -- used by libghc
  , p "bytestring" [0,10,6,0]
--  , p "Cabal" [1,18,1,3]  package is upgradeable
  , p "containers" [0,5,6,2]
  , p "deepseq" [1,4,1,1] -- used by time
  , p "directory" [1,2,2,0]
  , p "filepath" [1,4,0,0]
  , p "ghc-prim" [0,4,0,0]
  -- , p "haskell2010" [1,1,2,0] -- stopped shipping in 7.10, deprecated
  -- , p "haskell98" [2,0,0,3] -- stopped shipping in 7.10, deprecated
  , p "hoopl" [3,10,0,2] -- used by libghc
  , p "hpc" [0,6,0,2] -- used by libghc
  , p "integer-gmp" [1,0,0,0]
  -- , p "old-locale" [1,0,0,6] -- stopped shipping in 7.10, deprecated
  -- , p "old-time" [1,1,0,2] -- stopped shipping in 7.10, deprecated
  , p "pretty" [1,1,2,0]
  , p "process" [1,2,3,0]
  , p "template-haskell" [2,10,0,0] -- used by libghc
  , p "time" [1,5,0,1] -- used by haskell98, unix, directory, hpc, ghc. unsafe to upgrade
  , p "transformers" [0,4,2,0] -- used by libghc
  , p "unix" [2,7,1,0]
  ]

ghc782_pkgs :: [Cabal.PackageIdentifier]
ghc782_pkgs =
  [ p "array" [0,5,0,0]
  , p "base" [4,7,0,0]
  , p "binary" [0,7,1,0] -- used by libghc
  , p "bytestring" [0,10,4,0]
--  , p "Cabal" [1,18,1,3]  package is upgradeable
  , p "containers" [0,5,5,1]
  , p "deepseq" [1,3,0,2] -- used by time, haskell98
  , p "directory" [1,2,1,0]
  , p "filepath" [1,3,0,2]
  , p "ghc-prim" [0,3,1,0]
  , p "haskell2010" [1,1,2,0]
  , p "haskell98" [2,0,0,3]
  , p "hoopl" [3,10,0,1] -- used by libghc
  , p "hpc" [0,6,0,1] -- used by libghc
  , p "integer-gmp" [0,5,1,0]
  -- , p "old-locale" [1,0,0,6] -- stopped shipping in 7.10, deprecated
  -- , p "old-time" [1,1,0,2] -- stopped shipping in 7.10, deprecated
  , p "pretty" [1,1,1,1]
  , p "process" [1,2,0,0]
  , p "template-haskell" [2,9,0,0] -- used by libghc
  , p "time" [1,4,2] -- used by haskell98, unix, directory, hpc, ghc. unsafe to upgrade
  , p "transformers" [0,3,0,0] -- used by libghc
  , p "unix" [2,7,0,1]
  ]

ghc762_pkgs :: [Cabal.PackageIdentifier]
ghc762_pkgs =
  [ p "array" [0,4,0,1]
  , p "base" [4,6,0,1]
  , p "binary" [0,5,1,1] -- used by libghc
  , p "bytestring" [0,10,0,2]
--  , p "Cabal" [1,16,0]  package is upgradeable
  , p "containers" [0,5,0,0]
  , p "deepseq" [1,3,0,1] -- used by time, haskell98
  , p "directory" [1,2,0,1]
  , p "filepath" [1,3,0,1]
  , p "ghc-prim" [0,3,0,0]
  , p "haskell2010" [1,1,1,0]
  , p "haskell98" [2,0,0,2]
  , p "hoopl" [3,9,0,0] -- used by libghc
  , p "hpc" [0,6,0,0] -- used by libghc
  , p "integer-gmp" [0,5,0,0]
  -- , p "old-locale" [1,0,0,5] -- stopped shipping in 7.10, deprecated
  -- , p "old-time" [1,1,0,1] -- stopped shipping in 7.10, deprecated
  , p "pretty" [1,1,1,0]
  , p "process" [1,1,0,2]
  , p "template-haskell" [2,8,0,0] -- used by libghc
  , p "time" [1,4,0,1] -- used by haskell98, unix, directory, hpc, ghc. unsafe to upgrade
  , p "unix" [2,6,0,1]
  ]

ghc761_pkgs :: [Cabal.PackageIdentifier]
ghc761_pkgs =
  [ p "array" [0,4,0,1]
  , p "base" [4,6,0,0]
  , p "binary" [0,5,1,1] -- used by libghc
  , p "bytestring" [0,10,0,0]
--  , p "Cabal" [1,16,0]  package is upgradeable
  , p "containers" [0,5,0,0]
  , p "deepseq" [1,3,0,1] -- used by time, haskell98
  , p "directory" [1,2,0,0]
  , p "filepath" [1,3,0,1]
  , p "ghc-prim" [0,3,0,0]
  , p "haskell2010" [1,1,1,0]
  , p "haskell98" [2,0,0,2]
  , p "hoopl" [3,9,0,0] -- used by libghc
  , p "hpc" [0,6,0,0] -- used by libghc
  , p "integer-gmp" [0,5,0,0]
  -- , p "old-locale" [1,0,0,5] -- stopped shipping in 7.10, deprecated
  -- , p "old-time" [1,1,0,1] -- stopped shipping in 7.10, deprecated
  , p "pretty" [1,1,1,0]
  , p "process" [1,1,0,2]
  , p "template-haskell" [2,8,0,0] -- used by libghc
  , p "time" [1,4,0,1] -- used by haskell98, unix, directory, hpc, ghc. unsafe to upgrade
  , p "unix" [2,6,0,0]
  ]

ghc742_pkgs :: [Cabal.PackageIdentifier]
ghc742_pkgs =
  [ p "array" [0,4,0,0]
  , p "base" [4,5,1,0]
  , p "binary" [0,5,1,0] -- used by libghc
  , p "bytestring" [0,9,2,1]
--  , p "Cabal" [1,14,0]  package is upgradeable
  , p "containers" [0,4,2,1]
  , p "deepseq" [1,3,0,0] -- used by time, haskell98
  , p "directory" [1,1,0,2]
-- , p "extensible-exceptions" [0,1,1,4] -- package is upgradeable, stopped shipping in 7.6
  , p "filepath" [1,3,0,0]
  , p "ghc-prim" [0,2,0,0]
  , p "haskell2010" [1,1,0,1]
  , p "haskell98" [2,0,0,1]
  , p "hoopl" [3,8,7,3] -- used by libghc
  , p "hpc" [0,5,1,1] -- used by libghc
  , p "integer-gmp" [0,4,0,0]
  -- , p "old-locale" [1,0,0,4] -- stopped shipping in 7.10, deprecated
  -- , p "old-time" [1,1,0,0] -- stopped shipping in 7.10, deprecated
  , p "pretty" [1,1,1,0]
  , p "process" [1,1,0,1]
  , p "template-haskell" [2,7,0,0] -- used by libghc
  , p "time" [1,4]
  , p "unix" [2,5,1,1]
  ]

ghc741_pkgs :: [Cabal.PackageIdentifier]
ghc741_pkgs =
  [ p "array" [0,4,0,0]
  , p "base" [4,5,0,0]
  , p "binary" [0,5,1,0] -- used by libghc
  , p "bytestring" [0,9,2,1]
--  , p "Cabal" [1,14,0]  package is upgradeable
  , p "containers" [0,4,2,1]
  , p "deepseq" [1,3,0,0] -- used by time, haskell98
  , p "directory" [1,1,0,2]
-- , p "extensible-exceptions" [0,1,1,4] -- package is upgradeable, stopped shipping in 7.6
  , p "filepath" [1,3,0,0]
  , p "ghc-prim" [0,2,0,0]
  , p "haskell2010" [1,1,0,1]
  , p "haskell98" [2,0,0,1]
  , p "hoopl" [3,8,7,3] -- used by libghc
  , p "hpc" [0,5,1,1] -- used by libghc
  , p "integer-gmp" [0,4,0,0]
  -- , p "old-locale" [1,0,0,4] -- stopped shipping in 7.10, deprecated
  -- , p "old-time" [1,1,0,0] -- stopped shipping in 7.10, deprecated
  , p "pretty" [1,1,1,0]
  , p "process" [1,1,0,1]
  , p "template-haskell" [2,7,0,0] -- used by libghc
  , p "time" [1,4]
  , p "unix" [2,5,1,0]
  ]

p :: String -> [Int] -> Cabal.PackageIdentifier
p pn vs = Cabal.PackageIdentifier (Cabal.mkPackageName pn) (mkVersion vs)