Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add `opam-admin depexts` #886

Merged
merged 4 commits into from

2 participants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 25, 2013
  1. @avsm

    Add .*.swp Vim files to gitignore

    avsm authored
  2. @avsm

    Expose OpamFile.with_depexts

    avsm authored
  3. @avsm
  4. @avsm

    sync CHANGES

    avsm authored
This page is out of date. Refresh to see the latest.
View
1  .gitignore
@@ -1,4 +1,5 @@
_obuild/
+.*.swp
src_ext/cudf/
src_ext/dose/
src_ext/cmdliner/
View
4 CHANGES
@@ -1,3 +1,7 @@
+1.1.0-trunk
+* Document use of `OPAMCOLOR` for optional ANSI coloring
+* Add `opam-admin depexts` utility to rewrite OPAM files with external dependencies
+
1.1.0-beta [Sept 2013]
* Automatic backup before any operation which might alter the list of installed packages
* Support for arbitrary sub-directories for metadata repositories
View
1  src/core/opamFile.ml
@@ -860,6 +860,7 @@ module X = struct
let with_maintainer t maintainer = { t with maintainer }
let with_patches t patches = { t with patches }
let with_bug_reports t bug_reports = { t with bug_reports }
+ let with_depexts t depexts = { t with depexts }
let to_string filename t =
let make_file =
View
3  src/core/opamFile.mli
@@ -207,6 +207,9 @@ module OPAM: sig
(** Construct using [bug_reports] *)
val with_bug_reports: t -> string list -> t
+ (** Construct using [depexts] *)
+ val with_depexts: t -> tags option -> t
+
end
(** Package descriptions: [$opam/descr/] *)
View
7 src/scripts/opam_admin.ml
@@ -36,11 +36,16 @@ let stats_cmd =
Term.(Opam_stats.(pure process $ pure ())),
Term.info "stats" ~doc
+let depexts_cmd =
+ let doc = "Add external dependencies." in
+ Term.(Opam_depexts_change.(pure process $ args)),
+ Term.info "depexts" ~doc
+
let () =
try
match
Term.eval_choice ~catch:false
- default_cmd [make_repo_cmd; check_repo_cmd; stats_cmd]
+ default_cmd [make_repo_cmd; check_repo_cmd; stats_cmd; depexts_cmd]
with
| `Error _ -> exit 2
| _ -> exit 0
View
68 src/scripts/opam_depexts_change.ml
@@ -0,0 +1,68 @@
+(**************************************************************************)
+(* *)
+(* Copyright 2012-2013 OCamlPro *)
+(* Copyright 2012 INRIA *)
+(* *)
+(* All rights reserved.This file is distributed under the terms of the *)
+(* GNU Lesser General Public License version 3.0 with linking *)
+(* exception. *)
+(* *)
+(* OPAM is distributed in the hope that it will be useful, but WITHOUT *)
+(* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *)
+(* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *)
+(* License for more details. *)
+(* *)
+(**************************************************************************)
+
+(* Script to check that a given repository is well-typed (or well-parsed) *)
+open OpamTypes
+open OpamFilename.OP
+
+type args = {
+ pkg: name;
+ os: string list;
+ deps: string list;
+}
+
+let args =
+ let open Cmdliner in
+ let os =
+ let doc = "Operating system tag" in
+ Arg.(value & opt_all string [] & info ["os"] ~doc)
+ in
+ let deps =
+ let doc = "Extdep tag" in
+ Arg.(value & opt_all string [] & info ["dep"] ~doc)
+ in
+ let pkg =
+ let doc = "OPAM package name" in
+ Arg.(required & pos 1 (some OpamArg.package_name) None & info [] ~doc)
+ in
+ Term.(pure (fun os deps pkg -> { os; deps; pkg }) $ os $ deps $ pkg)
+
+let process args =
+
+ let repo = OpamRepository.local (OpamFilename.cwd ()) in
+
+ let packages = OpamRepository.packages_with_prefixes repo in
+
+ (** packages *)
+ OpamPackage.Map.iter (fun package prefix ->
+ OpamGlobals.msg "Processing (package) %s\n" (OpamPackage.to_string package);
+ (** OPAM *)
+ let opam_f = OpamPath.Repository.opam repo prefix package in
+ let opam = OpamFile.OPAM.read opam_f in
+ let pkgname = OpamFile.OPAM.name opam in
+ if pkgname = args.pkg then begin
+ let depexts =
+ let os = OpamMisc.StringSet.of_list args.os in
+ let deps = OpamMisc.StringSet.of_list args.deps in
+ match OpamFile.OPAM.depexts opam with
+ | None -> OpamMisc.StringSetMap.of_list [ os, deps ]
+ | Some depexts' -> (* TODO: Replace existing entry? *)
+ OpamMisc.StringSetMap.add os deps depexts'
+ in
+ let opam = OpamFile.OPAM.with_depexts opam (Some depexts) in
+ OpamFile.OPAM.write opam_f opam;
+ end;
+ ) packages
View
2  src/scripts/scripts.ocp
@@ -6,6 +6,6 @@ begin program "opam-check"
end
begin program "opam-admin"
- files = [ "opam_mk_repo.ml" "opam_repo_check.ml" "opam_stats.ml" "opam_admin.ml" ]
+ files = [ "opam_mk_repo.ml" "opam_repo_check.ml" "opam_stats.ml" "opam_depexts_change.ml" "opam_admin.ml" ]
requires = [ "opam-client" ]
end
Something went wrong with that request. Please try again.