Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 47 lines (39 sloc) 1.458 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
(* Update scrip for rsync-ed repositories *)

let _ =
  if Array.length Sys.argv <> 2 then (
    Printf.eprintf "Usage: %s <remote-address>" Sys.argv.(0);
    exit 1;
  )

let local_path = Run.cwd ()
let remote_address = Sys.argv.(1)

open Types
let (/) = Stdlib_filename.concat

let log = Globals.log "opam-rsync-update"

let rsync ?fn dir =
  let option, filter = match fn with
    | None -> "" , (fun _ -> None)
    | Some f -> "v", f in
  let lines =
    Run.read_command_output [
      "rsync"; "--delete"; "-ar"^option ; (remote_address / dir) ; dir
    ] in
  let files = Utils.filter_map filter lines in
  List.iter (fun x -> log "updated: %s" (NV.to_string x)) files;
  List.fold_left (fun set f -> NV.Set.add f set) NV.Set.empty files

let () =
  let fn str = NV.of_filename (Filename.of_string str) in
  let opam = rsync ~fn "opam/" in
  let descr = try rsync "descr/" with e -> let _ = Globals.warning "%s" (Printexc.to_string e) in NV.Set.empty in
  let archives =
    let files = Run.files_with_links "archives" in
    List.fold_left (fun set f -> NV.Set.union (rsync ~fn f) set) NV.Set.empty files in
  let updates = NV.Set.union archives (NV.Set.union opam descr) in
  File.Updated.write
    (Path.R.updated (Path.R.of_path (Dirname.of_string local_path)))
    updates;

  (* Update compiler descriptions *)
  let _comps =
    try ignore (rsync "compilers/") with
      | e ->
        Globals.warning "%s" (Printexc.to_string e) in
  ()
Something went wrong with that request. Please try again.