123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307(*
* Copyright (c) 2016-2017 Anil Madhavapeddy <anil@recoil.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*)(** Distro selection for various OPAM combinations *)openAstringtypet=[|`Alpineof[`V3_3|`V3_4|`V3_5|`V3_6|`V3_7|`Latest]|`CentOSof[`V6|`V7|`Latest]|`Debianof[`V9|`V8|`V7|`Stable|`Testing|`Unstable]|`Fedoraof[`V21|`V22|`V23|`V24|`V25|`V26|`V27|`V28|`Latest]|`OracleLinuxof[`V7|`Latest]|`OpenSUSEof[`V42_1|`V42_2|`V42_3|`Latest]|`Ubuntuof[`V12_04|`V14_04|`V15_04|`V15_10|`V16_04|`V16_10|`V17_04|`V17_10|`V18_04|`LTS|`Latest]][@@derivingsexp]typestatus=[|`Deprecated|`Activeof[`Tier1|`Tier2]|`Aliasoft][@@derivingsexp]typearch=[|`X86_64|`Aarch64|`Ppc64le][@@derivingsexp]letdistros=[`Alpine`V3_3;`Alpine`V3_4;`Alpine`V3_5;`Alpine`V3_6;`Alpine`V3_7;`Alpine`Latest;`CentOS`V6;`CentOS`V7;`CentOS`Latest;`Debian`V9;`Debian`V8;`Debian`V7;`Debian`Stable;`Debian`Testing;`Debian`Unstable;`Fedora`V23;`Fedora`V24;`Fedora`V25;`Fedora`V26;`Fedora`V27;`Fedora`V28;`Fedora`Latest;`OracleLinux`V7;`OracleLinux`Latest;`OpenSUSE`V42_1;`OpenSUSE`V42_2;`OpenSUSE`V42_3;`OpenSUSE`Latest;`Ubuntu`V12_04;`Ubuntu`V14_04;`Ubuntu`V15_04;`Ubuntu`V15_10;`Ubuntu`V16_04;`Ubuntu`V16_10;`Ubuntu`V17_04;`Ubuntu`V17_10;`Ubuntu`V18_04;`Ubuntu`Latest;`Ubuntu`LTS]letdistro_status(d:t):status=matchdwith|`Alpine(`V3_3|`V3_4|`V3_5|`V3_6)->`Deprecated|`Alpine`V3_7->`Active`Tier1|`Alpine`Latest->`Alias(`Alpine`V3_7)|`CentOS`V7->`Active`Tier2|`CentOS`V6->`Deprecated|`CentOS`Latest->`Alias(`CentOS`V7)|`Debian`V7->`Deprecated|`Debian`V8->`Active`Tier2|`Debian`V9->`Active`Tier1|`Debian`Stable->`Alias(`Debian`V9)|`Debian`Testing->`Active`Tier2|`Debian`Unstable->`Active`Tier2|`Fedora(`V21|`V22|`V23|`V24|`V25|`V26)->`Deprecated|`Fedora`V28->`Active`Tier1|`Fedora`V27->`Active`Tier2|`Fedora`Latest->`Alias(`Fedora`V28)|`OracleLinux`V7->`Active`Tier2|`OracleLinux`Latest->`Alias(`OracleLinux`V7)|`OpenSUSE`V42_1|`OpenSUSE`V42_2->`Deprecated|`OpenSUSE`V42_3->`Active`Tier2|`OpenSUSE`Latest->`Alias(`OpenSUSE`V42_3)|`Ubuntu`V14_04->`Active`Tier2|`Ubuntu(`V16_04|`V18_04)->`Active`Tier1|`Ubuntu(`V12_04|`V15_04|`V15_10|`V16_10|`V17_04|`V17_10)->`Deprecated|`Ubuntu`LTS->`Alias(`Ubuntu`V18_04)|`Ubuntu`Latest->`Alias(`Ubuntu`V18_04)letlatest_distros=[`Alpine`Latest;`CentOS`Latest;`Debian`Stable;`OracleLinux`Latest;`OpenSUSE`Latest;`Fedora`Latest;`Ubuntu`Latest;`Ubuntu`LTS]letmaster_distro=`Debian`Stableletresolve_aliasd=matchdistro_statusdwith|`Aliasx->x|_->dmoduleOV=Ocaml_versionletdistro_archesov(d:t):archlist=matchresolve_aliasd,ovwith|`Debian`V9,ovwhenOV.(compareReleases.v4_05_0ov)=-1->[`X86_64;`Aarch64;`Ppc64le]|`Alpine(`V3_6|`V3_7),ovwhenOV.(compareReleases.v4_05_0ov)=-1->[`X86_64;`Aarch64]|`Ubuntu(`V16_04|`V18_04|`V17_10),ovwhenOV.(compareReleases.v4_05_0ov)=-1->[`X86_64;`Aarch64]|_->[`X86_64]letdistro_supported_on(a:arch)ov(d:t)=List.mema(distro_archesovd)letactive_distrosarch=List.filter(fund->matchdistro_statusdwith`Active_->true|_->false)distros|>List.filter(distro_supported_onarchOV.Releases.latest)letactive_tier1_distrosarch=List.filter(fund->matchdistro_statusdwith`Active`Tier1->true|_->false)distros|>List.filter(distro_supported_onarchOV.Releases.latest)letactive_tier2_distrosarch=List.filter(fund->matchdistro_statusdwith`Active`Tier2->true|_->false)distros|>List.filter(distro_supported_onarchOV.Releases.latest)(* The distro-supplied version of OCaml *)letbuiltin_ocaml_of_distro(d:t):stringoption=matchresolve_aliasdwith|`Debian`V7->Some"3.12.1"|`Debian`V8->Some"4.01.0"|`Debian`V9->Some"4.02.3"|`Ubuntu`V12_04->Some"3.12.1"|`Ubuntu`V14_04->Some"4.01.0"|`Ubuntu`V15_04->Some"4.01.0"|`Ubuntu`V15_10->Some"4.01.0"|`Ubuntu`V16_04->Some"4.02.3"|`Ubuntu`V16_10->Some"4.02.3"|`Ubuntu`V17_04->Some"4.02.3"|`Ubuntu`V17_10->Some"4.04.0"|`Ubuntu`V18_04->Some"4.05.0"|`Alpine`V3_3->Some"4.02.3"|`Alpine`V3_4->Some"4.02.3"|`Alpine`V3_5->Some"4.04.0"|`Alpine`V3_6->Some"4.04.1"|`Alpine`V3_7->Some"4.04.2"|`Fedora`V21->Some"4.01.0"|`Fedora`V22->Some"4.02.0"|`Fedora`V23->Some"4.02.2"|`Fedora`V24->Some"4.02.3"|`Fedora`V25->Some"4.02.3"|`Fedora`V26->Some"4.04.0"|`Fedora`V27->Some"4.05.0"|`Fedora`V28->Some"4.06.0"|`CentOS`V6->Some"3.11.2"|`CentOS`V7->Some"4.01.0"|`OpenSUSE`V42_1->Some"4.02.3"|`OpenSUSE`V42_2->Some"4.03.0"|`OpenSUSE`V42_3->Some"4.03.0"|`OracleLinux`V7->None|`Alpine`Latest|`CentOS`Latest|`OracleLinux`Latest|`OpenSUSE`Latest|`Ubuntu`LTS|`Ubuntu`Latest|`Debian(`Testing|`Unstable|`Stable)|`Fedora`Latest->assertfalse(* The Docker tag for this distro *)lettag_of_distro(d:t)=matchdwith|`Ubuntu`V12_04->"ubuntu-12.04"|`Ubuntu`V14_04->"ubuntu-14.04"|`Ubuntu`V15_04->"ubuntu-15.04"|`Ubuntu`V15_10->"ubuntu-15.10"|`Ubuntu`V16_04->"ubuntu-16.04"|`Ubuntu`V16_10->"ubuntu-16.10"|`Ubuntu`V17_04->"ubuntu-17.04"|`Ubuntu`V17_10->"ubuntu-17.10"|`Ubuntu`V18_04->"ubuntu-18.04"|`Ubuntu`Latest->"ubuntu"|`Ubuntu`LTS->"ubuntu-lts"|`Debian`Stable->"debian-stable"|`Debian`Unstable->"debian-unstable"|`Debian`Testing->"debian-testing"|`Debian`V9->"debian-9"|`Debian`V8->"debian-8"|`Debian`V7->"debian-7"|`CentOS`V6->"centos-6"|`CentOS`V7->"centos-7"|`CentOS`Latest->"centos"|`Fedora`Latest->"fedora"|`Fedora`V21->"fedora-21"|`Fedora`V22->"fedora-22"|`Fedora`V23->"fedora-23"|`Fedora`V24->"fedora-24"|`Fedora`V25->"fedora-25"|`Fedora`V26->"fedora-26"|`Fedora`V27->"fedora-27"|`Fedora`V28->"fedora-28"|`OracleLinux`V7->"oraclelinux-7"|`OracleLinux`Latest->"oraclelinux"|`Alpine`V3_3->"alpine-3.3"|`Alpine`V3_4->"alpine-3.4"|`Alpine`V3_5->"alpine-3.5"|`Alpine`V3_6->"alpine-3.6"|`Alpine`V3_7->"alpine-3.7"|`Alpine`Latest->"alpine"|`OpenSUSE`V42_1->"opensuse-42.1"|`OpenSUSE`V42_2->"opensuse-42.2"|`OpenSUSE`V42_3->"opensuse-42.3"|`OpenSUSE`Latest->"opensuse"letdistro_of_tagx:toption=matchxwith|"ubuntu-12.04"->Some(`Ubuntu`V12_04)|"ubuntu-14.04"->Some(`Ubuntu`V14_04)|"ubuntu-15.04"->Some(`Ubuntu`V15_04)|"ubuntu-15.10"->Some(`Ubuntu`V15_10)|"ubuntu-16.04"->Some(`Ubuntu`V16_04)|"ubuntu-16.10"->Some(`Ubuntu`V16_10)|"ubuntu-17.04"->Some(`Ubuntu`V17_04)|"ubuntu-17.10"->Some(`Ubuntu`V17_10)|"ubuntu-18.04"->Some(`Ubuntu`V18_04)|"ubuntu"->Some(`Ubuntu`Latest)|"ubuntu-lts"->Some(`Ubuntu`LTS)|"debian-stable"->Some(`Debian`Stable)|"debian-unstable"->Some(`Debian`Unstable)|"debian-testing"->Some(`Debian`Testing)|"debian-9"->Some(`Debian`V9)|"debian-8"->Some(`Debian`V8)|"debian-7"->Some(`Debian`V7)|"centos-6"->Some(`CentOS`V6)|"centos-7"->Some(`CentOS`V7)|"fedora-21"->Some(`Fedora`V21)|"fedora-22"->Some(`Fedora`V22)|"fedora-23"->Some(`Fedora`V23)|"fedora-24"->Some(`Fedora`V24)|"fedora-25"->Some(`Fedora`V25)|"fedora-26"->Some(`Fedora`V26)|"fedora-27"->Some(`Fedora`V27)|"fedora-28"->Some(`Fedora`V28)|"fedora"->Some(`Fedora`Latest)|"oraclelinux-7"->Some(`OracleLinux`V7)|"oraclelinux"->Some(`OracleLinux`Latest)|"alpine-3.3"->Some(`Alpine`V3_3)|"alpine-3.4"->Some(`Alpine`V3_4)|"alpine-3.5"->Some(`Alpine`V3_5)|"alpine-3.6"->Some(`Alpine`V3_6)|"alpine-3.7"->Some(`Alpine`V3_7)|"alpine"->Some(`Alpine`Latest)|"opensuse-42.1"->Some(`OpenSUSE`V42_1)|"opensuse-42.2"->Some(`OpenSUSE`V42_2)|"opensuse-42.3"->Some(`OpenSUSE`V42_3)|"opensuse"->Some(`OpenSUSE`Latest)|_->Noneletrechuman_readable_string_of_distro(d:t)=letalias()=human_readable_string_of_distro(resolve_aliasd)inmatchdwith|`Ubuntu`V12_04->"Ubuntu 12.04"|`Ubuntu`V14_04->"Ubuntu 14.04"|`Ubuntu`V15_04->"Ubuntu 15.04"|`Ubuntu`V15_10->"Ubuntu 15.10"|`Ubuntu`V16_04->"Ubuntu 16.04"|`Ubuntu`V16_10->"Ubuntu 16.10"|`Ubuntu`V17_04->"Ubuntu 17.04"|`Ubuntu`V17_10->"Ubuntu 17.10"|`Ubuntu`V18_04->"Ubuntu 18.04"|`Debian`Stable->"Debian Stable"|`Debian`Unstable->"Debian Unstable"|`Debian`Testing->"Debian Testing"|`Debian`V9->"Debian 9 (Stretch)"|`Debian`V8->"Debian 8 (Jessie)"|`Debian`V7->"Debian 7 (Wheezy)"|`CentOS`V6->"CentOS 6"|`CentOS`V7->"CentOS 7"|`Fedora`V21->"Fedora 21"|`Fedora`V22->"Fedora 22"|`Fedora`V23->"Fedora 23"|`Fedora`V24->"Fedora 24"|`Fedora`V25->"Fedora 25"|`Fedora`V26->"Fedora 26"|`Fedora`V27->"Fedora 27"|`Fedora`V28->"Fedora 28"|`OracleLinux`V7->"OracleLinux 7"|`Alpine`V3_3->"Alpine 3.3"|`Alpine`V3_4->"Alpine 3.4"|`Alpine`V3_5->"Alpine 3.5"|`Alpine`V3_6->"Alpine 3.6"|`Alpine`V3_7->"Alpine 3.7"|`OpenSUSE`V42_1->"OpenSUSE 42.1"|`OpenSUSE`V42_2->"OpenSUSE 42.2"|`OpenSUSE`V42_3->"OpenSUSE 42.3"|`Alpine`Latest|`Ubuntu`Latest|`Ubuntu`LTS|`CentOS`Latest|`Fedora`Latest|`OracleLinux`Latest|`OpenSUSE`Latest->alias()lethuman_readable_short_string_of_distro(t:t)=matchtwith|`Ubuntu_->"Ubuntu"|`Debian_->"Debian"|`CentOS_->"CentOS"|`Fedora_->"Fedora"|`OracleLinux_->"OracleLinux"|`Alpine_->"Alpine"|`OpenSUSE_->"OpenSUSE"(* The alias tag for the latest stable version of this distro *)letlatest_tag_of_distro(t:t)=matchtwith|`Ubuntu_->"ubuntu"|`Debian_->"debian"|`CentOS_->"centos"|`Fedora_->"fedora"|`OracleLinux_->"oraclelinux"|`Alpine_->"alpine"|`OpenSUSE_->"opensuse"letcompareab=String.compare(human_readable_string_of_distroa)(human_readable_string_of_distrob)