From 2dc1548a84d0aca6e872363c16fffb6ffea7b92a Mon Sep 17 00:00:00 2001 From: Kate Date: Fri, 17 Oct 2025 18:48:37 +0100 Subject: [PATCH] Remove the unused admin-scripts folder --- admin-scripts/Makefile | 18 --- admin-scripts/add-build-deps.ml | 27 ---- admin-scripts/add-github-dev.ml | 31 ----- admin-scripts/compilers-to-packages.ml | 155 ----------------------- admin-scripts/couverture.ml | 141 --------------------- admin-scripts/cudf-debug.ml | 53 -------- admin-scripts/depopts_to_conflicts.ml | 78 ------------ admin-scripts/extract_mini_repository.sh | 143 --------------------- admin-scripts/lint.ml | 61 --------- admin-scripts/ocamlinit | 14 -- admin-scripts/split_install.ml | 49 ------- admin-scripts/to_1_1.ml | 131 ------------------- master_changes.md | 1 + 13 files changed, 1 insertion(+), 901 deletions(-) delete mode 100644 admin-scripts/Makefile delete mode 100755 admin-scripts/add-build-deps.ml delete mode 100755 admin-scripts/add-github-dev.ml delete mode 100755 admin-scripts/compilers-to-packages.ml delete mode 100755 admin-scripts/couverture.ml delete mode 100755 admin-scripts/cudf-debug.ml delete mode 100755 admin-scripts/depopts_to_conflicts.ml delete mode 100755 admin-scripts/extract_mini_repository.sh delete mode 100755 admin-scripts/lint.ml delete mode 100644 admin-scripts/ocamlinit delete mode 100755 admin-scripts/split_install.ml delete mode 100755 admin-scripts/to_1_1.ml diff --git a/admin-scripts/Makefile b/admin-scripts/Makefile deleted file mode 100644 index bee9b5e2110..00000000000 --- a/admin-scripts/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -DEPS = core format repository - -INCLUDE = $(patsubst %,-I ../src/%,$(DEPS)) -I ../src/tools - -LIBS = $(patsubst %,../src/opam-%.cma,$(DEPS)) - -%: %.ml - sed 's/^#.*//' $< >$*-tmp.ml - ocamlfind ocamlc -package unix,re.glob,ocamlgraph -linkpkg $(INCLUDE) $(LIBS) ../src/tools/opam_admin_top.ml $*-tmp.ml -o $@ - rm $*-tmp.ml - -1_2_to_2_0: compilers-to-packages - cp $< $@ - -couverture: couverture.ml - sed 's/^#.*//' $< >couverture-tmp.ml - ocamlfind ocamlopt -package re.glob,opam-lib.state -linkpkg ../src/tools/opam_admin_top.ml couverture-tmp.ml -o $@ - rm couverture-tmp.ml diff --git a/admin-scripts/add-build-deps.ml b/admin-scripts/add-build-deps.ml deleted file mode 100755 index 4cefc0fc777..00000000000 --- a/admin-scripts/add-build-deps.ml +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env opam-admin.top - -#directory "+../opam-lib";; -open Opam_admin_top;; - -(* Add the "build" dependency flag to all ocamlfind depends *) - -let to_build = List.map OpamPackage.Name.of_string ["ocamlfind"] - -let addbuild (pkg, (flags, cstr) as atom) = - if List.mem pkg to_build && not (List.mem OpamTypes.Depflag_Build flags) then - OpamFormula.Atom (pkg, (OpamTypes.Depflag_Build::flags, cstr)) - else - OpamFormula.Atom atom -;; - -iter_packages ~opam:(fun _ opam0 -> - let open OpamFile.OPAM in - let opam = opam0 in - let opam = with_depends opam @@ OpamFormula.map addbuild @@ depends opam in - let opam = with_depopts opam @@ OpamFormula.map addbuild @@ depopts opam in - let opam = if opam <> opam0 - then with_opam_version opam @@ OpamVersion.of_string "1.2" - else opam - in - opam) - () diff --git a/admin-scripts/add-github-dev.ml b/admin-scripts/add-github-dev.ml deleted file mode 100755 index c5115a8a5bc..00000000000 --- a/admin-scripts/add-github-dev.ml +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env opam-admin.top -#directory "+../opam-lib";; -open Opam_admin_top;; - -#use "topfind";; -#require "re";; - -let github_re = - Re.compile (Re_perl.re "([^/]*github.com/.*)/archive/.*");; - -iter_packages_gen @@ fun nv ~prefix:_ ~opam ~descr:_ ~url ~dot_install:_ -> -let opam = - if OpamFile.OPAM.dev_repo opam <> None then opam else - match url with - | None -> opam - | Some u -> - let url = OpamFile.URL.url u in - if url.OpamUrl.backend = `http && - Re.execp github_re url.OpamUrl.path then - let substrings = Re.exec github_re url.OpamUrl.path in - let dev_url = - { OpamUrl.transport = "git"; - path = Re.get substrings 1; - hash = None; - backend = `git } - in - let opam = OpamFile.OPAM.with_dev_repo opam dev_url in - OpamFile.OPAM.with_opam_version opam (OpamVersion.of_string "1.2") - else opam -in -opam, `Keep, `Keep, `Keep diff --git a/admin-scripts/compilers-to-packages.ml b/admin-scripts/compilers-to-packages.ml deleted file mode 100755 index 935f889b4b6..00000000000 --- a/admin-scripts/compilers-to-packages.ml +++ /dev/null @@ -1,155 +0,0 @@ -#!/usr/bin/env opam-admin.top - -#directory "+../opam-lib";; -#directory "+../re";; - -(**************************************************************************) -(* *) -(* Copyright 2013-2016 OCamlPro *) -(* *) -(* All rights reserved. This file is distributed under the terms of the *) -(* GNU Lesser General Public License version 2.1, with the special *) -(* exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) - -open OpamTypes -open OpamProcess.Job.Op -open Opam_admin_top -open OpamStd.Option.Op -;; - -let () = - let error_printer = function - | OpamParallel.Errors (_, (_,exc)::_, _) -> Some (Printexc.to_string exc) - | _ -> None - in - Printexc.register_printer error_printer -;; - -let compilers = - let compilers_dir = OpamFilename.Op.(repo.repo_root / "compilers") in - if OpamFilename.exists_dir compilers_dir then ( - List.fold_left (fun map f -> - if OpamFilename.check_suffix f ".comp" then - let c = OpamFilename.(Base.to_string (basename (chop_extension f))) in - OpamStd.String.Map.add c f map - else - map) - OpamStd.String.Map.empty (OpamFilename.rec_files compilers_dir) - ) else - OpamStd.String.Map.empty -;; - -OpamStd.String.Map.iter (fun c comp_file -> - let comp = OpamFile.Comp.read (OpamFile.make comp_file) in - let descr_file = - OpamFilename.(opt_file (add_extension (chop_extension comp_file) "descr")) - in - let descr = descr_file >>| fun f -> OpamFile.Descr.read (OpamFile.make f) in - let comp = - let drop_names = [ OpamPackage.Name.of_string "base-ocamlbuild" ] in - (* ocamlbuild has requirements on variable ocaml-version: it can't be in - the dependencies *) - OpamFile.Comp.with_packages - (OpamFormula.map - (fun ((name, _) as atom) -> - if List.mem name drop_names then OpamFormula.Empty - else Atom atom) - (OpamFile.Comp.packages comp)) - comp - in - let opam = - OpamFile.Comp.to_package (OpamPackage.Name.of_string "ocaml") - comp descr - in - let nv = OpamFile.OPAM.package opam in - let patches = OpamFile.Comp.patches comp in - if patches <> [] then - OpamConsole.msg "Fetching patches of %s to check their checksums...\n" - (OpamPackage.to_string nv); - let cache_file : string list list OpamFile.t = - OpamFile.make @@ - OpamFilename.of_string "~/.cache/opam-compilers-to-packages/url-hashes" - in - let url_md5 = - (OpamFile.Lines.read_opt cache_file +! [] |> List.map @@ function - | [url; md5] -> OpamUrl.of_string url, md5 - | _ -> failwith "Bad cache") |> - OpamUrl.Map.of_list - in - let extra_sources = - (* Download them just to get their mandatory MD5 *) - OpamParallel.map - ~jobs:3 - ~command:(fun url -> - try Done (Some (url, OpamUrl.Map.find url url_md5, None)) - with Not_found -> - let err e = - OpamConsole.error - "Could not get patch file for %s from %s (%s), skipping" - (OpamPackage.to_string nv) (OpamUrl.to_string url) - (Printexc.to_string e); - Done None - in - OpamFilename.with_tmp_dir_job @@ fun dir -> - try - (* Download to package.patch, rather than allowing the name to be - guessed since, on Windows, some of the characters which are - valid in URLs are not valid in filenames *) - let f = - let base = OpamFilename.Base.of_string "package.patch" in - OpamFilename.create dir base - in - OpamProcess.Job.catch err - (OpamDownload.download_as ~overwrite:false url f @@| fun () -> - Some (url, OpamFilename.digest f, None)) - with e -> err e) - (OpamFile.Comp.patches comp) - in - List.fold_left - (fun url_md5 -> function - | Some (url,md5,_) -> OpamUrl.Map.add url md5 url_md5 - | None -> url_md5) - url_md5 extra_sources |> - OpamUrl.Map.bindings |> - List.map (fun (url,m) -> [OpamUrl.to_string url; m]) |> - OpamFile.Lines.write cache_file; - if List.mem None extra_sources then () - else - let opam = - opam |> - OpamFile.OPAM.with_extra_sources - (OpamStd.List.filter_some extra_sources) |> - OpamFile.OPAM.with_substs - [OpamFilename.Base.of_string "ocaml.config"] - in - OpamFile.OPAM.write (OpamRepositoryPath.opam repo (Some "ocaml") nv) opam; - let config = - OpamFile.Dot_config.create @@ - List.map (fun (v,c) -> OpamVariable.of_string v, c) @@ - [ "ocaml-version", - S (OpamFile.Comp.version comp); - "compiler", S (OpamFile.Comp.name comp); - "preinstalled", B false; - (* fixme: generate those from build/config artifacts using a script ? - Guess from os and arch vars and use static 'features' + variable - expansion ? - ... or just let them be fixed by hand ? *) - "ocaml-native", B true; - "ocaml-native-tools", B true; - "ocaml-native-dynlink", B true; - "ocaml-stubsdir", S "%{lib}%/stublibs"; ] - in - OpamFile.Dot_config.write - (OpamFile.make - OpamFilename.Op.(OpamRepositoryPath.files repo (Some "ocaml") nv - // "ocaml.config.in")) - config; - OpamFilename.remove comp_file; - OpamStd.Option.iter OpamFilename.remove descr_file; - OpamFilename.rmdir_cleanup (OpamFilename.dirname comp_file); - OpamConsole.msg "Compiler %s successfully converted to package %s\n" - c (OpamPackage.to_string nv)) - compilers -;; diff --git a/admin-scripts/couverture.ml b/admin-scripts/couverture.ml deleted file mode 100755 index 381c5b4cafb..00000000000 --- a/admin-scripts/couverture.ml +++ /dev/null @@ -1,141 +0,0 @@ -#!/usr/bin/env opam-admin.top - -#directory "+../opam-lib";; - -(**************************************************************************) -(* *) -(* Copyright 2015-2018 OCamlPro *) -(* *) -(* All rights reserved. This file is distributed under the terms of the *) -(* GNU Lesser General Public License version 2.1, with the special *) -(* exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) - -(** This script gives scenarios to install all named packages in a given set. - This may require several steps, in case of conflicts. - - Consistent installation steps are printed one per line to stdout. Stderr - gives more detail. - - Relies on the current opam root for the list of available packages, i.e. - depends on configured remotes, OS and OCaml version, but not on the set of - currently installed packages. -*) - -open OpamTypes - -let max_install t inst_packages = - let universe = OpamState.universe t Query in - let wish_field = "wished" in - let base = OpamState.base_packages t in - let universe = - { universe with u_installed = base; - u_installed_roots = base; - u_attrs = [wish_field, inst_packages]; } - in - if not (OpamCudf.external_solver_available ()) then - failwith "No external solver found"; - let preferences = - let preferences = OpamSolverConfig.criteria `Default in - Some (lazy (Printf.sprintf "+sum(solution,%s),%s" wish_field preferences)) - in - OpamSolverConfig.update ~solver_preferences_default:preferences (); - let version_map = - OpamSolver.cudf_versions_map universe universe.u_available - in - let request = { - wish_install = []; - wish_remove = []; - wish_upgrade = []; - extra_attributes = [wish_field]; - criteria = `Default; - } in - let cudf_universe = - OpamSolver.load_cudf_universe ~build:true universe ~version_map - universe.u_available - in - match OpamCudf.resolve ~extern:true ~version_map cudf_universe request with - | Conflicts _ -> failwith "Solver error (unexpected conflicts)" - | Success u -> - OpamPackage.Set.diff - (OpamPackage.Set.of_list - (List.map OpamCudf.cudf2opam (OpamCudf.packages u))) - base - -module P = OpamPackage -open P.Set.Op - -let rec couverture acc t pkgs = - Printf.eprintf "# %d packages remaining...\n%!" - (P.Name.Set.cardinal (P.names_of_packages pkgs)); - let step = max_install t pkgs in - let added = - P.Name.Set.inter (P.names_of_packages step) (P.names_of_packages pkgs) - in - if P.Name.Set.is_empty added then - let () = - Printf.eprintf "# -> %d uninstallable packages remaining.\n%!" - (P.Name.Set.cardinal (P.names_of_packages pkgs)) - in - List.rev acc, pkgs - else - let n = P.Name.Set.cardinal added in - Printf.eprintf "# -> Step %d: covering %d/%d packages%s.\n%!" - (List.length acc + 1) n (P.Name.Set.cardinal (P.names_of_packages pkgs)) - (if n > 5 then "" else - OpamStd.List.concat_map ~left:" (" ~right:")" " " P.Name.to_string - (OpamPackage.Name.Set.elements added)); - let pkgs = - P.Set.filter - (fun nv -> not (P.has_name step (P.name nv))) pkgs - in - couverture (step::acc) t pkgs - -let () = - let root = OpamStateConfig.opamroot () in - OpamFormatConfig.init (); - if not (OpamStateConfig.load_defaults root) then - failwith "Opam root not found"; - OpamCoreConfig.init (); - OpamSolverConfig.init (); - OpamStateConfig.init (); - let t = - OpamState.load_state ~save_cache:false "couverture" - (OpamStateConfig.get_switch_opt ()) - in - let avail = Lazy.force t.OpamState.Types.available_packages in - let wanted = match Array.to_list Sys.argv with - | [] | _::[] -> - avail -- P.packages_of_names avail (OpamState.base_package_names t) - | _::l -> - List.fold_left (fun wanted name -> - let nvs = - if String.contains name '.' then - P.Set.singleton (P.of_string name) - else - P.packages_of_name avail - (P.Name.of_string name) - in - if P.Set.is_empty (nvs %% avail) then - failwith (Printf.sprintf "Package %s not found" name) - else - wanted ++ nvs - ) P.Set.empty l - in - let couv,remaining = couverture [] t wanted in - let avail_names = P.names_of_packages avail in - let remaining_names = P.names_of_packages remaining in - Printf.eprintf "# Found a couverture for %d over %d packages in %d steps:\n%!" - (P.Name.Set.cardinal (P.Name.Set.diff avail_names remaining_names)) - (P.Name.Set.cardinal avail_names) - (List.length couv); - List.iter (fun s -> - print_endline - (OpamStd.List.concat_map " " OpamPackage.to_string - (P.Set.elements s))) - couv; - Printf.eprintf "# %d uninstallable packages remain: %s\n%!" - (P.Name.Set.cardinal remaining_names) - (OpamStd.List.concat_map " " OpamPackage.Name.to_string - (P.Name.Set.elements remaining_names)) diff --git a/admin-scripts/cudf-debug.ml b/admin-scripts/cudf-debug.ml deleted file mode 100755 index 84639bc2f72..00000000000 --- a/admin-scripts/cudf-debug.ml +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env opam-admin.top - -#directory "+../cudf";; -#directory "+../dose3";; -#directory "+../opam-lib";; -open Opam_admin_top;; - -let cudf2opam_name cpkg = - OpamPackage.Name.of_string - (try Cudf.lookup_package_property cpkg OpamCudf.s_source - with Not_found -> Common.CudfAdd.decode cpkg.Cudf.package) - -let cudf2opam_version cpkg = - OpamPackage.Version.of_string - (try Cudf.lookup_package_property cpkg OpamCudf.s_source_number - with Not_found -> Printf.sprintf "#cudf%d" cpkg.Cudf.version) - -let cudf_pp cpkg = - OpamPackage.Name.to_string (cudf2opam_name cpkg), - OpamPackage.Version.to_string (cudf2opam_version cpkg), - [] - -let rebuild_version_map univ = - Cudf.fold_packages (fun acc cpkg -> - let nv = - OpamPackage.create (cudf2opam_name cpkg) (cudf2opam_version cpkg) - in - OpamPackage.Map.add nv cpkg.Cudf.version acc - ) - OpamPackage.Map.empty univ - -let _ = - match Cudf_parser.load_from_file Sys.argv.(1) with - | Some preamble, univ, Some req -> - begin match Dose_algo.Depsolver.check_request ~explain:true (preamble, univ, req) with - | Dose_algo.Depsolver.Unsat (Some f) -> - OpamConsole.msg "== DOSE MESSAGE ==\n"; - flush stdout; - Dose_algo.Diagnostic.fprintf_human - ~pp:cudf_pp - Format.err_formatter - f; - flush stderr; - let version_map = rebuild_version_map univ in - begin match OpamCudf.make_conflicts ~version_map univ f with - | OpamTypes.Conflicts cs -> - OpamConsole.msg "== OPAM MESSAGE ==\n%s\n" - (OpamCudf.string_of_conflict (fun a -> Printf.sprintf "%s unavailable" (OpamFormula.string_of_atom a)) cs) - | _ -> prerr_endline "unhandled case" - end - | _ -> () - end - | _ -> OpamConsole.error_and_exit `Solver_error "unsupported cudf file" diff --git a/admin-scripts/depopts_to_conflicts.ml b/admin-scripts/depopts_to_conflicts.ml deleted file mode 100755 index a3d372ed2dc..00000000000 --- a/admin-scripts/depopts_to_conflicts.ml +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env opam-admin.top - -#directory "+../opam-lib";; -open Opam_admin_top;; - -let contains_neq f = - try - OpamFormula.iter (function (_,cs) -> - OpamFormula.iter (function (`Neq,_) -> raise Exit | _ -> ()) cs) - f; - false - with Exit -> true -;; - -iter_packages ~opam:(fun _ opam -> - let depopts = - let formula = OpamFile.OPAM.depopts opam in - let atoms = - OpamFormula.fold_left - (fun acc (n,(flags,_)) -> - OpamFormula.Atom (n, (flags, OpamFormula.Empty)) :: acc) - [] formula - in - OpamFormula.ors @@ - OpamStd.List.remove_duplicates @@ - List.rev atoms - in - let conflicts = (* add complement of the depopts as conflicts *) - let module NM = OpamPackage.Name.Map in - let depopts = (* get back a map (name => version_constraint) *) - (* XXX this takes _all_ the atoms not considering con/disjunctions *) - OpamFormula.fold_left (fun acc (name,(_,f)) -> - try - NM.add name ((OpamFormula.ors [f; NM.find name acc])) acc - with Not_found -> NM.add name f acc) - NM.empty - (OpamFile.OPAM.depopts opam) in - let neg_depopts = - NM.fold (fun name f acc -> - if f = OpamFormula.Empty then acc else - let f = OpamFormula.(neg (fun (op,v) -> neg_relop op, v) f) in - match OpamFormula.to_cnf (OpamFormula.Atom (name,f)) with - | [] -> acc - | [conj] -> conj @ acc - | [x;y] when x = y -> x @ acc - | cnf -> - (* Formula is not a conjunction, we are left with no choice - but to enumerate *) - let f = - OpamFormula.to_atom_formula @@ OpamFormula.ands @@ - List.map OpamFormula.of_disjunction cnf in - let conflict_packages = - OpamPackage.Set.filter - (fun pkg -> - OpamFormula.eval (fun atom -> OpamFormula.check atom pkg) f) - (OpamPackage.packages_of_name packages name) - in - OpamPackage.Set.fold (fun nv acc -> - (OpamPackage.name nv, Some (`Eq, OpamPackage.version nv)) - :: acc) - conflict_packages acc) - depopts [] in - let conflicts = OpamFile.OPAM.conflicts opam in - let add_conflicts = - let c = OpamFormula.to_disjunction conflicts in - List.filter (fun f -> not (List.mem f c)) neg_depopts in - OpamFormula.ors (conflicts :: [OpamFormula.of_disjunction add_conflicts]) - in - let opam = OpamFile.OPAM.with_depopts opam depopts in - let opam = OpamFile.OPAM.with_conflicts opam conflicts in - let opam = - if contains_neq conflicts then - OpamFile.OPAM.with_opam_version opam (OpamVersion.of_string "1.2") - else opam - in - opam) - () -;; diff --git a/admin-scripts/extract_mini_repository.sh b/admin-scripts/extract_mini_repository.sh deleted file mode 100755 index 6836c0f4155..00000000000 --- a/admin-scripts/extract_mini_repository.sh +++ /dev/null @@ -1,143 +0,0 @@ -#! /bin/sh - -set -e - -if [ $# = 0 ]; then - cat < /dev/null || true -done - -## Convert the required compilers as packages - -"${SOURCE_DIR}"/compilers-to-packages.ml - -## Fetch the packages and compilers archives - -for version in ${COMPILERS}; do - opam admin make --resolve --compiler ${version} ocaml.${version} ${PACKAGES} -done - -## Remove the unrequired package "versions - -unrequired_version() { - case "$1" in - base-*) - return 1;; - *) - for version in archives/* - do - if [ "${version}" = "archives/$1+opam.tar.gz" ]; then return 1; fi - done - esac - return 0 -} - -for dir in packages/*/* -do - if unrequired_version "${dir##packages/*/}"; then - rm -r "${dir}" - fi -done - -# Remove empty directories in "packages/" - -for dir in packages/* -do - rmdir "${dir}" 2> /dev/null || true -done - -## Remove unrequired files - -rm -f .gitignore .travis-ci-install.sh .travis-ci.sh .travis.yml README.md - -## Build the archive - -cd "${WORK_DIR}" -tar czf "${TARGET_DIR}/opam-mini-repository.tar.gz" ${REPO_DIR_NAME} diff --git a/admin-scripts/lint.ml b/admin-scripts/lint.ml deleted file mode 100755 index 35a25af8b18..00000000000 --- a/admin-scripts/lint.ml +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env opam-admin.top - -#directory "+../opam-lib";; -open Opam_admin_top;; - -let includes = ref [] -let excludes = ref [] -let short = ref false -let list = ref false - -let usage = - "Arguments:\n\ - \ -s\tshort format, don't print explanations\n\ - \ -l\tlist format, only print package names\n\ - \ [N]\tshow only the listed warnings\n\ - \ -[N]\tskip any packages that trigger any of these warnings\n\ - " - -let () = - let args = match Array.to_list Sys.argv with - | _::args -> args - | [] -> [] - in - List.iter (function - | "-s" -> short := true - | "-l" -> list := true - | a -> - try - if String.length a > 0 && a.[0] = '-' then - excludes := 0 - int_of_string a :: !excludes - else - includes := int_of_string a :: !includes - with Failure _ -> - OpamConsole.msg "%s" usage; - OpamStd.Sys.exit_because `Bad_argument) - args - -let () = - OpamPackage.Map.iter (fun nv prefix -> - let opam_file = OpamRepositoryPath.opam repo prefix nv in - let w, _ = OpamFileTools.lint_file opam_file in - if List.exists (fun (n,_,_) -> List.mem n !excludes) w then () else - let w = - if !includes = [] then w - else List.filter (fun (n,_,_) -> List.mem n !includes) w - in - if w <> [] then - if !list then - print_endline (OpamPackage.to_string nv) - else if !short then - OpamConsole.msg "%s %s\n" (OpamPackage.to_string nv) - (OpamStd.List.concat_map " " (fun (n,k,_) -> - OpamConsole.colorise - (match k with `Warning -> `yellow | `Error -> `red) - (string_of_int n)) - w) - else - OpamConsole.msg "\r\027[KIn %s:\n%s\n" - (OpamPackage.to_string nv) - (OpamFileTools.warns_to_string w)) - (OpamRepository.packages_with_prefixes repo) diff --git a/admin-scripts/ocamlinit b/admin-scripts/ocamlinit deleted file mode 100644 index 6189228711e..00000000000 --- a/admin-scripts/ocamlinit +++ /dev/null @@ -1,14 +0,0 @@ -#use "topfind";; -#use "down.top";; -#require "opam-client";; - -OpamClientConfig.opam_init ();; - -let gt = OpamGlobalState.load `Lock_none;; -OpamConsole.msg "Opam global state for %s loaded in 'gt'\n" - OpamStateConfig.(OpamFilename.Dir.to_string !r.root_dir);; -let rt = OpamRepositoryState.load `Lock_none gt;; -OpamConsole.msg "Opam repository state loaded in 'rt'\n";; -let st = OpamSwitchState.load `Lock_none gt rt (OpamStateConfig.get_switch ());; -OpamConsole.msg "Opam switch state of '%s' loaded in 'st'\n" - (OpamSwitch.to_string (OpamStateConfig.get_switch ()));; diff --git a/admin-scripts/split_install.ml b/admin-scripts/split_install.ml deleted file mode 100755 index 33661606fc3..00000000000 --- a/admin-scripts/split_install.ml +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env opam-admin.top - -#directory "+../opam-lib";; -#directory "+../re";; -open Opam_admin_top;; -open OpamTypes;; - -iter_packages ~opam:(fun _ opam -> - let module O = OpamFile.OPAM in - if O.install opam <> [] then opam else - let rec rev_split_while acc cond = function - | [] -> acc, [] - | x::r when cond x -> rev_split_while (x::acc) cond r - | l -> acc, List.rev l - in - let condition = function - | (CString "install",_)::_, _ -> true - | (CString "cp",_)::r, _ -> - (try - let dest = - match List.filter (function - | CString s, _ -> not (OpamStd.String.starts_with ~prefix:"-" s) - | CIdent _, _ -> true) - (List.rev r) - with - | (d, _)::_ -> d - | _ -> raise Not_found - in - let dests = ["prefix";"bin";"sbin";"lib";"man";"doc";"share";"etc"; - "toplevel";"stublibs";"doc"] in - match dest with - | CIdent i -> List.mem i dests - | CString s -> - Re.(execp (compile (seq [alt (List.map str dests); str "}%"])) s) - with Not_found -> false) - | l, _ -> - List.exists (function - | (CString arg, _) -> OpamStd.String.contains ~sub:"install" arg - | _ -> false) - l - in - let install, build = - rev_split_while [] condition (List.rev (O.build opam)) - in - opam |> - OpamFile.OPAM.with_build build |> - OpamFile.OPAM.with_install install) - () -;; diff --git a/admin-scripts/to_1_1.ml b/admin-scripts/to_1_1.ml deleted file mode 100755 index ff2c5d64fb1..00000000000 --- a/admin-scripts/to_1_1.ml +++ /dev/null @@ -1,131 +0,0 @@ -#!/usr/bin/env opam-admin.top - -#directory "+../opam-lib";; -#directory "+../re";; - -(* Converts OPAM 1.2 packages for compat with OPAM 1.1 - * merge 'install' with 'build' - * remove the new fields: install, flags and dev-repo - * remove dependency flags ('build', 'test', 'doc') - * set file version - * replace inequality constraints with '> & <' - * remove new global variables from filters in commands, messages, 'patches', - 'available' -*) - -open OpamTypes -open OpamStd.Option.Op -;; - -OpamFormatConfig.update ~all_parens:true;; - -let rewrite_constraint ~conj = (* Rewrites '!=' *) - OpamFormula.map OpamFormula.(function - | (`Neq,v) -> - if conj then And (Atom (`Lt,v), Atom (`Gt,v)) - else Or (Atom (`Lt,v), Atom (`Gt,v)) - | atom -> Atom atom) -;; - -let vars_new_1_2 = [ "compiler"; "ocaml-native"; "ocaml-native-tools"; - "ocaml-native-dynlink"; "arch" ] - -let filter_string = - let rex = - Re.(compile ( seq [ - str "%{"; - rep (seq [opt (char '%'); opt (char '}'); diff notnl (set "}%")]); - str "}%"; - ])) - in - Re_pcre.substitute ~rex ~subst:(fun s -> - match String.sub s 2 (String.length s - 4) with - | "compiler" -> "ocaml-version" - | "ocaml-native" | "ocaml-native-tools" | "ocaml-native-dynlink" -> "true" - | s when List.mem s vars_new_1_2 -> "" - | s when String.contains s '?' -> (* new if/else printers: use default *) - (try let i = String.rindex s ':' + 1 in String.sub s i (String.length s - i) - with Not_found -> s) - | _ -> s - ) - -let rec filter_vars = function - | FIdent ([],i,None) when List.mem (OpamVariable.to_string i) vars_new_1_2 -> - None - | FString s -> Some (FString (filter_string s)) - | FBool _ | FIdent _ as f -> Some f - | FOp (f1,op,f2) -> - (match filter_vars f1, filter_vars f2 with - | Some f1, Some f2 -> Some (FOp (f1, op, f2)) - | _ -> Some (FBool false)) - | FAnd (f1,f2) -> - (match filter_vars f1, filter_vars f2 with - | Some f1, Some f2 -> Some (FAnd (f1, f2)) - | opt, None | None, opt -> Some (FBool false)) - | FOr (f1,f2) -> - (match filter_vars f1, filter_vars f2 with - | Some f1, Some f2 -> Some (FOr (f1, f2)) - | opt, None | None, opt -> opt) - | FNot f -> - (match filter_vars f with - | Some f -> Some (FNot f) - | None -> None) - | FUndef -> None - -let filter_vars_optlist ol = - List.map - (fun (x, filter) -> x, filter >>= filter_vars) - ol - -let filter_args sl = - OpamStd.List.filter_map - (fun (s, filter) -> match s with - | CString s -> Some (CString (filter_string s),filter) - | CIdent i when List.mem i vars_new_1_2 -> None - | id -> Some (id,filter)) - sl - -let filter_vars_commands ol = - List.map - (fun (args, filter) -> filter_args (filter_vars_optlist args), - filter >>= filter_vars) - ol - -let to_1_1 _ opam = - let module OF = OpamFile.OPAM in - if - OpamVersion.compare (OF.opam_version opam) (OpamVersion.of_string "1.2") - < 0 - then opam - else - let opam = - OF.with_build opam - (filter_vars_commands (OF.build opam @ OF.install opam)) in - let opam = OF.with_install opam [] in - let opam = OF.with_flags opam [] in - let opam = OF.with_dev_repo opam None in - let opam = OF.with_features opam [] in - let opam = OF.with_opam_version opam (OpamVersion.of_string "1.1") in - let remove_ext = - OpamFormula.map (fun (n, (_,cstr)) -> - OpamFormula.Atom (n, ([], rewrite_constraint ~conj:false cstr))) - in - let opam = OF.with_depends opam (remove_ext (OF.depends opam)) in - let opam = OF.with_depopts opam (remove_ext (OF.depopts opam)) in - let opam = - OF.with_conflicts opam - (OpamFormula.map (fun (n, cstr) -> - OpamFormula.Atom (n, rewrite_constraint ~conj:false cstr)) - (OF.conflicts opam)) - in - let opam = OF.with_available opam (filter_vars (OF.available opam) +! FBool true) in - let opam = OF.with_patches opam (filter_vars_optlist (OF.patches opam)) in - let opam = OF.with_libraries opam [] in - let opam = OF.with_syntax opam [] in - let opam = OF.with_messages opam (filter_vars_optlist (OF.messages opam)) in - let opam = - OF.with_post_messages opam (filter_vars_optlist (OF.post_messages opam)) in - opam -;; - -Opam_admin_top.iter_packages ~opam:to_1_1 () diff --git a/master_changes.md b/master_changes.md index 300115ed290..a36c99451ab 100644 --- a/master_changes.md +++ b/master_changes.md @@ -94,6 +94,7 @@ users) ## Shell ## Internal + * Remove the unused `admin-scripts` folder [#6750 @kit-ty-kate] ## Internal: Unix