Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow $topdir and ${pkgroot} as --prefix values. #4872

Closed
angerman opened this issue Nov 7, 2017 · 4 comments · Fixed by #4892
Closed

Allow $topdir and ${pkgroot} as --prefix values. #4872

angerman opened this issue Nov 7, 2017 · 4 comments · Fixed by #4892

Comments

@angerman
Copy link
Collaborator

angerman commented Nov 7, 2017

That lifts the need to rewrite the prefix in the registration hook, when one wants to install packages $topdir or ${pkgroot} relative.

@angerman
Copy link
Collaborator Author

angerman commented Nov 7, 2017

This would allow to register a package relocatable, without resorting to the following hack

registerPackage :: Context -> Action ()
registerPackage context@Context {..} = do
    top     <- topDirectory
    ctxPath <- (top -/-) <$> Context.contextPath context
    Just (Cabal _ _ _ gpd _ _) <- readCabalFile context
    let userHooks = Hooks.autoconfUserHooks
        regHooks = userHooks
        hooks = regHooks {
          Hooks.regHook = \pd lbi us flags ->
              let lbi' = lbi { C.installDirTemplates = updateInstallDirTemplates (C.installDirTemplates lbi) }
              in (Hooks.regHook regHooks) pd lbi' us flags
          }

    liftIO $ defaultMainWithHooksNoReadArgs hooks gpd ["register", "--builddir", ctxPath]

  -- XXX: allow configure to set a prefix with a known variable. $topdir or $pkgroot
  --      that would elivate the need for this hack.
  where updateInstallDirTemplates :: LBI.InstallDirTemplates -> LBI.InstallDirTemplates
        updateInstallDirTemplates idts = idts { LBI.prefix = LBI.toPathTemplate "${pkgroot}/.." }

@23Skidoo
Copy link
Member

23Skidoo commented Nov 7, 2017

IIRC @dcoutts was opposed to implementing relocatable packages via $topdir/$pkgroot, don't remember why...

@angerman
Copy link
Collaborator Author

angerman commented Nov 7, 2017

Hmm... the logic for that is still in ghc-cabal and ghc-pkg though. And it's used on the ghc windows builds by default I believe.

@angerman
Copy link
Collaborator Author

After discussing with @hvr on a related issue yesterday. I believe the reason @dcoutts is against it might be that cabal hardcodes absolute paths (w.r.t. the $prefix) in the Paths_* file.

As such I plan to allow only ${pkgroot} and make it a non-documented/advertised option. With a note in the sourced, that this needs to be used with care. To get the Paths_* issue right, we might try to evaluate querying gkc-pkg for the path's instead. This however would likely work for global and user databases out of the box, but would need some further exploration for other package databases and how to pass their path's correctly.

@angerman angerman mentioned this issue Nov 15, 2017
4 tasks
@angerman angerman self-assigned this Nov 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants