cabal2arch 0.7.6 → 0.7.7
raw patch · 6 files changed
+372/−61 lines, 6 filesdep +mtldep ~archlinux
Dependencies added: mtl
Dependency ranges changed: archlinux
Files
- Cabal2Arch/Util.hs +115/−0
- Main.hs +19/−59
- cabal2arch.cabal +7/−2
- data/ghc-provides.txt +77/−0
- data/library-providers.txt +110/−0
- data/platform-provides.txt +44/−0
+ Cabal2Arch/Util.hs view
@@ -0,0 +1,115 @@+-- |+-- Module : Cabal2Arch.Util: utility functions for cabal2arch+-- Copyright : (c) Don Stewart, 2008 .. 2010+-- License : BSD3+--+-- Maintainer: Arch Haskell Team <arch-haskell@haskell.org>+-- Stability : provisional++module Cabal2Arch.Util where++import Data.List++import Control.Monad+import Control.Concurrent+import qualified Control.Exception as CE++import System.Directory+import System.Environment+import System.Exit+import System.FilePath+import System.IO+import System.Process hiding(cwd)++import Control.Monad.Trans+import Control.Monad.Error+import Distribution.ArchLinux.SystemProvides++import Paths_cabal2arch++type IOErr a = ErrorT String IO a++------------------------------------------------------------------------+-- Read a file from a URL+--+getFromURL :: String -> IOErr String+getFromURL url = do+ res <- liftIO (myReadProcess "curl" ["-f", url] "")+ case res of+ Left _ -> throwError ("Unable to retrieve " ++ url)+ Right s -> liftIO (return s)++-- Read from a file+getFromFile :: String -> IOErr String+getFromFile path = do+ b <- liftIO (doesFileExist path)+ if not b+ then throwError ("File " ++ path ++ " does not exist!")+ else liftIO (readFile path)++-- getDefaultSystemProvides = getSystemProvidesFromPath "http://andromeda.kiwilight.com/~remy.oudompheng/arch-haskell/default"+getDefaultSystemProvides = getSystemProvidesFromPath =<< (liftIO $ getDataFileName "data")++getSystemProvidesFromPath :: String -> IOErr SystemProvides+getSystemProvidesFromPath dir+ | null dir = getDefaultSystemProvides+ | "http://" `isPrefixOf` dir || "ftp://" `isPrefixOf` dir = do+ fc <- getFromURL (dir </> "ghc-provides.txt")+ fp <- getFromURL (dir </> "platform-provides.txt")+ ft <- getFromURL (dir </> "library-providers.txt")+ return (parseSystemProvides fc fp ft)+ | otherwise = do+ fc <- getFromFile (dir </> "ghc-provides.txt")+ fp <- getFromFile (dir </> "platform-provides.txt")+ ft <- getFromFile (dir </> "library-providers.txt")+ return (parseSystemProvides fc fp ft)++------------------------------------------------------------------------+-- Some extras+--++die :: String -> IO a+die s = do+ hPutStrLn stderr $ "cabal2pkg:\n" ++ s+ exitWith (ExitFailure 1)++-- Safe wrapper for getEnv+getEnvMaybe :: String -> IO (Maybe String)+getEnvMaybe _name = CE.handle ((const :: a -> CE.SomeException -> a) $ return Nothing) (Just `fmap` getEnv _name)++------------------------------------------------------------------------++--+-- Strict process reading+--+myReadProcess :: FilePath -- ^ command to run+ -> [String] -- ^ any arguments+ -> String -- ^ standard input+ -> IO (Either (ExitCode,String,String) String) -- ^ either the stdout, or an exitcode and any output++myReadProcess cmd _args input = CE.handle (return . handler) $ do+ (inh,outh,errh,pid) <- runInteractiveProcess cmd _args Nothing Nothing++ output <- hGetContents outh+ outMVar <- newEmptyMVar+ _ <- forkIO $ (CE.evaluate (length output) >> putMVar outMVar ())++ errput <- hGetContents errh+ errMVar <- newEmptyMVar+ _ <- forkIO $ (CE.evaluate (length errput) >> putMVar errMVar ())++ when (not (null input)) $ hPutStr inh input+ takeMVar outMVar+ takeMVar errMVar+ ex <- CE.catch (waitForProcess pid) ((const :: a -> CE.SomeException -> a) $ return ExitSuccess)+ hClose outh+ hClose inh -- done with stdin+ hClose errh -- ignore stderr++ return $ case ex of+ ExitSuccess -> Right output+ ExitFailure _ -> Left (ex, errput, output)++ where+ handler (ExitFailure e) = Left (ExitFailure e,"","")+ handler e = Left (ExitFailure 1, show e, "")
Main.hs view
@@ -17,7 +17,7 @@ -- rather than makedepends import Distribution.PackageDescription.Parse-import Distribution.PackageDescription+import Distribution.PackageDescription (GenericPackageDescription) import Distribution.Simple.Utils hiding (die) import Distribution.Verbosity import Distribution.Text@@ -29,7 +29,7 @@ import Distribution.ArchLinux.HackageTranslation import Control.Monad-import Control.Concurrent+import Control.Monad.Error import qualified Control.Exception as CE import Data.List@@ -38,25 +38,27 @@ import Text.PrettyPrint import Paths_cabal2arch+import Data.Version (showVersion) import System.Directory-import System.Environment import System.Exit import System.FilePath import System.IO import System.Process hiding(cwd) import System.Console.CmdArgs+import Cabal2Arch.Util data CmdLnArgs- = CmdLnConvertOne { argCabalFile :: String, argCreateTar :: Bool }- | CmdLnConvertMany { argPkgList :: FilePath, argTarBall :: FilePath, argRepo :: FilePath }+ = CmdLnConvertOne { argCabalFile :: String, argCreateTar :: Bool, argDataFiles :: String }+ | CmdLnConvertMany { argPkgList :: FilePath, argTarBall :: FilePath, argRepo :: FilePath, argDataFiles :: String } deriving (Data, Typeable) cmdLnConvertOne :: CmdLnArgs cmdLnConvertOne = CmdLnConvertOne { argCabalFile = "" &= argPos 0 &= typ "FILE|DIR|URL" , argCreateTar = False &= name "tar" &= explicit &= help "Create a tar-ball for the source package."+ , argDataFiles = "" &= name "sysinfo" &= typDir &= explicit &= help "Use custom system information files." } &= auto &= name "conv" &= help "Convert a single CABAL file." cmdLnConvertMany :: CmdLnArgs@@ -64,6 +66,7 @@ { argPkgList = def &= argPos 0 &= typFile , argTarBall = def &= argPos 1 &= typFile , argRepo = def &= argPos 2 &= typDir+ , argDataFiles = "" &= name "sysinfo" &= typDir &= explicit &= help "Use custom system information files." } &= name "convtar" &= help "Convert a tarball of CABAL files into an ABS tree." &= details [ " cabal2arch convtar list tar abs"@@ -75,13 +78,13 @@ cmdLnArgs :: CmdLnArgs cmdLnArgs = modes [cmdLnConvertOne, cmdLnConvertMany] &= program "cabal2arch"- &= summary "cabal2arch: Convert .cabal file to ArchLinux source package"+ &= summary ("cabal2arch, v. " ++ showVersion version ++ ": Convert .cabal file to ArchLinux source package") main :: IO () main = cmdArgs cmdLnArgs >>= subCmd subCmd :: CmdLnArgs -> IO ()-subCmd (CmdLnConvertOne cabalLoc createTar) =+subCmd (CmdLnConvertOne cabalLoc createTar dataFiles) = CE.bracket -- We do all our work in a temp directory (do _cwd <- getCurrentDirectory@@ -116,7 +119,10 @@ cabalsrc <- readPackageDescription normal cabalfile -- Create a package description with all configurations resolved.- sysProvides <- getDefaultSystemProvides+ maybeSysProvides <- runErrorT $ getSystemProvidesFromPath dataFiles+ sysProvides <- case maybeSysProvides of+ Left s -> die s+ Right sp -> return sp let finalcabal = preprocessCabal cabalsrc sysProvides finalcabal' <- case finalcabal of Nothing -> die "Aborting..."@@ -167,7 +173,7 @@ (arch_pkgdesc pkgbuild) (arch_url pkgbuild)) ++ "\n" -subCmd (CmdLnConvertMany pkgListLoc tarballLoc repoLoc) = do+subCmd (CmdLnConvertMany pkgListLoc tarballLoc repoLoc dataFiles) = do pkglist <- readFile pkgListLoc tarball <- Bytes.readFile tarballLoc repo <- canonicalizePath repoLoc@@ -178,7 +184,10 @@ hPutStrLn stderr "Warning: ARCH_HASKELL environment variable not set. Set this to the maintainer contact you wish to use. \n E.g. 'Arch Haskell Team <arch-haskell@haskell.org>'" return [] Just s -> return s- sysProvides <- getDefaultSystemProvides+ maybeSysProvides <- runErrorT $ getSystemProvidesFromPath dataFiles+ sysProvides <- case maybeSysProvides of+ Left s -> die s+ Right sp -> return sp let cabals = getSpecifiedCabalsFromTarball tarball (lines pkglist) mapM_ (exportPackage repo email sysProvides) cabals @@ -266,52 +275,3 @@ then die $ "directory doesn't exist: " ++ show dir else findPackageDesc dir ---------------------------------------------------------------------------- Some extras-----die :: String -> IO a-die s = do- hPutStrLn stderr $ "cabal2pkg:\n" ++ s- exitWith (ExitFailure 1)---- Safe wrapper for getEnv-getEnvMaybe :: String -> IO (Maybe String)-getEnvMaybe _name = CE.handle ((const :: a -> CE.SomeException -> a) $ return Nothing) (Just `fmap` getEnv _name)--------------------------------------------------------------------------------- Strict process reading----myReadProcess :: FilePath -- ^ command to run- -> [String] -- ^ any arguments- -> String -- ^ standard input- -> IO (Either (ExitCode,String,String) String) -- ^ either the stdout, or an exitcode and any output--myReadProcess cmd _args input = CE.handle (return . handler) $ do- (inh,outh,errh,pid) <- runInteractiveProcess cmd _args Nothing Nothing-- output <- hGetContents outh- outMVar <- newEmptyMVar- _ <- forkIO $ (CE.evaluate (length output) >> putMVar outMVar ())-- errput <- hGetContents errh- errMVar <- newEmptyMVar- _ <- forkIO $ (CE.evaluate (length errput) >> putMVar errMVar ())-- when (not (null input)) $ hPutStr inh input- takeMVar outMVar- takeMVar errMVar- ex <- CE.catch (waitForProcess pid) ((const :: a -> CE.SomeException -> a) $ return ExitSuccess)- hClose outh- hClose inh -- done with stdin- hClose errh -- ignore stderr-- return $ case ex of- ExitSuccess -> Right output- ExitFailure _ -> Left (ex, errput, output)-- where- handler (ExitFailure e) = Left (ExitFailure e,"","")- handler e = Left (ExitFailure 1, show e, "")
cabal2arch.cabal view
@@ -1,5 +1,5 @@ name: cabal2arch-version: 0.7.6+version: 0.7.7 homepage: http://github.com/archhaskell/ synopsis: Create Arch Linux packages from Cabal packages. description: Create Arch Linux packages from Cabal packages.@@ -10,6 +10,7 @@ maintainer: ArchHaskell Team <arch-haskell@haskell.org> cabal-version: >= 1.6 build-type: Simple+data-files: data/*.txt source-repository head type: git@@ -28,5 +29,9 @@ bytestring, Cabal > 1.8, filepath,- archlinux >= 0.3.5,+ mtl,+ archlinux >= 0.3.6, cmdargs++ other-modules:+ Cabal2Arch.Util
+ data/ghc-provides.txt view
@@ -0,0 +1,77 @@+##+## Core packages and their versions. These come with+## ghc, so we should be right.+##+## http://haskell.org/haskellwiki/Libraries_released_with_GHC+##+## And what Arch Linux thinks GHC provides:+##+## http://repos.archlinux.org/wsvn/packages/ghc/repos/extra-x86_64/PKGBUILD+##+## Note: we could just list these directly, and have yaourt solve them.+##+## NEW POLICY:+## We rely on all "provides" from the GHC library to be listed explicitly.+##++base==4.1.0.0+dph-base+dph-par+dph-prim-interface+dph-prim-par+dph-prim-seq+dph-seq+ghc+ghc-prim+integer+integer-gmp+ghc-binary++## Official Provides: http://repos.archlinux.org/wsvn/packages/ghc/repos/extra-x86_64/PKGBUILD+#array==0.3.0.1+#bytestring==0.9.1.7+#cabal==1.8.0.6+#containers==0.3.0.0+#directory==1.0.1.1+#extensible-exceptions==0.1.1.1+#filepath==1.1.0.4+#haskell98==1.0.1.1+#hpc==0.5.0.5+#old-locale==1.0.0.2+#old-time==1.0.0.5+#pretty==1.0.1.1+#process==1.0.1.3+#random==1.0.0.2+#syb==0.1.0.2+#template-haskell==2.4.0.1+#time==1.1.4+#unix==2.4.0.2+#haddock==2.6.0+## utf8-string+#+#+## Removed in 6.12.x+# html==1.0.1.2+# integer==0.1.0.0+# QuickCheck==1.2.0.0+# haskell-src==1.0.1.3+# parsec==2.1.0.0+# packedstring==0.1.0.1+# parallel==1.1.0.0+# network==2.2.0.1+# mtl==1.1.0.2+# stm==2.1.1.2+# HUnit==1.2.0.3+# xhtml==3000.2.0.1+# regex-base==0.72.0.2+# regex-compat==0.71.0.1+# regex-posix==0.72.0.2+#+## Removed in 6.10.x+# editline+# ALUT==2.1.0.0+# cgi==3001.1.5.1+# fgl==5.4.1.1 -- gone+# GLUT==2.1.1.1+# OpenAL==1.3.1.1 -- gone+# readline==1.0.1.0
+ data/library-providers.txt view
@@ -0,0 +1,110 @@+# This file lists external library dependencies and the ArchLinux+# packages providing them. For example, if the openssl package+# provides libssl.so, there should be a line+#+# ssl openssl+#++Imlib2 imlib2+SDL sdl+adns adns+alut freealut+bz2 bzip2+cblas blas+crack cracklib+crypto openssl+curl curl+freetype freetype2+glib glib2+wmflite libwmf+il devil++jpeg libjpeg+ldap libldap+pcap libpcap+png libpng+x11 libx11+xrandr libxrandr+xml2 libxml2+libxml libxml2+exif libexif+tiff libtiff+sndfile libsndfile+gcrypt libgcrypt+gnutls gnutls+gnutls-extra gnutls+fftw3 fftw++pq postgresql+ssl openssl+wx wxgtk+odbc unixodbc+z zlib+curses ncurses+xslt libxslt+uuid e2fsprogs+ev libev+pthread glibc+m glibc+gl mesa+glu mesa+glut freeglut+db_cxx db+sqlite3 sqlite3+xdamage libxdamage++icui18n icu+icuuc icu+icudata icu++netsnmp net-snmp+asound alsa-lib+ffi libffi+ogg libogg+theora libtheora+mtp libmtp+cv opencv+highgui opencv+xss libxss+idn libidn+libgsasl gsasl+event libevent+gcc_s gcc-libs+stdc++ gcc-libs++# subsumed into glib++gobject glib2+gmodule glib2+gio glib2+gthread glib+gnome-vfs-module+gstreamer-audio gstreamer0.10-base+gstreamer-base gstreamer0.10+gstreamer-controller gstreamer0.10+gstreamer-dataprotocol gstreamer0.10+gstreamer-net gstreamer0.10+ogremain++webkit libwebkit+cairo cairo+pango pango+pangocairo pango+gtk+ gtk2+gdk gtk+gdk-x11-2.0 gtk2+gtk-x11-2.0 gtk2+vte vte+xine xine-lib+ncurses ncurses+ncursesw ncurses+panel ncurses++gstreamer gstreamer0.10+gstreamer-plugins-base gstreamer0.10-base++# Packages from AUR+xenctrl xen+csound64 csound5+doublefann fann+zmq zeromq
+ data/platform-provides.txt view
@@ -0,0 +1,44 @@+# Packages in GHC 6.12+array ==0.3.0.1+bytestring ==0.9.1.7+Cabal ==1.8.0.6+containers ==0.3.0.0+directory ==1.0.1.1+extensible-exceptions ==0.1.1.1+filepath ==1.1.0.4+haskell98 ==1.0.1.1+hpc ==0.5.0.5+old-locale ==1.0.0.2+old-time ==1.0.0.5+pretty ==1.0.1.1+process ==1.0.1.3+random ==1.0.0.2+syb ==0.1.0.2+template-haskell ==2.4.0.1+time ==1.1.4+unix ==2.4.0.2+# Packages in HP 2010.2+cgi ==3001.1.7.3+fgl ==5.4.2.3+GLUT ==2.1.2.1+haskell-src ==1.0.1.3+html ==1.0.1.2+HUnit ==1.2.2.1+mtl ==1.1.0.2,+network ==2.2.1.7+OpenGL ==2.2.3.0+parallel ==2.2.0.1+parsec ==2.1.0.1+QuickCheck ==2.1.1.1+regex-base ==0.93.2+regex-compat ==0.93.1+regex-posix ==0.94.2+stm ==2.1.2.1+xhtml ==3000.2.0.1+zlib ==0.5.2.0+HTTP ==4000.0.9+deepseq ==1.1.0.0+cabal-install ==0.8.2+alex ==2.3.3+happy ==1.18.5+haddock ==2.7.2