packages feed

cblrepo 0.18.2 → 0.19.0

raw patch · 3 files changed

+125/−97 lines, 3 files

Files

cblrepo.cabal view
@@ -1,5 +1,5 @@ name: cblrepo-version: 0.18.2+version: 0.19.0 cabal-version: >= 1.6 license: OtherLicense license-file: LICENSE-2.0@@ -23,14 +23,46 @@ executable cblrepo     hs-source-dirs: src     main-is: Main.hs-    other-modules: Add BumpPkgs BuildPkgs Update Versions Upgrades ListPkgs PkgBuild OldPkgDB ConvertDB Remove Extract CreateConfig-        PkgDB Util.Translation Util.Cabal Util.HackageIndex Util.Misc Util.Dist Util.Cfg-    build-depends: base ==4.8.*, filepath ==1.4.*,-        directory ==1.2.*, Cabal ==1.22.*, transformers ==0.4.*,-        bytestring ==0.10.*, tar ==0.4.*, zlib ==0.6.*, mtl ==2.2.*,-        process ==1.2.*, Unixutils ==1.54.*, unix ==2.7.*,-        ansi-wl-pprint ==0.6.*, aeson ==0.10.*, stringsearch ==0.3.*,-        optparse-applicative ==0.11.*, safe ==0.3.*, containers ==0.5.*,+    other-modules:+        Add+        BuildPkgs+        BumpPkgs+        ConvertDB+        CreateConfig+        Extract+        ListPkgs+        OldPkgDB+        PkgBuild+        PkgDB+        Remove+        Update+        Upgrades+        Util.Cabal+        Util.Cfg+        Util.Dist+        Util.HackageIndex+        Util.Misc+        Util.Translation+        Versions+    build-depends:+        base ==4.8.*,+        filepath ==1.4.*,+        directory ==1.2.*,+        Cabal ==1.22.*,+        transformers ==0.4.*,+        bytestring ==0.10.*,+        tar ==0.4.*,+        zlib ==0.6.*,+        mtl ==2.2.*,+        process ==1.2.*,+        Unixutils ==1.54.*,+        unix ==2.7.*,+        ansi-wl-pprint ==0.6.*,+        aeson ==0.10.*,+        stringsearch ==0.3.*,+        optparse-applicative ==0.11.*,+        safe ==0.3.*,+        containers ==0.5.*,         utf8-string ==1.0.*  Source-Repository head
src/Main.hs view
@@ -35,118 +35,114 @@ import Paths_cblrepo  import Distribution.Text-import System.Directory import Options.Applicative as OA+import System.Directory  -- -- {{{1 command line arguments argAppDir, argDbFile :: Parser String-argAppDir = strOption (long "appdir" <> value "" <> help "Path to application data directory")-argDbFile = strOption (long "db" <> value "cblrepo.db" <> help "Path to package database")+argAppDir = strOption (long "appdir" <> value "" <> showDefault  <> help "Path to application data directory")+argDbFile = strOption (long "db" <> value "cblrepo.db" <> showDefault  <> help "Path to package database")+ argDryRun :: Parser Bool argDryRun = switch (short 'n' <> help "Make no changes, (dry run)")  cmdAddPkgOpts :: Parser Cmds cmdAddPkgOpts = CmdAdd-    <$> strOption (long "patchdir" <> value "patches" <> help "Location of patches (patches)")-    <*> option ghcVersionArgReader (long "ghc-version" <> value ghcDefVersion <> help "GHC version to use")-    <*> many (option ghcPkgArgReader (short 'g' <> long "ghc-pkg" <> metavar "PKG,VER" <> help "GHC base package (multiple)"))-    <*> many (option distroPkgArgReader (short 'd' <> long "distro-pkg" <> metavar "PKG,VER,REL" <> help "Distro package (multiple)"))-    <*> many (option strCblFileArgReader (short 'f' <> long "cbl-file" <> metavar "FILE[:flag,-flag]" <> help "CABAL file (multiple)"))-    <*> many (argument strCblPkgArgReader (metavar "PKGNAME,VERSION[:flag,-flag] ..."))+                <$> strOption (long "patchdir" <> value "patches" <> showDefault <> help "Location of patches")+                <*> option ghcVersionArgReader (long "ghc-version" <> value ghcDefVersion <> showDefault <> help "GHC version to use")+                <*> many (option ghcPkgArgReader (short 'g' <> long "ghc-pkg" <> metavar "PKG,VER" <> help "GHC base package (multiple)"))+                <*> many (option distroPkgArgReader (short 'd' <> long "distro-pkg" <> metavar "PKG,VER,REL" <> help "Distro package (multiple)"))+                <*> many (option strCblFileArgReader (short 'f' <> long "cbl-file" <> metavar "FILE[:flag,-flag]" <> help "CABAL file (multiple)"))+                <*> many (argument strCblPkgArgReader (metavar "PKGNAME,VERSION[:flag,-flag] ...")) -cmdAddPkgCmd = command "add" (info (helper <*> cmdAddPkgOpts)-    (fullDesc <> progDesc "Add a package to the database"))+cmdAddPkgCmd = command "add" (info (helper <*> cmdAddPkgOpts) (fullDesc <> progDesc "Add a package to the database")) -cmdBumpPkgsOpts = CmdBumpPkgs-    <$> switch (long "inclusive" <> help "Include the listed packages")-    <*> some (strArgument (metavar "PKGNAME ..."))-cmdBumpPkgsCmd = command "bump" (info (helper <*> cmdBumpPkgsOpts)-    (fullDesc <> progDesc "Bump packages that need it after updating the named packages"))+cmdBumpPkgsCmd = command "bump" (info (helper <*> cmdBumpPkgsOpts) (fullDesc <> progDesc "Bump packages that need it after updating the named packages"))+  where+    cmdBumpPkgsOpts = CmdBumpPkgs+                      <$> switch (long "inclusive" <> help "Include the listed packages")+                      <*> some (strArgument (metavar "PKGNAME ...")) -cmdBuildPkgsOpts = CmdBuildPkgs-    <$> some (strArgument (metavar "PKGNAME ...")) cmdBuildPkgsCmd = command "build" (info (helper <*> cmdBuildPkgsOpts)-    (fullDesc <> progDesc "Re-order packages into a good build order"))+                                   (fullDesc <> progDesc "Re-order packages into a good build order"))+  where+    cmdBuildPkgsOpts = CmdBuildPkgs <$> some (strArgument (metavar "PKGNAME ...")) -cmdUpdateOpts = CmdUpdate <$> switch (internal <> hidden)-cmdUpdateCmd = command "update" (info (helper <*> cmdUpdateOpts)-    (fullDesc <> progDesc "Update the index"))+cmdUpdateCmd = command "update" (info (helper <*> cmdUpdateOpts) (fullDesc <> progDesc "Update the index"))+  where+    cmdUpdateOpts = CmdUpdate <$> switch (internal <> hidden) -cmdVersionsOpts = CmdVersions-    <$> switch (short 'l' <> long "latest" <> help "List only the latest version of packages")-    <*> some (strArgument (metavar "PKGNAME ..."))-cmdVersionsCmd = command "versions" (info (helper <*> cmdVersionsOpts)-    (fullDesc <> progDesc "List available versions of packages"))+cmdVersionsCmd = command "versions" (info (helper <*> cmdVersionsOpts) (fullDesc <> progDesc "List available versions of packages"))+  where+    cmdVersionsOpts = CmdVersions+                      <$> switch (short 'l' <> long "latest" <> help "List only the latest version of packages")+                      <*> some (strArgument (metavar "PKGNAME ...")) -cmdUpgradesOpts = CmdUpgrades-    <$> switch (short 's' <> help "A shorter output suitable for scripting")-cmdUpgradesCmd = command "upgrades" (info (helper <*> cmdUpgradesOpts)-    (fullDesc <> progDesc "Check for packages that can be upgraded"))+cmdUpgradesCmd = command "upgrades" (info (helper <*> cmdUpgradesOpts) (fullDesc <> progDesc "Check for packages that can be upgraded"))+  where+    cmdUpgradesOpts = CmdUpgrades <$> switch (short 's' <> help "A shorter output suitable for scripting") -cmdListPkgsOpts = CmdListPkgs-    <$> switch (short 'g' <> long "ghc" <> help "List ghc packages")-    <*> switch (short 'd' <> long "distro" <> help "List distro packages")-    <*> switch (long "no-repo" <> help "Do not list repo packages")-    <*> option listFormatReader (short 'f' <> long "format" <> value CmdListNormalFmt <>-            help "Output format: short, normal (default), hackage")-    <*> many (argument str (metavar "PKGNAME ..."))-cmdListPkgsCmd = command "list" (info (helper <*> cmdListPkgsOpts)-    (fullDesc <> progDesc "List packages in repo"))+cmdListPkgsCmd = command "list" (info (helper <*> cmdListPkgsOpts) (fullDesc <> progDesc "List packages in repo"))+  where+    cmdListPkgsOpts = CmdListPkgs+                      <$> switch (short 'g' <> long "ghc" <> help "List ghc packages")+                      <*> switch (short 'd' <> long "distro" <> help "List distro packages")+                      <*> switch (long "no-repo" <> help "Do not list repo packages")+                      <*> option listFormatReader (short 'f' <> long "format" <> value CmdListNormalFmt <> help "Output format: short, normal, hackage (default: normal)")+                      <*> many (argument str (metavar "PKGNAME ...")) -cmdPkgBuildOpts = CmdPkgBuild-    <$> option ghcVersionArgReader (long "ghc-version" <> value ghcDefVersion <> help "GHC version to use in PKGBUILD")-    <*> option auto (long "ghc-release" <> value ghcDefRelease <> help "GHC release to use in PKGBUILD")-    <*> strOption (long "patchdir" <> value "patches" <> help "Location of patches (patches)")-    <*> some (strArgument (metavar "PKGNAME ..."))-cmdPkgBuildCmd = command "pkgbuild" (info (helper <*> cmdPkgBuildOpts)-    (fullDesc <> progDesc "Create PKGBUILD other files necessary for an Arch package"))+cmdPkgBuildCmd = command "pkgbuild" (info (helper <*> cmdPkgBuildOpts) (fullDesc <> progDesc "Create PKGBUILD other files necessary for an Arch package"))+  where+    cmdPkgBuildOpts = CmdPkgBuild+                      <$> option ghcVersionArgReader (long "ghc-version" <> value ghcDefVersion <> help "GHC version to use in PKGBUILD (default: 7.10.3)")+                      <*> option auto (long "ghc-release" <> value ghcDefRelease <> showDefault <> help "GHC release to use in PKGBUILD")+                      <*> strOption (long "patchdir" <> value "patches" <> showDefault  <> help "Location of patches")+                      <*> some (strArgument (metavar "PKGNAME ...")) -cmdConvertDbOpts = CmdConvertDb-    <$> strOption (short 'i' <> long "indb" <> value "cblrepo.db" <> help "Old database")-    <*> strOption (short 'o' <> long "outdb" <> value "new-cblrepo.db" <> help "New database")-cmdConvertDbCmd = command "convertdb" (info (helper <*> cmdConvertDbOpts)-    (fullDesc <> progDesc "Convert an old database to the new format"))+cmdConvertDbCmd = command "convertdb" (info (helper <*> cmdConvertDbOpts) (fullDesc <> progDesc "Convert an old database to the new format"))+  where+    cmdConvertDbOpts = CmdConvertDb+                       <$> strOption (short 'i' <> long "indb" <> value "cblrepo.db" <> showDefault  <> help "Old database")+                       <*> strOption (short 'o' <> long "outdb" <> value "new-cblrepo.db" <> showDefault  <> help "New database") -cmdRemovePkgOpts = CmdRemovePkg-    <$> some (strArgument (metavar "PKGNAME ..."))-cmdRemovePkgCmd = command "rm" (info (helper <*> cmdRemovePkgOpts)-    (fullDesc <> progDesc "Remove packages"))+cmdRemovePkgCmd = command "rm" (info (helper <*> cmdRemovePkgOpts) (fullDesc <> progDesc "Remove packages"))+  where+    cmdRemovePkgOpts = CmdRemovePkg <$> some (strArgument (metavar "PKGNAME ...")) -cmdExtractOpts = CmdExtract-    <$> many (argument pkgNVersionArgReader (metavar "PKGNAME,VERSION")) cmdExtractCmd = command "extract" (info (helper <*> cmdExtractOpts) (fullDesc <> progDesc "Extract Cabal file from index"))+  where+    cmdExtractOpts = CmdExtract <$> many (argument pkgNVersionArgReader (metavar "PKGNAME,VERSION")) -cmdCreateConfigOpts = pure CmdCreateConfig cmdCreateConfigCmd = command "create-config" (info (helper <*> cmdCreateConfigOpts) (fullDesc <> progDesc "Create configuration file with defaults"))+  where+    cmdCreateConfigOpts = pure CmdCreateConfig -argParser = info (helper <*> opts) (fullDesc <> header (progName ++ " v" ++ display version) <> progDesc "Maintain a datatbase of dependencies of CABAL packages")-    where-        opts = Opts <$> argAppDir <*> argDbFile <*> argDryRun-            <*> subparser ( cmdAddPkgCmd-                <> cmdBumpPkgsCmd <> cmdBuildPkgsCmd <> cmdUpdateCmd <> cmdVersionsCmd <> cmdUpgradesCmd-                <> cmdListPkgsCmd <> cmdPkgBuildCmd <> cmdConvertDbCmd <> cmdRemovePkgCmd <> cmdExtractCmd-                <> cmdCreateConfigCmd-                )+argParser = info (helper <*> opts) (fullDesc <> header (progName ++ " v" ++ display version) <> progDesc "Maintain a database of dependencies of CABAL packages")+  where+    opts = Opts+           <$> argAppDir <*> argDbFile <*> argDryRun+           <*> subparser (cmdAddPkgCmd <> cmdBumpPkgsCmd <> cmdBuildPkgsCmd <> cmdUpdateCmd <> cmdVersionsCmd <> cmdUpgradesCmd <>+                          cmdListPkgsCmd <> cmdPkgBuildCmd <> cmdConvertDbCmd <> cmdRemovePkgCmd <> cmdExtractCmd <> cmdCreateConfigCmd)  -- {{{1 main main :: IO () main = do-    defAppDir <- getAppUserDataDirectory progName-    execParser argParser >>= \ o -> do-        let aD = if null (appDir o) then defAppDir else appDir o-        createDirectoryIfMissing True aD-        cfg <- readCfg "cblrepo.cfg"-        let e = (o { appDir = aD }, cfg)-        case optsCmd o of-            CmdAdd {} -> runCommand e add-            CmdBuildPkgs {} -> runCommand e buildPkgs-            CmdBumpPkgs {} -> runCommand e bumpPkgs-            CmdUpdate {} -> runCommand e update-            CmdVersions {} -> runCommand e versions-            CmdListPkgs {} -> runCommand e listPkgs-            CmdUpgrades {} -> runCommand e upgrades-            CmdPkgBuild {} -> runCommand e pkgBuild-            CmdConvertDb {} -> runCommand e convertDb-            CmdRemovePkg {} -> runCommand e remove-            CmdExtract {} -> runCommand e extract-            CmdCreateConfig -> runCommand e createConfig+  defAppDir <- getAppUserDataDirectory progName+  execParser argParser >>= \ o -> do+    let aD = if null (appDir o) then defAppDir else appDir o+    createDirectoryIfMissing True aD+    cfg <- readCfg "cblrepo.cfg"+    let e = (o { appDir = aD }, cfg)+    case optsCmd o of+      CmdAdd {} -> runCommand e add+      CmdBuildPkgs {} -> runCommand e buildPkgs+      CmdBumpPkgs {} -> runCommand e bumpPkgs+      CmdUpdate {} -> runCommand e update+      CmdVersions {} -> runCommand e versions+      CmdListPkgs {} -> runCommand e listPkgs+      CmdUpgrades {} -> runCommand e upgrades+      CmdPkgBuild {} -> runCommand e pkgBuild+      CmdConvertDb {} -> runCommand e convertDb+      CmdRemovePkg {} -> runCommand e remove+      CmdExtract {} -> runCommand e extract+      CmdCreateConfig -> runCommand e createConfig
src/Util/Misc.hs view
@@ -56,8 +56,8 @@ progName = "cblrepo" dbName = progName ++ ".db" -ghcDefVersion = Version [7, 10, 2] []-ghcDefRelease = 2 :: Int+ghcDefVersion = Version [7, 10, 3] []+ghcDefRelease = 1 :: Int ghcVersionDep :: Version -> Int -> String ghcVersionDep ghcVer ghcRel = "ghc=" ++ display ghcVer ++ "-" ++ show ghcRel