Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

ability to retrieve tar.gz contents from links

  • Loading branch information...
commit dc7dd130201f13003ba741acf995b361e85b9527 1 parent 6173b7b
@tuong tuong authored
Showing with 27 additions and 9 deletions.
  1. +2 −0  src/file.ml
  2. +15 −2 src/path.ml
  3. +10 −7 src/server.ml
View
2  src/file.ml
@@ -225,6 +225,7 @@ struct
(** Convert to Debian packages to feed the solver *)
val to_package : t -> bool (* true : installed *) -> Debian.Packages.package
+ val urls : t -> string list
end
module Spec : SPEC = struct
@@ -273,6 +274,7 @@ struct
let description t = t.description
let name t = t.name
let version t = {deb = t.version}
+ let urls t = t.urls
let default_package (t:t) =
let assoc f s =
View
17 src/path.ml
@@ -37,7 +37,8 @@ type raw_binary =
| Raw_binary of string (* contents *)
type raw_filename =
- | Raw_filename of string (* pointer to the contents *)
+ | Raw_filename of string (* pointer to the local contents *)
+ | Raw_links of string list (* pointer to some external http links *)
type binary_data =
| Binary of raw_binary
@@ -478,8 +479,20 @@ module Path : PATH = struct
let oc = BatUnix.open_process_out "tar xzv" in
BatIO.write_string oc bin;
BatIO.close_out oc)
- (*IO.read_all (Common.Input.open_file fic)*)
+ | Tar_gz (Filename (Raw_links urls)) ->
+ R_lazy
+ (fun () ->
+ let rec aux = function
+ | [] -> Globals.error_and_exit "No tar.gz found"
+ | url :: urls ->
+ let err = Sys.command (Printf.sprintf "wget %s -O - | tar xzv" url) in
+ if err = 0 then
+ ()
+ else
+ aux urls in
+ aux urls)
+
| Tar_gz (Filename (Raw_filename fic)) -> failwith "to complete !" (* R_filename [Raw fic] *)
let raw_targz f = Tar_gz (Filename (Raw_filename (s_of_filename f)))
View
17 src/server.ml
@@ -85,13 +85,16 @@ module Server = struct
with Not_found -> failwith (string_of_nv n_v ^ " not found")
let getArchive t n_v =
- let p = Path.archives_targz t.home (Some n_v) in
- match Path.is_directory p with
- | Some dir -> Tar_gz (Filename dir)
- | None ->
- match Path.find_binary p with
- | Path.File s -> Tar_gz (Binary s)
- | _ -> failwith ("Cannot find " ^ string_of_nv n_v)
+ match File.Spec.urls (File.Spec.find_err (Path.index t.home (Some n_v))) with
+ | [] ->
+ (let p = Path.archives_targz t.home (Some n_v) in
+ match Path.is_directory p with
+ | Some dir -> Tar_gz (Filename dir)
+ | None ->
+ match Path.find_binary p with
+ | Path.File s -> Tar_gz (Binary s)
+ | _ -> failwith ("Cannot find " ^ string_of_nv n_v))
+ | url -> Tar_gz (Filename (Raw_links url))
let f_archive t n_v opam archive =
let opam_file = Path.index t.home (Some n_v) in
Please sign in to comment.
Something went wrong with that request. Please try again.