Permalink
Browse files

Remove curl -J option as it is not available on old curl

Replace it with custom-made file detection (thx to @chambard).

This should fix #288
  • Loading branch information...
1 parent c57e9b0 commit 45651c324d0cef460eb388fa2352354ae2a37cd3 @samoht samoht committed Nov 22, 2012
Showing with 30 additions and 12 deletions.
  1. +1 −1 README.md
  2. +29 −11 src/core/opamSystem.ml
View
@@ -9,7 +9,7 @@ things, used by Debian to manage their packages.
### Prerequisites:
* ocaml (>= 3.12.1)
-* curl (>= 7.20.0) or wget
+* curl or wget
* git
* rsync
View
@@ -314,6 +314,15 @@ module Tar = struct
[ [ "tar.gz" ; "tgz" ], 'z'
; [ "tar.bz2" ; "tbz" ], 'j' ]
+ let guess_type f =
+ let ic = open_in f in
+ let c1 = input_char ic in
+ let c2 = input_char ic in
+ match c1, c2 with
+ | '\031', '\139' -> Some 'z'
+ | 'B' , 'Z' -> Some 'j'
+ | _ -> None
+
let match_ext file ext =
List.exists (Filename.check_suffix file) ext
@@ -326,17 +335,26 @@ module Tar = struct
(List.concat (List.map fst extensions))
let extract_function file =
- List.fold_left
- (function
- | Some s -> (fun _ -> Some s)
+ let command c dir =
+ command [ "tar" ; Printf.sprintf "xf%c" c ; file; "-C" ; dir ] in
+
+ let ext =
+ List.fold_left
+ (fun acc (ext, c) -> match acc with
+ | Some f -> Some f
| None ->
- (fun (ext, c) ->
- if match_ext file ext then
- Some (fun dir -> command [ "tar" ; Printf.sprintf "xf%c" c ; file; "-C" ; dir ])
- else
- None))
- None
- extensions
+ if match_ext file ext
+ then Some (command c)
+ else None)
+ None
+ extensions in
+ match ext with
+ | Some f -> Some f
+ | None ->
+ match guess_type file with
+ | None -> None
+ | Some c -> Some (command c)
+
end
let is_tar_archive = Tar.is_archive
@@ -443,7 +461,7 @@ let system_ocamlc_version = system [ "ocamlc"; "-version" ]
let download_command = lazy (
try
command ~verbose:false ["which"; "curl"];
- (fun src -> [ "curl"; "--insecure" ; "-OLJ"; src ])
+ (fun src -> [ "curl"; "--insecure" ; "-OL"; src ])
with Process_error _ ->
try
command ~verbose:false ["which"; "wget"];

0 comments on commit 45651c3

Please sign in to comment.