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

opam admin add-constraint allow to specify a list of excluded packages #3077

Closed
dbuenzli opened this issue Oct 12, 2017 · 8 comments · Fixed by #5386
Closed

opam admin add-constraint allow to specify a list of excluded packages #3077

dbuenzli opened this issue Oct 12, 2017 · 8 comments · Fixed by #5386

Comments

@dbuenzli
Copy link
Contributor

Currently this affects all --depend-on packages but you may want to specify exceptions. Alternatively you may want to specify only a few that should be affected.

@dbuenzli
Copy link
Contributor Author

opam admin add-constraint is truly excellent but sadly falls short because of this issue.

That being said I don't think you want to specify a list of excluded packages, you want to specify a list of affected packages, namely those whose build you witnessed failing.

A simple way would be to turn the synopsis into:

opam admin add-constraint CONSTRAINT [PKG[.VERSION]...]

@dbuenzli
Copy link
Contributor Author

Another useful thing would be to output on stdout the affected files (possibly behind a cli switch).

@dbuenzli
Copy link
Contributor Author

dbuenzli commented Oct 4, 2021

A simple way would be to turn the synopsis into:

opam admin add-constraint CONSTRAINT [PKG[.VERSION]...]

And to be clear this should also add the constraint on the given packages even if the constraint is not currently in the specified package's deps.

@kit-ty-kate
Copy link
Member

kit-ty-kate commented Feb 6, 2022

I don’t personally have time to dedicate to this at the moment but this seems to be "workaroundable" with a simple bash script such as:

add-constraint-except.sh:

#!/bin/bash

opam admin add-constraint "$1"
sed_args=() ; for pkg in $2; do sed_args=("${sed_args[@]}" -e "/^packages\\/$pkg/{p;n;}"); done
git restore -- $(git status --short | grep "^ M " | sed "s/^ M //" | sed -n "${sed_args[@]}")

@dbuenzli
Copy link
Contributor Author

dbuenzli commented Feb 6, 2022

Yes it's always workaroundable with a dose of shell scripting :-(

The add constraint everywhere and then commit only those files you want to change works. But it's a tad annoying.

For reference in this case combining with @dra27's sed runes to get the failure from CI. I get to something like:

opam admin add-constraint 'cmdliner<1.1.0'
curl -Ls https://opam.ci.ocaml.org/github/ocaml/opam-repository/commit/9e1c4741f678920dce29d3280af125f48430e81d \
| sed -e 's/>/\n/g' \
| sed -nE 's/^([^ ]*) \(failed: (This|Unbound|The).*/\1/p' \
| sort \
| uniq \
| sed 's/\(\([^\.]*\).*\)/packages\/\2\/\1\/opam/g' \
| git add --pathspec-from-file=-
git checkout packages
git commit -m 'Constrain failures on cmdliner 1.1.0'

@kit-ty-kate
Copy link
Member

just in case you want to have a shot at doing it, it seem relatively easy:

OpamPackage.Map.iter (fun nv prefix ->

This would be just a matter of a couple of ifs and a new argument around here I believe

@dbuenzli
Copy link
Contributor Author

dbuenzli commented Dec 2, 2022

After five years, I'm still very very interested in having a good workflow for fixing massive opam-repository failures (see e.g. ocaml/opam-repository#22598) and this is part of it.

Could this please be put on a release target ?

@dbuenzli
Copy link
Contributor Author

dbuenzli commented Sep 6, 2023

Thank you @rjbou ! I missed the resolution. Look forward to integrate that in my tooling.

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.

3 participants