packages feed

cabal-macosx 0.2 → 0.2.2

raw patch · 2 files changed

+67/−16 lines, 2 filesnew-uploaderPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

Distribution/MacOSX.hs view
@@ -25,7 +25,8 @@  import Control.Exception import Prelude hiding ( catch )-import Control.Monad (forM_, when)+import Control.Monad (forM_, when, filterM)+import Data.List ( isPrefixOf ) import Data.String.Utils (replace) import Distribution.PackageDescription (PackageDescription(..),                                         Executable(..))@@ -40,7 +41,8 @@ import System.Cmd (system) import System.FilePath import System.Info (os)-import System.Directory (copyFile, createDirectoryIfMissing)+import System.Directory (copyFile, createDirectoryIfMissing, doesDirectoryExist,+                         getHomeDirectory) import System.Exit  import Distribution.MacOSX.AppBuildInfo@@ -78,6 +80,11 @@   -> InstallFlags -> PackageDescription -> LocalBuildInfo -> IO () appBundleInstallHook apps _ iflags pkg localb = when isMacOS $ do   let verbosity = fromFlagOrDefault normal (installVerbosity iflags)+  libraryHaskell  <- flip fmap getHomeDirectory $ (</> "Library/Haskell")+  let standardPrefix = (libraryHaskell ++ "/") `isPrefixOf` prefix installDir+  let applicationsDir = if standardPrefix+                           then libraryHaskell    </> "Applications"+                           else prefix installDir </> "Applications"   createDirectoryIfMissing False applicationsDir   forM_ apps $ \app -> do     let appInfo    = toAppBuildInfo localb app@@ -88,18 +95,53 @@     installExecutableFile    verbosity (exe appPathSrc) (exe appPathTgt)     -- generate a tiny shell script for users who expect to run their     -- applications from the command line with flags and all-    let script = "`dirname $0`" </> "../Applications"-                                </> takeFileName appPathSrc-                                </> "Contents/MacOS" </> appName app-                 ++ " \"$@\""+    let script = if standardPrefix+                    then bundleScriptLibraryHaskell localb app+                    else bundleScriptElsewhere      localb app         scriptFileSrc = buildDir localb   </> "_" ++ appName app <.> "sh"         scriptFileTgt = bindir installDir </> appName app     writeFile scriptFileSrc script     installExecutableFile verbosity scriptFileSrc scriptFileTgt   where     installDir = absoluteInstallDirs pkg localb NoCopyDest-    applicationsDir = prefix installDir </> "Applications" +bundleScriptLibraryHaskell :: LocalBuildInfo -> MacApp -> String+bundleScriptLibraryHaskell localb app = unlines+  [ "#!/bin/bash"+  , "$HOME/Library/Haskell/Applications"+           </> takeFileName appPathSrc+           </> "Contents/MacOS" </> appName app ++ " \"$@\""+  ]+  where+    appInfo    = toAppBuildInfo localb app+    appPathSrc = abAppPath appInfo+ +bundleScriptElsewhere :: LocalBuildInfo -> MacApp -> String+bundleScriptElsewhere localb app = unlines+  [ "#!/bin/bash"+  , "COUNTER=0"+  , "MAX_DEPTH=256"+  , "ZERO=$0"+  , "NZERO=`readlink $ZERO`; STATUS=$?"+  , ""+  , "# The counter is just a safeguard in case I'd done something silly"+  , "while [ $STATUS -eq 0 -a $COUNTER -lt $MAX_DEPTH ]; do"+  , "  let COUNTER=COUNTER+1"+  , "  ZERO=$NZERO"+  , "  NZERO=`readlink $ZERO`; STATUS=$?"+  , "done"+  , "if [ $COUNTER -ge $MAX_DEPTH ]; then"+  , "  echo >&2 Urk! exceeded symlink depth of $MAX_DEPTH trying to dereference $0"+  , "  exit 1"+  , "fi"+  , "`dirname $ZERO`" </> "../Applications"+           </> takeFileName appPathSrc+           </> "Contents/MacOS" </> appName app ++ " \"$@\""+  ]+  where+    appInfo    = toAppBuildInfo localb app+    appPathSrc = abAppPath appInfo+  isMacOS :: Bool isMacOS = os == "darwin" @@ -182,7 +224,10 @@   FilePath -- ^ Path to application bundle root.   -> MacApp -> IO () osxIncantations appPath app =-  do putStrLn "Running Rez, etc."+  do dtools <- developerTools+     let rez     = dtools </> "Rez"+         setFile = dtools </> "SetFile"+     putStrLn "Running Rez, etc."      ExitSuccess <- system $ rez ++ " Carbon.r -o " ++        appPath </> pathInApp app (appName app)      writeFile (appPath </> "PkgInfo") "APPL????"@@ -190,13 +235,19 @@      ExitSuccess <- system $ setFile ++ " -a C " ++ appPath </> "Contents"      return () --- | Path to @Rez@ tool.-rez :: FilePath-rez = "/Developer/Tools/Rez"---- | Path to @SetFile@ tool.-setFile :: FilePath-setFile = "/Developer/Tools/SetFile"+-- | Path to the developer tools directory, if one exists+developerTools :: IO FilePath+developerTools =+   do ds <- filterM doesDirectoryExist cands+      case ds of+        [] -> do putStrLn $ "Can't find the developer tools directory. Have you installed the Developer tools?\n"+                            ++ "I tried looking for:\n" ++ unlines (map ("* " ++) cands)+                 exitWith (ExitFailure 1)+        (d:_) -> return d+  where+    cands = [ "/Applications/XCode.app/Contents/Developer/Tools"+            , "/Developer/Tools"+            ]  -- | Default plist template, based on that in macosx-app from wx (but -- with version stuff removed).
cabal-macosx.cabal view
@@ -1,5 +1,5 @@ Name:                   cabal-macosx-Version:                0.2+Version:                0.2.2 Stability:              Alpha Synopsis:               Cabal support for creating Mac OSX application bundles. Description: