Wed Nov 19 10:53:22 CET 2008  pepe <mnislaih@gmail.com>
  * Towards easily building your own hackage repo

New patches:

[Towards easily building your own hackage repo
pepe <mnislaih@gmail.com>**20081119095322] {
hunk ./Distribution/Client/Setup.hs 25
     , checkCommand
     , uploadCommand, UploadFlags(..)
     , reportCommand
+    , serverCommand
 
     , parsePackageArgs
     --TODO: stop exporting these:
hunk ./Distribution/Client/Setup.hs 276
     commandOptions      = \_ -> [optionVerbosity id const]
   }
 
+serverCommand :: CommandUI (Flag Verbosity)
+serverCommand = CommandUI {
+    commandName         = "server",
+    commandSynopsis     = "Generate the scripts to set up a local Hackage server.",
+    commandDescription  = Just (const "Put all your tar.gz package files in a directory, and run this command to set everything up.\n Make sure you point your web server appropriately too\n"),
+    commandUsage        = \pname -> "Usage: " ++ pname ++ " server\n",
+    commandDefaultFlags = toFlag normal,
+    commandOptions      = \_ -> [optionVerbosity id const]
+  }
+
+
 -- ------------------------------------------------------------
 -- * List flags
 -- ------------------------------------------------------------
hunk ./Main.hs 16
 
 module Main where
 
+import Control.Arrow
+import Data.List (span)
+import Data.Maybe (isJust)
+import Distribution.Version
+import System.Cmd
+import Text.Printf
+
 import Distribution.Client.Setup
          ( GlobalFlags(..), globalCommand, globalRepos
          , ConfigFlags(..), configureCommand
hunk ./Main.hs 31
          , updateCommand
          , ListFlags(..), listCommand
          , UploadFlags(..), uploadCommand
-         , reportCommand
+         , reportCommand, serverCommand
          , parsePackageArgs, configPackageDB' )
 import Distribution.Simple.Setup
          ( BuildFlags(..), buildCommand
hunk ./Main.hs 65
 import Distribution.Simple.Configure (configCompilerAux)
 import Distribution.Simple.Utils (cabalVersion, die, intercalate)
 import Distribution.Text
-         ( display )
+         ( display, simpleParse )
 import Distribution.Verbosity as Verbosity
hunk ./Main.hs 67
-       ( Verbosity, normal, intToVerbosity )
+       ( Verbosity, normal, silent, verbose, intToVerbosity )
 import qualified Paths_cabal_install (version)
 
 import System.Environment       (getArgs, getProgName)
hunk ./Main.hs 72
 import System.Exit              (exitFailure)
-import System.FilePath          (splitExtension, takeExtension)
-import System.Directory         (doesFileExist)
+import System.FilePath          (splitExtension, takeExtension, (</>))
+import System.Directory         (doesFileExist, getDirectoryContents, setCurrentDirectory)
 import Data.List                (intersperse)
 import Data.Maybe               (fromMaybe)
 import Data.Monoid              (Monoid(..))
hunk ./Main.hs 77
-import Control.Monad            (unless)
+import Control.Monad            (unless, when)
 
 -- | Entry point
 --
hunk ./Main.hs 124
       ,checkCommand           `commandAddAction` checkAction
       ,sdistCommand           `commandAddAction` sdistAction
       ,reportCommand          `commandAddAction` reportAction
+      ,serverCommand          `commandAddAction` serverAction
       ,wrapperAction (buildCommand defaultProgramConfiguration)
                      buildVerbosity    buildDistPref
       ,wrapperAction copyCommand
hunk ./Main.hs 312
       _  ->           Verbosity.normal
 win32SelfUpgradeAction _ = return ()
 
+
+serverAction :: Flag Verbosity -> [String] -> GlobalFlags -> IO ()
+serverAction verbosityFlag extraArgs _
+    = do
+  unless (null extraArgs) $ do
+    die $ "'server' doesn't take any extra arguments: " ++ unwords extraArgs
+  let verbosity = fromFlag verbosityFlag
+      run cmd = when (verbosity >= verbose) (putStrLn cmd) >> system cmd >> return ()
+  run "mkdir -p packages"
+  files <- getDirectoryContents "."
+  forM_ [f | f <- files, length f > 7] $ \f -> do
+    -- could use a regexp but want to avoid dependencies
+    let (version, name) = (reverse *** (reverse.tail)) $ span (/= '-') $
+                          drop 7 $ reverse f
+    if (isJust (simpleParse version `asTypeOf` Just (Version [] [])) && not (null name))
+       then do
+        let descriptordir = name </> version
+            destdir = "packages" </> srcdir
+            srcdir  = name ++ "-" ++ version
+        run (printf "rm -rf %s && mkdir -p %s && mkdir -p %s" destdir destdir descriptordir)
+        run ("tar xzf " ++ f)
+        run (printf "mv %s/%s.cabal %s && rm -rf %s" srcdir name descriptordir srcdir)
+        run (printf "mv %s %s/tarball" f destdir)
+        return [name]
+       else do
+        when (verbosity > silent) $ putStrLn ("Ignoring " ++ f)
+        return []
+  run ("find . -maxdepth 3 -name '*.cabal' " ++
+	       "| tar -c -T - -f - | gzip -9 > 00-index.tar.gz")
+  putStrLn "Done."
+
+  where forM_ = flip mapM_
}

Context:

[TAG 0.6.0
Duncan Coutts <duncan@haskell.org>**20081011195420] 
[Bump version to 0.6.0
Duncan Coutts <duncan@haskell.org>**20081011195314] 
[Improve the README, better install instructions
Duncan Coutts <duncan@haskell.org>**20081011185919
 And slightly better intro guide to the main commands.
] 
[Bump versions of deps in the bootstrap script
Duncan Coutts <duncan@haskell.org>**20081011184937] 
[Add Eq for a couple types in the anon build reports
Duncan Coutts <duncan@haskell.org>**20081011184825] 
[Drop silly export
Duncan Coutts <duncan@haskell.org>**20081011184805] 
[Apparnetly builds with unix-2.0 which is what came with ghc-6.6
Duncan Coutts <duncan@haskell.org>**20081010234836] 
[Fix the -i dir for compiling Setup.hs when it's the current dir
Duncan Coutts <duncan@haskell.org>**20081010234558
 map "" to "."
] 
[Tidy up the preferred-versions file parser
Duncan Coutts <duncan@haskell.org>**20081010070105] 
[Bump version number and dependencies
Duncan Coutts <duncan@haskell.org>**20081010065854] 
[Relax deps to build with ghc-6.10
Duncan Coutts <duncan@haskell.org>**20081007230701] 
[Handle build reports with missing logs better
Duncan Coutts <duncan@haskell.org>**20081007230635] 
[Add DownloadFailed as a possible failure for installation
Duncan Coutts <duncan@haskell.org>**20081007230418
 Should now be caught during installing a bunch of packages
 and not cause immediate overall failure. It should instead
 be treated like any other package build failure and be
 reported at the end and only affect other dependent builds.
] 
[Fix search paths for compiling Setup.hs scrips
Duncan Coutts <duncan@haskell.org>**20081007213630
 and in particular for bootstrapping the Cabal lib.
] 
[Fix selecting paired packages
Duncan Coutts <duncan@haskell.org>**20081007062930
 Previously when we selected base 4 (and as a consequence
 slected base 3 too) we didn't properly trace the dependencies
 of base 3 so if nothing actually required base 3 then we ended
 up with base 3 in the solution but not with syb which it
 depends on. Consequently the solution was invalid.
 Now we select the paired package properly (hopefully).
] 
[Take preferred versions into account in dependency planning
Duncan Coutts <duncan@haskell.org>**20081006055129
 This means we can now globally prefer base 3 rather than 4.
 However we need to be slightly careful or we end up deciding
 to do silly things like rebuild haskell98 against base 3.
 That would happen because the h98 package doesn't constrain
 the choice to one or the other and we would prefer base 3.
 So we have to add that we really prefer whatever it uses
 currently (if any).
] 
[Pass the package suggested version constraints through to the resolver
Duncan Coutts <duncan@haskell.org>**20081006042758
 Not used yet.
] 
[Fix selection of paired packages
Duncan Coutts <duncan@haskell.org>**20081006040616] 
[Read preferred versions from the package index
Duncan Coutts <duncan@haskell.org>**20081006030259
 From a file named 'preferred-versions' in the 00-index.tar.gz
 If there are several they are combined. Contents is like:
 base < 4
 one suggested version constraint per line.
] 
[Refactor and update the hackage index reading code
Duncan Coutts <duncan@haskell.org>**20081005202747] 
[Print more details about what is to be installed with -v
Duncan Coutts <duncan@haskell.org>**20081005075556
 Reports if installs are new or reinstalls and for reinstalls
 prints what dependencies have changed.
] 
[When finalising paired packages, cope with there being multiple choices
Duncan Coutts <duncan@haskell.org>**20081005053821
 For ordinary packages we selected a single version which means
  we added an equality constraint. As a consequence we used to
 assume there was only one version left when finalising. For
 paired packages there may be two versions left if the package
 did not directly constrain the choice to just one. If there is
 more than one version remaining then we have to pick between
 them. At the moment we still pick the highest version, but
 later we can take a global preference or polciy into account.
] 
[When selecting paired packages, select both.
Duncan Coutts <duncan@haskell.org>**20081005053804] 
[Handle constraints on paired packages
Duncan Coutts <duncan@haskell.org>**20081005051919
 The trick is that when applying constraints to paired
 packages, the constraint has to exclude both packages at
 once. We exclude the pair together or not at all. If it
 would only exclude one then we discard the constraint.
] 
[Add the notion of paired packages to the Constraints ADT
Duncan Coutts <duncan@haskell.org>**20081005013141
 Packages like base-3 and base-4 are paired. This means they are
 supposed to be treated equivalently in some contexts. Paired
 packages are installed packages with the same name where one
 version depends on the other.
] 
[Make InstalledPackage an instance of PackageFixedDeps
Duncan Coutts <duncan@haskell.org>**20081005012741] 
[Add the glue code to actully report excluded packages
Duncan Coutts <duncan@haskell.org>**20081005001400
 Now displayed in the output of install --dry-run -v
] 
[Have Constraints.constrain report the excluded packages
Duncan Coutts <duncan@haskell.org>**20081004235006
 Each time we apply a constraint we can end up excluding some
 extra package. Report that list of packages because it is
 quite interesting information to get insight into what the
 resolver is actually doing.
] 
[Separate the construction of the exclusion list from its use
Duncan Coutts <duncan@haskell.org>**20081004234421
 Previously directly inserted packages into the excluded package
 list. Now we generate a list of them and then add them. We want
 the list of newly excluded packages separately because it is
 interesting information to report to the user when -v is on.
] 
[Generalise the logging of selected and discarded packages
Duncan Coutts <duncan@haskell.org>**20081004232555
 Allow for selecting several packages in one go.
 Currently when we select a package we only list the over versions
 of the same package that that excludes, and not the other packages
 we exclude by applying the dependency constraints of the selected
 package. In future we would like to do that so we now report the
 package name of discards not just the version. Though we do group
 by the package name to avoid too much repition.
] 
[Fix infinite loop in the TopDown dependency resolver
Andrea Vezzosi <sanzhiyan@gmail.com>**20080925181441
 The loop occurred only if a package depended on another one
 with the same name, e.g. base-3.0.3.0 <- base-4.0.0.0
] 
[small improvements to bootstrap
Duncan Coutts <duncan@haskell.org>**20080926214828
 patch sent in by brian0, ticket #357
] 
[Update to the development version of the Cabal lib
Duncan Coutts <duncan@haskell.org>**20080831225243
 The branch of cabal-install that tracks Cabal-1.4 now lives at
 http://darcs.haskell.org/cabal-branches/cabal-install-0.5/
] 
[Allow use of curl in bootstrap.sh
Duncan Coutts <duncan@haskell.org>**20080826233400
 Patch from jsnx. Fixes ticket #343. Also, use "cd blah; cd .."
 instead of "pushd blah; popd" as some shells lack pushd/popd
] 
[Relax version constraint on unix package
Duncan Coutts <duncan@haskell.org>**20080826232851
 Allows building with ghc-6.6.1
] 
[Use mplus not mappend for combining tar filename checks
Duncan Coutts <duncan@haskell.org>**20080826232606
 mappend would join the error messages in the case that both
 checks failed. Also the monoid instance was new in base 3.
] 
[TAG 0.5.2
Duncan Coutts <duncan@haskell.org>**20080826214238] 
Patch bundle hash:
5d014875a1a21c26cd3200a1392eb9c5a3cc840d
