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

Implement file+noindex:///local/repositories #6448

Merged
merged 1 commit into from
Dec 23, 2019

Conversation

phadej
Copy link
Collaborator

@phadej phadej commented Dec 18, 2019

Resolve #6359

preferred-versions are left out for now.
It shouldn't be difficult to add, but needs work nevertheless.

Also change the index cache to use Distribution.Utils.Structured,
making Binary instances generically derived.

Almost as a feature generated 01-index.cache is never updated.
If you change the contents of the directory, you have to purge
01-index.cache file yourself.

Screenshot from 2019-12-19 14-32-56

@phadej phadej requested a review from hvr December 18, 2019 22:34
@phadej phadej force-pushed the local-no-index branch 4 times, most recently from 7f7633b to 74c8ea4 Compare December 20, 2019 16:44
@phadej
Copy link
Collaborator Author

phadej commented Dec 20, 2019

I used the current state to build hadrian in "offline" mode, see https://gitlab.haskell.org/ghc/ghc/merge_requests/2348

I'll merge this soon to backport to 3.2 branch. Please review.

@phadej phadej added this to the 3.2.0.0 milestone Dec 20, 2019
@typedrat
Copy link
Collaborator

This is exactly functionality that I was sorely missing the last time that I worked on trying to redesign/fix v2-install! Nice.

@phadej
Copy link
Collaborator Author

phadej commented Dec 21, 2019

@typedrat could you expand on that? What breaks with packages: **/*.tar.gz? Could you open issue describing that problem. We might want to extend what can be specified in the project file still. There is overlap, and drawing a line is difficult.

Creating a temporary LocalRepo with a sdists of a cabal.project is simple and elegant solution, if we have a way to force cabal install versions from that LocalRepo, and not other configured repositories. The repository overriding / preference is not developed yet. #6139 is related. Yet we have to think about the problem better. I guess we

  • often want package wide shadowing, i.e. "later" repository with pkg-verA removes all pkg from previous repositories
  • but sometimes only per-version shadowing is enough, i.e. pkg-verA shadows only pkg-verB
  • and with case of remote repositories we might want to selectively pick only some packages (or package-versions`) from overlays

I.e. we have develop a small configuration language for mconcat in

let (pkgs, prefs) = mconcat pkgss
prefs' = Map.fromListWith intersectVersionRanges
[ (name, range) | Dependency name range _ <- prefs ]
i.e. parametrise PackageIndex merge
-- | Merge two indexes.
--
-- Packages from the second mask packages of the same exact name
-- (case-sensitively) from the first.
--
merge :: Package pkg => PackageIndex pkg -> PackageIndex pkg -> PackageIndex pkg
merge i1@(PackageIndex m1) i2@(PackageIndex m2) =
assert (invariant i1 && invariant i2) $
mkPackageIndex (Map.unionWith mergeBuckets m1 m2)
-- | Elements in the second list mask those in the first.
mergeBuckets :: Package pkg => [pkg] -> [pkg] -> [pkg]
mergeBuckets [] ys = ys
mergeBuckets xs [] = xs
mergeBuckets xs@(x:xs') ys@(y:ys') =
case packageId x `compare` packageId y of
GT -> y : mergeBuckets xs ys'
EQ -> y : mergeBuckets xs' ys'
LT -> x : mergeBuckets xs' ys
(EDIT: fixed the snippet)

@phadej
Copy link
Collaborator Author

phadej commented Dec 21, 2019

Note: the overriding is not important for offline usage, as there you would specify the sole LocalRepo. Single repository is simple case :)

Resolve haskell#6359

`preferred-versions` are left out for now.
It shouldn't be difficult to add, but needs work nevertheless.

We also allow relative paths, which kind of work,
if you are careful.

In addtition
- change the index cache to use `Distribution.Utils.Structured`,
  making Binary instances generically derived.
- separate Distribution.Client.HashValue into own module.
  This allows to use HashValue for hashing the part of localRepoPath
  (breaks module dependency cycle).

Almost as a feature generated 01-index.cache is never updated.
If you change the contents of the directory, you have to purge
01-index.cache file yourself.
Copy link
Member

@hvr hvr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Thanks for doing this!

@phadej phadej merged commit 0dda5b9 into haskell:master Dec 23, 2019
@phadej phadej deleted the local-no-index branch December 23, 2019 09:07
@phadej phadej mentioned this pull request Dec 23, 2019
@phadej
Copy link
Collaborator Author

phadej commented Dec 23, 2019

Backported to 3.2 in #6461

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFC: New local fs index.tar-less repository style to simplify "offline" source-distribution
4 participants