Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[scripts] Fix creation scripts

  • Loading branch information...
commit bf5ff98c2554c6122a6677be7dbedc2ac0272575 1 parent c1b55c6
@samoht samoht authored
View
4 src/globals.ml
@@ -50,11 +50,13 @@ let warning fmt =
Printf.kprintf (fun str ->
Printf.eprintf "[%d] WARNING: %s\n%!" (Unix.getpid ()) str
) fmt
+
+exception Error
let error_and_exit fmt =
Printf.kprintf (fun str ->
error "%s" str;
- exit 1
+ raise Error
) fmt
let msg fmt =
View
2  src/linelexer.mll
@@ -20,7 +20,7 @@ rule main words lines = parse
| [' ' '\t']+ { main words lines lexbuf }
| [^' ' '\t' '\n']+ { main (Lexing.lexeme lexbuf :: words) lines lexbuf }
| _ { assert false }
-| eof { List.rev (words :: lines) }
+| eof { List.rev (List.rev words :: lines) }
{
let main = main [] []
View
1  src/opam.ml
@@ -295,4 +295,5 @@ let () =
| Failure ("no subcommand defined" as s) ->
ArgExt.pp_print_help ArgExt.NoSubCommand Format.err_formatter global_args ();
Globals.error "%s" s
+ | Globals.Error -> exit 1
| e -> raise e
View
19 src/run.ml
@@ -237,21 +237,24 @@ let extract file dst =
log "untar %s" file;
let files = read_command_output "tar tf %s" file in
log "%s contains %d files: %s" file (List.length files) (String.concat ", " files);
- let aux name =
- let root = root name in
- let n = String.length root in
- let rest = String.sub name n (String.length name - n) in
- Filename.concat tmp_dir name, dst ^ rest in
- let moves = List.map aux files in
remove_dir tmp_dir;
mkdir tmp_dir;
let err =
match is_archive file with
- | Some f_cmd -> f_cmd tmp_dir
- | None -> Globals.error_and_exit "%s is not a valid archive" file in
+ | Some f_cmd -> f_cmd tmp_dir
+ | None -> Globals.error_and_exit "%s is not a valid archive" file in
if err <> 0 then
Globals.error_and_exit "Error while extracting %s" file
else
+ let aux accu name =
+ if not (Sys.is_directory (Filename.concat tmp_dir name)) then
+ let root = root name in
+ let n = String.length root in
+ let rest = String.sub name n (String.length name - n) in
+ (Filename.concat tmp_dir name, dst ^ rest) :: accu
+ else
+ accu in
+ let moves = List.fold_left aux [] files in
List.iter (fun (src, dst) ->
mkdir (Filename.dirname dst);
copy src dst
View
14 src/scripts/opam_mk_install.ml
@@ -37,8 +37,11 @@ let add_l x = add ("lib", x)
let add_s x = add ("lib", x)
let add_b x = add ("bin", x)
+let pr = ref ""
+
let specs = Arg.align [
("-version", Arg.Unit version, " display version information");
+ ("-prefix" , Arg.Set_string pr,"<prefix> build path");
("-bin" , Arg.String add_b, "<name> add a library");
("-lib" , Arg.String add_l, "<name> add a library");
("-syntax" , Arg.String add_s, "<name> add a syntax extension");
@@ -62,13 +65,20 @@ let package =
let sections = List.rev !sections
+let prefix = !pr
+
let () =
let oc = open_out (package ^ ".install") in
let libs = List.filter (fun (s,_) -> s = "lib") sections in
let bins = List.filter (fun (s,_) -> s = "bin") sections in
if libs <> [] then (
- Printf.fprintf oc "lib: [";
- List.iter (fun (_, name) -> Printf.fprintf oc "%S " name) libs;
+ Printf.fprintf oc "lib: [\n";
+ List.iter (fun (_, name) ->
+ Printf.fprintf oc " %S\n" (Filename.concat prefix (name ^ ".cma"));
+ Printf.fprintf oc " %S\n" (Filename.concat prefix (name ^ ".cmi"));
+ Printf.fprintf oc " %S\n" (Filename.concat prefix (name ^ ".cmxa"));
+ Printf.fprintf oc " %S\n" (Filename.concat prefix (name ^ ".a"));
+ ) libs;
Printf.fprintf oc "]\n"
);
if bins <> [] then (
View
26 src/scripts/opam_mk_repo.ml
@@ -66,6 +66,22 @@ let wget src =
| Globals.Darwin -> Printf.sprintf "ftp %s" src
| _ -> Printf.sprintf "wget %s" src
+let archive_name src =
+ let name = F.basename src in
+ if F.check_suffix name ".tar.gz" then
+ name
+ else if F.check_suffix name ".tar.bz2" then
+ name
+ else
+ Printf.sprintf "%s.tar.gz" name
+
+let mv src =
+ let name = archive_name src in
+ if (F.basename src) = name then
+ ""
+ else
+ Printf.sprintf "mv %s %s" (F.basename src) name
+
let () =
Dirname.mkdir (Path.R.archive_dir root);
NV.Set.iter (fun nv ->
@@ -76,11 +92,13 @@ let () =
| None -> ()
| Some url ->
Dirname.mkdir (tmp nv);
- let err = Dirname.exec (tmp nv) [ wget url ] in
- if err = 0 then (
- Filename.extract (tmp nv // F.basename url) tmp_dir;
- ) else
+ let err = Dirname.exec (tmp nv) [
+ wget url;
+ mv url;
+ ] in
+ if err <> 0 then
Globals.error_and_exit "Cannot get %s" url;
+ Filename.extract (tmp nv // archive_name url) tmp_dir;
end;
List.iter (fun f ->
Filename.copy_in f tmp_dir
Please sign in to comment.
Something went wrong with that request. Please try again.