Ticket #490: fix-_490_-unpack-now-gives-a-proper-error-message_.dpatch

File fix-_490_-unpack-now-gives-a-proper-error-message_.dpatch, 23.8 KB (added by Saizan, 4 years ago)

initial patch

Line 
1Sun Feb  8 17:52:40 CET 2009  Andrea Vezzosi <sanzhiyan@gmail.com>
2  * Fix #490, unpack now gives a proper error message.
3
4New patches:
5
6[Fix #490, unpack now gives a proper error message.
7Andrea Vezzosi <sanzhiyan@gmail.com>**20090208165240
8 Ignore-this: 358dd291624f8858a52ae2ff27a7e0c2
9] {
10hunk ./Distribution/Client/Unpack.hs 23
11 import Distribution.Package ( packageId, Dependency(..) )
12 import Distribution.Simple.PackageIndex as PackageIndex (lookupDependency)
13 import Distribution.Simple.Setup(fromFlag, fromFlagOrDefault)
14-import Distribution.Simple.Utils(info, notice)
15+import Distribution.Simple.Utils(info, notice, die)
16 import Distribution.Text(display)
17 import Distribution.Version (VersionRange(..))
18 
19hunk ./Distribution/Client/Unpack.hs 30
20 import Distribution.Client.Setup(UnpackFlags(unpackVerbosity,
21                                              unpackDestDir))
22 import Distribution.Client.Types(UnresolvedDependency(..),
23-                                 Repo, AvailablePackageSource(RepoTarballPackage),
24+                                 Repo, AvailablePackageSource(..),
25                                  AvailablePackage(AvailablePackage),
26                                  AvailablePackageDb(AvailablePackageDb))
27 import Distribution.Client.Fetch(fetchPackage)
28hunk ./Distribution/Client/Unpack.hs 60
29 
30   unless (null prefix) $
31          createDirectoryIfMissing True prefix
32-  sequence_
33-      [ do pkgPath <- fetchPackage verbosity repo pkgid
34-           let pkgdir = display pkgid
35-           notice verbosity $ "Unpacking " ++ display pkgid ++ "..."
36-           info verbosity $ "Extracting " ++ pkgPath
37-                    ++ " to " ++ prefix </> pkgdir ++ "..."
38-           extractTarGzFile prefix pkgPath
39-      | (AvailablePackage pkgid _ (RepoTarballPackage repo)) <- pkgs ]
40 
41hunk ./Distribution/Client/Unpack.hs 61
42+  flip mapM_ pkgs $ \pkg ->
43+      case pkg of
44+
45+        Left (Dependency name ver) ->
46+            die $ "There is no available version of " ++ display name
47+                  ++ " that satisfies " ++ display ver
48+
49+        Right (AvailablePackage pkgid _ (RepoTarballPackage repo)) -> do
50+                 pkgPath <- fetchPackage verbosity repo pkgid
51+                 let pkgdir = display pkgid
52+                 notice verbosity $ "Unpacking " ++ display pkgid ++ "..."
53+                 info verbosity $ "Extracting " ++ pkgPath
54+                          ++ " to " ++ prefix </> pkgdir ++ "..."
55+                 extractTarGzFile prefix pkgPath
56+
57+        Right (AvailablePackage _ _ LocalUnpackedPackage) ->
58+            error "Distribution.Client.Unpack.unpack: the impossible happened."
59     where
60       verbosity = fromFlag (unpackVerbosity flags)
61       prefix = fromFlagOrDefault "" (unpackDestDir flags)
62hunk ./Distribution/Client/Unpack.hs 85
63 
64 resolvePackages :: AvailablePackageDb
65                    -> [Dependency]
66-                   -> [AvailablePackage]
67+                   -> [Either Dependency AvailablePackage]
68 resolvePackages (AvailablePackageDb available prefs) deps =
69hunk ./Distribution/Client/Unpack.hs 87
70-    map (maximumBy (comparing packageId) . candidates) deps
71+    map (\d -> best d (candidates d)) deps
72     where
73       candidates dep@(Dependency name ver) =
74           let [x,y] = map (PackageIndex.lookupDependency available)
75hunk ./Distribution/Client/Unpack.hs 96
76                          `IntersectVersionRanges` ver)
77                       , dep ]
78           in if null x then y else x
79+      best d [] = Left d
80+      best _ xs = Right $ maximumBy (comparing packageId) xs
81+
82}
83
84Context:
85
86[Use the new withTempDirectory function
87Duncan Coutts <duncan@haskell.org>**20090202012255
88 In particular it means that install will unpack packages into
89 different temp dirs on each invocation which means that running
90 install on the same package for different compilers at the same
91 time should not clash. This is quite useful for testing.
92]
93[Add compat withTempDirectory function
94Duncan Coutts <duncan@haskell.org>**20090202011917
95 This is already in Cabal HEAD but we cannot use that yet
96]
97[Add homepage and bug-reports fields to .cabal file
98Duncan Coutts <duncan@haskell.org>**20090201225021]
99[Remove the prefernece and cabal lib version flags from the InstallFlags
100Duncan Coutts <duncan@haskell.org>**20090126012412
101 They are now in the ConfigExFlags instead.
102]
103[Change the install and configure modules to use the extended config flags
104Duncan Coutts <duncan@haskell.org>**20090126011942]
105[Add ConfigExFlags into the configure, install and upgrade commands
106Duncan Coutts <duncan@haskell.org>**20090126010918
107 Not yet passed all the way through.
108]
109[Add ConfigExFlags and related command
110Duncan Coutts <duncan@haskell.org>**20090126010132
111 This is for configure flags that we use in the configure command in the
112 cabal command line tool that are not present in runghc Setup configure
113 command line interface. These are flags that we are moving from the
114 install command, so that we can also use them for the configure command.
115 Initially it's just the flags for specifying package version preferences
116 and  the cabal library version. We'll add constraints later.
117]
118[Remove unnecessary qualified use of ConfigFlags
119Duncan Coutts <duncan@haskell.org>**20090126003951]
120[Make configure use the dependency resolver
121Duncan Coutts <duncan@haskell.org>**20090125170951
122 This means it makes smarter decisions and also decions that are more
123 consistent with those taken by the install command.
124]
125[Update HTTP dep in the bootstrap script
126Duncan Coutts <duncan@haskell.org>**20090123160700]
127[Improve error message when ghc or ghc-pkg are mismatched or not found
128Duncan Coutts <duncan@haskell.org>**20090123160550]
129[Don't use grep -e, solaris does not like it
130Duncan Coutts <duncan@haskell.org>**20090123160443]
131[Fix some FIXMEs and do some TODOs in the list command
132Duncan Coutts <duncan@haskell.org>**20090123004810
133 Now properly prints if the haddock docs are installed and if the
134 tarball is cached. It did print them before but it was lying.
135]
136[Add initial implementation of cabal info
137Duncan Coutts <duncan@haskell.org>**20090119025202
138 It provides more detailed information on a particular package.
139 Still a few TODOs. Fixes #361, #449 and #456.
140]
141[Only print the config file location for the global --help
142Duncan Coutts <duncan@haskell.org>**20090116175900]
143[Update to using HTTP-4000.x
144Duncan Coutts <duncan@haskell.org>**20090116135646
145 This should fix a long-standing bug with http proxies (ticket #352)
146 It should also make downloads faster, or at least use less memory.
147]
148[Parse compiler field from old config files correctly
149Duncan Coutts <duncan@haskell.org>**20090116002851
150 Really old versions of cabal-install generated a default config
151 containing "compiler: GHC". Sadly the new way we generate the
152 config file parser from the command line parser means we end up
153 with a case-sensitive parser as it only matches the exact
154 command line flags. So we hack it and add in a traditional
155 parser for that field only. Really the command line and config
156 file infrastructure needs rewriting again. Sigh.
157]
158[Improve the printing of config file field parse error messages
159Duncan Coutts <duncan@haskell.org>**20090116001421]
160[Read install dirs correctly from old-style .cabal/config files
161Duncan Coutts <duncan@haskell.org>**20090116001321
162 Should fix ticket #365
163]
164[Note in the README that zlib needs the zlib C lib package
165Duncan Coutts <duncan@haskell.org>**20090116000541]
166[Traditional /bin/sh portability fixes for bootstrap.sh
167Duncan Coutts <duncan@haskell.org>**20090115113227]
168[More improvments to the bootstrap.sh script
169Duncan Coutts <duncan@haskell.org>**20090115110612]
170[Rewrite the bootstrap.sh script
171Duncan Coutts <duncan@haskell.org>**20090115102210
172 Hopefully more useful and more robust. In particular it does not
173 download and install packages where suitable versions are already
174 installed. It also checks for deps.
175]
176[Don't add installed constraints system packages that are not installed
177Duncan Coutts <duncan@haskell.org>**20090114143540
178 In particular fixes a problem (ticket #439) where we required the
179 installed version of ghc-prim with compilers that do not have that
180 package such as ghc-6.8 and older, hugs, nhc, lhc etc.
181]
182[cabal update now reports if a newer version of cabal-install is available
183Duncan Coutts <duncan@haskell.org>**20090114133220]
184[Warn if a package index from a remote repo is 15 days or older
185Duncan Coutts <duncan@haskell.org>**20090114124827
186 For example it will print:
187 Warning: The package list for 'hackage.haskell.org' is 16 days old.
188 Run 'cabal update' to get the latest list of available packages.
189]
190[Don't display the category in cabal list output
191Duncan Coutts <duncan@haskell.org>**20090114003549
192 It is probably not sufficiently useful to justify the space it takes.
193]
194[In cabal list, always display available and installed versions
195Duncan Coutts <duncan@haskell.org>**20090114003329
196 Previously we omitted the line if it was not installed, or was
197 not available. However that confused people because it was not
198 obvious that it would list both. Now it shows something like:
199  * foo
200        Latest version available: 1.0
201        Latest version installed: [ Not installed ]
202]
203[Print the location of the config file in the global --help
204Duncan Coutts <duncan@haskell.org>**20090113192215
205 Ticket #413
206]
207[Improve the cabal --help output
208Duncan Coutts <duncan@haskell.org>**20090113192058
209 Put the general info message at the top and make the explanation of
210 installing a hackage package somewhat clearer.
211]
212[Display examples in cabal install --help
213Duncan Coutts <duncan@haskell.org>**20090113161426
214 Examples:
215   cabal install                     Package in the current directory
216   cabal install foo                 Package from the hackage server
217   cabal install foo-1.0             Specific version of a package
218   cabal install 'foo < 2'           Constrained package version
219]
220[Print a newline after entering upload password
221Duncan Coutts <duncan@haskell.org>**20090113142604
222 So we end up with:
223   Hackage password:
224   Uploading test.tar.gz...
225 rather than:
226   Hackage password: Uploading test.tar.gz...
227]
228[Respect the --package-db flag when compiling Setup.hs
229Duncan Coutts <duncan@haskell.org>**20081221184755
230 Fixes ticket #394.
231]
232[Use a more precise package substitution test in improvePlan
233Duncan Coutts <duncan@haskell.org>**20081219215922
234 This is where we take a valid plan and we "improve" it by swapping
235 installed packages for available packages wherever possible. This
236 change is to the condition we use in deciding if it is safe to use
237 the installed package in place of a reinstall. Previously we checked
238 that the dependencies of the installed version were exactly the same
239 as the dependencies we were planning to reinstall with. That was
240 valid but rather conservative. It caused problems in some situations
241 where the installed package did not exactly match the available
242 package (eg when using development versions of a package or of ghc).
243 What we do now is test if the extra constraints implied by selecting
244 the installed version are consistent with the existing set of
245 constraints. This involves threading the constraint set around. In
246 theory this should even cope with adding additional packages to the
247 plan as a result of selecting an installed package.
248]
249[Use installed constraints instead of hiding versions of the base package
250Duncan Coutts <duncan@haskell.org>**20081219193740
251 We want to stop cabal-install from accidentally trying to upgrade
252 the base package since this doesn't work in most cases. We used to
253 achieve that by deleting the base package from the available package
254 index. We now do it by leaving the package index as is and instead
255 adding a constraint that we pick only an installed version of base.
256 This is a nicer hack and has the potential to give better error
257 messages.
258]
259[Extend the invariant on the Constraints ADT
260Duncan Coutts <duncan@haskell.org>**20081219192309
261 It now carries around the original version of the database
262 purely so that it can do a much more extensive consistency
263 check. Packages are never gained or lost, just transfered
264 between pots in various slightly tricky ways.
265]
266[Fix constraint set handling for installed constraints
267Duncan Coutts <duncan@haskell.org>**20081219182328
268 A rather subtle bug. The code was actually correct but the transitionsTo
269 assertion was not accounting for a transition between the case where
270 a package's available version had been excluded and then the whole thing
271 got excluded by a version constraint. It counted one side as a loss
272 without a corresponding gain on the other side.
273]
274[Add a install/upgrade --preference='foo < 2' flag
275Duncan Coutts <duncan@haskell.org>**20081218213849
276 This behaves just like the preferred-versions file in the hackage index
277 but it can be specified on the command line or in a config file.
278]
279[Generalise the way preferences are specified to the resolver
280Duncan Coutts <duncan@haskell.org>**20081218204917
281 We still provide a default global policy, but now we give a
282 list of per-package preferences which can be on the version
283 or installed state. Later preferences override earlier ones.
284]
285[Workaround for a url parsing bug that breaks http proxies that need auth
286Duncan Coutts <duncan@haskell.org>**20081218165541
287 Diagnosis and patch from Valery V. Vorotyntsev.
288]
289[Implement cabal install --constraint=
290Duncan Coutts <duncan@haskell.org>**20081216235032
291 Connect up the existing user interface with the new dep resolver api.
292]
293[Have the dep resolver take constraints and targets separately
294Duncan Coutts <duncan@haskell.org>**20081216233446]
295[Add PackageInstalledConstraint to the PackageConstraint type
296Duncan Coutts <duncan@haskell.org>**20081215224538
297 This should be useful for things like preventing upgrading
298 the base package for ghc.
299]
300[A bit more renaming in the top down resolver
301Duncan Coutts <duncan@haskell.org>**20081215224324]
302[Take preferences into account in the bogus resolver
303Duncan Coutts <duncan@haskell.org>**20081215221728]
304[Mostly renaming and trivial refactoring
305Duncan Coutts <duncan@haskell.org>**20081215221034]
306[Change the dep resolver interface to pass constraints separately from targets
307Duncan Coutts <duncan@haskell.org>**20081215215634
308 This lets us specify constraints for packages that are not targets.
309]
310[Rename and rearrange the PackagePreferences type
311Duncan Coutts <duncan@haskell.org>**20081215204836]
312[Don't re-export PackageName from Distribution.Client.Dependency
313Duncan Coutts <duncan@haskell.org>**20081215203617
314 It used to be a type alias.
315]
316[Use the Platform type rather than passing around the OS and Arch separately
317Duncan Coutts <duncan@haskell.org>**20081215202856]
318[Bump version to 0.6.1
319Duncan Coutts <duncan@haskell.org>**20081210224713]
320[Tidy up the unpack code
321Duncan Coutts <duncan@haskell.org>**20081210223633
322 Also fix a bug for tar files that contain entries for files
323 without preceding entries for the directories they are in.
324]
325[Clean up the code in Main
326Duncan Coutts <duncan@haskell.org>**20081210223242
327 Make the names more regular and set up the various flags
328 in a more regular way.
329]
330[Use (\_ -> []) instead of mempty to avoid funky Monoid instance
331Duncan Coutts <duncan@haskell.org>**20081210223106
332 This would let us build with ghc-6.4 or nhc if it were not for other issues.
333]
334[Fix warning aobut -fffi in OPTIONS pragma
335Duncan Coutts <duncan@haskell.org>**20081203005449]
336[Mention where files get downloaded to at verbosity level verbose
337Duncan Coutts <duncan@haskell.org>**20081203004427]
338[Implement 'cabal unpack' command as in #390
339Andrea Vezzosi <sanzhiyan@gmail.com>**20081113185923]
340[Remove use of tabs
341Duncan Coutts <duncan@haskell.org>**20081122163527]
342[Put explicit lower bound on version of base
343Duncan Coutts <duncan@haskell.org>**20081122163151
344 It does not build with ghc-6.4.2, missing Functor instance for Either.
345]
346[Use a more general fix for "cabal install base"
347Duncan Coutts <duncan@haskell.org>**20081122163026
348 It's not specific to LHC. Normally we prevent upgrading of base
349 since it's unlikely to work and would normally be accidental.
350 However when the user explicitly asks to upgrade base then we
351 let them do that and they can keep the pieces when it breaks.
352]
353[Warn about use of tabs
354Duncan Coutts <duncan@haskell.org>**20081122154309]
355[Only send the base file name when uploading tarballs
356Duncan Coutts <duncan@haskell.org>**20080903230334
357 The server should ignore the dir part anyway but there's no
358 need to send it in the first place.
359]
360[Slightly better lhc support.
361Lemmih <lemmih@gmail.com>**20081121034338
362 Ignore-this: 9f51f465aa87d1c6677ca492f877ecd6
363]
364[TAG 0.6.0
365Duncan Coutts <duncan@haskell.org>**20081011195420]
366[Bump version to 0.6.0
367Duncan Coutts <duncan@haskell.org>**20081011195314]
368[Improve the README, better install instructions
369Duncan Coutts <duncan@haskell.org>**20081011185919
370 And slightly better intro guide to the main commands.
371]
372[Bump versions of deps in the bootstrap script
373Duncan Coutts <duncan@haskell.org>**20081011184937]
374[Add Eq for a couple types in the anon build reports
375Duncan Coutts <duncan@haskell.org>**20081011184825]
376[Drop silly export
377Duncan Coutts <duncan@haskell.org>**20081011184805]
378[Apparnetly builds with unix-2.0 which is what came with ghc-6.6
379Duncan Coutts <duncan@haskell.org>**20081010234836]
380[Fix the -i dir for compiling Setup.hs when it's the current dir
381Duncan Coutts <duncan@haskell.org>**20081010234558
382 map "" to "."
383]
384[Tidy up the preferred-versions file parser
385Duncan Coutts <duncan@haskell.org>**20081010070105]
386[Bump version number and dependencies
387Duncan Coutts <duncan@haskell.org>**20081010065854]
388[Relax deps to build with ghc-6.10
389Duncan Coutts <duncan@haskell.org>**20081007230701]
390[Handle build reports with missing logs better
391Duncan Coutts <duncan@haskell.org>**20081007230635]
392[Add DownloadFailed as a possible failure for installation
393Duncan Coutts <duncan@haskell.org>**20081007230418
394 Should now be caught during installing a bunch of packages
395 and not cause immediate overall failure. It should instead
396 be treated like any other package build failure and be
397 reported at the end and only affect other dependent builds.
398]
399[Fix search paths for compiling Setup.hs scrips
400Duncan Coutts <duncan@haskell.org>**20081007213630
401 and in particular for bootstrapping the Cabal lib.
402]
403[Fix selecting paired packages
404Duncan Coutts <duncan@haskell.org>**20081007062930
405 Previously when we selected base 4 (and as a consequence
406 slected base 3 too) we didn't properly trace the dependencies
407 of base 3 so if nothing actually required base 3 then we ended
408 up with base 3 in the solution but not with syb which it
409 depends on. Consequently the solution was invalid.
410 Now we select the paired package properly (hopefully).
411]
412[Take preferred versions into account in dependency planning
413Duncan Coutts <duncan@haskell.org>**20081006055129
414 This means we can now globally prefer base 3 rather than 4.
415 However we need to be slightly careful or we end up deciding
416 to do silly things like rebuild haskell98 against base 3.
417 That would happen because the h98 package doesn't constrain
418 the choice to one or the other and we would prefer base 3.
419 So we have to add that we really prefer whatever it uses
420 currently (if any).
421]
422[Pass the package suggested version constraints through to the resolver
423Duncan Coutts <duncan@haskell.org>**20081006042758
424 Not used yet.
425]
426[Fix selection of paired packages
427Duncan Coutts <duncan@haskell.org>**20081006040616]
428[Read preferred versions from the package index
429Duncan Coutts <duncan@haskell.org>**20081006030259
430 From a file named 'preferred-versions' in the 00-index.tar.gz
431 If there are several they are combined. Contents is like:
432 base < 4
433 one suggested version constraint per line.
434]
435[Refactor and update the hackage index reading code
436Duncan Coutts <duncan@haskell.org>**20081005202747]
437[Print more details about what is to be installed with -v
438Duncan Coutts <duncan@haskell.org>**20081005075556
439 Reports if installs are new or reinstalls and for reinstalls
440 prints what dependencies have changed.
441]
442[When finalising paired packages, cope with there being multiple choices
443Duncan Coutts <duncan@haskell.org>**20081005053821
444 For ordinary packages we selected a single version which means
445  we added an equality constraint. As a consequence we used to
446 assume there was only one version left when finalising. For
447 paired packages there may be two versions left if the package
448 did not directly constrain the choice to just one. If there is
449 more than one version remaining then we have to pick between
450 them. At the moment we still pick the highest version, but
451 later we can take a global preference or polciy into account.
452]
453[When selecting paired packages, select both.
454Duncan Coutts <duncan@haskell.org>**20081005053804]
455[Handle constraints on paired packages
456Duncan Coutts <duncan@haskell.org>**20081005051919
457 The trick is that when applying constraints to paired
458 packages, the constraint has to exclude both packages at
459 once. We exclude the pair together or not at all. If it
460 would only exclude one then we discard the constraint.
461]
462[Add the notion of paired packages to the Constraints ADT
463Duncan Coutts <duncan@haskell.org>**20081005013141
464 Packages like base-3 and base-4 are paired. This means they are
465 supposed to be treated equivalently in some contexts. Paired
466 packages are installed packages with the same name where one
467 version depends on the other.
468]
469[Make InstalledPackage an instance of PackageFixedDeps
470Duncan Coutts <duncan@haskell.org>**20081005012741]
471[Add the glue code to actully report excluded packages
472Duncan Coutts <duncan@haskell.org>**20081005001400
473 Now displayed in the output of install --dry-run -v
474]
475[Have Constraints.constrain report the excluded packages
476Duncan Coutts <duncan@haskell.org>**20081004235006
477 Each time we apply a constraint we can end up excluding some
478 extra package. Report that list of packages because it is
479 quite interesting information to get insight into what the
480 resolver is actually doing.
481]
482[Separate the construction of the exclusion list from its use
483Duncan Coutts <duncan@haskell.org>**20081004234421
484 Previously directly inserted packages into the excluded package
485 list. Now we generate a list of them and then add them. We want
486 the list of newly excluded packages separately because it is
487 interesting information to report to the user when -v is on.
488]
489[Generalise the logging of selected and discarded packages
490Duncan Coutts <duncan@haskell.org>**20081004232555
491 Allow for selecting several packages in one go.
492 Currently when we select a package we only list the over versions
493 of the same package that that excludes, and not the other packages
494 we exclude by applying the dependency constraints of the selected
495 package. In future we would like to do that so we now report the
496 package name of discards not just the version. Though we do group
497 by the package name to avoid too much repition.
498]
499[Fix infinite loop in the TopDown dependency resolver
500Andrea Vezzosi <sanzhiyan@gmail.com>**20080925181441
501 The loop occurred only if a package depended on another one
502 with the same name, e.g. base-3.0.3.0 <- base-4.0.0.0
503]
504[small improvements to bootstrap
505Duncan Coutts <duncan@haskell.org>**20080926214828
506 patch sent in by brian0, ticket #357
507]
508[Update to the development version of the Cabal lib
509Duncan Coutts <duncan@haskell.org>**20080831225243
510 The branch of cabal-install that tracks Cabal-1.4 now lives at
511 http://darcs.haskell.org/cabal-branches/cabal-install-0.5/
512]
513[Allow use of curl in bootstrap.sh
514Duncan Coutts <duncan@haskell.org>**20080826233400
515 Patch from jsnx. Fixes ticket #343. Also, use "cd blah; cd .."
516 instead of "pushd blah; popd" as some shells lack pushd/popd
517]
518[Relax version constraint on unix package
519Duncan Coutts <duncan@haskell.org>**20080826232851
520 Allows building with ghc-6.6.1
521]
522[Use mplus not mappend for combining tar filename checks
523Duncan Coutts <duncan@haskell.org>**20080826232606
524 mappend would join the error messages in the case that both
525 checks failed. Also the monoid instance was new in base 3.
526]
527[TAG 0.5.2
528Duncan Coutts <duncan@haskell.org>**20080826214238]
529Patch bundle hash:
530da39cd83b767c01aac3451407b7d3990cfc560ce