Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
View
@@ -2,13 +2,7 @@ BIN = /usr/local/bin
OCPBUILD ?= ./_obuild/unixrun ./boot/ocp-build.boot
OCAMLC=ocamlc
SRC_EXT=src_ext
-TARGETS = opam opam-server \
- opam-rsync-init opam-rsync-update opam-rsync-download opam-rsync-upload \
- opam-curl-init opam-curl-update opam-curl-download opam-curl-upload \
- opam-git-init opam-git-update opam-git-download opam-git-upload \
- opam-server-init opam-server-update opam-server-download opam-server-upload \
- opam-mk-config opam-mk-install opam-mk-repo \
- opam-repo-convert-0.3
+TARGETS = opam opam-mk-repo opam-repo-convert-0.3
.PHONY: all
@@ -68,8 +62,9 @@ tests-git:
cp _obuild/$*/$*.asm $(BIN)/$*
.PHONY: install
-install: $(TARGETS:%=%-install)
- @
+install:
+ rm $(BIN)/opam*
+ $(MAKE) $(TARGETS:%=%-install)
doc: compile
mkdir -p doc/html/
77 opam.ocp
View
@@ -53,61 +53,6 @@ end
(*
-
-(* RSYNC *)
-begin library "opam-rsync-lib"
- files = [ "src/repo/rsync/rsync.ml" ]
- requires = [ "opam-lib" ]
-end
-
-begin program "opam-rsync-init"
- files = [ "src/repo/rsync/init.ml" ]
- requires = [ "opam-rsync-lib" ]
-end
-
-begin program "opam-rsync-update"
- files = [ "src/repo/rsync/update.ml" ]
- requires = [ "opam-rsync-lib" ]
-end
-
-begin program "opam-rsync-download"
- files = [ "src/repo/rsync/download.ml" ]
- requires = [ "opam-rsync-lib" ]
-end
-
-begin program "opam-rsync-upload"
- files = [ "src/repo/rsync/upload.ml" ]
- requires = [ "opam-rsync-lib" ]
-end
-
-
-(* GIT *)
-begin library "opam-git-lib"
- files = [ "src/repo/git/git.ml" ]
- requires = [ "opam-lib" ]
-end
-
-begin program "opam-git-init"
- files = [ "src/repo/git/init.ml" ]
- requires = [ "opam-git-lib" ]
-end
-
-begin program "opam-git-update"
- files = [ "src/repo/git/update.ml" ]
- requires = [ "opam-git-lib" ]
-end
-
-begin program "opam-git-download"
- files = [ "src/repo/git/download.ml" ]
- requires = [ "opam-git-lib" ]
-end
-
-begin program "opam-git-upload"
- files = [ "src/repo/git/upload.ml" ]
- requires = [ "opam-git-lib" ]
-end
-
-
(* SERVER *)
begin library "opam-server-lib"
files = [
@@ -131,26 +76,6 @@ begin program "opam-server"
]
end
-begin program "opam-server-init"
- files = [ "src/repo/server/init.ml" ]
- requires = [ "opam-server-lib" ]
-end
-
-begin program "opam-server-update"
- files = [ "src/repo/server/update.ml" ]
- requires = [ "opam-server-lib" ]
-end
-
-begin program "opam-server-download"
- files = [ "src/repo/server/download.ml" ]
- requires = [ "opam-server-lib" ]
-end
-
-begin program "opam-server-upload"
- files = [ "src/repo/server/upload.ml" ]
- requires = [ "opam-server-lib" ]
-end
-
*)
(* Helpers *)
@@ -167,7 +92,7 @@ end
begin program "opam-mk-repo"
files = [ "src/scripts/opam_mk_repo.ml" ]
- requires = [ "opam-curl-lib" ]
+ requires = [ "opam-lib" ]
end
begin program "opam-check"
4 src/path.ml
View
@@ -208,9 +208,9 @@ module R = struct
let files t nv = package t nv / "files"
- let tmp_root t = t / "tmp"
+ let tmp t = t / "tmp"
- let tmp_dir t nv = tmp_root t / NV.to_string nv
+ let tmp_dir t nv = tmp t / NV.to_string nv
let available_files t nv =
if Dirname.exists (files t nv) then
41 src/repositories.mli
View
@@ -20,41 +20,50 @@
open Types
+(** Initialize {i $opam/repo/$repo} *)
+val init: repository -> unit
+
+(** Updated {i $opam/repo/$repo} *)
+val update: repository -> unit
+
+(** Run {i opam-$kind-download} in {i $opam/repo/$repo} *)
+val download: repository -> nv -> unit
+
+(** Upload the content of {i $opam/repo/$repo/upload} *)
+val upload: repository -> unit
+
type kind = string
+(** {2 Repository backends *)
+
(** Backend signature *)
module type BACKEND = sig
(** Initialize the repository *)
val init: repository -> unit
- (** Update the repository. Return the list of updated files *)
+ (** Update the repository. Return the list of updated local files. *)
val update: repository -> Filename.Set.t
- (** Download the package archive on the server *)
+ (** Download the package archive on the server. Return the local file. *)
val download_archive: repository -> nv -> filename download
- (** Download a file *)
+ (** Download a file. Return the local file. Use {i $repo/tmp/$nv/}
+ as tempory location. *)
val download_file: repository -> nv -> filename -> filename download
- (** Download a directory *)
+ (** Download a directory. Return the local directory. Use {i
+ $repo/tmp/$nv} as location to store transient state between
+ downloads. *)
val download_dir: repository -> nv -> dirname -> dirname download
- (** Upload a local directory *)
+ (** Upload a local directory. Return the updated local files. *)
val upload_dir: repository -> dirname -> Filename.Set.t
+
end
(** Register a repository backend *)
val register_backend: kind -> (module BACKEND) -> unit
-(** Initialize {i $opam/repo/$repo} *)
-val init: repository -> unit
-
-(** Updated {i $opam/repo/$repo} *)
-val update: repository -> unit
-
-(** Run {i opam-$kind-download} in {i $opam/repo/$repo} *)
-val download: repository -> nv -> unit
-
-(** Upload the content of {i $opam/repo/$repo/upload} *)
-val upload: repository -> unit
+(** Find a repository *)
+val find_backend: repository -> (module BACKEND)
18 src/scripts/opam_mk_repo.ml
View
@@ -26,9 +26,7 @@
After the script is run, archives/ contains all the package archives
for the available descr and OPAM files *)
-open Repo_helpers
open Types
-open Curl
let all, index, packages =
let usage = Printf.sprintf "%s [-all] [<package>]*" (Stdlib_filename.basename Sys.argv.(0)) in
@@ -46,13 +44,8 @@ let all, index, packages =
let () =
let local_path = Dirname.cwd () in
- let local_repo = Path.R.of_dirname local_path in
- let state = {
- local_path; local_repo;
- remote_path = local_path;
- remote_repo = local_repo;
- } in
let repo = Repository.create ~name:"local" ~kind:"curl" ~address:(Dirname.to_string local_path) in
+ let local_repo = Path.R.create repo in
(* Create urls.txt *)
let local_index_file = Filename.of_string "urls.txt" in
@@ -71,14 +64,17 @@ let () =
) in
File.Urls_txt.write local_index_file urls;
- let updates = Curl.get_updates state in
+ let module B = (val Repositories.find_backend repo: Repositories.BACKEND) in
+ let updates = B.update repo in
+ let packages =
+ NV.Set.of_list (Utils.filter_map NV.of_filename (Filename.Set.elements updates)) in
(* Update the archive files *)
NV.Set.iter (fun nv ->
Globals.msg "Updating %s as some file have changed\n" (NV.to_string nv);
if Filename.exists (Path.R.archive local_repo nv) then
Repositories.download repo nv
- ) updates;
+ ) packages;
(* Create the archives asked by the user *)
NV.Set.iter (fun nv ->
@@ -86,7 +82,7 @@ let () =
Globals.msg "Creating archive for %s\n" (NV.to_string nv);
Repositories.download repo nv
end
- ) updates;
+ ) packages;
(* Create index.tar.gz *)
let err = Run.command [
29 src/scripts/opam_repo_convert.ml
View
@@ -34,7 +34,7 @@ module Syntax = struct
(String.concat ", " fields)
end
-module X = struct
+module OPAM_X = struct
let internal = "opam"
@@ -243,6 +243,16 @@ module X = struct
ocaml_version; build_env }
end
+module URL_X = struct
+ let internal = "url"
+ type t = string
+ let empty = "<none>"
+ let to_string f t =
+ Raw.of_string (Utils.string_strip t)
+ let of_string f t =
+ Utils.string_strip (Raw.to_string t)
+end
+
module type F = sig
val internal : string
type t
@@ -292,10 +302,14 @@ module Make (F : F) = struct
end
module OPAM = struct
- include X
- include Make (X)
+ include OPAM_X
+ include Make (OPAM_X)
end
+module URL = struct
+ include URL_X
+ include Make (URL_X)
+end
end
module Path_0_3 = struct
@@ -395,7 +409,14 @@ end
end
let () =
- let open File_0_3.X in
+ let usage = Printf.sprintf "Usage: %s" Sys.argv.(0) in
+ let specs = [] in
+ let ano x =
+ Printf.eprintf "%s: invalid argument" x in
+ Arg.parse specs ano usage
+
+let () =
+ let open File_0_3.OPAM_X in
let t3 = Path_0_3.R.of_path (Dirname.cwd ()) in
let t4 = Path.R.of_dirname (Dirname.cwd ()) in
NV.Set.iter (fun nv ->
Please sign in to comment.
Something went wrong with that request. Please try again.