-
Notifications
You must be signed in to change notification settings - Fork 703
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
Support relocatable packages #462
Comments
(Imported comment by @dcoutts on 2009-01-20) Note that the mechanism to support relocatable packages can and should also be used to let us run programs from the build tree and still enable them to find their data files in the build tree. The use of environment variables in the current Paths_pkgname module already allow this use, at least on Unix. We just need to take advantage of it by generating wrapper scripts. This would also be nice for supporting running programs with runhaskell (eg for hugs or ghc). |
(Imported comment by @bos on 2009-01-20) This would definitely be nice to have. I have a small application that I'd like to redistribute in binary form, but it needs data files, and I've no idea how I'd create a relocatable package on Linux, OS X, or Windows at the moment. At least on OS X and Linux, I can fudge by just installing it in /usr, but I don't have any such luxury on Windows. |
#1542 seems related |
Are there any plans to do this? I've just discovered we had a local hack in our custom build system to find data files relative to an executable, and it broke with a recent change to the default datadir in Cabal. I'd love to be able to get rid of our custom hacks and use real relocatable package support. It can't be that hard, given that we already do it on Windows. |
Also, |
I don't think there's anyone who has time to do it, but on the other hand it shouldn't be that hard for an adventurous coder that understands the problem. ;) |
I've started working on this at: https://github.com/christiaanb/cabal Currently you can do: cabal install --global --enable-relocatable
I'll report back soon to tell you if it's possible to build a relocatable Haskell platform. Currently I have a completely relocatable GHC 7.8.3 install, with a dynamically linked |
As of christiaanb@08f4d93 I have now build a relocatable version of the Haskell Platform 2014.2.0.0, with:
What I've tested until now:
I'll do some more testing, and then move on to cleaning up a bit. After that I'll start testing on Linux. |
@christiaanb What's the current state of this ticket? Is this likely to make it into a |
The only thing that I need to do is have Additionally, I'd like to test it on Linux, as I've currently only tested in on OS X. At the moment I've setup relocatable packages to fail configuring when the platform is unsupported. |
@christiaanb Very exciting, can't wait. I'll go ahead and start using this as soon as it's merged into cabal |
@christiaanb Do relocatable packages enable a relocatable |
@gibiansky It needs an absolute prefix to know where to put things. As long as the specified |
@christiaanb Ah, got it, thanks. In that case, it should be safe to do something like this:
This way we can emulate having a relative directory |
@gibiansky Actually... |
@gibiansky: The The only non-relocatable item in the |
@christiaanb: I believe the issues of relocatable GHC packages and relocatable With relocatable GHC packages, we will be halfway to having relocatable Cabal sandboxes, as each sandbox contains a GHC package configuration database. The One of the remaining issue for relocatable Cabal sandboxes is the |
@christiaanb: Does PR#2255 being merged mean this issue is fully fixed and can be closed? |
No, this issue cannot be closed. At the end of #2255 it says: As said, this partially implements #462. To fully implement that issue, we would additionally need a deploy command. Which you would call like: cabal deploy --deploy-dir=<deploy_dir> which would collect the binaries, libraries of the dependencies (in case of a dynamically linked executable), and data-files, and turn them into a relocatable bundle at the specified directory. |
@christiaanb: From the point of view of the user, what would be the difference between |
@mietek: |
@christiaanb Are you still working on this and (if so) how close is this to landing (modulo code review)? |
@BardurArantsson No, #2255 is the last I worked on it. #2255 provides a good start, I'd say it gets you 33% to 50% of achieving the goals of this (#462) issue. What is still needed:
I don't see myself working on the above issues any time soon. What #2255 does get you is (mostly) relocatable sandboxes: http://christiaanb.github.io/posts/relocatable-sandboxes/ |
One way people (including myself) deal around the |
@mantkiew: what's the cross-platform support for |
I confirm that it works on Windows and Linux. I haven't tested on MacOS yet. It certainly is not a universal mechanism and there will be size limits. Besides, keeping 1GB on the heap does not make any sense. I only used it for small files. |
See also haskell#462. Signed-off-by: Edward Z. Yang <[email protected]>
@bos @simonmar @christiaanb However,
There’s obviously a lot of interest in the capability and the lack of it is holding back deployment of Haskell-based tools. Are there any plans to tackle this soon? Related: |
No one is actively working on this AFAIK, but I think it'd make a good GSoC project. |
The approach described by hlint's author @ndmitchell solves the issue of hardcoded All that's required is to specify the path within a file called
Also, setting the environment variable Also see commercialhaskell/stack#5026. |
Relocatable data files are still not supported in Stack, and there are no per-package workarounds in Gitit or its dependencies other than Pandoc's embed_data_files flag. Therefore, I will continue the existing approach of using Cabal with frozen deps instead of Stack. jgm/gitit#622 haskell/cabal#462 commercialhaskell/stack#848
(Imported from Trac #469, reported by @dcoutts on 2009-01-20)
This is both useful and doable on both Windows and Unix systems.
We already have limited support for relocatable (also sometimes called prefix-independent) packages on Windows. Specifically, a relocatable package is often what people want when they want to prepare a package for redistribution, especially on Windows for use with an installer. What is required is that an exe and all supporting files (data files and potentially also other shared libs) exist together in one directory hierarchy and that that directory can be placed anywhere in the filesystem and the exe will still be able to find all its associated support files.
There are some restrictions on preparing a relocatable package. In particular the user must configure it such that all install directories for the various kinds of files (libdir, datadir etc) are relative to the $prefix.
Configuring a relocatable package should be something that is done explicitly. At the moment it is done simply by configuring it in the right way, but Cabal is never aware that the user is trying to construct a relocatable package. If it is explicit then we can take different actions if necessary (as it is on unix) and do additional checks.
So a configure option --relocatable or something should be used. Installing a relocatable package is somewhat of an exception because it involves using a prefix which would otherwise be empty. Creating an image for a relocatable package would use a empty $prefix.
The tricky issues that have to be addressed are:
- data files for the program itself
- data files in library dependencies
- shared libraries
The mechanism for finding data files at runtime is the Paths_pkgname module that Cabal generates. On Windows this can make use of the Win32 api that lets a .exe program discover where it was run from. On unix there is no reliable equivalent but the next best alternative is to use wrapper scripts to set environment variables before running the real program.This mechanism can work pretty well for data files that belong to the executable. It is rather harder for data files in dependent packages (see #459). One option would be to copy the data files belonging to dependent packages and install them along with the executable (checking for clashes). This would involve being able to locate the data files of installed libraries which would require extending the data stored for installed packages. Libraries that require data files are relatively rare (though this should be checked) so this feature could be punted for an initial version.
In future there will also be the issue of shared libraries to consider. That is, when Haskell implementations can produce Haskell libs as shared libraries. This complicates the construction of relocatable packages. Again the approach taken on Windows and Unix will have to be different. On Windows it will be possible to copy the .dll files into the same directory as the .exe file (or a subdir if using .manifest files). On Unix a wrapper script using LD_LIBRARY_PATH will probably be necessary.
The text was updated successfully, but these errors were encountered: