gregorycollins / cabal2macpkg

A program to generate OSX installer files for Cabal libraries (Haskell Platform)

This URL has Read+Write access

commit  527934abadc2951707356a2e149526e5af672318
tree    6a55a47da7bc2f7deb5a6fbbf842f9e017f26223
parent  5cc4579ef6f30f8fbd38c22bc9a1fb93e3fe6b9a
cabal2macpkg / Main.hs
100644 66 lines (56 sloc) 1.873 kb
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
-- |
-- Module : cabal2macpkg: convert cabal packages to OSX package format
-- Copyright : (c) Gregory D. Collins, 2008-2009
-- License : BSD3
-- Maintainer: greg@gregorycollins.net
--
-- Loosely based on cabal2arch by Don Stewart.
--
-- Rough outline of the process:
--
-- 1. find a .cabal file in the current working directory
--
-- 2. run @cabal build; cabal haddock@ into a staging area
--
-- 3. run @cabal register --gen-script@ to generate a registration
-- script that will be run by the OS X installer
--
-- 4. turn the staging area into a mac package file using the OS X
-- developer tools
--
-- A consequence of this quick n' dirty approach is that in order to
-- build the installer for a cabal package, you need to have already
-- installed all of its dependencies on the build machine.
------------------------------------------------------------------------
 
module Main (
  -- * Program entry point
    main
  , runMakePackage
 ) where
 
 
import Control.Exception
import Control.Monad
 
import System.IO
 
 
------------------------------------------------------------------------
-- local imports
import Program.MakePackage
import Program.MakeMetaPackage
import Program.Options
import Program.Util
 
------------------------------------------------------------------------
-- | Program entry point. Parses command line options, creates a
-- scratch directory, runs the package building process, and cleans up
-- after itself.
------------------------------------------------------------------------
main :: IO ()
main = do
  opts <- getOptions
  bracket getTempDirectory
          --cleanupTempDirectory
          (const $ return ())
          (runMain opts)
 
 
runMain :: Options -> FilePath -> IO ()
runMain opts tempdir =
  if areBuildingMetaPackage opts then
      runMakeMetaPkg opts tempdir
    else
      runMakePackage opts tempdir