Cabal 1.18, 帶有萬眾矚目沙盒功能的 cabal 終於降臨這個世界了!從聽說這版本會導入沙盒功能開始就一直期待到現在,終於出了!或許我們可以準備 cabal-dev 的退休金,讓他回鄉下養老了。關於沙盒功能,有篇文章做了不錯的介紹,歡迎參考。
上面那個其實算是題外話。這裡要紀錄如何修改,讓 cairo-0.12.4.1 (目前,20130906,在 gtk2hs 程式碼倉庫上最新的版本)可以被 cabal 1.18 建置。
首先,要從 gtk2hs 的原始碼倉庫取得最新版的 cairo 原始檔,接著照下面修改:
diff -rN -u old-gtk2hs/cairo/cairo.cabal new-gtk2hs/cairo/cairo.cabal
--- old-gtk2hs/cairo/cairo.cabal 2013-09-06 21:17:11.559949736 +0800
+++ new-gtk2hs/cairo/cairo.cabal 2013-09-06 21:17:11.798946617 +0800
@@ -1,5 +1,5 @@
Name: cairo
-Version: 0.12.4.1
+Version: 0.12.4.1.1
License: BSD3
License-file: COPYRIGHT
Copyright: (c) 2001-2010 The Gtk2Hs Team, (c) Paolo Martini 2005, (c) Abraham Egnor 2003, 2004, (c) Aetion Technologies LLC 2004
diff -rN -u old-gtk2hs/cairo/Gtk2HsSetup.hs new-gtk2hs/cairo/Gtk2HsSetup.hs
--- old-gtk2hs/cairo/Gtk2HsSetup.hs 2013-09-06 21:17:11.557949762 +0800
+++ new-gtk2hs/cairo/Gtk2HsSetup.hs 2013-09-06 21:17:11.797946630 +0800
@@ -17,6 +17,7 @@
import Distribution.Simple
import Distribution.Simple.PreProcess
+import Distribution.Simple.Program.Find (defaultProgramSearchPath)
import Distribution.InstalledPackageInfo ( importDirs,
showInstalledPackageInfo,
libraryDirs,
@@ -441,7 +442,7 @@
checkGtk2hsBuildtools :: [Program] -> IO ()
checkGtk2hsBuildtools programs = do
programInfos <- mapM (\ prog -> do
- location <- programFindLocation prog normal
+ location <- programFindLocation prog normal defaultProgramSearchPath
return (programName prog, location)
) programs
let printError name = do
diff -rN -u old-gtk2hs/cairo/SetupWrapper.hs new-gtk2hs/cairo/SetupWrapper.hs
--- old-gtk2hs/cairo/SetupWrapper.hs 2013-09-06 21:17:11.558949749 +0800
+++ new-gtk2hs/cairo/SetupWrapper.hs 2013-09-06 21:17:11.797946630 +0800
@@ -6,7 +6,7 @@
import Distribution.Package
import Distribution.Compiler
-import Distribution.Simple.Utils
+import Distribution.Simple.Utils hiding (moreRecentFile)
import Distribution.Simple.Program
import Distribution.Simple.Compiler
import Distribution.Simple.BuildPaths (exeExtension)
接著
cd /path/to/your/designated/sandbox
cabal sandbox init
cabal install path/to/patched/cairo
注意事項
如果使用
cabal --with-ghc=your-ghc install
的話有機會導致失敗:在建立安裝程式碼的時候,cabal 似乎會使用系統預設的 ghc ,也就是在系統路徑下可以找到的那個 ghc。如果 your-ghc 的版本和 ghc 差太多,而且各自的預設 haskell 套件庫裡面的 Cabal 版本不一致,就會導致很嚴重且難以追蹤的錯誤。
這樣子弄完後應該就可以使用了。為了弄 Chart 以及 Chart-cairo (Chart-diagrams 好像很悲劇的不能畫出中文)結果被 cairo 卡了好幾個小時...