From 8c4713b5ab15215a938d91a4d4aa67b0c2803eee Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Glondu?= Date: Sat, 3 Aug 2024 02:13:47 +0200 Subject: [PATCH] Use OCAML_STDLIB_DIR more often --- debian/dispatch.ml | 62 +++++++++++++++++++++++++++------------------- debian/rules | 4 +-- 2 files changed, 38 insertions(+), 28 deletions(-) diff --git a/debian/dispatch.ml b/debian/dispatch.ml index 53009bdc..c7c03981 100644 --- a/debian/dispatch.ml +++ b/debian/dispatch.ml @@ -3,6 +3,16 @@ Copyright © 2019-2024 Stéphane Glondu *) +let stdlib_dir = + match Sys.getenv_opt "OCAML_STDLIB_DIR" with + | Some x -> + let n = String.length x in + if n > 0 && x.[0] = '/' then + String.sub x 1 (n - 1) + else + failwith "OCAML_STDLIB_DIR does not start with /" + | None -> failwith "OCAML_STDLIB_DIR is missing" + let read_lines fn = let ic = open_in fn in Fun.protect @@ -50,10 +60,10 @@ let dev_stdlib = ref [] let run_stdlib = ref [] let dev_compiler_libs = ref [] -let ocaml_base = ref [ "debian/ld.conf usr/lib/ocaml" ] +let ocaml_base = ref [ "debian/ld.conf " ^ stdlib_dir ] let ocaml = ref [ - "debian/native-archs usr/lib/ocaml"; + "debian/native-archs " ^ stdlib_dir; ] let ocaml_interp = ref [ @@ -101,20 +111,20 @@ let () = "usr/bin/ocamlmklib", ocaml; "usr/bin/ocamlprof", ocaml; "usr/bin/ocamlmktop", ocaml; - "usr/lib/ocaml/camlheader", ocaml; - "usr/lib/ocaml/camlheaderd", ocaml; - "usr/lib/ocaml/camlheaderi", ocaml; - "usr/lib/ocaml/eventlog_metadata", ocaml; - "usr/lib/ocaml/Makefile.config", ocaml; - "usr/lib/ocaml/extract_crc", ocaml; - "usr/lib/ocaml/camlheader_ur", ocaml; - "usr/lib/ocaml/expunge", ocaml; - "usr/lib/ocaml/VERSION", ocaml_base; - "usr/lib/ocaml/target_camlheaderd", ocaml; - "usr/lib/ocaml/objinfo_helper", ocaml; - "usr/lib/ocaml/target_camlheaderi", ocaml; - "usr/lib/ocaml/runtime-launch-info", ocaml; - "usr/lib/ocaml/sys.ml.in", ocaml; + stdlib_dir ^ "/camlheader", ocaml; + stdlib_dir ^ "/camlheaderd", ocaml; + stdlib_dir ^ "/camlheaderi", ocaml; + stdlib_dir ^ "/eventlog_metadata", ocaml; + stdlib_dir ^ "/Makefile.config", ocaml; + stdlib_dir ^ "/extract_crc", ocaml; + stdlib_dir ^ "/camlheader_ur", ocaml; + stdlib_dir ^ "/expunge", ocaml; + stdlib_dir ^ "/VERSION", ocaml_base; + stdlib_dir ^ "/target_camlheaderd", ocaml; + stdlib_dir ^ "/objinfo_helper", ocaml; + stdlib_dir ^ "/target_camlheaderi", ocaml; + stdlib_dir ^ "/runtime-launch-info", ocaml; + stdlib_dir ^ "/sys.ml.in", ocaml; "usr/bin/ocamlmklib.opt", ocaml; "usr/bin/ocamllex.byte", ocaml; "usr/bin/ocamldebug", ocaml; @@ -165,7 +175,7 @@ let base_set = ref SSet.empty let () = List.iter (fun x -> - match chop_prefix ~prefix:"usr/lib/ocaml/stdlib__" x with + match chop_prefix ~prefix:(stdlib_dir ^ "/stdlib__") x with | None -> () | Some x -> let i = String.index x '.' in @@ -223,15 +233,15 @@ let remaining = installed_files |> move_all_to ocaml ((=) "usr/share/doc/ocaml/Changes") |> move_all_to ocaml ((=) "usr/share/doc/ocaml/README.adoc") - |> move_all_to ocaml (String.starts_with ~prefix:"usr/lib/ocaml/caml/") - |> move_all_to dev_stdlib (String.starts_with ~prefix:"usr/lib/ocaml/threads/") - |> move_all_to dev_stdlib (String.starts_with ~prefix:"usr/lib/ocaml/std_exit.") - |> move_all_to dev_stdlib (String.starts_with ~prefix:"usr/lib/ocaml/stdlib.") - |> move_all_to dev_stdlib (String.starts_with ~prefix:"usr/lib/ocaml/dynlink") - |> move_all_to dev_compiler_libs (String.starts_with ~prefix:"usr/lib/ocaml/topdirs.") - |> move_all_to dev_compiler_libs (String.starts_with ~prefix:"usr/lib/ocaml/compiler-libs/") - |> move_all_to dev_compiler_libs (String.starts_with ~prefix:"usr/lib/ocaml/ocamldoc/") - |> move_all_to dev_compiler_libs (String.starts_with ~prefix:"usr/lib/ocaml/runtime_events/") + |> move_all_to ocaml (String.starts_with ~prefix:(stdlib_dir ^ "/caml/")) + |> move_all_to dev_stdlib (String.starts_with ~prefix:(stdlib_dir ^ "/threads/")) + |> move_all_to dev_stdlib (String.starts_with ~prefix:(stdlib_dir ^ "/std_exit.")) + |> move_all_to dev_stdlib (String.starts_with ~prefix:(stdlib_dir ^ "/stdlib.")) + |> move_all_to dev_stdlib (String.starts_with ~prefix:(stdlib_dir ^ "/dynlink")) + |> move_all_to dev_compiler_libs (String.starts_with ~prefix:(stdlib_dir ^ "/topdirs.")) + |> move_all_to dev_compiler_libs (String.starts_with ~prefix:(stdlib_dir ^ "/compiler-libs/")) + |> move_all_to dev_compiler_libs (String.starts_with ~prefix:(stdlib_dir ^ "/ocamldoc/")) + |> move_all_to dev_compiler_libs (String.starts_with ~prefix:(stdlib_dir ^ "/runtime_events/")) |> move_all_to ocaml_man (String.ends_with ~suffix:".3o") |> List.filter_map process_static |> List.filter_map process_file diff --git a/debian/rules b/debian/rules index c18dc457..9c95a69f 100755 --- a/debian/rules +++ b/debian/rules @@ -213,7 +213,7 @@ install-stamp: $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp ifeq (,$(DEB_TEST_BUILD_PREFIX)) # Remove Debian-specific file - rm -f $(INSTDIR)/lib/ocaml/ld.conf + rm -f debian/tmp$(OCAML_STDLIB_DIR)/ld.conf # Remove uninstalled files rm -f \ $(INSTDIR)/share/man/man1/ocamlopt.opt.1 \ @@ -232,7 +232,7 @@ endif $(INSTDIR)/share/doc/ocaml/LICENSE # Dispatch files with dh_install find debian/tmp \( -type f -or -type l \) -printf '%P\n' > debian/installed-files - boot/ocamlrun ./ocaml -nostdlib -I debian/tmp/usr/lib/ocaml debian/dispatch.ml + boot/ocamlrun ./ocaml -nostdlib -I debian/tmp$(OCAML_STDLIB_DIR) debian/dispatch.ml dh_install endif touch $@ -- 2.30.2