diff --git a/net/unison/Makefile b/net/unison/Makefile index 4156f99912e1..a3988171bdcc 100644 --- a/net/unison/Makefile +++ b/net/unison/Makefile @@ -1,96 +1,96 @@ PORTNAME= unison -PORTVERSION= 2.53.2 +PORTVERSION= 2.53.3 DISTVERSIONPREFIX= v CATEGORIES= net MAINTAINER= madpilot@FreeBSD.org COMMENT= User-level file synchronization tool WWW= https://www.cis.upenn.edu/~bcpierce/unison/ LICENSE= GPLv3+ LICENSE_FILE= ${WRKSRC}/COPYING FLAVORS= x11 nox11 FLAVOR?= ${FLAVORS:[1]} nox11_PKGNAMESUFFIX= -nox11 nox11_CONFLICTS_INSTALL= unison x11_CONFLICTS_INSTALL= unison-nox11 x11_BUILD_DEPENDS= icotool:graphics/icoutils \ ocaml-lablgtk3>0:x11-toolkits/ocaml-lablgtk3 x11_LIB_DEPENDS= libfontconfig.so:x11-fonts/fontconfig \ libfreetype.so:print/freetype2 \ libharfbuzz.so:print/harfbuzz USES= gmake localbase USE_OCAML= yes WRKSRC_SUBDIR= src NO_OCAML_RUNDEPENDS= yes CONFLICTS= unison-devel MAKE_ENV= CLIBS="${LIBS:S/^-/-ccopt -/}" \ COFLAGS="${CFLAGS:C/ *(-[^ ]*) */ -ccopt \"\1 \"/gW}" ALL_TARGET= unison all PLIST_SUB= PORTVERSION=${PORTVERSION} USE_GITHUB= yes GH_ACCOUNT= bcpierce00 DOCS= NEWS.md README.md OPTIONS_DEFINE= DOCS FSMONITOR OPTIONS_DEFAULT?= FSMONITOR FSMONITOR_DESC= Compile and install fsmonitor plugin OPTIONS_SUB= YES FSMONITOR_LIB_DEPENDS= libinotify.so:devel/libinotify .if ${FLAVOR} == nox11 MAKE_ARGS= UISTYLE=text PKGMESSAGE= ${PKGDIR}/pkg-message.nox11 PLIST_SUB+= X11="@comment " .else MAKE_ARGS= UISTYLE=gtk3 SUB_FILES= ${PORTNAME}.desktop USE_GNOME+= atk cairo gdkpixbuf2 glib20 gtk30 pango USES+= gettext-runtime gnome PLIST_SUB+= X11="" .endif post-patch-FSMONITOR-off: @${REINPLACE_CMD} -e 's/-include fsmonitor/#&/' \ ${WRKSRC}/Makefile.OCaml post-patch: .if ${FLAVOR} == x11 @${REINPLACE_CMD} -Ee 's@(\+|/)(lablgtk3)@\1site-lib/\2@' \ ${WRKSRC}/Makefile.OCaml .endif post-build: (cd ${WRKSRC} && HOME=${WRKSRC} ./unison -selftest -ui text -batch) .if ${FLAVOR} == x11 @${ECHO} Building text-only version @${ECHO} ${WRKSRC} ${SETENV} ${MAKE_ENV} ${MAKE_CMD} -C ${WRKSRC} UISTYLE=text NAME=unison-text @cd ${WRKSRC}/win32rc && ${LOCALBASE}/bin/icotool -x U.ico .endif do-install: ${INSTALL_PROGRAM} ${WRKSRC}/${PORTNAME} ${STAGEDIR}${PREFIX}/bin .if ${FLAVOR} == x11 ${INSTALL_PROGRAM} ${WRKSRC}/${PORTNAME}-text ${STAGEDIR}${PREFIX}/bin ${INSTALL_DATA} ${WRKDIR}/${PORTNAME}.desktop ${STAGEDIR}${DESKTOPDIR} ${INSTALL_DATA} ${WRKSRC}/win32rc/U_4_48x48x32.png ${STAGEDIR}${PREFIX}/share/pixmaps/${PORTNAME}.png .endif do-install-DOCS-on: @${MKDIR} ${STAGEDIR}${DOCSDIR} cd ${WRKSRC}/.. && ${INSTALL_DATA} ${DOCS} ${STAGEDIR}${DOCSDIR} do-install-FSMONITOR-on: ${INSTALL_PROGRAM} ${WRKSRC}/${PORTNAME}-fsmonitor ${STAGEDIR}${PREFIX}/bin .include diff --git a/net/unison/distinfo b/net/unison/distinfo index f05f0fe44a51..48327d0f92cb 100644 --- a/net/unison/distinfo +++ b/net/unison/distinfo @@ -1,3 +1,3 @@ -TIMESTAMP = 1679421059 -SHA256 (bcpierce00-unison-v2.53.2_GH0.tar.gz) = fb337c221722e496916b385e50e99a49604b8aed3f5fafcc45029c1d2aa1232b -SIZE (bcpierce00-unison-v2.53.2_GH0.tar.gz) = 1410117 +TIMESTAMP = 1682664394 +SHA256 (bcpierce00-unison-v2.53.3_GH0.tar.gz) = aaea04fc5bc76dcfe8627683c9659ee4c194d4f992cc8aaa15bbb2820fc8de46 +SIZE (bcpierce00-unison-v2.53.3_GH0.tar.gz) = 1415490 diff --git a/net/unison/files/patch-Makefile.OCaml b/net/unison/files/patch-Makefile.OCaml index 5df9f0758e48..330f26d01721 100644 --- a/net/unison/files/patch-Makefile.OCaml +++ b/net/unison/files/patch-Makefile.OCaml @@ -1,35 +1,23 @@ ---- Makefile.OCaml.orig 2023-03-19 12:38:58 UTC +--- Makefile.OCaml.orig 2023-04-24 16:49:02 UTC +++ Makefile.OCaml -@@ -34,7 +34,11 @@ ifeq ($(shell uname),NetBSD) - else - ifeq ($(shell uname),NetBSD) - OSARCH=NetBSD -+else -+ifeq ($(shell uname),FreeBSD) -+ OSARCH=FreeBSD - endif -+endif - ifeq ($(shell uname),Linux) - OSARCH=Linux - endif -@@ -271,7 +275,7 @@ OCAMLOBJS+=main.cmo +@@ -248,7 +248,7 @@ OCAMLOBJS+=main.cmo # OCaml libraries for the bytecode version # File extensions will be substituted for the native code version -OCAMLLIBS+=unix.cma str.cma +OCAMLLIBS+=unix.cma str.cma bigarray.cma INCLFLAGS+=-I +unix -I +str COBJS+=osxsupport$(OBJ_EXT) pty$(OBJ_EXT) bytearray_stubs$(OBJ_EXT) hash_compat$(OBJ_EXT) props_xattr$(OBJ_EXT) props_acl$(OBJ_EXT) -@@ -332,6 +336,11 @@ ifeq ($(OSARCH),Linux) +@@ -309,6 +309,11 @@ ifeq ($(OSARCH),Linux) ### Filesystem monitoring ifeq ($(OSARCH),Linux) +-include fsmonitor/linux/Makefile src/fsmonitor/linux/Makefile +INCLFLAGS+=-I fsmonitor -I fsmonitor/linux +endif + +ifeq ($(OSARCH),FreeBSD) -include fsmonitor/linux/Makefile src/fsmonitor/linux/Makefile INCLFLAGS+=-I fsmonitor -I fsmonitor/linux endif diff --git a/net/unison/files/patch-fsmonitor_linux_Makefile b/net/unison/files/patch-fsmonitor_linux_Makefile index 820041472d23..7d44e1c8b925 100644 --- a/net/unison/files/patch-fsmonitor_linux_Makefile +++ b/net/unison/files/patch-fsmonitor_linux_Makefile @@ -1,20 +1,13 @@ ---- fsmonitor/linux/Makefile.orig 2017-03-23 16:47:46 UTC +--- fsmonitor/linux/Makefile.orig 2023-04-24 16:49:02 UTC +++ fsmonitor/linux/Makefile -@@ -18,6 +18,10 @@ else +@@ -18,6 +18,10 @@ endif FSMCAMLLIBS=$(FSMOCAMLLIBS) endif +ifeq ($(OSARCH),FreeBSD) + CLIBS+=-cclib -linotify +endif + buildexecutable:: $(FSMONITOR)$(EXEC_EXT) $(FSMONITOR)$(EXEC_EXT): $(FSMCAMLOBJS) $(FSMCOBJS) -@@ -26,4 +30,4 @@ $(FSMONITOR)$(EXEC_EXT): $(FSMCAMLOBJS) $(FSMCOBJS) - - clean:: - rm -f $(DIR)/*.cm[iox] $(DIR)/*.o $(DIR)/*~ -- rm -f $(FSMONITOR)$(EXEC_EXT) -\ No newline at end of file -+ rm -f $(FSMONITOR)$(EXEC_EXT) diff --git a/net/unison/files/patch-ocaml_4.07-compat b/net/unison/files/patch-ocaml_4.07-compat index 33cf9da99040..cfaabd107123 100644 --- a/net/unison/files/patch-ocaml_4.07-compat +++ b/net/unison/files/patch-ocaml_4.07-compat @@ -1,303 +1,475 @@ -From b787de04da85da2f911c8248e07342e58b4e8625 Mon Sep 17 00:00:00 2001 -From: Tõivo Leedjärv -Date: Fre, 24 Mar 2023 17:22:09 +0100 +From ad79ecf3c42e0f10b05c7cb8eb5671c66b8a09e9 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?T=C3=B5ivo=20Leedj=C3=A4rv?= +Date: Thu, 17 Nov 2022 11:53:35 +0100 Subject: [PATCH] Restore compatibility with OCaml 4.06 and 4.07 (temporary patch) This patch should not break compilation with OCaml 4.x but it is recommended to drop the patch for OCaml > 4.07. It will break compilation with OCaml >= 5.0 (due to the change in Makefile.OCaml). --- src/fswatchold.ml | 25 +++-- src/remote.ml | 3 +- src/system/system_generic.ml | 204 +++++++++++++++++++++++++++++++++++ - src/uitext.ml | 1 - - 6 files changed, 326 insertions(+), 14 deletions(-) + src/ubase/umarshal.ml | 105 ++++++++++++++++++ + src/uicommon.ml | 12 +-- + src/uitext.ml | 3 +- + 6 files changed, 332 insertions(+), 20 deletions(-) -index 17f22dcb..13cab93b 100644 +diff --git a/src/fswatchold.ml b/src/fswatchold.ml +index 84912071a..5b266f519 100644 --- fswatchold.ml +++ fswatchold.ml -@@ -116,19 +116,22 @@ let readChanges wi = +@@ -113,19 +113,22 @@ let readChanges wi = let watcherRunning archHash = RootMap.mem archHash !watchers && let wi = RootMap.find archHash !watchers in + let cleanup () = + watchers := RootMap.remove archHash !watchers; + begin + try ignore (System.close_process_out wi.proc) + with Unix.Unix_error _ -> () + end; + begin match wi.ch with + | Some ch -> close_in_noerr ch + | None -> () + end; + false + in match Unix.waitpid [Unix.WNOHANG] (System.process_out_pid wi.proc) with + | exception Unix.Unix_error (ECHILD, _, _) -> cleanup () | (0, _) -> true - | _ | exception Unix.Unix_error (ECHILD, _, _) -> - watchers := RootMap.remove archHash !watchers; - begin - try ignore (System.close_process_out wi.proc) - with Unix.Unix_error _ -> () - end; - begin match wi.ch with - | Some ch -> close_in_noerr ch - | None -> () - end; - false + | _ -> cleanup () let getChanges archHash = if StringSet.mem archHash !newWatchers then diff --git a/src/remote.ml b/src/remote.ml -index d320470a..0ed393ae 100644 +index d101c3903..bedf2e3ba 100644 --- remote.ml +++ remote.ml @@ -1887,11 +1887,12 @@ let buildShellConnection shell host userOpt portOpt rootName termInteract = let kill_noerr si = try Unix.kill pid si with Unix.Unix_error _ -> () | Invalid_argument _ -> () in match Unix.waitpid [WNOHANG] pid with + | exception Unix.Unix_error _ -> () | (0, _) -> (* Grace period before killing. Important to give ssh a chance to restore terminal settings, should that be needed. *) kill_noerr Sys.sigterm; Unix.sleepf 0.01; kill_noerr Sys.sigkill - | _ | exception Unix.Unix_error _ -> () + | _ -> () in let () = at_exit end_ssh in (None, pid) diff --git a/src/system/system_generic.ml b/src/system/system_generic.ml -index 2147d44d..3ef4fb09 100644 +index 6f6c6895a..15509abd5 100644 --- system/system_generic.ml +++ system/system_generic.ml @@ -15,6 +15,210 @@ along with this program. If not, see . *) +(* OCaml 4.07 compatibility ONLY *) +module Unix = struct + +include Unix + +(* The following code is taken from OCaml sources. + Authors of code snippets: Xavier Leroy, Damien Doligez and Romain Beauxis *) + +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* 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. *) +(* *) +(**************************************************************************) + +external dumpFd : Unix.file_descr -> int = "%identity" + +external sys_exit : int -> 'a = "caml_sys_exit" + +let rec waitpid_non_intr pid = + try waitpid [] pid + with Unix_error (EINTR, _, _) -> waitpid_non_intr pid + +(* Duplicate [fd] if needed to make sure it isn't one of the + standard descriptors (stdin, stdout, stderr). + Note that this function always leaves the standard descriptors open, + the caller must take care of closing them if needed. + The "cloexec" mode doesn't matter, because + the descriptor returned by [dup] will be closed before the [exec], + and because no other thread is running concurrently + (we are in the child process of a fork). + *) +let rec file_descr_not_standard fd = + if dumpFd fd >= 3 then fd else file_descr_not_standard (dup fd) + +let safe_close fd = + try close fd with Unix_error(_,_,_) -> () + +let perform_redirections new_stdin new_stdout new_stderr = + let new_stdin = file_descr_not_standard new_stdin in + let new_stdout = file_descr_not_standard new_stdout in + let new_stderr = file_descr_not_standard new_stderr in + (* The three dup2 close the original stdin, stdout, stderr, + which are the descriptors possibly left open + by file_descr_not_standard *) + dup2 ~cloexec:false new_stdin stdin; + dup2 ~cloexec:false new_stdout stdout; + dup2 ~cloexec:false new_stderr stderr; + safe_close new_stdin; + safe_close new_stdout; + safe_close new_stderr + +type popen_process = + Process of in_channel * out_channel + | Process_in of in_channel + | Process_out of out_channel + | Process_full of in_channel * out_channel * in_channel + +let popen_processes = (Hashtbl.create 7 : (popen_process, int) Hashtbl.t) + +let open_proc cmd envopt proc input output error = + match fork() with + 0 -> perform_redirections input output error; + let shell = "/bin/sh" in + let argv = [| shell; "-c"; cmd |] in + begin try + match envopt with + | Some env -> execve shell argv env + | None -> execv shell argv + with _ -> + sys_exit 127 + end + | id -> Hashtbl.add popen_processes proc id + +let open_process_in cmd = + let (in_read, in_write) = pipe ~cloexec:true () in + let inchan = in_channel_of_descr in_read in + begin + try + open_proc cmd None (Process_in inchan) stdin in_write stderr + with e -> + close_in inchan; + close in_write; + raise e + end; + close in_write; + inchan + +let open_process_out cmd = + let (out_read, out_write) = pipe ~cloexec:true () in + let outchan = out_channel_of_descr out_write in + begin + try + open_proc cmd None (Process_out outchan) out_read stdout stderr + with e -> + close_out outchan; + close out_read; + raise e + end; + close out_read; + outchan + +let open_process cmd = + let (in_read, in_write) = pipe ~cloexec:true () in + let (out_read, out_write) = + try pipe ~cloexec:true () + with e -> close in_read; close in_write; raise e in + let inchan = in_channel_of_descr in_read in + let outchan = out_channel_of_descr out_write in + begin + try + open_proc cmd None (Process(inchan, outchan)) out_read in_write stderr + with e -> + close out_read; close out_write; + close in_read; close in_write; + raise e + end; + close out_read; + close in_write; + (inchan, outchan) + +let open_process_full cmd env = + let (in_read, in_write) = pipe ~cloexec:true () in + let (out_read, out_write) = + try pipe ~cloexec:true () + with e -> close in_read; close in_write; raise e in + let (err_read, err_write) = + try pipe ~cloexec:true () + with e -> close in_read; close in_write; + close out_read; close out_write; raise e in + let inchan = in_channel_of_descr in_read in + let outchan = out_channel_of_descr out_write in + let errchan = in_channel_of_descr err_read in + begin + try + open_proc cmd (Some env) (Process_full(inchan, outchan, errchan)) + out_read in_write err_write + with e -> + close out_read; close out_write; + close in_read; close in_write; + close err_read; close err_write; + raise e + end; + close out_read; + close in_write; + close err_write; + (inchan, outchan, errchan) + +let find_proc_id fun_name proc = + try + let pid = Hashtbl.find popen_processes proc in + Hashtbl.remove popen_processes proc; + pid + with Not_found -> + raise(Unix_error(EBADF, fun_name, "")) + +let close_process_in inchan = + let pid = find_proc_id "close_process_in" (Process_in inchan) in + close_in inchan; + snd(waitpid_non_intr pid) + +let close_process_out outchan = + let pid = find_proc_id "close_process_out" (Process_out outchan) in + (* The application may have closed [outchan] already to signal + end-of-input to the process. *) + begin try close_out outchan with Sys_error _ -> () end; + snd(waitpid_non_intr pid) + +let close_process (inchan, outchan) = + let pid = find_proc_id "close_process" (Process(inchan, outchan)) in + close_in inchan; + begin try close_out outchan with Sys_error _ -> () end; + snd(waitpid_non_intr pid) + +let close_process_full (inchan, outchan, errchan) = + let pid = + find_proc_id "close_process_full" + (Process_full(inchan, outchan, errchan)) in + close_in inchan; + begin try close_out outchan with Sys_error _ -> () end; + close_in errchan; + snd(waitpid_non_intr pid) + +let process_in_pid inchan = + find_proc_id "process_in_pid" (Process_in inchan) +let process_out_pid outchan = + find_proc_id "process_out_pid" (Process_out outchan) +let process_pid (inchan, outchan) = + find_proc_id "process_pid" (Process(inchan, outchan)) +let process_full_pid (inchan, outchan, errchan) = + find_proc_id "process_full_pid" + (Process_full(inchan, outchan, errchan)) + +end +(* / *) + type fspath = string let mfspath = Umarshal.string +diff --git a/src/ubase/umarshal.ml b/src/ubase/umarshal.ml +index 5c5f061ad..d65e1a7c5 100644 +--- ubase/umarshal.ml ++++ ubase/umarshal.ml +@@ -15,6 +15,111 @@ + along with this program. If not, see . + *) + ++(* OCaml 4.07 compatibility ONLY *) ++module Bytes = struct ++ ++include Bytes ++ ++(* The following code is taken from OCaml sources. ++ Authors of the code snippet: Alain Frisch and Daniel Bünzli *) ++ ++(**************************************************************************) ++(* *) ++(* OCaml *) ++(* *) ++(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) ++(* *) ++(* Copyright 1996 Institut National de Recherche en Informatique et *) ++(* en Automatique. *) ++(* *) ++(* 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. *) ++(* *) ++(**************************************************************************) ++ ++(** {6 Binary encoding/decoding of integers} *) ++ ++external get_uint8 : bytes -> int -> int = "%string_safe_get" ++external get_uint16_ne : bytes -> int -> int = "%caml_string_get16" ++external get_int32_ne : bytes -> int -> int32 = "%caml_string_get32" ++external get_int64_ne : bytes -> int -> int64 = "%caml_string_get64" ++external set_int8 : bytes -> int -> int -> unit = "%string_safe_set" ++external set_int16_ne : bytes -> int -> int -> unit = "%caml_string_set16" ++external set_int32_ne : bytes -> int -> int32 -> unit = "%caml_string_set32" ++external set_int64_ne : bytes -> int -> int64 -> unit = "%caml_string_set64" ++external swap16 : int -> int = "%bswap16" ++external swap32 : int32 -> int32 = "%bswap_int32" ++external swap64 : int64 -> int64 = "%bswap_int64" ++ ++let get_int8 b i = ++ ((get_uint8 b i) lsl (Sys.int_size - 8)) asr (Sys.int_size - 8) ++ ++let get_uint16_le b i = ++ if Sys.big_endian then swap16 (get_uint16_ne b i) ++ else get_uint16_ne b i ++ ++let get_uint16_be b i = ++ if not Sys.big_endian then swap16 (get_uint16_ne b i) ++ else get_uint16_ne b i ++ ++let get_int16_ne b i = ++ ((get_uint16_ne b i) lsl (Sys.int_size - 16)) asr (Sys.int_size - 16) ++ ++let get_int16_le b i = ++ ((get_uint16_le b i) lsl (Sys.int_size - 16)) asr (Sys.int_size - 16) ++ ++let get_int16_be b i = ++ ((get_uint16_be b i) lsl (Sys.int_size - 16)) asr (Sys.int_size - 16) ++ ++let get_int32_le b i = ++ if Sys.big_endian then swap32 (get_int32_ne b i) ++ else get_int32_ne b i ++ ++let get_int32_be b i = ++ if not Sys.big_endian then swap32 (get_int32_ne b i) ++ else get_int32_ne b i ++ ++let get_int64_le b i = ++ if Sys.big_endian then swap64 (get_int64_ne b i) ++ else get_int64_ne b i ++ ++let get_int64_be b i = ++ if not Sys.big_endian then swap64 (get_int64_ne b i) ++ else get_int64_ne b i ++ ++let set_int16_le b i x = ++ if Sys.big_endian then set_int16_ne b i (swap16 x) ++ else set_int16_ne b i x ++ ++let set_int16_be b i x = ++ if not Sys.big_endian then set_int16_ne b i (swap16 x) ++ else set_int16_ne b i x ++ ++let set_int32_le b i x = ++ if Sys.big_endian then set_int32_ne b i (swap32 x) ++ else set_int32_ne b i x ++ ++let set_int32_be b i x = ++ if not Sys.big_endian then set_int32_ne b i (swap32 x) ++ else set_int32_ne b i x ++ ++let set_int64_le b i x = ++ if Sys.big_endian then set_int64_ne b i (swap64 x) ++ else set_int64_ne b i x ++ ++let set_int64_be b i x = ++ if not Sys.big_endian then set_int64_ne b i (swap64 x) ++ else set_int64_ne b i x ++ ++let set_uint8 = set_int8 ++let set_uint16_ne = set_int16_ne ++let set_uint16_be = set_int16_be ++let set_uint16_le = set_int16_le ++ ++end ++(* / *) ++ + exception Error of string + + type 'a t = { +diff --git a/src/uicommon.ml b/src/uicommon.ml +index 94fbc66ef..8a16270c3 100644 +--- uicommon.ml ++++ uicommon.ml +@@ -484,7 +484,7 @@ let addIgnorePattern theRegExp = + module Stats = struct + + let calcETA rem rate = +- if Float.is_nan rate || Float.is_nan rem || rem < 0. then "" else ++ if rate <> rate || rem <> rem || rem < 0. then "" else + let t = truncate (rem /. rate +. 0.5) in + (* Estimating the remaining time is not accurate. Reduce the display + precision (and reduce more when longer time remaining). *) +@@ -501,8 +501,8 @@ let calcETA rem rate = + Printf.sprintf "%02d:%02d:%02d" h m sec + + let movAvg curr prev ?(c = 1.) deltaTime avgPeriod = +- if Float.is_nan prev then curr else +- let a = c *. Float.min (1. -. exp (-. deltaTime /. avgPeriod)) 1. in ++ if prev <> prev then curr else ++ let a = c *. min (1. -. exp (-. deltaTime /. avgPeriod)) 1. in + (* Simplified from a *. curr +. (1. -. a) *. prev *) + prev +. a *. (curr -. prev) + +@@ -525,7 +525,7 @@ let init totalToTransfer = + let t0 = 0. in + { t0; t = t0; totalToComplete = Uutil.Filesize.toInt64 totalToTransfer; + completed = 0L; +- curRate = Float.nan; avgRateS = Float.nan; avgRateDoubleSGauss = Float.nan; ++ curRate = nan; avgRateS = nan; avgRateDoubleSGauss = nan; + } + + let calcAvgRate' sta totTime deltaCompleted deltaTime = +@@ -534,11 +534,11 @@ let calcAvgRate' sta totTime deltaCompleted deltaTime = + changes (like switching from cache to disk or from disk to network + of from receiving to sending or with wildly variable network speed). *) + let avgRateS = movAvg curRate sta.avgRateS deltaTime +- (Float.min_num totTime avgPeriodS) in ++ (min totTime avgPeriodS) in + let cpr = (avgRateS -. sta.avgRateDoubleSGauss) /. sta.avgRateDoubleSGauss in + let c = 1. -. exp (-.(cpr ** 2.) /. gaussC) in + let avgRateDoubleSGauss = movAvg avgRateS sta.avgRateDoubleSGauss ~c deltaTime +- (Float.min_num totTime avgPeriodD) in ++ (min totTime avgPeriodD) in + sta.curRate <- curRate; + sta.avgRateS <- avgRateS; + sta.avgRateDoubleSGauss <- avgRateDoubleSGauss diff --git a/src/uitext.ml b/src/uitext.ml -index 1c2e509d..fbb4f7f1 100644 +index 5d1513a03..fc1f8c716 100644 --- uitext.ml +++ uitext.ml -@@ -1621,7 +1621,6 @@ and breakRepeat = function +@@ -833,7 +833,7 @@ let doTransport reconItemList numskip isSkip = + else if v >= 100. then "00:00:00" + else + let rate = Uicommon.Stats.avgRate1 sta in +- if Float.is_nan rate then "--:--" ++ if rate <> rate then "--:--" + else + Format.sprintf "%8s/s %s" + (Util.bytes2string (Int64.of_float rate)) +@@ -1692,7 +1692,6 @@ and breakRepeat = function | Assert_failure _ | Match_failure _ | Invalid_argument _ - | Fun.Finally_raised _ (* Async exceptions *) | Out_of_memory | Stack_overflow --- -2.39.2 - diff --git a/net/unison/files/patch-ocaml_4.07-compat-copyquoterem-01 b/net/unison/files/patch-ocaml_4.07-compat-copyquoterem-01 new file mode 100644 index 000000000000..2fb4193f76fa --- /dev/null +++ b/net/unison/files/patch-ocaml_4.07-compat-copyquoterem-01 @@ -0,0 +1,209 @@ +From accfb998cc9afc95c0b13dac20d9b49ef9af7e8d Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?T=C3=B5ivo=20Leedj=C3=A4rv?= +Date: Fri, 14 Apr 2023 14:48:48 +0200 +Subject: [PATCH] Revert "Avoid problems with quoting arguments to copyprog" + +This reverts commit e737106fbbd541c5d9536606fb15b04cb165f5d2. +--- + src/copy.ml | 38 ++++++++++++++++++++++-------- + src/external.ml | 45 +++--------------------------------- + src/external.mli | 1 - + src/system/system_generic.ml | 2 -- + src/system/system_intf.ml | 3 --- + 6 files changed, 31 insertions(+), 58 deletions(-) + +diff --git a/src/copy.ml b/src/copy.ml +index 21e22743d..fa704f35c 100644 +--- copy.ml ++++ copy.ml +@@ -911,8 +911,17 @@ let copythreshold = + ^ "See \\sectionref{speeding}{Making Unison Faster on Large Files} " + ^ "for more information.") + +-(* Pref copyquoterem removed since 2.53.3 *) +-let () = Prefs.markRemoved "copyquoterem" ++let copyquoterem = ++ Prefs.createBoolWithDefault "copyquoterem" ++ ~category:(`Advanced `General) ++ "add quotes to remote file name for copyprog (true/false/default)" ++ ("When set to {\\tt true}, this flag causes Unison to add an extra layer " ++ ^ "of quotes to the remote path passed to the external copy program. " ++ ^ "This is needed by rsync, for example, which internally uses an ssh " ++ ^ "connection requiring an extra level of quoting for paths containing " ++ ^ "spaces. When this flag is set to {\\tt default}, extra quotes are " ++ ^ "added if the value of {\\tt copyprog} contains the string " ++ ^ "{\\tt rsync}.") + + let copymax = + Prefs.createInt "copymax" 1 +@@ -1022,25 +1031,34 @@ let transferFileUsingExternalCopyprog + rootFrom pathFrom rootTo fspathTo pathTo realPathTo + update desc fp ress id useExistingTarget = + Uutil.showProgress id Uutil.Filesize.zero "ext"; +- let progWithArgs = ++ let prog = + if useExistingTarget then + Prefs.read copyprogrest + else + Prefs.read copyprog + in ++ let extraquotes = Prefs.read copyquoterem = `True ++ || ( Prefs.read copyquoterem = `Default ++ && Util.findsubstring "rsync" prog <> None) in ++ let addquotes root s = ++ match root with ++ | Common.Local, _ -> s ++ | Common.Remote _, _ -> if extraquotes then Uutil.quotes s else s in + let fromSpec = + (formatConnectionInfo rootFrom) +- ^ (Fspath.toString (Fspath.concat (snd rootFrom) pathFrom)) in ++ ^ (addquotes rootFrom ++ (Fspath.toString (Fspath.concat (snd rootFrom) pathFrom))) in + let toSpec = + (formatConnectionInfo rootTo) +- ^ (Fspath.toString (Fspath.concat fspathTo pathTo)) in +- Trace.log (progWithArgs ^ " " ^ fromSpec ^ " " ^ toSpec ^ "\n"); ++ ^ (addquotes rootTo ++ (Fspath.toString (Fspath.concat fspathTo pathTo))) in ++ let cmd = prog ^ " " ++ ^ (Uutil.quotes fromSpec) ^ " " ++ ^ (Uutil.quotes toSpec) in ++ Trace.log (Printf.sprintf "%s\n" cmd); + Lwt_util.resize_region !copyprogReg (Prefs.read copymax); +- let args = Str.split (Str.regexp "[ \t]+") progWithArgs in +- let prog = match args with [] -> assert false | h :: _ -> h in + Lwt_util.run_in_region !copyprogReg 1 +- (fun () -> External.runExternalProgramArgs prog +- (Array.of_list (args @ [fromSpec; toSpec]))) >>= fun (_, log) -> ++ (fun () -> External.runExternalProgram cmd) >>= fun (_, log) -> + debug (fun() -> + let l = Util.trimWhitespace log in + Util.msg "transferFileUsingExternalCopyprog %s: returned...\n%s%s" +diff --git a/src/external.ml b/src/external.ml +index f13368231..cefb9ea98 100644 +--- external.ml ++++ external.ml +@@ -25,26 +25,6 @@ let debug = Util.debug "external" + let (>>=) = Lwt.bind + open Lwt + +-(* For backwards compatibility with OCaml < 4.12 *) +-let path = +- try +- Str.split (Str.regexp (if Util.osType = `Win32 then ";" else ":")) +- (Sys.getenv "PATH") +- with Not_found -> +- [] +- +-let search_in_path ?(path = path) name = +- if String.contains name '/' then name else +- Filename.concat +- (List.find (fun dir -> +- let p = Filename.concat dir name in +- let found = System.file_exists p in +- debug (fun () -> Util.msg "'%s' ...%s\n" p +- (match found with true -> "found" | false -> "not found")); +- found) +- path) +- name +- + (* Make sure external process resources are collected and zombie processes + reaped when the Lwt thread calling the external program is stopped + suddenly due to remote connection being closed. *) +@@ -66,17 +46,9 @@ let fullProcRes = + let openProcessIn cmd = inProcRes.register (System.open_process_in cmd) + let closeProcessIn = inProcRes.release + +-(* Remove call to search_in_path once we require OCaml >= 4.12. *) +-let openProcessArgsIn cmd args = inProcRes.register (System.open_process_args_in (search_in_path cmd) args) +-let closeProcessArgsIn = inProcRes.release +- + let openProcessFull cmd = fullProcRes.register (System.open_process_full cmd) + let closeProcessFull = fullProcRes.release + +-(* Remove call to search_in_path once we require OCaml >= 4.12. *) +-let openProcessArgsFull cmd args = fullProcRes.register (System.open_process_args_full (search_in_path cmd) args) +-let closeProcessArgsFull = fullProcRes.release +- + let readChannelTillEof c = + let lst = ref [] in + let rec loop () = +@@ -108,11 +80,10 @@ let readChannelsTillEof l = + >>= (fun res -> return (String.concat "\n" (Safelist.rev res)))) + l + +- +-let runExternalProgramAux ~winProc ~posixProc = ++let runExternalProgram cmd = + if Util.osType = `Win32 && not Util.isCygwin then begin + debug (fun()-> Util.msg "Executing external program windows-style\n"); +- let c = winProc () in ++ let c = openProcessIn ("\"" ^ cmd ^ "\"") in + let log = Util.trimWhitespace (readChannelTillEof c) in + let returnValue = closeProcessIn c in + let resultLog = +@@ -124,7 +95,7 @@ let runExternalProgramAux ~winProc ~posixProc = + "") in + Lwt.return (returnValue, resultLog) + end else +- let (out, ipt, err) as desc = posixProc () in ++ let (out, ipt, err) as desc = openProcessFull cmd in + let out = Lwt_unix.intern_in_channel out in + let err = Lwt_unix.intern_in_channel err in + readChannelsTillEof [out;err] +@@ -143,13 +114,3 @@ let runExternalProgramAux ~winProc ~posixProc = + else "\n\n" ^ Util.process_status_to_string returnValue))) + (* Stop typechechecker from complaining about non-exhaustive pattern above *) + | _ -> assert false) +- +-let runExternalProgram cmd = +- runExternalProgramAux +- ~winProc:(fun () -> openProcessIn ("\"" ^ cmd ^ "\"")) +- ~posixProc:(fun () -> openProcessFull cmd) +- +-let runExternalProgramArgs cmd args = +- runExternalProgramAux +- ~winProc:(fun () -> openProcessArgsIn cmd args) +- ~posixProc:(fun () -> openProcessArgsFull cmd args) +diff --git a/src/external.mli b/src/external.mli +index d2d0bae5b..30d2dbd05 100644 +--- external.mli ++++ external.mli +@@ -2,5 +2,4 @@ + (* Copyright 1999-2020, Benjamin C. Pierce (see COPYING for details) *) + + val runExternalProgram : string -> (Unix.process_status * string) Lwt.t +-val runExternalProgramArgs : string -> string array -> (Unix.process_status * string) Lwt.t + val readChannelTillEof : in_channel -> string +diff --git a/src/system/system_generic.ml b/src/system/system_generic.ml +index 15509abd5..3ef4fb09b 100644 +--- system/system_generic.ml ++++ system/system_generic.ml +@@ -272,10 +272,8 @@ let open_in_bin = open_in_bin + + let create_process = Unix.create_process + let open_process_in = Unix.open_process_in +-let open_process_args_in = Unix.open_process_args_in + let open_process_out = Unix.open_process_out + let open_process_full cmd = Unix.open_process_full cmd (Unix.environment ()) +-let open_process_args_full cmd args = Unix.open_process_args_full cmd args (Unix.environment ()) + let process_in_pid = Unix.process_in_pid + let process_out_pid = Unix.process_out_pid + let process_full_pid = Unix.process_full_pid +diff --git a/src/system/system_intf.ml b/src/system/system_intf.ml +index 873f4ca57..4dc60dd3b 100644 +--- system/system_intf.ml ++++ system/system_intf.ml +@@ -99,12 +99,9 @@ val create_process : + string -> string array -> + Unix.file_descr -> Unix.file_descr -> Unix.file_descr -> int + val open_process_in : string -> in_channel +-val open_process_args_in : string -> string array -> in_channel + val open_process_out : string -> out_channel + val open_process_full : + string -> in_channel * out_channel * in_channel +-val open_process_args_full : +- string -> string array -> in_channel * out_channel * in_channel + val process_in_pid : in_channel -> int + val process_out_pid : out_channel -> int + val process_full_pid : in_channel * out_channel * in_channel -> int diff --git a/net/unison/files/patch-ocaml_4.07-compat-copyquoterem-02 b/net/unison/files/patch-ocaml_4.07-compat-copyquoterem-02 new file mode 100644 index 000000000000..cdd50a67e1d3 --- /dev/null +++ b/net/unison/files/patch-ocaml_4.07-compat-copyquoterem-02 @@ -0,0 +1,54 @@ +From f9191b19dfaba01f5903ce36eb0258edef09964e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?T=C3=B5ivo=20Leedj=C3=A4rv?= +Date: Tue, 25 Apr 2023 09:35:14 +0200 +Subject: [PATCH] Revert "Regen strings.ml" + +This reverts commit 63963d80157346c2f3c9073f741bbd58e5c32545. +--- + src/strings.ml | 19 +++++++++++++++++++ + 1 file changed, 19 insertions(+) + +diff --git a/src/strings.ml b/src/strings.ml +index 6e853eb07..eb00eac5f 100644 +--- strings.ml ++++ strings.ml +@@ -1286,6 +1286,8 @@ let docs = + \032 -copymax n maximum number of simultaneous copyprog transfers\n\ + \032 -copyprog xxx external program for copying large files\n\ + \032 -copyprogrest xxx variant of copyprog for resuming partial transfers\n\ ++ \032 -copyquoterem xxx add quotes to remote file name for copyprog\n\ ++ \032 (true/false/default)\n\ + \032 -copythreshold n use copyprog on files bigger than this (if >=0, in Kb)\n\ + \032 -diff xxx set command for showing differences between files\n\ + \032 -ignorelocks ignore locks left over from previous run (dangerous!)\n\ +@@ -1502,6 +1504,15 @@ let docs = + \032 rsync). The default setting invokes rsync with appropriate\n\ + \032 options\226\128\148most users should not need to change it.\n\ + \n\ ++ \032 copyquoterem xxx\n\ ++ \032 When set to true, this flag causes Unison to add an extra layer\n\ ++ \032 of quotes to the remote path passed to the external copy\n\ ++ \032 program. This is needed by rsync, for example, which internally\n\ ++ \032 uses an ssh connection requiring an extra level of quoting for\n\ ++ \032 paths containing spaces. When this flag is set to default, extra\n\ ++ \032 quotes are added if the value of copyprog contains the string\n\ ++ \032 rsync.\n\ ++ \n\ + \032 copythreshold n\n\ + \032 A number indicating above what filesize (in kilobytes) Unison\n\ + \032 should use the external copying utility specified by copyprog.\n\ +@@ -3113,6 +3124,14 @@ let docs = + \032 copyprog = rsync --inplace --compress\n\ + \032 copyprogrest = rsync --partial --inplace --compress\n\ + \n\ ++ \032 You may also need to set the copyquoterem preference. When it is set to\n\ ++ \032 true, this causes Unison to add an extra layer of quotes to the remote\n\ ++ \032 path passed to the external copy program. This is is needed by rsync,\n\ ++ \032 for example, which internally uses an ssh connection, requiring an\n\ ++ \032 extra level of quoting for paths containing spaces. When this flag is\n\ ++ \032 set to default, extra quotes are added if the value of copyprog\n\ ++ \032 contains the string rsync. The default value is default, naturally.\n\ ++ \n\ + \032 If a directory transfer is interrupted, the next run of Unison will\n\ + \032 automatically skip any files that were completely transferred before\n\ + \032 the interruption. (This behavior is always on: it does not depend on\n\ diff --git a/net/unison/files/patch-ubase_umarshal.ml b/net/unison/files/patch-ubase_umarshal.ml deleted file mode 100644 index 0edb9f18aec5..000000000000 --- a/net/unison/files/patch-ubase_umarshal.ml +++ /dev/null @@ -1,114 +0,0 @@ ---- ubase/umarshal.ml.orig 2022-10-30 19:42:39 UTC -+++ ubase/umarshal.ml -@@ -15,6 +15,111 @@ - along with this program. If not, see . - *) - -+(* OCaml 4.07 compatibility ONLY *) -+module Bytes = struct -+ -+include Bytes -+ -+(* The following code is taken from OCaml sources. -+ Authors of the code snippet: Alain Frisch and Daniel Bünzli *) -+ -+(**************************************************************************) -+(* *) -+(* OCaml *) -+(* *) -+(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -+(* *) -+(* Copyright 1996 Institut National de Recherche en Informatique et *) -+(* en Automatique. *) -+(* *) -+(* 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. *) -+(* *) -+(**************************************************************************) -+ -+(** {6 Binary encoding/decoding of integers} *) -+ -+external get_uint8 : bytes -> int -> int = "%string_safe_get" -+external get_uint16_ne : bytes -> int -> int = "%caml_string_get16" -+external get_int32_ne : bytes -> int -> int32 = "%caml_string_get32" -+external get_int64_ne : bytes -> int -> int64 = "%caml_string_get64" -+external set_int8 : bytes -> int -> int -> unit = "%string_safe_set" -+external set_int16_ne : bytes -> int -> int -> unit = "%caml_string_set16" -+external set_int32_ne : bytes -> int -> int32 -> unit = "%caml_string_set32" -+external set_int64_ne : bytes -> int -> int64 -> unit = "%caml_string_set64" -+external swap16 : int -> int = "%bswap16" -+external swap32 : int32 -> int32 = "%bswap_int32" -+external swap64 : int64 -> int64 = "%bswap_int64" -+ -+let get_int8 b i = -+ ((get_uint8 b i) lsl (Sys.int_size - 8)) asr (Sys.int_size - 8) -+ -+let get_uint16_le b i = -+ if Sys.big_endian then swap16 (get_uint16_ne b i) -+ else get_uint16_ne b i -+ -+let get_uint16_be b i = -+ if not Sys.big_endian then swap16 (get_uint16_ne b i) -+ else get_uint16_ne b i -+ -+let get_int16_ne b i = -+ ((get_uint16_ne b i) lsl (Sys.int_size - 16)) asr (Sys.int_size - 16) -+ -+let get_int16_le b i = -+ ((get_uint16_le b i) lsl (Sys.int_size - 16)) asr (Sys.int_size - 16) -+ -+let get_int16_be b i = -+ ((get_uint16_be b i) lsl (Sys.int_size - 16)) asr (Sys.int_size - 16) -+ -+let get_int32_le b i = -+ if Sys.big_endian then swap32 (get_int32_ne b i) -+ else get_int32_ne b i -+ -+let get_int32_be b i = -+ if not Sys.big_endian then swap32 (get_int32_ne b i) -+ else get_int32_ne b i -+ -+let get_int64_le b i = -+ if Sys.big_endian then swap64 (get_int64_ne b i) -+ else get_int64_ne b i -+ -+let get_int64_be b i = -+ if not Sys.big_endian then swap64 (get_int64_ne b i) -+ else get_int64_ne b i -+ -+let set_int16_le b i x = -+ if Sys.big_endian then set_int16_ne b i (swap16 x) -+ else set_int16_ne b i x -+ -+let set_int16_be b i x = -+ if not Sys.big_endian then set_int16_ne b i (swap16 x) -+ else set_int16_ne b i x -+ -+let set_int32_le b i x = -+ if Sys.big_endian then set_int32_ne b i (swap32 x) -+ else set_int32_ne b i x -+ -+let set_int32_be b i x = -+ if not Sys.big_endian then set_int32_ne b i (swap32 x) -+ else set_int32_ne b i x -+ -+let set_int64_le b i x = -+ if Sys.big_endian then set_int64_ne b i (swap64 x) -+ else set_int64_ne b i x -+ -+let set_int64_be b i x = -+ if not Sys.big_endian then set_int64_ne b i (swap64 x) -+ else set_int64_ne b i x -+ -+let set_uint8 = set_int8 -+let set_uint16_ne = set_int16_ne -+let set_uint16_be = set_int16_be -+let set_uint16_le = set_int16_le -+ -+end -+(* / *) -+ - exception Error of string - - type 'a t = {