Skip to content

Commit fd657f3

Browse files
authored
Merge pull request #6917 from rjbou/path-names
Add modules to specify some path elements names
2 parents 84608f6 + a906a42 commit fd657f3

28 files changed

Lines changed: 264 additions & 94 deletions

doc/index.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,14 @@ <h1>opam %{OPAMVERSION}% API and libraries documentation</h1>
110110
<td>Definitions of many types used throughout</td></tr>
111111
<tr><th><a href="opam-format/OpamTypesBase">opamTypesBase.ml</a></th>
112112
<td>Helper functions on the base types. Often opened</td></tr>
113+
<tr><th><a href="opam-format/OpamPathName">opamPathName.ml</a></th>
114+
<td>Defines the names of internal opam root elements</td></tr>
113115
<tr><th><a href="opam-format/OpamPath">opamPath.ml</a></th>
114116
<td>Defines the file hierarchy in ~/.opam</td></tr>
117+
<tr><th><a href="opam-repository/OpamRepositoryPathName">opamRepositoryPathName.ml</a></th>
118+
<td>Defines the names of a repository elements layout</td></tr>
119+
<tr><th><a href="opam-repository/OpamRepositoryPath">opamRepositoryPath.ml</a></th>
120+
<td>Defines the file hierarchy in repositories</td></tr>
115121

116122
<tr><td colspan="2" class="sublib">Basic types, used as keys</td></tr>
117123

@@ -160,8 +166,6 @@ <h1>opam %{OPAMVERSION}% API and libraries documentation</h1>
160166
<td>Configuration options for this lib (record, global reference, setter, initialisation)</td></tr>
161167
<tr><th><a href="opam-repository/OpamRepositoryBackend">opamRepositoryBackend.ml</a></th>
162168
<td>Signature for repository handlers and some helpers for the repository type</td></tr>
163-
<tr><th><a href="opam-repository/OpamRepositoryPath">opamRepositoryPath.ml</a></th>
164-
<td>Defines the file hierarchy in repositories</td></tr>
165169
<tr><th><a href="opam-repository/OpamDownload">opamDownload.ml</a></th>
166170
<td>Configuration init and handling of downloading commands</td></tr>
167171
<tr><th><a href="opam-repository/OpamHTTP">opamHTTP.ml</a></th>

master_changes.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ users)
207207
* `OpamSolution.get_depexts` remove no longer needed `recover` option that was used with `--depext-only` option [#6489 @arozovyk]
208208

209209
## opam-repository
210+
* `OpamRepositoryPath` was moved to `opam-format` [#6917 @rjbou]
210211

211212
## opam-state
212213
* `OpamStateConfig.t`: replace `no_depexts` fields that contains disabling informations by `depexts` field that returns if the depexts mechanism is enabled. This field is automatically update by global config value in `OpamStateConfig.load_defaults` [#6489 @rjbou]
@@ -242,6 +243,9 @@ users)
242243
* `OpamSysPkg`: add `availability_mode` type to indicate the availability of system packages on a given system [#6489 @arozovyk]
243244
* `OpamSysPkg`: add `equal_availability_mode` function [#6489 @arozovyk]
244245
* `OpamTypes`: change `result` type name to `solver_result` to avoid conflicts with Stdlib [#6885 @rjbou]
246+
* `OpamPathName` was added [#6917 @rjbou]
247+
* `OpamRepositoryPathName` was added [#6917 @rjbou]
248+
* `OpamRepositoryPath` was moved from `opam-repository` [#6917 @rjbou]
245249

246250
## opam-core
247251
* `OpamCmdliner` was added. It is accessible through a new `opam-core.cmdliner` sub-library [#6755 @kit-ty-kate]

src/client/opamAction.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ let prepare_package_build env opam nv dir =
354354
in
355355
let print_subst basename =
356356
let file = OpamFilename.Base.to_string basename in
357-
let file_in = file ^ ".in" in
357+
let file_in = file ^ OpamPathName.subst_suffix in
358358
log "%s: expanding opam variables in %s, generating %s.\n"
359359
(OpamPackage.name_to_string nv)
360360
file_in file;

src/client/opamAdminCommand.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ let index_command cli =
125125
OpamFile.Repo.write repo_file repo_def;
126126
if urls_txt <> `no_urls_txt then
127127
(OpamConsole.msg "Generating urls.txt...\n";
128-
OpamFilename.of_string "repo" ::
128+
OpamFilename.of_string OpamRepositoryPathName.repo_f ::
129129
(if urls_txt = `full_urls_txt then
130130
OpamFilename.rec_files OpamFilename.Op.(repo_root / "compilers") @
131131
OpamFilename.rec_files (OpamRepositoryPath.packages_dir repo_root)
@@ -837,7 +837,8 @@ let lint_command cli =
837837
let cmd global_options short list incl excl ign warn_error () =
838838
OpamArg.apply_global_options cli global_options;
839839
let repo_root = checked_repo_root () in
840-
if not (OpamFilename.exists_dir OpamFilename.Op.(repo_root / "packages"))
840+
if not (OpamFilename.exists_dir
841+
OpamFilename.Op.(repo_root / OpamRepositoryPathName.packages_d))
841842
then
842843
OpamConsole.error_and_exit `Bad_arguments
843844
"No repository found in current directory.\n\

src/client/opamAuxCommands.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ let opams_of_dir_w_target ?locked ?recurse ?subpath
128128
let name_and_dir_of_opam_file ?locked f =
129129
let srcdir = OpamFilename.dirname f in
130130
let srcdir =
131-
if OpamFilename.dir_ends_with ".opam" srcdir &&
131+
if OpamFilename.dir_ends_with OpamPathName.opam_suffix srcdir &&
132132
OpamUrl.guess_version_control (OpamFilename.Dir.to_string srcdir)
133133
= None
134134
then OpamFilename.dirname_dir srcdir

src/client/opamCommands.ml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3854,9 +3854,11 @@ let source cli =
38543854
= None
38553855
then
38563856
let f =
3857-
if OpamFilename.exists_dir Op.(dir / "opam")
3858-
then OpamFile.make Op.(dir / "opam" // "opam")
3859-
else OpamFile.make Op.(dir // "opam")
3857+
let opam_f = OpamPathName.opam_f in
3858+
let opam_d = OpamPathName.opam_d in
3859+
if OpamFilename.exists_dir Op.(dir / opam_d)
3860+
then OpamFile.make Op.(dir / opam_d // opam_f)
3861+
else OpamFile.make Op.(dir // opam_f)
38603862
in
38613863
OpamFile.OPAM.write f
38623864
(OpamFile.OPAM.with_substs [] @@

src/client/opamListCommand.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ let apply_selector ~base st = function
377377
in
378378
let matching_change_files =
379379
List.filter (fun change_f ->
380-
OpamFilename.check_suffix change_f ".changes" &&
380+
OpamFilename.check_suffix change_f OpamPathName.changes_suffix &&
381381
let changes =
382382
OpamFile.Changes.safe_read (OpamFile.make change_f)
383383
in
@@ -870,7 +870,7 @@ let info st ~fields ~raw ~where ?normalise ?(show_empty=false)
870870
if where then
871871
OpamConsole.msg "%s\n"
872872
(match OpamFile.OPAM.metadata_dir opam with
873-
| Some (None, dir) -> Filename.concat dir "opam"
873+
| Some (None, dir) -> Filename.concat dir OpamPathName.opam_f
874874
| Some (Some repo, rdir) ->
875875
let repo_dir = OpamRepositoryPath.root st.switch_global.root repo in
876876
let tar = OpamRepositoryPath.tar st.switch_global.root repo in

src/client/opamPinCommand.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ let edit st ?version name =
292292
OpamFile.OPAM.get_url opam >>= OpamUrl.local_dir >>| fun dir ->
293293
let src_opam =
294294
(OpamPinned.find_opam_file_in_source name dir >>| fst)
295-
+! (OpamFile.make OpamFilename.Op.(dir // "opam"))
295+
+! (OpamFile.make OpamFilename.Op.(dir // OpamPathName.opam_f))
296296
in
297297
let clean_opam =
298298
OpamFile.OPAM.with_url_opt None @*

src/format/opamFile.ml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2773,9 +2773,13 @@ module OPAMSyntax = struct
27732773
| Some r, rel ->
27742774
{ pos_null with
27752775
filename =
2776-
Printf.sprintf "<%s>/%s/opam" (OpamRepositoryName.to_string r) rel }
2776+
Printf.sprintf "<%s>/%s/%s"
2777+
(OpamRepositoryName.to_string r)
2778+
rel
2779+
OpamRepositoryPathName.opam_f }
27772780
| None, d ->
2778-
pos_file OpamFilename.Op.(OpamFilename.Dir.of_string d // "opam")
2781+
let open OpamFilename.Op in
2782+
pos_file (OpamFilename.Dir.of_string d // OpamPathName.opam_f)
27792783
in
27802784
Pp.bad_format ?pos "Field '%s:' is required" name
27812785
| Some n -> n
@@ -3661,7 +3665,7 @@ module OPAM = struct
36613665
(match metadata_dir o with
36623666
| None -> None
36633667
| Some (None, abs) ->
3664-
let files_dir = OpamFilename.Dir.of_string abs / "files" in
3668+
let files_dir = OpamFilename.Dir.of_string abs / OpamPathName.files_d in
36653669
extra_files o >>| List.map @@ fun (basename, hash) ->
36663670
let content =
36673671
let f = OpamFilename.create files_dir basename in
@@ -3672,7 +3676,10 @@ module OPAM = struct
36723676
in
36733677
(basename, content, hash)
36743678
| Some (Some r, rel) ->
3675-
let files = get_repo_files r (rel ^ Filename.dir_sep ^ "files") in
3679+
let files =
3680+
get_repo_files r
3681+
(rel ^ Filename.dir_sep ^ OpamRepositoryPathName.files_d)
3682+
in
36763683
extra_files o >>| List.map @@ fun (basename, hash) ->
36773684
let content =
36783685
OpamStd.List.assoc_opt OpamFilename.Base.equal basename files
@@ -3694,7 +3701,7 @@ module OPAM = struct
36943701
Printf.sprintf " in %s" dir
36953702
| _, _, _, Some (Some repo, dir) ->
36963703
Printf.sprintf " %s from repository %s"
3697-
(Filename.concat dir "opam")
3704+
(Filename.concat dir OpamRepositoryPathName.opam_f)
36983705
(OpamRepositoryName.to_string repo)
36993706
| _ -> "")
37003707
(OpamStd.Format.itemize

src/format/opamFilter.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ let expand_interpolations_in_file_full env ~src ~dst =
463463
(* Substitute the file contents *)
464464
let expand_interpolations_in_file env file =
465465
let file = OpamFilename.of_basename file in
466-
let src = OpamFilename.add_extension file "in" in
466+
let src = OpamFilename.add_extension file OpamPathName.subst_ext in
467467
expand_interpolations_in_file_full env ~src ~dst:file
468468

469469
(* Apply filters and interpolations to package commands *)

0 commit comments

Comments
 (0)