Commit 5303684c authored by Moritz Angermann's avatar Moritz Angermann

Adds --target-packge-db

parent 08f7b13b
......@@ -146,6 +146,8 @@ copyAction flags args = do
let destArgs = case fromFlag $ copyDest flags of
NoCopyDest -> ["install"]
CopyTo path -> ["copy", "destdir=" ++ path]
CopyToDb _ -> error "CopyToDb not supported via Make"
rawSystemExit (fromFlag $ copyVerbosity flags) "make" destArgs
installAction :: InstallFlags -> [String] -> IO ()
......
......@@ -742,7 +742,7 @@ defaultInstallHook :: PackageDescription -> LocalBuildInfo
defaultInstallHook pkg_descr localbuildinfo _ flags = do
let copyFlags = defaultCopyFlags {
copyDistPref = installDistPref flags,
copyDest = toFlag NoCopyDest,
copyDest = installDest flags,
copyVerbosity = installVerbosity flags
}
install pkg_descr localbuildinfo copyFlags
......
......@@ -59,7 +59,8 @@ import Distribution.Text
import System.Directory (getAppUserDataDirectory)
import System.FilePath
( (</>), isPathSeparator
, pathSeparator, dropDrive )
, pathSeparator, dropDrive
, takeDirectory )
#ifdef mingw32_HOST_OS
import qualified Prelude
......@@ -287,19 +288,26 @@ absoluteInstallDirs :: PackageIdentifier
absoluteInstallDirs pkgId libname compilerId copydest platform dirs =
(case copydest of
CopyTo destdir -> fmap ((destdir </>) . dropDrive)
CopyToDb dbdir -> fmap (substPrefix "${pkgroot}" (takeDirectory dbdir))
_ -> id)
. appendSubdirs (</>)
. fmap fromPathTemplate
$ substituteInstallDirTemplates env dirs
where
env = initialPathTemplateEnv pkgId libname compilerId platform
substPrefix pre root path
| pre `isPrefixOf` path = root ++ drop (length pre) path
| otherwise = path
-- |The location prefix for the /copy/ command.
data CopyDest
= NoCopyDest
| CopyTo FilePath
deriving (Eq, Show)
| CopyToDb FilePath
deriving (Eq, Show, Generic)
instance Binary CopyDest
-- | Check which of the paths are relative to the installation $prefix.
--
......
......@@ -958,9 +958,21 @@ copyCommand = CommandUI
,option "" ["destdir"]
"directory to copy files to, prepended to installation directories"
copyDest (\v flags -> flags { copyDest = v })
copyDest (\v flags -> case copyDest flags of
NoFlag -> flags { copyDest = v }
Flag NoCopyDest -> flags { copyDest = v }
_ -> error "Use either 'destdir' or 'target-package-db'.")
(reqArg "DIR" (succeedReadE (Flag . CopyTo))
(\f -> case f of Flag (CopyTo p) -> [p]; _ -> []))
,option "" ["target-package-db"]
"package database to copy files into. Required when using ${pkgroot} prefix."
copyDest (\v flags -> case copyDest flags of
NoFlag -> flags { copyDest = v }
Flag NoCopyDest -> flags { copyDest = v }
_ -> error "Use either 'destdir' or 'target-package-db'.")
(reqArg "DATABASE" (succeedReadE (Flag . CopyToDb))
(\f -> case f of Flag (CopyToDb p) -> [p]; _ -> []))
]
}
......@@ -981,6 +993,7 @@ instance Semigroup CopyFlags where
-- | Flags to @install@: (package db, verbosity)
data InstallFlags = InstallFlags {
installPackageDB :: Flag PackageDB,
installDest :: Flag CopyDest,
installDistPref :: Flag FilePath,
installUseWrapper :: Flag Bool,
installInPlace :: Flag Bool,
......@@ -991,6 +1004,7 @@ data InstallFlags = InstallFlags {
defaultInstallFlags :: InstallFlags
defaultInstallFlags = InstallFlags {
installPackageDB = NoFlag,
installDest = NoFlag,
installDistPref = NoFlag,
installUseWrapper = Flag False,
installInPlace = Flag False,
......@@ -1032,6 +1046,12 @@ installCommand = CommandUI
"upon configuration register this package in the user's local package database")
, (Flag GlobalPackageDB, ([],["global"]),
"(default) upon configuration register this package in the system-wide package database")])
,option "" ["target-package-db"]
"package database to copy files into. Required when using ${pkgroot} prefix."
installDest (\v flags -> flags { installDest = v })
(reqArg "DATABASE" (succeedReadE (Flag . CopyToDb))
(\f -> case f of Flag (CopyToDb p) -> [p]; _ -> []))
]
}
......
......@@ -514,6 +514,7 @@ convertToLegacySharedConfig
installFlags = InstallFlags {
installDocumentation = mempty,
installHaddockIndex = projectConfigHaddockIndex,
installDest = mempty,
installDryRun = projectConfigDryRun,
installReinstall = mempty, --projectConfigReinstall,
installAvoidReinstalls = mempty, --projectConfigAvoidReinstalls,
......
......@@ -1486,6 +1486,7 @@ instance Semigroup InfoFlags where
data InstallFlags = InstallFlags {
installDocumentation :: Flag Bool,
installHaddockIndex :: Flag PathTemplate,
installDest :: Flag Cabal.CopyDest,
installDryRun :: Flag Bool,
installMaxBackjumps :: Flag Int,
installReorderGoals :: Flag ReorderGoals,
......@@ -1530,6 +1531,7 @@ defaultInstallFlags :: InstallFlags
defaultInstallFlags = InstallFlags {
installDocumentation = Flag False,
installHaddockIndex = Flag docIndexFile,
installDest = Flag Cabal.NoCopyDest,
installDryRun = Flag False,
installMaxBackjumps = Flag defaultMaxBackjumps,
installReorderGoals = Flag (ReorderGoals False),
......@@ -1678,6 +1680,12 @@ installOptions showOrParseArgs =
"Do not install anything, only print what would be installed."
installDryRun (\v flags -> flags { installDryRun = v })
trueArg
, option "" ["target-package-db"]
"package database to install into. Required when using ${pkgroot} prefix."
installDest (\v flags -> flags { installDest = v })
(reqArg "DATABASE" (succeedReadE (Flag . Cabal.CopyToDb))
(\f -> case f of Flag (Cabal.CopyToDb p) -> [p]; _ -> []))
] ++
optionSolverFlags showOrParseArgs
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment