Skip to content

Commit

Permalink
Revert "Merge pull request ocaml#1089 from AltGr/allow-url-mirrors"
Browse files Browse the repository at this point in the history
This reverts commit fe48dea, reversing
changes made to 42dbc30.

Also removes the corresponding line from CHANGES
  • Loading branch information
AltGr committed Jan 15, 2014
1 parent 6c02033 commit d21d0b8
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 76 deletions.
1 change: 0 additions & 1 deletion CHANGES
Expand Up @@ -23,7 +23,6 @@
* Do not reinstall dev packages with `opam upgrade <pkg>` (#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)
Expand Down
Binary file modified doc/dev-manual/dev-manual.pdf
Binary file not shown.
23 changes: 9 additions & 14 deletions doc/dev-manual/dev-manual.tex
Expand Up @@ -421,20 +421,20 @@ \subsubsection{URL files: {\tt url}}
{
\begin{Verbatim}[frame=single]
<file> :=
?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
Expand All @@ -450,14 +450,9 @@ \subsubsection{URL files: {\tt url}}
the string ends by \verb+#<SHA1>+ or \verb+#<tag-name>+ or
\verb+#<branch-name>+. 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}
Expand Down
2 changes: 1 addition & 1 deletion src/client/opamClient.ml
Expand Up @@ -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 ]
Expand Down
16 changes: 8 additions & 8 deletions src/client/opamState.ml
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
20 changes: 7 additions & 13 deletions src/core/opamFile.ml
Expand Up @@ -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>", None];
url = ("<none>", None);
kind = None;
checksum= None;
}
Expand Down Expand Up @@ -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
Expand All @@ -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 }

Expand All @@ -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)]
Expand Down
6 changes: 3 additions & 3 deletions src/core/opamFile.mli
Expand Up @@ -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
Expand Down
20 changes: 4 additions & 16 deletions src/core/opamRepository.ml
Expand Up @@ -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
Expand Down Expand Up @@ -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 () ->
Expand Down
7 changes: 3 additions & 4 deletions src/core/opamRepository.mli
Expand Up @@ -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]. *)
Expand Down
14 changes: 0 additions & 14 deletions src/core/opamTypes.ml
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions src/core/opamTypes.mli
Expand Up @@ -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

Expand Down

0 comments on commit d21d0b8

Please sign in to comment.