cabal2arch 0.3.3 → 0.3.4
raw patch · 2 files changed
+65/−23 lines, 2 files
Files
- Main.hs +64/−22
- cabal2arch.cabal +1/−1
Main.hs view
@@ -13,7 +13,7 @@ -- Portability: -- --- TODO: libraries should be "haskell-$packagefoo"+-- TODO: LICENSE file might be missing. import Distribution.PackageDescription import Distribution.PackageDescription.Configuration@@ -80,7 +80,12 @@ ["--help"] -> help ["-h"] -> help _ -> return ()- email <- maybe "" id `fmap` getEnvMaybe "DARCS_EMAIL"+ email <- do+ r <- getEnvMaybe "ARCH_HASKELL" + case r of+ Nothing -> do hPutStrLn stderr "Warning: ARCH_HASKELL environment variable not set. Set this to the maintainer contat you wish to use. \n E.g. 'Arch Haskell Team <arch-haskell@haskell.com>'"+ return []+ Just s -> return s cabalfile <- findCabalFile cwd tmp hPutStrLn stderr $ "Using " ++ cabalfile@@ -112,7 +117,7 @@ dir = arch_pkgname pkgbuild setCurrentDirectory cwd- createDirectory dir+ createDirectoryIfMissing False dir setCurrentDirectory dir writeFile "PKGBUILD" (render doc ++ "\n")@@ -277,7 +282,7 @@ findCLibs :: PackageDescription -> [String] findCLibs (PackageDescription { library = lib, executables = exe }) = -- warn for packages not in list.- map canonicalise (some ++ rest)+ map (canonicalise . map toLower) (some ++ rest) where some = concatMap (extraLibs.buildInfo) exe rest = case lib of@@ -285,31 +290,45 @@ Just l -> extraLibs (libBuildInfo l) canonicalise k = case M.lookup k translationTable of- Nothing -> trace "WARNING: this library depends on a C library we do not know the pacman name for. Check the C library names in the generated PKGBUILD File" $ map toLower k+ Nothing -> trace ("WARNING: this library depends on a C library we do not know the pacman name for (" ++ map toLower k ++ ") . Check the C library names in the generated PKGBUILD File") $ map toLower k Just s -> s -- known pacman packages for C libraries we use: translationTable = M.fromList- [("curses", "ncurses")+ [("Imlib2", "imlib2")+ ,("SDL", "sdl")+ ,("alut", "freealut") ,("bz2", "bzip2")- ,("z", "zlib")- ,("Imlib2", "imlib2") ,("cblas", "blas")- ,("curl", "curl")- ,("xenctl", "xen")- ,("odbc", "unixodbc") ,("crack", "cracklib")- ,("pq", "postgresql")+ ,("crypto", "openssl")+ ,("curl", "curl")+ ,("freetype", "freetype2") ,("glib", "glib2")++ ,("jpeg", "libjpeg") ,("ldap", "libldap")- ,("SDL", "sdl")- ,("pcap", "libpcap")+ ,("pcap", "libpcap")+ ,("png", "libpng")+ ,("x11", "libx11")+ ,("xrandr", "libxrandr")+ ,("xml2", "libxml2")+ ,("exif", "libexif")+ ,("tiff", "libtiff")+ ,("sndfile", "libsndfile")++ ,("pq", "postgresql")+ ,("ssl", "openssl")+ ,("wx", "wxgtk")+ ,("xenctrl", "xen")+ ,("odbc", "unixodbc")+ ,("z", "zlib")+ ,("curses", "ncurses")++ ,("pthread", "") ,("m", "") ]-- -- TODO careful translation table for haskell libraries too,- --- -- xmonad, ghc, haxml+ -- atlas shouldNotBeLibraries :: [String] shouldNotBeLibraries =@@ -321,6 +340,28 @@ ,"cpphs" ] +-- translate some library dependencies to gtk names+--+gtk2hsIfy :: [Dependency] -> [Dependency]+gtk2hsIfy [] = []+gtk2hsIfy xs | foundSome = Dependency "gtk2hs" AnyVersion :+ [ v | v@(Dependency n _) <- xs+ , n `notElem` gtkLibs ]+ | otherwise = xs++ where+ foundSome = not . null $ filter (`elem` gtkLibs) (map unDep xs)+ unDep (Dependency n _) = n+++gtkLibs :: [String]+gtkLibs =+ ["glade" -- guihaskell+ ,"cairo"+ ,"glib"+ ,"gtk"+ ]+ ------------------------------------------------------------------------ -- Parsing and pretty printing: @@ -339,7 +380,7 @@ , text "pkgver" <=> disp (arch_pkgver pkg) , text "pkgdesc"- <=> doubleQuotes (text (arch_pkgdesc pkg))+ <=> text (show (arch_pkgdesc pkg)) , text "url" <=> doubleQuotes (text (arch_url pkg)) , text "license"@@ -394,8 +435,9 @@ -- TODO: use a real package spec to compute these names -- based on what is in Arch. ArchList- [ ArchDep (Dependency ("haskell" <-> map toLower d) v)- | Dependency d v <- buildDepends cabal ]+ [ ArchDep (Dependency (+ if d /= "gtk2hs" then "haskell" <-> map toLower d else d) v)+ | Dependency d v <- gtk2hsIfy (buildDepends cabal) ] `mappend` anyClibraries @@ -424,7 +466,7 @@ ++ ["runhaskell Setup copy --destdir=$startdir/pkg || return 1"] ++- (if license cabal `notElem` [GPL,LGPL]+ (if not (null (licenseFile cabal)) && license cabal `notElem` [GPL,LGPL] then ["install -D -m644 " ++ licenseFile cabal ++ " $startdir/pkg/usr/share/licenses/$pkgname/LICENSE || return 1" ] else [])
cabal2arch.cabal view
@@ -1,5 +1,5 @@ name: cabal2arch-version: 0.3.3+version: 0.3.4 homepage: http://code.haskell.org/~dons/code/cabal2arch synopsis: Create Arch Linux packages from Cabal packages description: Create Arch Linux packages from Cabal packages