Skip to content

Commit

Permalink
Add a new lint check: disallow the extra-files field in opam packages
Browse files Browse the repository at this point in the history
There's a great alternative - extra-sources - that should be used instead.
  • Loading branch information
hannesm committed May 22, 2024
1 parent 372690e commit affa276
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/lint.ml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type error =
| NameCollision of string
| WeakChecksum of string
| PinDepends
| ExtraFiles

type host_os = Macos | Other [@@deriving to_yojson]

Expand Down Expand Up @@ -375,6 +376,11 @@ module Check = struct
| [] -> errors
| _ -> (pkg, PinDepends) :: errors

let check_no_extra_files ~errors ~pkg opam =
match OpamFile.OPAM.extra_files opam with
| [] -> errors
| _ -> (pkg, ExtraFiles) :: errors

let opam_lint ~check_extra_files ~errors ~pkg opam =
OpamFileTools.lint ~check_extra_files ~check_upstream:true opam |>
List.fold_left (fun errors x -> (pkg, OpamLint x) :: errors) errors |>
Expand All @@ -394,6 +400,7 @@ module Check = struct
let errors = check_dune_subst ~errors ~pkg opam in
let errors = check_checksums ~errors ~pkg opam in
let errors = check_no_pin_depends ~errors ~pkg opam in
let errors = check_no_extra_files ~errors ~pkg opam in
check_dune_constraints ~host_os ~errors ~pkg opam >>= fun errors ->
check_name_collisions ~cwd ~errors ~pkg >>= fun errors ->
(* Check directory structure correctness *)
Expand Down Expand Up @@ -491,6 +498,8 @@ module Lint = struct
Fmt.str "Error in %s: Weak checksum algorithm(s) provided. Please use SHA-256 or SHA-512. Details: %s" pkg msg
| PinDepends ->
Fmt.str "Error in %s: pin-depends present. This is not allowed in the opam-repository." pkg
| ExtraFiles ->
Fmt.str "Error in %s: extra-files present. This is not allowed in the opam-repository. Please use extra-source instead." pkg
)

let run { master } job { Key.src; packages } { Value.host_os } =
Expand Down

0 comments on commit affa276

Please sign in to comment.