Skip to content
This repository has been archived by the owner on May 13, 2019. It is now read-only.

Commit

Permalink
md5sum | cut call replaced by module Digest functions. See #2.
Browse files Browse the repository at this point in the history
  • Loading branch information
sagotch committed Apr 28, 2014
1 parent 2b62382 commit c568b16
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions makorel.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
open Digest
open Str
open Sys
open Unix
open Str

open Urlex
open Unixx

Expand Down Expand Up @@ -84,19 +86,17 @@ let _ =
(k, replace v prev_ver new_ver)

| "checksum" ->
let checksum = Unixx.pipes [[|"curl"; "-Lsf"; new_url|];
[|"md5sum"|];
[|"cut"; "-d "; "-f"; "1"|]]
Unix.stdin in
(* assumes that everything goes well *)
let in_channel = Unix.in_channel_of_descr checksum in
let checksum = input_line in_channel in
close_in in_channel;
print_endline (checksum);
(k, checksum)

let curl_cmd = "curl -Lsf " ^ new_url in
let curl_out = open_process_in curl_cmd in
let checksum = Digest.input curl_out |> Digest.to_hex in
if Unix.close_process_in curl_out <> Unix.WEXITED 0
then failwith curl_cmd
else (k, checksum)

| "mirrors" -> (k, v) (* TODO: something interesting *)
| _ -> prerr_string ("unknown field " ^ k); exit 1

| _ -> failwith ("unknown field " ^ k)

in List.map process_field url_fields in

(* write to url file *)
Expand Down

0 comments on commit c568b16

Please # to comment.