diff --git a/CHANGES b/CHANGES index 0d413f67bf1..294e9a4e590 100644 --- a/CHANGES +++ b/CHANGES @@ -23,7 +23,6 @@ * Do not reinstall dev packages with `opam upgrade ` (#1001) * Be more careful with `opam init` to a non-empty root directory (#974) * Cleanup build-dir after successful compiler installation to save on space (#1006) -* Enable packagers to specify mirrors in url files (#807) 1.1.0 [Oct 2013] * Fix update of dev packages (#962) diff --git a/doc/dev-manual/dev-manual.pdf b/doc/dev-manual/dev-manual.pdf index 86a841eeb9a..5a647869eb6 100644 Binary files a/doc/dev-manual/dev-manual.pdf and b/doc/dev-manual/dev-manual.pdf differ diff --git a/doc/dev-manual/dev-manual.tex b/doc/dev-manual/dev-manual.tex index 91f0d123056..7dec4fe65ce 100644 --- a/doc/dev-manual/dev-manual.tex +++ b/doc/dev-manual/dev-manual.tex @@ -421,20 +421,20 @@ \subsubsection{URL files: {\tt url}} { \begin{Verbatim}[frame=single] := - ?src: [ STRING+ ] - ?archive: [ STRING+ ] - ?http: [ STRING+ ] - ?local: [ STRING+ ] - ?git: [ STRING+ ] - ?darcs: [ STRING+ ] - ?hg: [ STRING+ ] + ?src: STRING + ?archive: STRING + ?http: STRING + ?local: STRING + ?git: STRING + ?darcs: STRING + ?hg: STRING ?checksum: STRING \end{Verbatim} } {\tt src}, {\tt archive}, {\tt http}, {\tt local}, {\tt git}, {\tt hg}, {\tt darcs} are the location where the package upstream sources -can be downloaded. It can be one of: +can be downloaded. It can be: \begin{itemize} \item A directory on the local file system (which will be copied to @@ -450,14 +450,9 @@ \subsubsection{URL files: {\tt url}} the string ends by \verb+#+ or \verb+#+ or \verb+#+. Use {\tt git}, {\tt hg} or {\tt darcs}. \item \OPAM\ will try to guess the source kind if you use {\tt src} or - {\tt archive}. It shouldn't be used for version control systems, for - which the above are preferred. + {\tt archive}. \end{itemize} -If more than one address is specified for any given kind, they will be -understood as a list of mirrors, and tried in order until one succeeds. {\tt - src} and {\tt archive} require the addresses to be all of the same kind. - \subsection{Commands} \subsubsection{Creating a Fresh Client State} diff --git a/src/client/opamClient.ml b/src/client/opamClient.ml index e07d2b8611e..7b94afa1636 100644 --- a/src/client/opamClient.ml +++ b/src/client/opamClient.ml @@ -286,7 +286,7 @@ module API = struct match OpamFile.URL.kind u with | None -> "http" | Some k -> string_of_repository_kind k in - let url = OpamMisc.string_of_list string_of_address (OpamFile.URL.url u) in + let url = string_of_address (OpamFile.URL.url u) in let checksum = OpamFile.URL.checksum u in [ "upstream-url" , url; "upstream-kind", kind ] diff --git a/src/client/opamState.ml b/src/client/opamState.ml index cb0fa3ec73f..58c74d71801 100644 --- a/src/client/opamState.ml +++ b/src/client/opamState.ml @@ -437,16 +437,16 @@ let locally_pinned_package t n = let url_of_locally_pinned_package t n = let path, kind = locally_pinned_package t n in - OpamFile.URL.create (Some kind) [path] + OpamFile.URL.create (Some kind) path let repository_of_locally_pinned_package t n = let url = url_of_locally_pinned_package t n in let repo_address = OpamFile.URL.url url in - let repo_kind = guess_repository_kind_urls (OpamFile.URL.kind url) repo_address in + let repo_kind = guess_repository_kind (OpamFile.URL.kind url) repo_address in let repo_root = OpamPath.Switch.dev_package t.root t.switch (OpamPackage.pinned n) in { repo_name = OpamRepositoryName.of_string (OpamPackage.Name.to_string n); repo_priority = 0; - repo_root; repo_address = List.hd repo_address; repo_kind } + repo_root; repo_address; repo_kind } let real_package t nv = let name = OpamPackage.name nv in @@ -960,7 +960,7 @@ let is_dev_package t nv = match url t nv with | None -> false | Some url -> - match guess_repository_kind_urls (OpamFile.URL.kind url) (OpamFile.URL.url url) with + match guess_repository_kind (OpamFile.URL.kind url) (OpamFile.URL.url url) with | `http -> false | _ -> true @@ -1992,7 +1992,7 @@ let install_compiler t ~quiet switch compiler = else OpamFilename.with_tmp_dir (fun download_dir -> let result = OpamRepository.pull_url kind (OpamPackage.of_string "compiler.get") - download_dir None [comp_src] in + download_dir None comp_src in match result with | Not_available u -> OpamGlobals.error_and_exit "%s is not available." u | Up_to_date r @@ -2049,11 +2049,11 @@ let update_dev_package t nv = | None -> skip | Some url -> let remote_url = OpamFile.URL.url url in - match guess_repository_kind_urls (OpamFile.URL.kind url) remote_url with + match guess_repository_kind (OpamFile.URL.kind url) remote_url with | ` http -> skip | kind -> log "updating %s:%s" - (string_of_address (List.hd remote_url)) (string_of_repository_kind kind); + (string_of_address remote_url) (string_of_repository_kind kind); let dirname = dev_package t nv in let checksum = OpamFile.URL.checksum url in let r = OpamRepository.pull_url kind nv dirname checksum remote_url in @@ -2107,7 +2107,7 @@ let download_upstream t nv dirname = | None -> None | Some u -> let url = OpamFile.URL.url u in - let kind = guess_repository_kind_urls (OpamFile.URL.kind u) url in + let kind = guess_repository_kind (OpamFile.URL.kind u) url in let checksum = OpamFile.URL.checksum u in match OpamRepository.pull_url kind nv dirname checksum url with | Not_available u -> OpamGlobals.error_and_exit "%s is not available" u diff --git a/src/core/opamFile.ml b/src/core/opamFile.ml index c4e04baff77..22fb760d724 100644 --- a/src/core/opamFile.ml +++ b/src/core/opamFile.ml @@ -217,19 +217,17 @@ module X = struct let internal = "url" type t = { - url : address list; + url : address; kind : repository_kind option; checksum: string option; } - let create kind url = - if url = [] then OpamSystem.internal_error "empty mirror list"; - { - url; kind; checksum = None; - } + let create kind url = { + url; kind; checksum = None; + } let empty = { - url = ["", None]; + url = ("", None); kind = None; checksum= None; } @@ -270,7 +268,7 @@ module X = struct let s = Syntax.of_channel filename ic in Syntax.check s valid_fields; let get f = OpamFormat.assoc_option s.file_contents f - (OpamFormat.parse_list (OpamFormat.parse_string ++ address_of_string)) in + (OpamFormat.parse_string ++ address_of_string) in let archive = get s_archive in let http = get s_http in let src = get s_src in @@ -283,7 +281,6 @@ module X = struct let url, kind = url_and_kind ~src ~archive ~http ~git ~darcs ~hg ~local in let url = match url with | None -> OpamGlobals.error_and_exit "Missing URL" - | Some []-> OpamGlobals.error_and_exit "Empty URL list" | Some u -> u in { url; kind; checksum } @@ -295,10 +292,7 @@ module X = struct file_format = OpamVersion.current; file_name = OpamFilename.to_string filename; file_contents = [ - Variable (url_name , - OpamFormat.make_list - (string_of_address ++ OpamFormat.make_string) - t.url); + Variable (url_name , OpamFormat.make_string (string_of_address t.url)); ] @ match t.checksum with | None -> [] | Some c -> [Variable (s_checksum, OpamFormat.make_string c)] diff --git a/src/core/opamFile.mli b/src/core/opamFile.mli index 8f5f1d900a1..2574c8ff6f5 100644 --- a/src/core/opamFile.mli +++ b/src/core/opamFile.mli @@ -478,10 +478,10 @@ module URL: sig include IO_FILE - val create: repository_kind option -> address list -> t + val create: repository_kind option -> address -> t - (** URL address. Guaranteed to be non-empty *) - val url: t -> address list + (** URL address *) + val url: t -> address (** Backend kind (could be curl/rsync/git/darcs/hg at the moment) *) val kind: t -> repository_kind option diff --git a/src/core/opamRepository.ml b/src/core/opamRepository.ml index da2ba45e9a4..284a76d88f4 100644 --- a/src/core/opamRepository.ml +++ b/src/core/opamRepository.ml @@ -109,20 +109,8 @@ let init repo = ignore (B.pull_repo repo) let pull_url kind package local_dirname checksum remote_url = - let pull url = - let module B = (val find_backend_by_kind kind: BACKEND) in - B.pull_url package local_dirname checksum url in - let rec attempt = function - | [] -> assert false - | [url] -> pull url - | url::mirrors -> - match pull url with - | Not_available s -> - OpamGlobals.warning "download of %s failed, trying mirror" s; - attempt mirrors - | r -> r - in - attempt remote_url + let module B = (val find_backend_by_kind kind: BACKEND) in + B.pull_url package local_dirname checksum remote_url let revision repo = let kind = repo.repo_kind in @@ -295,9 +283,9 @@ let make_archive ?(gener_digest=false) repo prefix nv = let url = OpamFile.URL.read url_file in let checksum = OpamFile.URL.checksum url in let remote_url = OpamFile.URL.url url in - let kind = guess_repository_kind_urls (OpamFile.URL.kind url) remote_url in + let kind = guess_repository_kind (OpamFile.URL.kind url) remote_url in log "downloading %s:%s" - (string_of_address (List.hd remote_url)) (string_of_repository_kind kind); + (string_of_address remote_url) (string_of_repository_kind kind); if not (OpamFilename.exists_dir download_dir) then OpamFilename.mkdir download_dir; OpamFilename.in_dir download_dir (fun () -> diff --git a/src/core/opamRepository.mli b/src/core/opamRepository.mli index c1d67ccbf5f..b0540942f79 100644 --- a/src/core/opamRepository.mli +++ b/src/core/opamRepository.mli @@ -105,14 +105,13 @@ module type BACKEND = sig end -(** Download an url. Several mirrors can be provided, in which case they will be - tried in order in case of an error. *) +(** Download an url *) val pull_url: repository_kind -> - package -> dirname -> string option -> address list -> generic_file download + package -> dirname -> string option -> address -> generic_file download (** Pull and fix the resulting digest *) val pull_url_and_fix_digest: repository_kind -> - package -> dirname -> string -> filename -> address list -> generic_file download + package -> dirname -> string -> filename -> address -> generic_file download (** [check_digest file expected] check that the [file] digest is the one [expected]. *) diff --git a/src/core/opamTypes.ml b/src/core/opamTypes.ml index bd6506df02a..2cb458f433f 100644 --- a/src/core/opamTypes.ml +++ b/src/core/opamTypes.ml @@ -97,20 +97,6 @@ let guess_repository_kind kind (address, ext) = else `http -let guess_repository_kind_urls kind urls = - match kind with - | Some k -> k - | None -> match urls with - | url::r -> - let k = guess_repository_kind kind url in - if not (List.for_all (fun url -> guess_repository_kind kind url = k) r) - then - OpamGlobals.warning "Inconsistent address kinds in %s" - (OpamMisc.string_of_list string_of_address urls); - k - | [] -> assert false - - type repository = { repo_root : repository_root; repo_name : repository_name; diff --git a/src/core/opamTypes.mli b/src/core/opamTypes.mli index 58dcd7c9ca9..0f4408ceab0 100644 --- a/src/core/opamTypes.mli +++ b/src/core/opamTypes.mli @@ -172,8 +172,6 @@ val address_of_string: string -> address (** Guess the repository kind *) val guess_repository_kind: repository_kind option -> address -> repository_kind -val guess_repository_kind_urls: repository_kind option -> address list -> repository_kind - (** Pretty-print repository kinds. *) val string_of_repository_kind: [`http|`local|`git|`darcs|`hg] -> string