Hi all,

This patch adds a build-dep command to cabal-install, so
    cabal-install build-dep mypackage
installs all the dependencies of mypackage, but not mypackage itself.

There are at least a couple of problems with this patch:
* I don't know what happens if you say
      cabal-install build-dep foo bar
  and bar is one of the transitive dependencies of foo.
* Removing the packages from the install plan should probably do so
  directly, rather than converting the plan to a list and back again.

But I'm sending it now so it doesn't just sit on my HD for eternity.


Thanks
Ian

New patches:

[Derive some more Show instances
Ian Lynagh <ig...@earth.li>**20100111213750] {
hunk ./Distribution/Client/InstallPlan.hs 130
+    deriving Show
hunk ./Distribution/Client/Types.hs 59
+    deriving Show
hunk ./Distribution/Client/Types.hs 146
+    deriving Show
hunk ./Distribution/Client/Types.hs 148
+    deriving Show
hunk ./Distribution/Client/Types.hs 151
+    deriving Show
hunk ./Distribution/Client/Types.hs 153
+    deriving Show
}

[Add a build-dep command
Ian Lynagh <ig...@earth.li>**20100117121352] {
hunk ./Distribution/Client/Install.hs 106
-         ( PackageName, PackageIdentifier, packageName, packageVersion
+         ( PackageName, PackageIdentifier(..), packageName, packageVersion
hunk ./Distribution/Client/Install.hs 136
-install, upgrade
+install
hunk ./Distribution/Client/Install.hs 146
+  -> Bool
hunk ./Distribution/Client/Install.hs 149
-  configFlags configExFlags installFlags deps =
+  configFlags configExFlags installFlags deps depsOnly = do
hunk ./Distribution/Client/Install.hs 153
-        configFlags configExFlags installFlags
+        configFlags configExFlags installFlags deps depsOnly
hunk ./Distribution/Client/Install.hs 161
+upgrade
+  :: Verbosity
+  -> PackageDBStack
+  -> [Repo]
+  -> Compiler
+  -> ProgramConfiguration
+  -> ConfigFlags
+  -> ConfigExFlags
+  -> InstallFlags
+  -> [UnresolvedDependency]
+  -> IO ()
hunk ./Distribution/Client/Install.hs 177
-        configFlags configExFlags installFlags
+        configFlags configExFlags installFlags deps False
hunk ./Distribution/Client/Install.hs 200
+        -> [UnresolvedDependency]
+        -> Bool
hunk ./Distribution/Client/Install.hs 204
-  configFlags configExFlags installFlags = do
+  configFlags configExFlags installFlags deps depsOnly = do
hunk ./Distribution/Client/Install.hs 216
-    Right installPlan -> do
+    Right installPlanX -> do
+      let dependencyPackageName (Dependency pn _) = pn
+          depNames = map (dependencyPackageName . dependency) deps
+          notInDepNames p = pkgName (packageId p) `notElem` depNames
+          xs = InstallPlan.toList installPlanX
+      let xs' = if depsOnly
+                then filter notInDepNames xs
+                else xs
+      installPlan <- case InstallPlan.new
+                              (InstallPlan.planPlatform installPlanX)
+                              (InstallPlan.planCompiler installPlanX)
+                              (PackageIndex.fromList xs') of
+                     Left problems ->
+                         die (unlines ("Install plan problems:" :
+                                       map InstallPlan.showPlanProblem problems))
+                     Right ip -> return ip
hunk ./Distribution/Client/Setup.hs 19
+    , buildDepCommand
hunk ./Distribution/Client/Setup.hs 503
+  commandDefaultFlags = (mempty, mempty, mempty),
+  commandOptions      = \showOrParseArgs ->
+       liftOptions get1 set1 (configureOptions   showOrParseArgs)
+    ++ liftOptions get2 set2 (configureExOptions showOrParseArgs)
+    ++ liftOptions get3 set3 (installOptions     showOrParseArgs)
+  }
+  where
+    get1 (a,_,_) = a; set1 a (_,b,c) = (a,b,c)
+    get2 (_,b,_) = b; set2 b (a,_,c) = (a,b,c)
+    get3 (_,_,c) = c; set3 c (a,b,_) = (a,b,c)
+
+buildDepCommand :: CommandUI (ConfigFlags, ConfigExFlags, InstallFlags)
+buildDepCommand = CommandUI {
+  commandName         = "build-dep",
+  commandSynopsis     = "Installs the deps of a list of packages.",
+  commandUsage        = usagePackages "buildDep",
+  commandDescription  = Just $ \pname ->
+    let original = case commandDescription configureCommand of
+          Just desc -> desc pname ++ "\n"
+          Nothing   -> ""
+     in original
+     ++ "Examples:\n"
+     ++ "  " ++ pname ++ " buildDep                 "
+     ++ "    Package in the current directory\n"
+     ++ "  " ++ pname ++ " buildDep foo             "
+     ++ "    Package from the hackage server\n"
+     ++ "  " ++ pname ++ " buildDep foo-1.0         "
+     ++ "    Specific version of a package\n"
+     ++ "  " ++ pname ++ " buildDep 'foo < 2'       "
+     ++ "    Constrained package version\n",
hunk ./Main.hs 21
-         , installCommand, upgradeCommand
+         , installCommand, buildDepCommand, upgradeCommand
hunk ./Main.hs 126
-      [installCommand         `commandAddAction` installAction
+      [installCommand         `commandAddAction` installAction False
+      ,buildDepCommand        `commandAddAction` installAction True
hunk ./Main.hs 187
-installAction :: (ConfigFlags, ConfigExFlags, InstallFlags)
+installAction :: Bool -> (ConfigFlags, ConfigExFlags, InstallFlags)
hunk ./Main.hs 189
-installAction (configFlags, _, installFlags) _ _globalFlags
+installAction _ (configFlags, _, installFlags) _ _globalFlags
hunk ./Main.hs 195
-installAction (configFlags, configExFlags, installFlags)
+installAction depsOnly (configFlags, configExFlags, installFlags)
hunk ./Main.hs 212
+          depsOnly
}

Context:

[Adjust to the change in the type of getInstalledPackages
Duncan Coutts <dun...@haskell.org>**20091229212020
 It used to return Maybe, now it always gives us a PackageIndex.
 This depends on an API change in Cabal-1.9.x.
] 
[Display the exception for failed downloads
Duncan Coutts <dun...@haskell.org>**20091222132526
 Not great but better than nothing.
] 
[Remove now-unused compat module
Duncan Coutts <dun...@haskell.org>**20091222130959] 
[Change the default config on Windows to per-user installs
Duncan Coutts <dun...@haskell.org>**20091228165411
 Ignore-this: afccc874f09efd2b8298ee01163c0462
 Slightly experimental. We should look out for unexpected consequences.
] 
[Move downloadURI to HttpUtils module
Duncan Coutts <dun...@haskell.org>**20091222095152
 Ignore-this: 6a80342e38c618ed5fe541fc7dfbec08
 And use exceptions rather than return codes.
] 
[Fix a couple more ghc-6.12 -Wall warnings
Duncan Coutts <dun...@haskell.org>**20091222075821
 Ignore-this: 429818d8b6fc528a155162e0eb67913d
] 
[Fix cabal sdist --snapshot
Duncan Coutts <dun...@haskell.org>**20091222080537
 Ignore-this: a1f090e1bae653645cf5d55055deab3d
] 
[Distribution/Client/InstallSymlink.hs: explicitely import 'catch' and friend tom System.IO
Sergei Trofimovich <sly...@community.haskell.org>**20091220220105
 Ignore-this: d7a4b304976bc8ce42dfae963d58694c
] 
[Distribution/Client/Install.hs: removed unused 'compilerTemplateEnv' from import
Sergei Trofimovich <sly...@community.haskell.org>**20091220215508
 Ignore-this: e850510c11ec648f6fcec6d85ce23a82
] 
[Distribution/Client/Unpack.hs: removed redundant import
Sergei Trofimovich <sly...@community.haskell.org>**20091220214545
 Ignore-this: c1120ee8014c4c1bd3177857798e563d
] 
[Distribution/Client/Setup.hs: suppress warning (unused variable)
Sergei Trofimovich <sly...@community.haskell.org>**20091220214448
 Ignore-this: 382010da79af4baf200a406d478cc5ec
] 
[Distribution/Client/Haddock.hs: removed redundant instances
Sergei Trofimovich <sly...@community.haskell.org>**20091220213757
 Ignore-this: efffb1cd16256496f70314cce6001c6f
] 
[Distribution/Client/BuildReports/Anonymous.hs: removed unused import of BuildResult
Sergei Trofimovich <sly...@community.haskell.org>**20091220213350
 Ignore-this: 50c449c43df34ceb1b13c61788bb0758
] 
[Distribution/Client/IndexUtils.hs: fixed warning on -Wall (unused result)
Sergei Trofimovich <sly...@community.haskell.org>**20091220211940
 Ignore-this: a74aded9f99237229dbfe762fcf20478
] 
[Distribution/Client/SrcDist.hs: fixed warning on -Wall (unused result)
Sergei Trofimovich <sly...@community.haskell.org>**20091220211717
 Ignore-this: d7d4fade7b5e5464d114995efdabb216
] 
[Fix fromFlag error in upgrade
Duncan Coutts <dun...@haskell.org>**20091221140752
 Ignore-this: 82eee01373bf121c1c00a7c5d27bac0f
 Use the missing defaultInstallFlags.
] 
[Reorder commands in cabal --help output
Duncan Coutts <dun...@haskell.org>**20091219034451] 
[Use the standard form of copyright statement in BSD3 license template
Duncan Coutts <dun...@haskell.org>**20091219031017
 See http://www.opensource.org/licenses/bsd-license.php
] 
[Remove stability feature from cabal init
Duncan Coutts <dun...@haskell.org>**20091219030855
 The stability field in .cabal files is deprecated since it's mostly useless.
] 
[Make the cabal init command line flag names follow the normal convention
Duncan Coutts <dun...@haskell.org>**20091219030747
 Using hyphens rather than upper case.
] 
[Fix reporting of installed program versions in cabal list
Duncan Coutts <dun...@haskell.org>**20091218232501
 We do not know if programs are installed or not so report
 unknown rather than saying it is not installed.
] 
[Update the README
Duncan Coutts <dun...@haskell.org>**20091218173459
 Ignore-this: adde7b8406a92837f295ed3d57037827
] 
[Bump head to new dev version 0.9.x
Duncan Coutts <dun...@haskell.org>**20091218172245
 Ignore-this: 378cbb031583940fb4e301d0e640c396
] 
[Update various .cabal bits
Duncan Coutts <dun...@haskell.org>**20091218171642
 Ignore-this: a54518592cf53158e6a01ff7ad8753ef
] 
[Update the bootstrap script to work with ghc-6.12
Duncan Coutts <dun...@haskell.org>**20091218165234
 Ignore-this: b4aca31e814592f1cd6d53cf5a461859
 We can no longer expect mtl, network and parsec to be installed.
] 
[Update the changelog for 0.8
Duncan Coutts <dun...@haskell.org>**20091218165221
 Ignore-this: 35f1f722b56c7eec84574e9d4be0d0f3
] 
[Fix combination of --global --package-db when compiling Setup.hs scripts
Duncan Coutts <dun...@haskell.org>**20091218165119
 Ignore-this: 6a78eaf39c21dfc692458f1046d852ce
 The order of the package db stack is important.
] 
[Allow numeric fields in tar headers that use binary format
Duncan Coutts <dun...@haskell.org>**20091123063734
 This is an old non-standard extension that some tar tools still use.
] 
[Create all parent directories of extraced files
Duncan Coutts <dun...@haskell.org>**20091122080446
 Previously only created the immediate parent directory.
 No rely more heavily on the file security check to make
 sure we are not writing files outside of the target area.
] 
[Ignore PAX entries when checking for tarbombs
Duncan Coutts <dun...@haskell.org>**20091122080255
 When checking for tarbombs, ignore PAX entry types 'g' and 'x'.
 These do not get extracted so their names do not matter.
] 
[fixed 'cabal sdist'
Sergei Trofimovich <sly...@community.haskell.org>**20091113165833
 Ignore-this: a9061231f18a00fda66bd73e0d4bac86
] 
[Build with ghc-6.6
Duncan Coutts <dun...@haskell.org>**20091110113735
 Ignore-this: 939c6d822b78b7966ccc37a0739ecc81
] 
[Fix base 4 exceptions in #ifdef WIN32 code section
Duncan Coutts <dun...@haskell.org>**20091110112415
 Ignore-this: 53ad5959a1964ff8eccf93c17dd1e3d7
] 
[Add a couple checks to "cabal unpack" and improve the messages
Duncan Coutts <dun...@haskell.org>**20091104142658
 Ignore-this: 896cf992e5862393bb5e451a337545fa
] 
[Fix bootstrap (#599)
Robin Green <gree...@greenrd.org>**20091102073414
 Ignore-this: 67304fe1c399d679c0c7a7d0d01cff45
 
] 
[Switch to using some Utils from the Cabal lib
Duncan Coutts <dun...@haskell.org>**20091102150528
 Ignore-this: fe55da37cc85ce495a65949506ac3e42
 Remove local copies. Also fixes a bug recently introduced
 in the writeFileAtomic function, spotted by Peter Robinson.
] 
[Parly fix building with ghc-6.6
Duncan Coutts <dun...@haskell.org>**20091028163849
 Ignore-this: 75f4ae640c2c2d7d46cd4c00d835b618
 The new cabal init stuff needs some work.
] 
[Fix building with ghc-6.12
Duncan Coutts <dun...@haskell.org>**20091028163719
 Ignore-this: eb25e32b7696174a4702394ea59e03bc
] 
[Fix building with ghc-6.8
Duncan Coutts <dun...@haskell.org>**20091028163352
 Ignore-this: 9dc502c70fd2e5940729656168030953
] 
[Allow building with base 4
Duncan Coutts <dun...@haskell.org>**20091028163148
 Ignore-this: 2ac8c966a4a014af94a21b7801331c19
] 
[Bump version number a bit
Duncan Coutts <dun...@haskell.org>**20091028133527
 Ignore-this: e2a10bab1da090c8aeedeb6dba74cb3
] 
[Update list of modules (so sdist works)
Duncan Coutts <dun...@haskell.org>**20091028133513
 Ignore-this: 91abc5688f598cf0a5ecf96855ccfe76
] 
[Update new cabal init code for the recent package id changes
Duncan Coutts <dun...@haskell.org>**20091028132037
 Ignore-this: 83f7b69c2a0727dba37dd7242a4f5791
] 
[Initial go at converting to the new Cabal-1.8 installed package system
Duncan Coutts <dun...@haskell.org>**20091022123946
 Ignore-this: 5e6665609e707de9dc73612b0efd25e9
 It works by ignoring the possibility that there could be multiple
 installed packages sharing the same source package Id. We just pick
 the "top most" one which is usually ok. We make no attempt to check
 that we are using consistent installed packages.
] 
[Update for changes to finalizePackageDescription
Duncan Coutts <dun...@haskell.org>**20091018173233
 Ignore-this: f60d2b66f9f0e223599ab15ac78d112c
] 
[add 'init' subcommand for initializing project cabalisation
Brent Yorgey <byor...@cis.upenn.edu>**20091011165644
 Ignore-this: df51056f9e138d38d64f48c86cdf6376
] 
[Collecting some heuristics for creating an initial cabal file
benedikt.hu...@gmail.com**20090902160332
 Ignore-this: 50eb36690a888529d209f9da5af15078
] 
[Apply suggestion for bootstrap failure message
Duncan Coutts <dun...@haskell.org>**20091020212319
 Ignore-this: 70ed13514b158db7672f5d16a9ed90ea
 ghc ticket #3602
] 
[Fix calculation of paths in check for bindir symlink overwriting
Duncan Coutts <dun...@haskell.org>**20090829004959
 Ignore-this: d4dd8e12c03d23ce935de94cedbda257
 We were doing it wrong, but Linux realpath() C function was letting
 us get away with it. The Solaris realpath() is stricter.
 The new implementation is also simpler, relying on the fact that
 the canonicalizePath function will resolve symlinks.
] 
[Require Cabal lib version 1.7.3
Duncan Coutts <dun...@haskell.org>**20090707095944
 Needs recent api changes.
] 
[Make the documentation toggle determine if we make the haddock index
Duncan Coutts <dun...@haskell.org>**20090707013030
 Previously the --haddock-index=template flag controled both the
 template used and whether it's used at all. When no path was set
 then it was not used. The problem with that is that since we are
 not enabling this feature by default then the default is blank.
 That is the default config file would look like:
 -- haddock-index:
 which doesn't help anyone discover what it means or what a
 sensible setting would be. By having a separate toggle to     
 enable/disable we can have a default for the index file which
 makes it easy to discover in the config file:
 -- documentation: False
 -- doc-index-file: $datadir/doc/index.html
 All the user has to do is uncomment the first line and use True.
] 
[Be less noisy about warning about packages with missing docs
Duncan Coutts <dun...@haskell.org>**20090707005149] 
[Use defaultInstallFlags as the defaults
Duncan Coutts <dun...@haskell.org>**20090707004836] 
[Move regenerateHaddockIndex more out-of-line in the Install module
Duncan Coutts <dun...@haskell.org>**20090707003722
 Also update the code somewhat following the changes in
 the Cabal API for path templates and substitutions.
] 
[Use $pkgroot/package/$pkgid.tar.gz as tarball URL
Duncan Coutts <dun...@haskell.org>**20090704170602] 
[#516, maintains a per-user index of haddock docs
Andrea Vezzosi <sanzhi...@gmail.com>**20090607170512
 Ignore-this: 1114f6b944043781c4bf99620573b1cc
 If the haddock-index flag is set it keeps an index 
 of the haddock documentation of the packages in 
 the global and user databases
] 
[Now supporting explicit --user or --global switches in bootstrap.sh with usage feedback for bad args
Dino Morelli <d...@ui3.info>**20090613150958
 Ignore-this: 490a4fcdd5bc1940d6f32d71b0a042a5
 This change was adapted from work submitted to the cabal-devel mailing list by Jason Dusek.
] 
[add message to 'package not found' error advising to run 'cabal update'. (#497)
Brent Yorgey <byor...@cis.upenn.edu>**20090611171233] 
[Fix sdist
Duncan Coutts <dun...@haskell.org>**20090605023441
 Fix handling of base dir in tar file creation.
] 
[Fix use of deprecated version constructors
Duncan Coutts <dun...@haskell.org>**20090604180500] 
[Only report preferred new versions of cabal-install are available
Duncan Coutts <dun...@haskell.org>**20090604175726
 That is, use the "preferred-versions" mechanism when deciding
 whether there is a new version available. This would allow us to
 upload a new version without everyone immediately being told to
 get it and try it out.
] 
[Make cabal upload/check print out the error messages reported by the server
Duncan Coutts <dun...@haskell.org>**20090604124836
 The code to do it was already there but we were checking for the
 mime type text/plain using just (==) when in fact the server reports  
   text/plain; charset="ISO-8859-1"
 so we have to parse the field a bit better (still a bit of a hack).
] 
[Require latest Cabal lib version
Duncan Coutts <dun...@haskell.org>**20090603102312] 
[Improve formatting of cabal check output
Duncan Coutts <dun...@haskell.org>**20090603102254] 
[Only apply preferences to base if its version is unbounded above
Duncan Coutts <dun...@haskell.org>**20090603101623
 Fixes ticket #485. This means that for constraints like:
     build-depends: base >= 3 && < 5
 we will pick version 4. However we will continue to apply the
 version 3 preference for things like:
     build-depends: base >= 3
 Where there is no upper bound on the version. Note that we now
 also ignore preferences for base given on the command line.
 We should implement #483 to split prefs from shims.
] 
[Improve the parse error message for package name/deps
Duncan Coutts <dun...@haskell.org>**20090321154623
 Make it clear that it's the specification of the package name that
 is at fault rather than the package to which the name refers.
] 
[Debian in their wisdom decided to build network against parsec 3.
Duncan Coutts <dun...@haskell.org>**20090308142925
 So checking for parsec 2 fails. We don't strictly need parsec, it's
 just a dependency of network, so remove the check.
] 
[Simplify version ranges before printing in error messages
Duncan Coutts <dun...@haskell.org>**20090531191346
 Part of ticket #369
] 
[Use new top handler, should get better error messages
Duncan Coutts <dun...@haskell.org>**20090531190318] 
[Fix uses of deprecated stuff
Duncan Coutts <dun...@haskell.org>**20090531190239] 
[New development branch, version 0.7
Duncan Coutts <dun...@haskell.org>**20090531184336
 Update to development version of Cabal
] 
[Solaris 9 /bin/sh doesn't like the ! syntax in bootstrap.sh
Duncan Coutts <dun...@haskell.org>**20090318091730] 
[Clarify the instructions in the README and bootstrap.sh
Duncan Coutts <dun...@haskell.org>**20090315125407
 Addresses the complaint in ticket #523.
] 
[Select Configuration file via env var CABAL_CONFIG.
Paolo Losi <paolo.l...@gmail.com>**20090223005251
 Ignore-this: 26e5ded85cb69cb3a19cd57680a8a362
] 
[Update tar code based on new tar package
Duncan Coutts <dun...@haskell.org>**20090301174949] 
[Actually does compile with unix-1.0 that comes with ghc-6.6
Duncan Coutts <dun...@haskell.org>**20090221154605
 ghc-6.6.1 came with unix-2.1
] 
[TAG 0.6.2
Duncan Coutts <dun...@haskell.org>**20090219130720] 
Patch bundle hash:
3d86e7f5cfda498478f9d8a31bd03bd64d61d5ca
_______________________________________________
cabal-devel mailing list
cabal-devel@haskell.org
http://www.haskell.org/mailman/listinfo/cabal-devel

Reply via email to