Ticket #409: cabal-install-server.patch

File cabal-install-server.patch, 12.3 KB (added by mnislaih, 5 years ago)
Line 
1Wed Nov 19 10:53:22 CET 2008  pepe <mnislaih@gmail.com>
2  * Towards easily building your own hackage repo
3
4New patches:
5
6[Towards easily building your own hackage repo
7pepe <mnislaih@gmail.com>**20081119095322] {
8hunk ./Distribution/Client/Setup.hs 25
9     , checkCommand
10     , uploadCommand, UploadFlags(..)
11     , reportCommand
12+    , serverCommand
13 
14     , parsePackageArgs
15     --TODO: stop exporting these:
16hunk ./Distribution/Client/Setup.hs 276
17     commandOptions      = \_ -> [optionVerbosity id const]
18   }
19 
20+serverCommand :: CommandUI (Flag Verbosity)
21+serverCommand = CommandUI {
22+    commandName         = "server",
23+    commandSynopsis     = "Generate the scripts to set up a local Hackage server.",
24+    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"),
25+    commandUsage        = \pname -> "Usage: " ++ pname ++ " server\n",
26+    commandDefaultFlags = toFlag normal,
27+    commandOptions      = \_ -> [optionVerbosity id const]
28+  }
29+
30+
31 -- ------------------------------------------------------------
32 -- * List flags
33 -- ------------------------------------------------------------
34hunk ./Main.hs 16
35 
36 module Main where
37 
38+import Control.Arrow
39+import Data.List (span)
40+import Data.Maybe (isJust)
41+import Distribution.Version
42+import System.Cmd
43+import Text.Printf
44+
45 import Distribution.Client.Setup
46          ( GlobalFlags(..), globalCommand, globalRepos
47          , ConfigFlags(..), configureCommand
48hunk ./Main.hs 31
49          , updateCommand
50          , ListFlags(..), listCommand
51          , UploadFlags(..), uploadCommand
52-         , reportCommand
53+         , reportCommand, serverCommand
54          , parsePackageArgs, configPackageDB' )
55 import Distribution.Simple.Setup
56          ( BuildFlags(..), buildCommand
57hunk ./Main.hs 65
58 import Distribution.Simple.Configure (configCompilerAux)
59 import Distribution.Simple.Utils (cabalVersion, die, intercalate)
60 import Distribution.Text
61-         ( display )
62+         ( display, simpleParse )
63 import Distribution.Verbosity as Verbosity
64hunk ./Main.hs 67
65-       ( Verbosity, normal, intToVerbosity )
66+       ( Verbosity, normal, silent, verbose, intToVerbosity )
67 import qualified Paths_cabal_install (version)
68 
69 import System.Environment       (getArgs, getProgName)
70hunk ./Main.hs 72
71 import System.Exit              (exitFailure)
72-import System.FilePath          (splitExtension, takeExtension)
73-import System.Directory         (doesFileExist)
74+import System.FilePath          (splitExtension, takeExtension, (</>))
75+import System.Directory         (doesFileExist, getDirectoryContents, setCurrentDirectory)
76 import Data.List                (intersperse)
77 import Data.Maybe               (fromMaybe)
78 import Data.Monoid              (Monoid(..))
79hunk ./Main.hs 77
80-import Control.Monad            (unless)
81+import Control.Monad            (unless, when)
82 
83 -- | Entry point
84 --
85hunk ./Main.hs 124
86       ,checkCommand           `commandAddAction` checkAction
87       ,sdistCommand           `commandAddAction` sdistAction
88       ,reportCommand          `commandAddAction` reportAction
89+      ,serverCommand          `commandAddAction` serverAction
90       ,wrapperAction (buildCommand defaultProgramConfiguration)
91                      buildVerbosity    buildDistPref
92       ,wrapperAction copyCommand
93hunk ./Main.hs 312
94       _  ->           Verbosity.normal
95 win32SelfUpgradeAction _ = return ()
96 
97+
98+serverAction :: Flag Verbosity -> [String] -> GlobalFlags -> IO ()
99+serverAction verbosityFlag extraArgs _
100+    = do
101+  unless (null extraArgs) $ do
102+    die $ "'server' doesn't take any extra arguments: " ++ unwords extraArgs
103+  let verbosity = fromFlag verbosityFlag
104+      run cmd = when (verbosity >= verbose) (putStrLn cmd) >> system cmd >> return ()
105+  run "mkdir -p packages"
106+  files <- getDirectoryContents "."
107+  forM_ [f | f <- files, length f > 7] $ \f -> do
108+    -- could use a regexp but want to avoid dependencies
109+    let (version, name) = (reverse *** (reverse.tail)) $ span (/= '-') $
110+                          drop 7 $ reverse f
111+    if (isJust (simpleParse version `asTypeOf` Just (Version [] [])) && not (null name))
112+       then do
113+        let descriptordir = name </> version
114+            destdir = "packages" </> srcdir
115+            srcdir  = name ++ "-" ++ version
116+        run (printf "rm -rf %s && mkdir -p %s && mkdir -p %s" destdir destdir descriptordir)
117+        run ("tar xzf " ++ f)
118+        run (printf "mv %s/%s.cabal %s && rm -rf %s" srcdir name descriptordir srcdir)
119+        run (printf "mv %s %s/tarball" f destdir)
120+        return [name]
121+       else do
122+        when (verbosity > silent) $ putStrLn ("Ignoring " ++ f)
123+        return []
124+  run ("find . -maxdepth 3 -name '*.cabal' " ++
125+              "| tar -c -T - -f - | gzip -9 > 00-index.tar.gz")
126+  putStrLn "Done."
127+
128+  where forM_ = flip mapM_
129}
130
131Context:
132
133[TAG 0.6.0
134Duncan Coutts <duncan@haskell.org>**20081011195420]
135[Bump version to 0.6.0
136Duncan Coutts <duncan@haskell.org>**20081011195314]
137[Improve the README, better install instructions
138Duncan Coutts <duncan@haskell.org>**20081011185919
139 And slightly better intro guide to the main commands.
140]
141[Bump versions of deps in the bootstrap script
142Duncan Coutts <duncan@haskell.org>**20081011184937]
143[Add Eq for a couple types in the anon build reports
144Duncan Coutts <duncan@haskell.org>**20081011184825]
145[Drop silly export
146Duncan Coutts <duncan@haskell.org>**20081011184805]
147[Apparnetly builds with unix-2.0 which is what came with ghc-6.6
148Duncan Coutts <duncan@haskell.org>**20081010234836]
149[Fix the -i dir for compiling Setup.hs when it's the current dir
150Duncan Coutts <duncan@haskell.org>**20081010234558
151 map "" to "."
152]
153[Tidy up the preferred-versions file parser
154Duncan Coutts <duncan@haskell.org>**20081010070105]
155[Bump version number and dependencies
156Duncan Coutts <duncan@haskell.org>**20081010065854]
157[Relax deps to build with ghc-6.10
158Duncan Coutts <duncan@haskell.org>**20081007230701]
159[Handle build reports with missing logs better
160Duncan Coutts <duncan@haskell.org>**20081007230635]
161[Add DownloadFailed as a possible failure for installation
162Duncan Coutts <duncan@haskell.org>**20081007230418
163 Should now be caught during installing a bunch of packages
164 and not cause immediate overall failure. It should instead
165 be treated like any other package build failure and be
166 reported at the end and only affect other dependent builds.
167]
168[Fix search paths for compiling Setup.hs scrips
169Duncan Coutts <duncan@haskell.org>**20081007213630
170 and in particular for bootstrapping the Cabal lib.
171]
172[Fix selecting paired packages
173Duncan Coutts <duncan@haskell.org>**20081007062930
174 Previously when we selected base 4 (and as a consequence
175 slected base 3 too) we didn't properly trace the dependencies
176 of base 3 so if nothing actually required base 3 then we ended
177 up with base 3 in the solution but not with syb which it
178 depends on. Consequently the solution was invalid.
179 Now we select the paired package properly (hopefully).
180]
181[Take preferred versions into account in dependency planning
182Duncan Coutts <duncan@haskell.org>**20081006055129
183 This means we can now globally prefer base 3 rather than 4.
184 However we need to be slightly careful or we end up deciding
185 to do silly things like rebuild haskell98 against base 3.
186 That would happen because the h98 package doesn't constrain
187 the choice to one or the other and we would prefer base 3.
188 So we have to add that we really prefer whatever it uses
189 currently (if any).
190]
191[Pass the package suggested version constraints through to the resolver
192Duncan Coutts <duncan@haskell.org>**20081006042758
193 Not used yet.
194]
195[Fix selection of paired packages
196Duncan Coutts <duncan@haskell.org>**20081006040616]
197[Read preferred versions from the package index
198Duncan Coutts <duncan@haskell.org>**20081006030259
199 From a file named 'preferred-versions' in the 00-index.tar.gz
200 If there are several they are combined. Contents is like:
201 base < 4
202 one suggested version constraint per line.
203]
204[Refactor and update the hackage index reading code
205Duncan Coutts <duncan@haskell.org>**20081005202747]
206[Print more details about what is to be installed with -v
207Duncan Coutts <duncan@haskell.org>**20081005075556
208 Reports if installs are new or reinstalls and for reinstalls
209 prints what dependencies have changed.
210]
211[When finalising paired packages, cope with there being multiple choices
212Duncan Coutts <duncan@haskell.org>**20081005053821
213 For ordinary packages we selected a single version which means
214  we added an equality constraint. As a consequence we used to
215 assume there was only one version left when finalising. For
216 paired packages there may be two versions left if the package
217 did not directly constrain the choice to just one. If there is
218 more than one version remaining then we have to pick between
219 them. At the moment we still pick the highest version, but
220 later we can take a global preference or polciy into account.
221]
222[When selecting paired packages, select both.
223Duncan Coutts <duncan@haskell.org>**20081005053804]
224[Handle constraints on paired packages
225Duncan Coutts <duncan@haskell.org>**20081005051919
226 The trick is that when applying constraints to paired
227 packages, the constraint has to exclude both packages at
228 once. We exclude the pair together or not at all. If it
229 would only exclude one then we discard the constraint.
230]
231[Add the notion of paired packages to the Constraints ADT
232Duncan Coutts <duncan@haskell.org>**20081005013141
233 Packages like base-3 and base-4 are paired. This means they are
234 supposed to be treated equivalently in some contexts. Paired
235 packages are installed packages with the same name where one
236 version depends on the other.
237]
238[Make InstalledPackage an instance of PackageFixedDeps
239Duncan Coutts <duncan@haskell.org>**20081005012741]
240[Add the glue code to actully report excluded packages
241Duncan Coutts <duncan@haskell.org>**20081005001400
242 Now displayed in the output of install --dry-run -v
243]
244[Have Constraints.constrain report the excluded packages
245Duncan Coutts <duncan@haskell.org>**20081004235006
246 Each time we apply a constraint we can end up excluding some
247 extra package. Report that list of packages because it is
248 quite interesting information to get insight into what the
249 resolver is actually doing.
250]
251[Separate the construction of the exclusion list from its use
252Duncan Coutts <duncan@haskell.org>**20081004234421
253 Previously directly inserted packages into the excluded package
254 list. Now we generate a list of them and then add them. We want
255 the list of newly excluded packages separately because it is
256 interesting information to report to the user when -v is on.
257]
258[Generalise the logging of selected and discarded packages
259Duncan Coutts <duncan@haskell.org>**20081004232555
260 Allow for selecting several packages in one go.
261 Currently when we select a package we only list the over versions
262 of the same package that that excludes, and not the other packages
263 we exclude by applying the dependency constraints of the selected
264 package. In future we would like to do that so we now report the
265 package name of discards not just the version. Though we do group
266 by the package name to avoid too much repition.
267]
268[Fix infinite loop in the TopDown dependency resolver
269Andrea Vezzosi <sanzhiyan@gmail.com>**20080925181441
270 The loop occurred only if a package depended on another one
271 with the same name, e.g. base-3.0.3.0 <- base-4.0.0.0
272]
273[small improvements to bootstrap
274Duncan Coutts <duncan@haskell.org>**20080926214828
275 patch sent in by brian0, ticket #357
276]
277[Update to the development version of the Cabal lib
278Duncan Coutts <duncan@haskell.org>**20080831225243
279 The branch of cabal-install that tracks Cabal-1.4 now lives at
280 http://darcs.haskell.org/cabal-branches/cabal-install-0.5/
281]
282[Allow use of curl in bootstrap.sh
283Duncan Coutts <duncan@haskell.org>**20080826233400
284 Patch from jsnx. Fixes ticket #343. Also, use "cd blah; cd .."
285 instead of "pushd blah; popd" as some shells lack pushd/popd
286]
287[Relax version constraint on unix package
288Duncan Coutts <duncan@haskell.org>**20080826232851
289 Allows building with ghc-6.6.1
290]
291[Use mplus not mappend for combining tar filename checks
292Duncan Coutts <duncan@haskell.org>**20080826232606
293 mappend would join the error messages in the case that both
294 checks failed. Also the monoid instance was new in base 3.
295]
296[TAG 0.5.2
297Duncan Coutts <duncan@haskell.org>**20080826214238]
298Patch bundle hash:
2995d014875a1a21c26cd3200a1392eb9c5a3cc840d