Skip to content

Commit aa32ae4

Browse files
kit-ty-katerjbou
authored andcommitted
No longer call tar tool for creating archive, use tar library
1 parent 6340c07 commit aa32ae4

11 files changed

Lines changed: 16 additions & 48 deletions

master_changes.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ users)
6565
## Lint
6666

6767
## Repository
68+
* No longer call tar tool to create archives, use tar library instead [#6945 @kit-ty-kate]
6869

6970
## Lock
7071

@@ -215,6 +216,7 @@ users)
215216
* `OpamRepositoryPath` was moved to `opam-format` [#6917 @rjbou]
216217
* `OpamRepositoryRoot` was added [#6680 @kit-ty-kate @rjbou]
217218
* `OpamTar`: add module to manipulate tar gz archive. It handles only files, not directories [#6945 @kit-ty-kate @rjbou]
219+
* `OpamRepositoryCommand.update_with_auto_upgrade`, `OpamUpdate.repository`: no longer call an external process to create an archive [#6945 @kit-ty-kate]
218220

219221
## opam-state
220222
* `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]
@@ -280,3 +282,5 @@ users)
280282
* `OpamSystem.{command,commands,read_command_output}`: add a `?dir: dirname` optional arg to launch the command in a specific directory [#6910 @NathanReb]
281283
* `OpamFilename.Unix`: add `starts_with` [#6945 @rjbou]
282284
* `OpamCompat.Seq`: add `to_dispenser` [#6945 @kit-ty-kate]
285+
* `OpamSystem.directories_with_links`, `OpamSystem.rec_files`, `OpamFilename.rec_files`: add optional `?except_vcs` that default to false to exclude VCS directories [#6945 @kit-ty-kate @rjbou]
286+
* `OpamFilename.make_tar_gz{_job}`: rename `make_tar_gz_job` into `make_tar_gz` as it no longer need an external process call [#6945 @kit-ty-kate]

src/client/opamRepositoryCommand.ml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -259,23 +259,15 @@ let update_with_auto_upgrade rt repo_names =
259259
OpamRepositoryState.Cache.remove ());
260260
OpamConsole.msg "Upgrading repository \"%s\"...\n"
261261
(OpamRepositoryName.to_string r.repo_name);
262-
let open OpamProcess.Job.Op in
263262
let repo_root =
264263
match OpamRepositoryState.get_repo_root rt r with
265264
| OpamRepositoryRoot.Dir x -> x
266265
in
267266
OpamAdminRepoUpgrade.do_upgrade repo_root;
268267
if OpamRepositoryConfig.(!r.repo_tarring) then
269-
OpamProcess.Job.run
270-
(OpamRepositoryRoot.make_tar_gz_job
271-
(OpamRepositoryPath.tar rt.repos_global.root r.repo_name)
272-
repo_root
273-
@@| function
274-
| Some e ->
275-
Printf.ksprintf failwith
276-
"Failed to regenerate local repository archive: %s"
277-
(Printexc.to_string e)
278-
| None -> ());
268+
OpamRepositoryRoot.make_tar_gz
269+
(OpamRepositoryPath.tar rt.repos_global.root r.repo_name)
270+
repo_root;
279271
let def =
280272
OpamRepositoryRoot.Dir.Path.repo repo_root
281273
|> OpamFile.Repo.safe_read

src/core/opamFilename.ml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,9 +392,6 @@ let extract_in filename dirname =
392392
let extract_in_job filename dirname =
393393
OpamSystem.extract_in_job (to_string filename) ~dir:(Dir.to_string dirname)
394394

395-
let make_tar_gz_job filename dirname =
396-
OpamSystem.make_tar_gz_job (to_string filename) ~dir:(Dir.to_string dirname)
397-
398395
type generic_file =
399396
| D of Dir.t
400397
| F of t

src/core/opamFilename.mli

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,6 @@ val extract_in: t -> Dir.t -> unit
251251

252252
val extract_in_job: t -> Dir.t -> exn option OpamProcess.job
253253

254-
val make_tar_gz_job: t -> Dir.t -> exn option OpamProcess.job
255-
256254
(** Extract a generic file *)
257255
val extract_generic_file: generic_file -> Dir.t -> unit
258256

src/core/opamSystem.ml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -937,17 +937,6 @@ module Tar = struct
937937
make_command tar_cmd [ Printf.sprintf "xf%c" c ; f file; "-C" ; f dir ]
938938
in
939939
command (extract_option typ))
940-
941-
let compress_command =
942-
fun file dir ->
943-
let f = Lazy.force cygpath_tar in
944-
let tar_cmd = Lazy.force tar_cmd in
945-
make_command tar_cmd [
946-
"cfz"; f file;
947-
"-C" ; f (Filename.dirname dir);
948-
f (Filename.basename dir)
949-
]
950-
951940
end
952941
953942
module Zip = struct
@@ -988,16 +977,6 @@ let extract_command file =
988977
if Zip.is_archive file then Zip.extract_command file
989978
else Tar.extract_command file
990979
991-
let make_tar_gz_job ~dir file =
992-
let tmpfile = file ^ ".tmp" in
993-
remove_file tmpfile;
994-
Tar.compress_command tmpfile dir @@> fun r ->
995-
OpamProcess.cleanup r;
996-
if OpamProcess.is_success r then
997-
(mv tmpfile file; Done None)
998-
else
999-
(remove_file tmpfile; Done (Some (Process_error r)))
1000-
1001980
let extract_job ~dir file =
1002981
if not (Sys.file_exists file) then
1003982
Done (Some (File_not_found file))

src/core/opamSystem.mli

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,6 @@ val extract_in: dir:string -> string -> unit
287287
(** [extract_in_job] is similar to [extract_in], but as a job *)
288288
val extract_in_job: dir:string -> string -> exn option OpamProcess.job
289289

290-
val make_tar_gz_job: dir:string -> string -> exn option OpamProcess.job
291-
292290
(** Create a directory. Do not fail if the directory already
293291
exist. *)
294292
val mkdir: string -> unit

src/repository/opamRepositoryRoot.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ module Dir = struct
5555
end)
5656
end
5757

58-
let make_tar_gz_job = OpamFilename.make_tar_gz_job
58+
let make_tar_gz = OpamTar.create
5959
let extract_in_job = OpamFilename.extract_in_job
6060

6161
type t =

src/repository/opamRepositoryRoot.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ module Dir : sig
5454
and type 'a typed_file = 'a OpamFile.t
5555
end
5656

57-
val make_tar_gz_job : filename -> Dir.t -> exn option OpamProcess.job
57+
val make_tar_gz : filename -> Dir.t -> unit
5858
val extract_in_job : filename -> Dir.t -> exn option OpamProcess.job
5959

6060
type t =

src/state/opamUpdate.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ let repository rt repo =
125125
let tarred_repo = OpamRepositoryPath.tar gt.root repo.repo_name in
126126
(if OpamRepositoryConfig.(!r.repo_tarring) then
127127
match repo_root with
128-
| Dir dir -> OpamRepositoryRoot.make_tar_gz_job tarred_repo dir
129-
else Done None)
128+
| Dir dir -> OpamRepositoryRoot.make_tar_gz tarred_repo dir);
129+
Done None
130130
@@+ function
131131
| Some e ->
132132
OpamStd.Exn.fatal e;

tests/reftests/action-disk.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
N0REP0
2-
### OPAMDEBUGSECTIONS="SYSTEM FILE(config) FILE(repos-config) FILE(repo) FILE(switch-config) FILE(switch-state) FILE(opam) FILE(environment) FILE(package-version-list) FILE(.install) FILE(changes) FILE(.config) CACHE(installed) CACHE(repository)"
2+
### OPAMDEBUGSECTIONS="TAR SYSTEM FILE(config) FILE(repos-config) FILE(repo) FILE(switch-config) FILE(switch-state) FILE(opam) FILE(environment) FILE(package-version-list) FILE(.install) FILE(changes) FILE(.config) CACHE(installed) CACHE(repository)"
33
### OPAMDEBUG=-5
44
### OPAMVERBOSE=2
55
### OPAMYES=1

0 commit comments

Comments
 (0)