Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Start fixing the converter from 0.3 to 0.4

WIP
  • Loading branch information...
commit f09920fb3e220b4dc42d53a7ca871c6366e6c4f2 1 parent ae31909
Thomas Gazagnaire samoht authored
13 Makefile
@@ -2,13 +2,7 @@ BIN = /usr/local/bin
2 2 OCPBUILD ?= ./_obuild/unixrun ./boot/ocp-build.boot
3 3 OCAMLC=ocamlc
4 4 SRC_EXT=src_ext
5   -TARGETS = opam opam-server \
6   - opam-rsync-init opam-rsync-update opam-rsync-download opam-rsync-upload \
7   - opam-curl-init opam-curl-update opam-curl-download opam-curl-upload \
8   - opam-git-init opam-git-update opam-git-download opam-git-upload \
9   - opam-server-init opam-server-update opam-server-download opam-server-upload \
10   - opam-mk-config opam-mk-install opam-mk-repo \
11   - opam-repo-convert-0.3
  5 +TARGETS = opam opam-mk-repo opam-repo-convert-0.3
12 6
13 7 .PHONY: all
14 8
@@ -68,8 +62,9 @@ tests-git:
68 62 cp _obuild/$*/$*.asm $(BIN)/$*
69 63
70 64 .PHONY: install
71   -install: $(TARGETS:%=%-install)
72   - @
  65 +install:
  66 + rm $(BIN)/opam*
  67 + $(MAKE) $(TARGETS:%=%-install)
73 68
74 69 doc: compile
75 70 mkdir -p doc/html/
77 opam.ocp
@@ -53,61 +53,6 @@ end
53 53
54 54 (*
55 55
56   -
57   -(* RSYNC *)
58   -begin library "opam-rsync-lib"
59   - files = [ "src/repo/rsync/rsync.ml" ]
60   - requires = [ "opam-lib" ]
61   -end
62   -
63   -begin program "opam-rsync-init"
64   - files = [ "src/repo/rsync/init.ml" ]
65   - requires = [ "opam-rsync-lib" ]
66   -end
67   -
68   -begin program "opam-rsync-update"
69   - files = [ "src/repo/rsync/update.ml" ]
70   - requires = [ "opam-rsync-lib" ]
71   -end
72   -
73   -begin program "opam-rsync-download"
74   - files = [ "src/repo/rsync/download.ml" ]
75   - requires = [ "opam-rsync-lib" ]
76   -end
77   -
78   -begin program "opam-rsync-upload"
79   - files = [ "src/repo/rsync/upload.ml" ]
80   - requires = [ "opam-rsync-lib" ]
81   -end
82   -
83   -
84   -(* GIT *)
85   -begin library "opam-git-lib"
86   - files = [ "src/repo/git/git.ml" ]
87   - requires = [ "opam-lib" ]
88   -end
89   -
90   -begin program "opam-git-init"
91   - files = [ "src/repo/git/init.ml" ]
92   - requires = [ "opam-git-lib" ]
93   -end
94   -
95   -begin program "opam-git-update"
96   - files = [ "src/repo/git/update.ml" ]
97   - requires = [ "opam-git-lib" ]
98   -end
99   -
100   -begin program "opam-git-download"
101   - files = [ "src/repo/git/download.ml" ]
102   - requires = [ "opam-git-lib" ]
103   -end
104   -
105   -begin program "opam-git-upload"
106   - files = [ "src/repo/git/upload.ml" ]
107   - requires = [ "opam-git-lib" ]
108   -end
109   -
110   -
111 56 (* SERVER *)
112 57 begin library "opam-server-lib"
113 58 files = [
@@ -131,26 +76,6 @@ begin program "opam-server"
131 76 ]
132 77 end
133 78
134   -begin program "opam-server-init"
135   - files = [ "src/repo/server/init.ml" ]
136   - requires = [ "opam-server-lib" ]
137   -end
138   -
139   -begin program "opam-server-update"
140   - files = [ "src/repo/server/update.ml" ]
141   - requires = [ "opam-server-lib" ]
142   -end
143   -
144   -begin program "opam-server-download"
145   - files = [ "src/repo/server/download.ml" ]
146   - requires = [ "opam-server-lib" ]
147   -end
148   -
149   -begin program "opam-server-upload"
150   - files = [ "src/repo/server/upload.ml" ]
151   - requires = [ "opam-server-lib" ]
152   -end
153   -
154 79 *)
155 80
156 81 (* Helpers *)
@@ -167,7 +92,7 @@ end
167 92
168 93 begin program "opam-mk-repo"
169 94 files = [ "src/scripts/opam_mk_repo.ml" ]
170   - requires = [ "opam-curl-lib" ]
  95 + requires = [ "opam-lib" ]
171 96 end
172 97
173 98 begin program "opam-check"
4 src/path.ml
@@ -208,9 +208,9 @@ module R = struct
208 208
209 209 let files t nv = package t nv / "files"
210 210
211   - let tmp_root t = t / "tmp"
  211 + let tmp t = t / "tmp"
212 212
213   - let tmp_dir t nv = tmp_root t / NV.to_string nv
  213 + let tmp_dir t nv = tmp t / NV.to_string nv
214 214
215 215 let available_files t nv =
216 216 if Dirname.exists (files t nv) then
41 src/repositories.mli
@@ -20,41 +20,50 @@
20 20
21 21 open Types
22 22
  23 +(** Initialize {i $opam/repo/$repo} *)
  24 +val init: repository -> unit
  25 +
  26 +(** Updated {i $opam/repo/$repo} *)
  27 +val update: repository -> unit
  28 +
  29 +(** Run {i opam-$kind-download} in {i $opam/repo/$repo} *)
  30 +val download: repository -> nv -> unit
  31 +
  32 +(** Upload the content of {i $opam/repo/$repo/upload} *)
  33 +val upload: repository -> unit
  34 +
23 35 type kind = string
24 36
  37 +(** {2 Repository backends *)
  38 +
25 39 (** Backend signature *)
26 40 module type BACKEND = sig
27 41
28 42 (** Initialize the repository *)
29 43 val init: repository -> unit
30 44
31   - (** Update the repository. Return the list of updated files *)
  45 + (** Update the repository. Return the list of updated local files. *)
32 46 val update: repository -> Filename.Set.t
33 47
34   - (** Download the package archive on the server *)
  48 + (** Download the package archive on the server. Return the local file. *)
35 49 val download_archive: repository -> nv -> filename download
36 50
37   - (** Download a file *)
  51 + (** Download a file. Return the local file. Use {i $repo/tmp/$nv/}
  52 + as tempory location. *)
38 53 val download_file: repository -> nv -> filename -> filename download
39 54
40   - (** Download a directory *)
  55 + (** Download a directory. Return the local directory. Use {i
  56 + $repo/tmp/$nv} as location to store transient state between
  57 + downloads. *)
41 58 val download_dir: repository -> nv -> dirname -> dirname download
42 59
43   - (** Upload a local directory *)
  60 + (** Upload a local directory. Return the updated local files. *)
44 61 val upload_dir: repository -> dirname -> Filename.Set.t
  62 +
45 63 end
46 64
47 65 (** Register a repository backend *)
48 66 val register_backend: kind -> (module BACKEND) -> unit
49 67
50   -(** Initialize {i $opam/repo/$repo} *)
51   -val init: repository -> unit
52   -
53   -(** Updated {i $opam/repo/$repo} *)
54   -val update: repository -> unit
55   -
56   -(** Run {i opam-$kind-download} in {i $opam/repo/$repo} *)
57   -val download: repository -> nv -> unit
58   -
59   -(** Upload the content of {i $opam/repo/$repo/upload} *)
60   -val upload: repository -> unit
  68 +(** Find a repository *)
  69 +val find_backend: repository -> (module BACKEND)
18 src/scripts/opam_mk_repo.ml
@@ -26,9 +26,7 @@
26 26 After the script is run, archives/ contains all the package archives
27 27 for the available descr and OPAM files *)
28 28
29   -open Repo_helpers
30 29 open Types
31   -open Curl
32 30
33 31 let all, index, packages =
34 32 let usage = Printf.sprintf "%s [-all] [<package>]*" (Stdlib_filename.basename Sys.argv.(0)) in
@@ -46,13 +44,8 @@ let all, index, packages =
46 44 let () =
47 45
48 46 let local_path = Dirname.cwd () in
49   - let local_repo = Path.R.of_dirname local_path in
50   - let state = {
51   - local_path; local_repo;
52   - remote_path = local_path;
53   - remote_repo = local_repo;
54   - } in
55 47 let repo = Repository.create ~name:"local" ~kind:"curl" ~address:(Dirname.to_string local_path) in
  48 + let local_repo = Path.R.create repo in
56 49
57 50 (* Create urls.txt *)
58 51 let local_index_file = Filename.of_string "urls.txt" in
@@ -71,14 +64,17 @@ let () =
71 64 ) in
72 65 File.Urls_txt.write local_index_file urls;
73 66
74   - let updates = Curl.get_updates state in
  67 + let module B = (val Repositories.find_backend repo: Repositories.BACKEND) in
  68 + let updates = B.update repo in
  69 + let packages =
  70 + NV.Set.of_list (Utils.filter_map NV.of_filename (Filename.Set.elements updates)) in
75 71
76 72 (* Update the archive files *)
77 73 NV.Set.iter (fun nv ->
78 74 Globals.msg "Updating %s as some file have changed\n" (NV.to_string nv);
79 75 if Filename.exists (Path.R.archive local_repo nv) then
80 76 Repositories.download repo nv
81   - ) updates;
  77 + ) packages;
82 78
83 79 (* Create the archives asked by the user *)
84 80 NV.Set.iter (fun nv ->
@@ -86,7 +82,7 @@ let () =
86 82 Globals.msg "Creating archive for %s\n" (NV.to_string nv);
87 83 Repositories.download repo nv
88 84 end
89   - ) updates;
  85 + ) packages;
90 86
91 87 (* Create index.tar.gz *)
92 88 let err = Run.command [
29 src/scripts/opam_repo_convert.ml
@@ -34,7 +34,7 @@ module Syntax = struct
34 34 (String.concat ", " fields)
35 35 end
36 36
37   -module X = struct
  37 +module OPAM_X = struct
38 38
39 39 let internal = "opam"
40 40
@@ -243,6 +243,16 @@ module X = struct
243 243 ocaml_version; build_env }
244 244 end
245 245
  246 +module URL_X = struct
  247 + let internal = "url"
  248 + type t = string
  249 + let empty = "<none>"
  250 + let to_string f t =
  251 + Raw.of_string (Utils.string_strip t)
  252 + let of_string f t =
  253 + Utils.string_strip (Raw.to_string t)
  254 +end
  255 +
246 256 module type F = sig
247 257 val internal : string
248 258 type t
@@ -292,10 +302,14 @@ module Make (F : F) = struct
292 302 end
293 303
294 304 module OPAM = struct
295   - include X
296   - include Make (X)
  305 + include OPAM_X
  306 + include Make (OPAM_X)
297 307 end
298 308
  309 +module URL = struct
  310 + include URL_X
  311 + include Make (URL_X)
  312 +end
299 313 end
300 314
301 315 module Path_0_3 = struct
@@ -395,7 +409,14 @@ end
395 409 end
396 410
397 411 let () =
398   - let open File_0_3.X in
  412 + let usage = Printf.sprintf "Usage: %s" Sys.argv.(0) in
  413 + let specs = [] in
  414 + let ano x =
  415 + Printf.eprintf "%s: invalid argument" x in
  416 + Arg.parse specs ano usage
  417 +
  418 +let () =
  419 + let open File_0_3.OPAM_X in
399 420 let t3 = Path_0_3.R.of_path (Dirname.cwd ()) in
400 421 let t4 = Path.R.of_dirname (Dirname.cwd ()) in
401 422 NV.Set.iter (fun nv ->

0 comments on commit f09920f

Please sign in to comment.
Something went wrong with that request. Please try again.