Permalink
Browse files

At upload time, the archive is sent everytime now.

  • Loading branch information...
tuong committed Mar 30, 2012
1 parent 06d7645 commit a7ec30cb0ada5ca2c88ab5f671fcf774f3338fce
Showing with 42 additions and 43 deletions.
  1. +10 −1 README.md
  2. +25 −31 src/client.ml
  3. +2 −2 src/protocol.ml
  4. +5 −9 src/server.ml
View
@@ -5,8 +5,17 @@
# Prerequisites:
* ocaml
-* wget (or ftp for "Darwin")
* tar
+* ocp-get (optional)
+
+Unless the following packages are already downloaded :
+* http://www.ocamlpro.com/pub/cudf.tar.bz2
+* http://www.ocamlpro.com/pub/dose.tar.bz2
+* http://ocaml-extlib.googlecode.com/files/extlib-1.5.2.tar.gz
+* http://www.ocamlpro.com/pub/ocaml-arg.tar.bz2
+* http://ocamlgraph.lri.fr/download/ocamlgraph-1.8.1.tar.gz
+* http://www.ocamlpro.com/pub/ocaml-re.tar.bz2
+a manual downloading will be performed.
To compile `ocp-get`, simply run:
View
@@ -640,42 +640,36 @@ module Client : CLIENT = struct
let archive_filename = Namespace.string_of_nv name version ^ ".tar.gz" in
let archive =
if Sys.file_exists archive_filename then
- Some (Raw_binary (Run.read archive_filename))
+ Raw_binary (Run.read archive_filename)
else
let urls = File.Spec.urls spec in
if urls = [] then
Globals.error_and_exit "No location specified for %s" archive_filename
else
- match File.Spec.patches spec with
- | patches when patches <> [] && List.for_all (function Internal _ -> true | _ -> false) patches ->
- (* the ".spec" being processed contains only local patches *)
- let nv = name, version in
- let tmp_nv = Path.concat Path.cwd (B (Namespace.string_of_nv (fst nv) (snd nv))) in
- let () =
- begin
- ((* try to check that patches are well-parsed before the copy *)
- List.iter
- (function Internal p ->
- if not (Sys.is_directory p) && Filename.check_suffix p "install" then
- (try ignore (File.To_install.parse (Run.read p)) with e ->
- Globals.error_and_exit "%s\nwhile parsing '%s'." (Printexc.to_string e) p)
- else
- () (* TODO perform the recursive check for a directory.
- Change [Path.add_rec] such that it accepts an optional checking function. *)
- | _ -> ())
- patches;
- );
-
- (* include the patches inside the downloaded directory *)
- Path.add_rec tmp_nv (Path.extract nv (Links { urls ; patches }));
- Path.to_archive archive_filename tmp_nv;
- Path.remove tmp_nv;
- end in
- Some (Raw_binary (Run.read archive_filename))
- | patches when List.for_all (function Internal _ -> false | _ -> true) patches ->
- (* in case there is no patch or it contains only external link *)
- None
- | _ -> failwith "the patch contains both internal and external links, situation not handled yet" in
+ let patches = File.Spec.patches spec in
+ (* the ".spec" being processed contains only local patches *)
+ let nv = name, version in
+ let tmp_nv = Path.concat Path.cwd (B (Namespace.string_of_nv (fst nv) (snd nv))) in
+ let () =
+ begin
+ (* try to check that patches are well-parsed before the copy *)
+ List.iter
+ (function Internal p ->
+ if not (Sys.is_directory p) && Filename.check_suffix p "install" then
+ (try ignore (File.To_install.parse (Run.read p)) with e ->
+ Globals.error_and_exit "%s\nwhile parsing '%s'." (Printexc.to_string e) p)
+ else
+ () (* TODO perform the recursive check for a directory.
+ Change [Path.add_rec] such that it accepts an optional checking function. *)
+ | _ -> ())
+ patches;
+
+ (* include the patches inside the downloaded directory *)
+ Path.add_rec tmp_nv (Path.extract nv (Links { urls ; patches }));
+ Path.to_archive archive_filename tmp_nv;
+ Path.remove tmp_nv;
+ end in
+ Raw_binary (Run.read archive_filename) in
(* Upload both files to the server and update the client
filesystem to reflect the new uploaded packages *)
View
@@ -21,8 +21,8 @@ type client_to_server =
| C2S_getList
| C2S_getSpec of name_version
| C2S_getArchive of name_version
- | C2S_newArchive of name_version * raw_binary * raw_binary option
- | C2S_updateArchive of name_version * raw_binary * raw_binary option * security_key
+ | C2S_newArchive of name_version * raw_binary * raw_binary
+ | C2S_updateArchive of name_version * raw_binary * raw_binary * security_key
type server_to_client =
| S2C_apiVersion of int
View
@@ -41,14 +41,13 @@ sig
val getArchive : t -> name_version -> raw_binary option
(** Process a first upload: it contains a spec file and a possible
- corresponding archive. If the archive is [None], then the spec
- file should contains links to downloadable archives that clients
- can use later. The function returns the secret key associated to
+ corresponding archive.
+ The function returns the secret key associated to
all the packages having the same name *)
- val newArchive : t -> name_version -> raw_binary -> raw_binary option -> security_key
+ val newArchive : t -> name_version -> raw_binary -> raw_binary -> security_key
(** Same as [newArchive] but for subsequent upload (using the secret key) *)
- val updateArchive : t -> name_version -> raw_binary -> raw_binary option -> security_key -> unit
+ val updateArchive : t -> name_version -> raw_binary -> raw_binary -> security_key -> unit
end
@@ -123,10 +122,7 @@ module Server : SERVER with type t = server_state = struct
begin match opam with
| Raw_binary s -> File.Spec.add opam_file (File.Spec.parse s)
end;
- begin match archive with
- | None -> ()
- | Some f -> Path.add archive_file (Path.File (Binary f))
- end
+ Path.add archive_file (Path.File (Binary archive))
let processArchive o_key t (name, v) spec archive =
let hashes = Path.hashes t.home name in

0 comments on commit a7ec30c

Please sign in to comment.