cabal2arch 0.6 → 0.6.1
raw patch · 2 files changed
+50/−230 lines, 2 filesdep +archlinux
Dependencies added: archlinux
Files
- Main.hs +47/−228
- cabal2arch.cabal +3/−2
Main.hs view
@@ -33,6 +33,9 @@ import Distribution.System import Distribution.Simple.PackageIndex +-- from the archlinux package:+import Distribution.ArchLinux.PkgBuild+ import Data.Digest.Pure.MD5 import qualified Data.ByteString.Lazy as B @@ -142,11 +145,23 @@ die "Unable to tar package" Right _ -> putStrLn ("Created " ++ (cwd </> dir <.> "tar.gz")) - -- RSS generation help- writeFile "title" (arch_pkgname pkgbuild ++ "-" ++ (render . disp $ arch_pkgver pkgbuild))- writeFile "desc" (show $ arch_pkgdesc pkgbuild)- writeFile "link" (show $ arch_url pkgbuild)+ -- If the user created a .cabal2arch.log file, append log results there.+ mh <- getEnvMaybe "HOME"+ case mh of+ Nothing -> return ()+ Just home -> do+ b <- doesFileExist $ home </> ".cabal2arch.log"+ if not b+ then return ()+ else do + -- Log to build file.+ appendFile (home </> ".cabal2arch.log") $ (show $ (,,)++ (arch_pkgname pkgbuild ++ "-" ++ (render . disp $ arch_pkgver pkgbuild))+ (arch_pkgdesc pkgbuild)+ (arch_url pkgbuild)) ++ "\n"+ ------------------------------------------------------------------------ -- | Given an abstract pkgbuild, download the source bundle,@@ -180,11 +195,18 @@ -- removeCoreFrom :: [Dependency] -> [Dependency] removeCoreFrom [] = []-removeCoreFrom (x@(Dependency n _):xs) =+removeCoreFrom (x@(Dependency n vr):xs) = case find (\(Dependency k _) -> n == k) corePackages of- Just _ -> removeCoreFrom xs- Nothing -> x : removeCoreFrom xs+ -- haskell-parsec, haskell-quickcheck+ Just (Dependency _ (ThisVersion v'))+ | withinRange v' vr -> removeCoreFrom xs + Just (Dependency (PackageName "base") _)+ -> removeCoreFrom xs++ Just (Dependency _ AnyVersion) -> removeCoreFrom xs+ _ -> x : removeCoreFrom xs+ -- -- Core packages and their versions. These come with -- ghc, so we should be right.@@ -202,7 +224,7 @@ ,Dependency (PackageName "HUnit") (ThisVersion (Version [1,2,0,3] [])) ,Dependency (PackageName "QuickCheck") (ThisVersion (Version [1,2,0,0] [])) ,Dependency (PackageName "array") (ThisVersion (Version [0,2,0,0] []))- ,Dependency (PackageName "base") (ThisVersion (Version [3,0,3,0] []))+ ,Dependency (PackageName "base") (ThisVersion (Version [4,1,0,0] [])) ,Dependency (PackageName "bytestring") (ThisVersion (Version [0,9,1,4] [])) ,Dependency (PackageName "containers") (ThisVersion (Version [0,2,0,0] [])) ,Dependency (PackageName "directory") (ThisVersion (Version [1,0,0,2] []))@@ -372,6 +394,8 @@ ,("gl", "") ,("glu", "") ,("db_cxx", "")+ ,("db_cxx", "")+ ,("xdamage", "") ,("icui18n", "icu") ,("icuuc", "icu")@@ -388,6 +412,7 @@ shouldNotBeLibraries :: [String] shouldNotBeLibraries = ["xmonad"+ ,"gitit" ,"l-seed" ,"hspresent" ,"haskell-platform"@@ -410,9 +435,14 @@ ,"gtk2hs" ,"darcs" ,"greencard"- ,"pandoc"+-- the pandoc package doesnt' ship haskell-pandoc+-- ,"pandoc" ,"pugs-drift" ,"wol"+ ,"timepiece"+ ,"hledger"+ ,"hp2any-graph"+ ,"hp2any-manager" ] -- translate some library dependencies to gtk names@@ -501,7 +531,7 @@ (emptyPkgBuild { arch_pkgname = archName , arch_pkgver = vers- , arch_url = "http://hackage.haskell.org/cgi-bin/hackage-scripts/package/"++display name+ , arch_url = "http://hackage.haskell.org/package/"++display name -- else homepage cabal , arch_pkgdesc = case synopsis cabal of [] -> take 80 (description cabal)@@ -596,6 +626,10 @@ | Dependency (PackageName d) v <- gtk2hsIfy (buildDepends cabal) ] `mappend` anyClibraries+ `mappend`+ ArchList [ ArchDep d | b <- allBuildInfo cabal+ , d@(Dependency n _) <- buildTools b+ , n /= PackageName "hsc2hs" ] -- TODO: need a 'nub' in here. @@ -608,6 +642,9 @@ where libs = [ ArchDep (Dependency (PackageName s) AnyVersion) | s <- nub (findCLibs cabal) ] +-- quickcheck 2.+-- parsec 3+ -- -- post install, and pre-remove hooks to run, to sync up ghc-pkg --@@ -637,224 +674,6 @@ , "op=$1" , "shift" , "$op $*" ]------- | A data type to represent PKGBUILD files----data PkgBuild =- PkgBuild- { arch_pkgname :: String- -- ^- -- The name of the package. This has be a unix-friendly name- -- as it will be used in the package filename.- , arch_pkgver :: Version- -- ^ The version of the software as released from the authorii- -- (e.g. ´2.7.1´).- , arch_pkgrel :: !Int- -- ^- -- This is the release number specific to the Arch Linux- -- release. This allows package maintainers to make updates to- -- the package´s configure flags, for example. A pkgrel of 1- -- is typically used for each upstream software release and is- -- incremented for intermediate PKGBUILD updates.- , arch_pkgdesc :: String- -- ^- -- This should be a brief description of the package and its- -- functionality. Try to keep the description to one line of text.- , arch_arch :: ArchList ArchArch- -- ^- -- Defines on which architectures the given package is- -- available (e.g. arch=(´i686´ ´x86_64´)).- , arch_url :: String- -- ^- -- This field contains a URL that is associated with the software- -- being packaged. This is typically the project´s website.- , arch_license :: ArchList License- -- ^- -- This field specifies the license(s) that apply to the package.- -- Commonly-used licenses are found in /usr/share/licenses/common. If- -- you see the package´s license there, simply reference it in the- -- license field (e.g. license=(´GPL´)). If the package provides a- -- license not found in /usr/share/licenses/common, then you should- -- include the license in the package itself and set- -- license=(´custom´) or license=(´custom:LicenseName´). The license- -- should be placed in $pkgdir/usr/share/licenses/$pkgname when- -- building the package. If multiple licenses are applicable for a- -- package, list all of them: license=(´GPL´ ´FDL´).- , arch_makedepends :: ArchList ArchDep- -- ^- -- An array of packages that this package depends on to build, but are- -- not needed at runtime. Packages in this list follow the same format- -- as depends.-- , arch_depends :: ArchList ArchDep- -- ^- -- An array of packages that this package depends on to run. Packages- -- in this list should be surrounded with single quotes and contain at- -- least the package name. Entries can also include a version- -- requirement of the form name<>version, where <> is one of five- -- comparisons: >= (greater than or equal to), <= (less than or equal- -- to), = (equal to), > (greater than), or < (less than).- , arch_source :: ArchList String- -- ^- -- An array of source files required to build the package. Source- -- files must either reside in the same directory as the PKGBUILD- -- file, or be a fully-qualified URL that makepkg will use to download- -- the file. In order to make the PKGBUILD as useful as possible, use- -- the $pkgname and $pkgver variables if possible when specifying the- -- download location. Any files that are compressed will automatically- -- be extracted, unless found in the noextract array listed below.- , arch_md5sum :: ArchList String- -- ^- -- This array contains an MD5 hash for every source file specified in- -- the source array (in the same order). makepkg will use this to- -- verify source file integrity during subsequent builds. To easily- -- generate md5sums, run “makepkg -g >> PKGBUILD”. If desired, move- -- the md5sums line to an appropriate location. NOTE: makepkg- -- supports multiple integrity algorithms and their corresponding- -- arrays (i.e. sha1sums for the SHA1 algorithm); however, official- -- packages use only md5sums for the time being.- , arch_build :: [String]- -- ^- -- The build hook-- , arch_install :: Maybe String- -- ^- -- Specifies a special install script that is to be included in the package. This- -- file should reside in the same directory as the PKGBUILD, and will be copied- -- into the package by makepkg. It does not need to be included in the source- -- array (e.g. install=pkgname.install).- --- , arch_options :: ArchList ArchOptions- -- ^- -- This array allows you to override some of makepkg´s default behavior when- -- building packages. To set an option, just include the option name in the- -- options array. To reverse the default behavior, place an “!” at the front of- -- the option. Only specify the options you specifically want to override, the- -- rest will be taken from makepkg.conf(5). NOTE: force is a special option only- -- used in a PKGBUILD(5), do not use it unless you know what you are doing.-- }- deriving (Show, Eq)--data ArchOptions- = Strip- deriving (Show, Eq)------- | An empty PKGBUILD----emptyPkgBuild :: PkgBuild-emptyPkgBuild =- PkgBuild- { arch_pkgname = display $ pkgName (package e)- , arch_pkgver = pkgVersion (package e)- , arch_pkgrel = 1- , arch_pkgdesc = synopsis e- , arch_arch = ArchList [Arch_X86, Arch_X86_64]- , arch_url = homepage e- , arch_license = ArchList [license e]-- -- everything depends on ghc and Cabal 1.4.x- , arch_makedepends = ArchList- [(ArchDep (Dependency (PackageName "ghc") AnyVersion))- ,(ArchDep (Dependency (PackageName "haskell-cabal") AnyVersion))--- ,(ArchDep (Dependency "haskell-cabal" (LaterVersion (Version [1,4,0,0] []))))- ]-- -- makedepends=('ghc>=6.6') ?- , arch_depends = ArchList []- , arch_source = ArchList []- , arch_md5sum = ArchList []- -- sha1sums=('a08670e4c749850714205f425cb460ed5a0a56b2')- , arch_build = []- , arch_install = Nothing -- executable- , arch_options = ArchList [Strip]- }- where- e = emptyPackageDescription----------------------------------------------------------------------------- Extra pretty printer instances and types--newtype ArchDep = ArchDep Dependency- deriving (Eq,Show)--instance Text ArchOptions where- disp Strip = text "strip"- parse = undefined---- the PKGBUILD version spec is less expressive than cabal, we can't--- really handle unions or intersections well yet.--instance Text ArchDep where- disp (ArchDep (Dependency name ver)) =- text (display name) <> mydisp ver- where- -- >= (greater than or equal to), <= (less than or- -- equal to), = (equal to), > (greater than), or <- mydisp AnyVersion = empty-- mydisp (ThisVersion v) = text "=" <> disp v- mydisp (LaterVersion v) = char '>' <> disp v- mydisp (EarlierVersion v) = char '<' <> disp v-- mydisp (UnionVersionRanges (ThisVersion v1) (LaterVersion v2))- | v1 == v2 = text ">=" <> disp v1- mydisp (UnionVersionRanges (LaterVersion v2) (ThisVersion v1))- | v1 == v2 = text ">=" <> disp v1- mydisp (UnionVersionRanges (ThisVersion v1) (EarlierVersion v2))- | v1 == v2 = text "<=" <> disp v1- mydisp (UnionVersionRanges (EarlierVersion v2) (ThisVersion v1))- | v1 == v2 = text "<=" <> disp v1--{-- mydisp (UnionVersionRanges r1 r2)- = disp r1 <+> text "||" <+> disp r2-- mydisp (IntersectVersionRanges r1 r2)- = disp r1 <+> text "&&" <+> disp r2--}-- mydisp x = trace ("WARNING: Can't handle this version format yet: " ++ show x ++ "\ncheck the dependencies by hand.")$ empty-- parse = undefined------- | Valid linux platforms----data ArchArch = Arch_X86 | Arch_X86_64- deriving (Show, Eq)--instance Text ArchArch where- disp x = case x of- Arch_X86 -> text "i686"- Arch_X86_64 -> text "x86_64"- parse = error "Text.parrse not defined for ArchList"---- Lists with quotes-newtype ArchList a = ArchList [a]- deriving (Show, Eq, Monoid, Functor)--instance Text String where- disp s = text s- parse = error "Text.parse not defined for String"--instance Text a => Text (ArchList a) where- disp (ArchList xs) =- parens (hcat- (intersperse space- (map (quotes . disp) xs)))- parse = error "Text.parse not defined for ArchList"---- | Printing with no quotes-dispNoQuotes :: Text a => ArchList a -> Doc-dispNoQuotes (ArchList xs) =- parens (hcat- (intersperse space- (map disp xs)))-------------------------------------------------------------------------- ------------------------------------------------------------------------ -- Some extras
cabal2arch.cabal view
@@ -1,5 +1,5 @@ name: cabal2arch-version: 0.6+version: 0.6.1 homepage: http://code.haskell.org/~dons/code/cabal2arch synopsis: Create Arch Linux packages from Cabal packages description: Create Arch Linux packages from Cabal packages@@ -24,5 +24,6 @@ bytestring, Cabal > 1.6, pureMD5 >= 0.2.1,- filepath+ filepath,+ archlinux > 0.1