Skip to content

Commit

Permalink
Workaround OPAM Bug 5132 (#447)
Browse files Browse the repository at this point in the history
This commit workaround OPAM Bug ocaml/opam#5132 by
ignoring files that should have been uninstalled.
  • Loading branch information
na4zagin3 committed May 14, 2022
1 parent 3708aa6 commit 5f5ef3c
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# SNAPSHOT: Package name of the current Satyrographos Repo snapshot
# ABORT_IMMEDIATELY: Imdediately abort when installation fails
# SKIP_OLDEST_DEPS: Skip building against oldest dependencies
# WORKAROUND_OPAM_BUG_5132: Skip integrity check against OPAM

set -exo pipefail

Expand All @@ -16,6 +17,13 @@ FAILED_PACKAGES=failed.pkgs
SUCCEEDED_PACKAGES=succeeded.pkgs
: > "$SUCCEEDED_PACKAGES"

case "$(opam --version)" in
2.0.*|2.1.*)
echo "Enable workaround for OPAM Bug #5132"
WORKAROUND_OPAM_BUG_5132=1
;;
esac

OCAML_PACKAGE="ocaml.$(opam show --color=never -f version ocaml)"

if [ -n "$SKIP_OLDEST_DEPS" ] || ! opam install opam-0install
Expand All @@ -27,13 +35,30 @@ else
fi

check_opam_integrity () {
if [ -n "$WORKAROUND_OPAM_BUG_5132" ]
then
echo "Skip OPAM integrity check"
return 0
fi

if find "$(opam var prefix)/.opam-switch/install" -iname 'satysfi-*.changes' -exec grep -e ^'contents-changed:' '{}' '+'
then
echo "OPAM misdetected file creation as modification"
exit 1
fi
}

check_satyrographos_integrity () {
if [ -n "$WORKAROUND_OPAM_BUG_5132" ]
then
echo "Workaround OPAM Bug #5132"
opam exec -- satyrographos install $(opam list --short --installed 'satysfi-*' | sed -e 's/^satysfi-/-l /')
return $?
fi

opam exec -- satyrographos install
}

opam_install_dry_run () {
local OPAM_INSTALL_RETURN_STATUS
check_opam_integrity
Expand Down Expand Up @@ -123,15 +148,15 @@ if true ; then
then
echo "$PACKAGE: install" >> "$FAILED_PACKAGES"
continue
elif ! opam exec -- satyrographos install || ! check_opam_integrity
elif ! check_satyrographos_integrity || ! check_opam_integrity
then
echo "$PACKAGE: satyrographos" >> "$FAILED_PACKAGES"
continue
elif [ -z "$SKIP_OLDEST_DEPS" ] && ! ( opam install opam-0install && opam install $(opam exec -- opam-0install --prefer-oldest "$PACKAGE" "$SATYSFI_PACKAGE" "$OCAML_PACKAGE") ) || ! check_opam_integrity
then
echo "$PACKAGE: install-with-oldest-deps" >> "$FAILED_PACKAGES"
continue
elif [ -z "$SKIP_OLDEST_DEPS" ] && ! opam exec -- satyrographos install
elif [ -z "$SKIP_OLDEST_DEPS" ] && ! check_satyrographos_integrity
then
echo "$PACKAGE: satyrographos-with-oldest-deps" >> "$FAILED_PACKAGES"
continue
Expand Down

0 comments on commit 5f5ef3c

Please sign in to comment.