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

Add package revision and cabal file hash to plan.json #5695

Merged
merged 2 commits into from
Nov 20, 2018

Conversation

arianvp
Copy link
Collaborator

@arianvp arianvp commented Nov 18, 2018

This is useful for external tools like plan2nix [1] which
can then create their own build plan based on the cabal
solver output, even in the presence of revised cabal files.

[1] - https://github.com/angerman/nix-tools/tree/master/plan2nix


Please include the following checklist in your PR:

  • Patches conform to the coding conventions.
  • Any changes that could be relevant to users have been recorded in the changelog.
  • The documentation has been updated, if necessary.
  • If the change is docs-only, [ci skip] is used to avoid triggering the build bots.

This is useful for external tools like plan2nix [1] which
can then create their own build plan based on the cabal
solver output, even in the presence of revised cabal files.

[1] - https://github.com/angerman/nix-tools/tree/master/plan2nix
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 18, 2018
"url":"pull/5695",
"account":"haskell",
"repo":"cabal",
"commit": "b9ed3a9c99b79fb8d56167db5185253c3145c730",
"tag":"linux-7.10.3"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 18, 2018
"url":"pull/5695",
"account":"haskell",
"repo":"cabal",
"commit": "b9ed3a9c99b79fb8d56167db5185253c3145c730",
"tag":"linux-7.8.4"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 18, 2018
"url":"pull/5695",
"account":"haskell",
"repo":"cabal",
"commit": "b9ed3a9c99b79fb8d56167db5185253c3145c730",
"tag":"linux-8.2.2"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 18, 2018
"url":"pull/5695",
"account":"haskell",
"repo":"cabal",
"commit": "b9ed3a9c99b79fb8d56167db5185253c3145c730",
"tag":"linux-8.0.2"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 18, 2018
"url":"pull/5695",
"account":"haskell",
"repo":"cabal",
"commit": "b9ed3a9c99b79fb8d56167db5185253c3145c730",
"tag":"linux-7.6.3"
}
@arianvp
Copy link
Collaborator Author

arianvp commented Nov 18, 2018

By the way, feel free to bikeshed about the field names. I just arbitrarily came up with something that sort of looked appropriate

haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 18, 2018
"url":"pull/5695",
"account":"haskell",
"repo":"cabal",
"commit": "b9ed3a9c99b79fb8d56167db5185253c3145c730",
"tag":"linux-8.4.4"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 18, 2018
"url":"pull/5695",
"account":"haskell",
"repo":"cabal",
"commit": "b9ed3a9c99b79fb8d56167db5185253c3145c730",
"tag":"linux-8.6.2"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 18, 2018
"url":"pull/5695",
"account":"haskell",
"repo":"cabal",
"commit": "b9ed3a9c99b79fb8d56167db5185253c3145c730",
"tag":"linux-8.4.4-fdebug-expensive-assertions"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 18, 2018
"url":"pull/5695",
"account":"haskell",
"repo":"cabal",
"commit": "b9ed3a9c99b79fb8d56167db5185253c3145c730",
"tag":"osx-7.8.4"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 18, 2018
"url":"pull/5695",
"account":"haskell",
"repo":"cabal",
"commit": "b9ed3a9c99b79fb8d56167db5185253c3145c730",
"tag":"osx-7.10.3"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 18, 2018
"url":"pull/5695",
"account":"haskell",
"repo":"cabal",
"commit": "b9ed3a9c99b79fb8d56167db5185253c3145c730",
"tag":"osx-8.0.2"
}
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.

Please drop the x-revision field -- it's misleading and generally unprincipled -- no tool should rely on it for anything; it was intentionally not included in plan.json for a reason

PS: and rename "pkg-revised-cabal-sha256" to "pkg-cabal-sha256"

@@ -141,6 +141,12 @@ encodePlanAsJson distDirLayout elaboratedInstallPlan elaboratedSharedConfig =
, "style" J..= J.String (style2str (elabLocalToProject elab) (elabBuildStyle elab))
, "pkg-src" J..= packageLocationToJ (elabPkgSourceLocation elab)
] ++
[ "pkg-revision" J..= J.String x
| Just x <- [lookup "x-revision" (PD.customFieldsPD (elabPkgDescription elab))]
Copy link
Member

@hvr hvr Nov 19, 2018

Choose a reason for hiding this comment

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

strong 👎 from me, sorry!

I'm strongly against adding the x-revision field to the plan.json file to infer the version; it's a completely unreliable field that is only used internally by Hackage (but other package repositories do not -- the x-revision field would be totally bogus there; notice the x--prefix which should have given this away already) for bookkeeping purposes and as a failsafe; any tooling which relies on it to be accurate is plain and simple broken!

Also, the revision number is a concept that breaks down completely for e.g. Hackage overlays; the only way to accurately identify a revision is via its SHA256. I plan to add support to cabal for pinning to revisions but I do not intend to support pinning by revision number; only by either SHA256 or by timestamp (the latter addressing scheme will likely be the first to be implemented as it's the one that's close to the --index-state design).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That indeed sounds like a saner approach to me. Let me just state that I would very much be interested for the plan.json to contain information about what revision is being used. The approach I implemented might be too fragile, so let's not merge it, but I would very much a less fragile approach to be available.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Adding the cabal revision sha256 could still be a useful addition but only of course if addressing revisions by sha is added first. So we could introduce that change once that is implemented.

@arianvp arianvp closed this Nov 19, 2018
[ "pkg-revision" J..= J.String x
| Just x <- [lookup "x-revision" (PD.customFieldsPD (elabPkgDescription elab))]
] ++
[ "pkg-revised-cabal-sha256" J..= J.String hash
Copy link
Member

@hvr hvr Nov 19, 2018

Choose a reason for hiding this comment

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

I'd just call it

Suggested change
[ "pkg-revised-cabal-sha256" J..= J.String hash
[ "pkg-cabal-sha256" J..= J.String hash

It doesn't really add much value to qualify it as revised and might even be inaccurate/misleading in some cases. If anything it should be called "override" which is more general than the somewhat Hackage-specific "revision" term. But more generally I'd rather leave it off, and ideally I'd like to see this field be non-optional (because for the tooling I have in mind, I need to know the cabal sha256 always)!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The hash is currently calculated from the cabal file ByteString that is only present when a revised cabal file is present. I'm not sure how I would get access to the cabal file verbatim in the case no revised cabal file is present.

Copy link
Member

@hvr hvr Nov 19, 2018

Choose a reason for hiding this comment

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

It's ok if we for now only have the SHA256 info for overridden .cabals included in plan.json; we might figure out a way to make it available always in a different PR; we definitely have access to the ByteString somewhere

@arianvp arianvp reopened this Nov 19, 2018
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 19, 2018
"url":"pull/5695",
"account":"haskell",
"repo":"cabal",
"commit": "b9ed3a9c99b79fb8d56167db5185253c3145c730",
"tag":"linux-7.8.4"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 19, 2018
"url":"pull/5695",
"account":"haskell",
"repo":"cabal",
"commit": "b9ed3a9c99b79fb8d56167db5185253c3145c730",
"tag":"linux-7.6.3"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 19, 2018
"url":"pull/5695",
"account":"haskell",
"repo":"cabal",
"commit": "b9ed3a9c99b79fb8d56167db5185253c3145c730",
"tag":"linux-8.0.2"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 19, 2018
"url":"pull/5695",
"account":"haskell",
"repo":"cabal",
"commit": "b9ed3a9c99b79fb8d56167db5185253c3145c730",
"tag":"linux-7.10.3"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 19, 2018
"url":"pull/5695",
"account":"haskell",
"repo":"cabal",
"commit": "b9ed3a9c99b79fb8d56167db5185253c3145c730",
"tag":"linux-8.2.2"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 19, 2018
"url":"pull/5695",
"account":"haskell",
"repo":"cabal",
"commit": "b9ed3a9c99b79fb8d56167db5185253c3145c730",
"tag":"linux-8.6.2"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 19, 2018
"url":"pull/5695",
"account":"haskell",
"repo":"cabal",
"commit": "b9ed3a9c99b79fb8d56167db5185253c3145c730",
"tag":"linux-8.4.4"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 19, 2018
"url":"pull/5695",
"account":"haskell",
"repo":"cabal",
"commit": "b9ed3a9c99b79fb8d56167db5185253c3145c730",
"tag":"linux-8.4.4-fdebug-expensive-assertions"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 19, 2018
"url":"pull/5695",
"account":"haskell",
"repo":"cabal",
"commit": "b9ed3a9c99b79fb8d56167db5185253c3145c730",
"tag":"osx-7.8.4"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 19, 2018
"url":"pull/5695",
"account":"haskell",
"repo":"cabal",
"commit": "b9ed3a9c99b79fb8d56167db5185253c3145c730",
"tag":"osx-8.0.2"
}
@hvr
Copy link
Member

hvr commented Nov 20, 2018

As discussed with @arianvp directly, I'm taking over the PR since he's got little time and I'd like to get this simple but quite useful addition into the upcoming 2.4.1 point rls

@hvr hvr added this to the 2.4.0.1 milestone Nov 20, 2018
@hvr hvr merged commit f7bcdfe into haskell:master Nov 20, 2018
hvr pushed a commit that referenced this pull request Nov 20, 2018
This is useful for external tools like plan2nix [1] which
can then create their own build plan based on the cabal
solver output, even in the presence of revised cabal files.

This adds a new `pkg-cabal-sha256` field alongside the already
existing `pkg-src-sha256` field. Always populated and uniquely
identifies (to the degree SHA256 is collision-free) which `.cabal`
package description file was used for constructing and executing
the build-plan.

[1]: https://github.com/angerman/nix-tools/tree/master/plan2nix

(cherry picked from commit f7bcdfe)
hvr added a commit that referenced this pull request Nov 20, 2018
@hvr
Copy link
Member

hvr commented Nov 20, 2018

also cherry-picked to 2.4 via 6928961 (+ changelog entry via 5c49e01)

haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 20, 2018
"url":"pull/5695",
"account":"haskell",
"repo":"cabal",
"commit": "6e0223ccbf9929293d434a1d7c48c813f2a5e5cc",
"tag":"linux-8.0.2"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 20, 2018
"url":"pull/5695",
"account":"haskell",
"repo":"cabal",
"commit": "6e0223ccbf9929293d434a1d7c48c813f2a5e5cc",
"tag":"linux-7.10.3"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 20, 2018
"url":"pull/5695",
"account":"haskell",
"repo":"cabal",
"commit": "6e0223ccbf9929293d434a1d7c48c813f2a5e5cc",
"tag":"linux-8.2.2"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 20, 2018
"url":"pull/5695",
"account":"haskell",
"repo":"cabal",
"commit": "6e0223ccbf9929293d434a1d7c48c813f2a5e5cc",
"tag":"linux-7.6.3"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 20, 2018
"url":"pull/5695",
"account":"haskell",
"repo":"cabal",
"commit": "6e0223ccbf9929293d434a1d7c48c813f2a5e5cc",
"tag":"linux-7.8.4"
}
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.

None yet

2 participants