Skip to content

Commit

Permalink
Workaround OPAM bug gh-5132 (#444)
Browse files Browse the repository at this point in the history
* Workaround OPAM bug gh-5132

This commit workarounds ocaml/opam#5132 by restoring `$(opam var prefix)/.opam-switch/install/` after running `opam install --dry-run`.
  • Loading branch information
na4zagin3 committed Apr 30, 2022
1 parent 0eab43f commit e450986
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

set -exo pipefail

TEMPORARY_WORK_DIR=$(mktemp -dt "ci.sh.XXXXXXXXXX")

export OPAMVERBOSE=1

FAILED_PACKAGES=failed.pkgs
Expand All @@ -32,6 +34,16 @@ check_opam_integrity () {
fi
}

opam_install_dry_run () {
check_opam_integrity
# Workaround https://github.com/ocaml/opam/issues/5132
mkdir -p "$TEMPORARY_WORK_DIR/opam"
rsync -av "$(opam var prefix)/.opam-switch/install/" "$TEMPORARY_WORK_DIR/opam/install"
opam install --dry-run "$@"
rsync -av "$TEMPORARY_WORK_DIR/opam/install/" "$(opam var prefix)/.opam-switch/install"
check_opam_integrity
}

# Test install/uninstall regardress if it's a PR
if true ; then
echo "Test updated packages"
Expand Down Expand Up @@ -69,12 +81,12 @@ if true ; then
SKIP_SATYSFI_MISMATCH=1
esac

if ! opam install --json=opam-output.json --dry-run --cli=2.1 --update-invariant "${PACKAGES_AND_OPTIONS[@]}" "$SATYSFI_PACKAGE"
if ! opam_install_dry_run --json=opam-output.json --cli=2.1 --update-invariant "${PACKAGES_AND_OPTIONS[@]}" "$SATYSFI_PACKAGE"
then
echo "Dependency does not meet."
cat opam-output.json

if [ -n "$SKIP_SATYSFI_MISMATCH" ] && opam install --json=opam-output.json --dry-run --cli=2.1 --update-invariant "${PACKAGES_AND_OPTIONS[@]}"
if [ -n "$SKIP_SATYSFI_MISMATCH" ] && opam_install_dry_run --json=opam-output.json --cli=2.1 --update-invariant "${PACKAGES_AND_OPTIONS[@]}"
then
echo "Can be installed with another satysfi version. Skipping."
cat opam-output.json
Expand All @@ -86,7 +98,7 @@ if true ; then
fi
fi

if ! opam install --json=opam-output.json --dry-run "${PACKAGES_AND_OPTIONS[@]}"
if ! opam_install_dry_run --json=opam-output.json "${PACKAGES_AND_OPTIONS[@]}"
then
if [ -n "$SKIP_OCAML_MISMATCH" ]
then
Expand Down Expand Up @@ -137,4 +149,4 @@ if [ -s "$FAILED_PACKAGES" ] ; then
sed -e 's/^/- /' -e "1iFailed packages:" "$FAILED_PACKAGES" 1>&2
exit 1
fi
# vim: set et fenc=utf-8 ff=unix sts=0 sw=8 ts=4 :
# vim: set et fenc=utf-8 ff=unix sts=0 sw=4 ts=4 :

0 comments on commit e450986

Please sign in to comment.