Skip to content

Commit

Permalink
opam-admin-top: remove descr & url
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesm committed Oct 21, 2024
1 parent fc6454e commit adb134e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 22 deletions.
23 changes: 6 additions & 17 deletions src/tools/opam_admin_top.ml
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,20 @@ let iter_packages_gen ?(quiet=false) f =
(OpamPackage.to_string package);
let opam_file = OpamRepositoryPath.opam repo prefix package in
let opam = OpamFile.OPAM.read opam_file in
let descr_file = OpamRepositoryPath.descr repo prefix package in
let descr = OpamFile.Descr.read_opt descr_file in
let url_file = OpamRepositoryPath.url repo prefix package in
let url = OpamFile.URL.read_opt url_file in
let dot_install_file : OpamFile.Dot_install.t OpamFile.t =
OpamFile.make
(OpamRepositoryPath.files repo prefix package
// (OpamPackage.Name.to_string (OpamPackage.name package) ^ ".install"))
in
let dot_install = OpamFile.Dot_install.read_opt dot_install_file in
let opam2, descr2, url2, dot_install2 =
f package ~prefix ~opam ~descr ~url ~dot_install
let opam2, dot_install2 =
f package ~prefix ~opam ~dot_install
in
let descr2 = of_action descr descr2 in
let url2 = of_action url url2 in
let dot_install2 = of_action dot_install dot_install2 in
let changed = ref false in
let upd () = changed := true; incr changed_files in
if opam <> opam2 then
(upd (); OpamFile.OPAM.write_with_preserved_format opam_file opam2);
if descr <> descr2 then
(upd (); wopt OpamFile.Descr.write descr_file descr2);
if url <> url2 then
(upd (); wopt OpamFile.URL.write url_file url2);
if dot_install <> dot_install2 then
(upd (); wopt OpamFile.Dot_install.write dot_install_file dot_install2);
if !changed then
Expand All @@ -92,16 +82,15 @@ let iter_packages_gen ?(quiet=false) f =
!changed_files !changed_pkgs

let iter_packages ?quiet
?(filter=true_) ?f ?(opam=identity) ?descr ?url ?dot_install
?(filter=true_) ?f ?(opam=identity) ?dot_install
() =
iter_packages_gen ?quiet
(fun p ~prefix ~opam:o ~descr:d ~url:u ~dot_install:i ->
(fun p ~prefix ~opam:o ~dot_install:i ->
if filter p then (
apply f p prefix o;
opam p o, to_action descr p d , to_action url p u,
to_action dot_install p i
opam p o, to_action dot_install p i
) else
o, `Keep, `Keep, `Keep)
o, `Keep)

let regexps_of_patterns patterns =
let contains_dot str =
Expand Down
6 changes: 1 addition & 5 deletions src/tools/opam_admin_top.mli
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ val iter_packages_gen:
(OpamPackage.t ->
prefix:string option ->
opam:OPAM.t ->
descr:Descr.t option ->
url:URL.t option ->
dot_install:Dot_install.t option ->
OPAM.t * Descr.t action * URL.t action * Dot_install.t action)
OPAM.t * Dot_install.t action)
-> unit

(** Turn a list of glob patterns into a proper filtering function on
Expand All @@ -44,7 +42,5 @@ val iter_packages:
?filter:(OpamPackage.t -> bool) ->
?f:(OpamPackage.t -> string option -> OPAM.t -> unit) ->
?opam:(OpamPackage.t -> OPAM.t -> OPAM.t) ->
?descr:(OpamPackage.t -> Descr.t -> Descr.t) ->
?url:(OpamPackage.t -> URL.t -> URL.t) ->
?dot_install:(OpamPackage.t -> Dot_install.t -> Dot_install.t) ->
unit -> unit

0 comments on commit adb134e

Please sign in to comment.