Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file opamRepositoryConfig.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143(**************************************************************************)(* *)(* Copyright 2015-2019 OCamlPro *)(* *)(* All rights reserved. This file is distributed under the terms of the *)(* GNU Lesser General Public License version 2.1, with the special *)(* exception on linking described in the file LICENSE. *)(* *)(**************************************************************************)openOpamTypesmoduleE=structtypeOpamStd.Config.E.t+=|CURLofstringoption|FETCHofstringoption|NOCHECKSUMSofbooloption|REQUIRECHECKSUMSofbooloption|RETRIESofintoption|VALIDATIONHOOKofstringoptionopenOpamStd.Config.Eletcurl=value(functionCURLs->s|_->None)letfetch=value(functionFETCHs->s|_->None)letnochecksums=value(functionNOCHECKSUMSb->b|_->None)letrequirechecksums=value(functionREQUIRECHECKSUMSb->b|_->None)letretries=value(functionRETRIESi->i|_->None)letvalidationhook=value(functionVALIDATIONHOOKs->s|_->None)endtypedl_tool_kind=[`Curl|`Default]typet={download_tool:(arglist*dl_tool_kind)Lazy.t;validation_hook:arglistoption;retries:int;force_checksums:booloption;}type'aoptions_fun=?download_tool:(OpamTypes.arglist*dl_tool_kind)Lazy.t->?validation_hook:arglistoption->?retries:int->?force_checksums:booloption->'aletdefault={download_tool=lazy(letos=OpamStd.Sys.os()intryletcurl="curl",`Curlinlettools=matchoswith|Darwin->["wget",`Default;curl]|FreeBSD->["fetch",`Default;curl]|OpenBSD->["ftp",`Default;curl]|_->[curl;"wget",`Default]inletcmd,kind=List.find(fun(c,_)->OpamSystem.resolve_commandc<>None)toolsin[CIdentcmd,None],kindwithNot_found->OpamConsole.error_and_exit`Configuration_error"Could not find a suitable download command. Please make sure you \
have %s installed, or specify a custom command through variable \
OPAMFETCH."(matchoswith|FreeBSD->"fetch"|OpenBSD->"ftp"|_->"either \"curl\" or \"wget\""));validation_hook=None;retries=3;force_checksums=None;}letsetkkt?download_tool?validation_hook?retries?force_checksums=let(+)xopt=matchoptwithSomex->x|None->xink{download_tool=t.download_tool+download_tool;validation_hook=t.validation_hook+validation_hook;retries=t.retries+retries;force_checksums=t.force_checksums+force_checksums;}letsett=setk(funx()->x)tletr=refdefaultletupdate?noop:_=setk(funcfg()->r:=cfg)!rletinitkk=letopenOpamStd.Option.Opinletdownload_tool=E.fetch()>>=(funs->letargs=OpamStd.String.splits' 'inmatchargswith|cmd::a->letcmd,kind=ifOpamStd.String.ends_with~suffix:"curl"cmdthen(CIdent"curl",None),`Curlelseifcmd="wget"then(CIdent"wget",None),`Defaultelse(CStringcmd,None),`Defaultinletc=cmd::List.map(funa->OpamTypes.CStringa,None)ainSome(lazy(c,kind))|[]->None)>>+fun()->E.curl()>>|(funs->lazy([CStrings,None],`Curl))inletvalidation_hook=E.validationhook()>>|funs->matchList.map(funs->CStrings,None)(OpamStd.String.splits' ')with|[]->None|l->Somelinletforce_checksums=matchE.requirechecksums(),E.nochecksums()with|Sometrue,_->Some(Sometrue)|_,Sometrue->Some(Somefalse)|None,None->None|_->SomeNoneinsetk(setk(func->r:=c;k))!r?download_tool?validation_hook?retries:(E.retries())?force_checksumsletinit?noop:_=initk(fun()->())