follow opkg rules

This commit is contained in:
Jeremie Dimino 2016-12-07 16:09:49 +01:00
parent 0f771a004b
commit f7b51ed1a0
4 changed files with 44 additions and 9 deletions

View File

@ -1151,12 +1151,24 @@ module Gen(P : Params) = struct
| _ -> [dll ~dir lib]
in
List.concat
[ List.map files ~f:(fun src ->
{ Install.Entry. src; dst = None; section = Lib })
; List.map dlls ~f:(fun src ->
{ Install.Entry. src; dst = None; section = Stublibs })
[ List.map files ~f:(Install.Entry.make Lib )
; List.map dlls ~f:(Install.Entry.make Stublibs)
]
let add_doc_file fn entries =
let suffixes = [""; ".md"; ".org"; ".txt"] in
match
List.find_map suffixes ~f:(fun suf ->
let path = Path.of_string (fn ^ suf) in
if Path.exists path then
Some path
else
None)
with
| None -> entries
| Some path ->
Install.Entry.make Doc path :: entries
let install_file package =
let entries =
List.concat_map P.stanzas ~f:(fun { ctx_dir = dir; stanzas; _ } ->
@ -1169,11 +1181,18 @@ module Gen(P : Params) = struct
let entries =
let meta = Path.of_string "META" in
if Path.exists meta then
{ Install.Entry.
src = meta
; dst = None
; section = Lib
} :: entries
Install.Entry.make Lib meta :: entries
else
entries
in
let entries =
List.fold_left ["README"; "LICENSE"] ~init:entries ~f:(fun acc fn ->
add_doc_file fn acc)
in
let entries =
let opam = Path.of_string "opam" in
if Path.exists opam then
Install.Entry.make Lib opam :: entries
else
entries
in

View File

@ -51,6 +51,14 @@ module List = struct
let partition_map l ~f =
let l, r = rev_partition_map l ~f in
(List.rev l, List.rev r)
let rec find_map l ~f =
match l with
| [] -> None
| x :: l ->
match f x with
| None -> find_map l ~f
| Some _ as res -> res
end
module Hashtbl = struct

View File

@ -38,6 +38,12 @@ module Entry = struct
; dst : string option
; section : Section.t
}
let make section ?dst src =
{ src
; dst
; section
}
end
module SMap = Map.Make(Section)

View File

@ -22,6 +22,8 @@ module Entry : sig
; dst : string option
; section : Section.t
}
val make : Section.t -> ?dst:string -> Path.t -> t
end
val files : Entry.t list -> Path.Set.t