diff --git a/master_changes.md b/master_changes.md index d4953ce85b5..b114ee686ca 100644 --- a/master_changes.md +++ b/master_changes.md @@ -114,6 +114,7 @@ users) ## Internal * Stop using polymorphic comparison when comparing `OpamTypes.switch_selections` [#6102 @kit-ty-kate] + * Structured download error types [#6107 @Keryan-dev] ## Internal: Windows diff --git a/src/client/opamAction.ml b/src/client/opamAction.ml index da544b35502..da8846cc815 100644 --- a/src/client/opamAction.ml +++ b/src/client/opamAction.ml @@ -245,7 +245,7 @@ let download_shared_source st url nvs = | None, _ | _, [_] -> "" | Some url, _ -> " " ^ OpamUrl.to_string (OpamFile.URL.url url))) url; if OpamStateConfig.(!r.dryrun) || OpamClientConfig.(!r.fake) - then Done None else + then Done (Result ()) else let nvs = (* filter out version-pinned packages since we already have their source *) List.filter (fun nv -> @@ -259,7 +259,7 @@ let download_shared_source st url nvs = OpamFile.OPAM.version_opt) = Some nv.version)) nvs in - if nvs = [] then Done None + if nvs = [] then Done (Up_to_date ()) else let print_action = OpamConsole.msg "%s retrieved %s (%s)\n" @@ -290,14 +290,16 @@ let download_shared_source st url nvs = OpamProcess.Job.catch (fun e -> let na = match e with - | OpamDownload.Download_fail (s,l) -> (s,l) - | e -> (None, Printexc.to_string e) + | OpamDownload.Download_fail failure -> failure + | e -> Generic_failure + { short_reason = None; long_reason = Printexc.to_string e } in - Done (Some na)) + Done (Not_available na)) @@ fun () -> OpamUpdate.download_shared_package_source st url nvs @@| function - | Some (Not_available (s, l)), _ -> - let msg = OpamStd.Option.default l s in + | Some (Not_available failure), _ -> + let r = OpamTypesBase.get_dl_failure_reason failure in + let msg = OpamStd.Option.default r.long_reason r.short_reason in OpamConsole.error "Failed to get sources of %s%s: %s" (labelise OpamPackage.to_string) (match url, nvs with @@ -305,34 +307,36 @@ let download_shared_source st url nvs = | Some url, _ -> Printf.sprintf " (%s)" (OpamUrl.to_string (OpamFile.URL.url url))) msg; - Some (s, l) - | _, ((nv, name, Not_available (s, l)) :: _) -> - let msg = match s with None -> l | Some s -> s in + Not_available failure + | _, ((nv, name, Not_available failure) :: _) -> + let r = OpamTypesBase.get_dl_failure_reason failure in + let msg = OpamStd.Option.default r.long_reason r.short_reason in OpamConsole.error "Failed to get extra source \"%s\" of %s: %s" name (OpamPackage.to_string nv) msg; - Some (s, l) + Not_available failure | Some (Result msg), _ -> - print_full_action msg; None + print_full_action msg; Result () | Some (Up_to_date msg), _ -> - print_full_action msg; None - | None, [] -> None + print_full_action msg; Up_to_date () + | None, [] -> Up_to_date () | None, (e :: es as extras) -> if List.for_all (function _, _, Up_to_date _ -> true | _ -> false) extras then - print_full_action "cached" + (print_full_action "cached"; + Up_to_date ()) else - (match e, es with - | (_, _, Result msg), [] -> print_full_action msg - | _, _ -> - print_single_actions - (List.map (fun (nv, _, _) -> - nv, - (Printf.sprintf "%d extra sources" - (List.length - (List.filter (fun (nv',_,_) -> - OpamPackage.compare nv nv' = 0) - extras)))) - extras)); - None + ((match e, es with + | (_, _, Result msg), [] -> print_full_action msg + | _, _ -> + print_single_actions + (List.map (fun (nv, _, _) -> + nv, + (Printf.sprintf "%d extra sources" + (List.length + (List.filter (fun (nv',_,_) -> + OpamPackage.compare nv nv' = 0) + extras)))) + extras)); + Result ()) let download_package st nv = download_shared_source st @@ -468,7 +472,9 @@ let prepare_package_source st nv dir = (OpamFile.URL.url urlf :: OpamFile.URL.mirrors urlf) @@| function | Result () | Up_to_date () -> None - | Not_available (_,msg) -> Some (Failure msg) + | Not_available failure -> + let r = OpamTypesBase.get_dl_failure_reason failure in + Some (Failure r.long_reason) in List.fold_left (fun job dl -> job @@+ function diff --git a/src/client/opamAction.mli b/src/client/opamAction.mli index f355859e18e..b1e57bfc3c8 100644 --- a/src/client/opamAction.mli +++ b/src/client/opamAction.mli @@ -21,14 +21,14 @@ open OpamStateTypes This doesn't update dev packages that already have a locally cached source. *) val download_package: - rw switch_state -> package -> (string option * string) option OpamProcess.job + rw switch_state -> package -> unit download OpamProcess.job (** [download_same_source_package t url packages] As [download_package], download upstream shared source [url] between [packages]. *) val download_shared_source: rw switch_state -> OpamFile.URL.t option -> package list -> - (string option * string) option OpamProcess.job + unit download OpamProcess.job (** [prepare_package_source t pkg dir] updates the given source [dir] with the extra downloads, overlays and patches from the package's metadata diff --git a/src/client/opamAdminCommand.ml b/src/client/opamAdminCommand.ml index 9714372eed6..c7d10c5166b 100644 --- a/src/client/opamAdminCommand.ml +++ b/src/client/opamAdminCommand.ml @@ -175,7 +175,8 @@ let package_files_to_cache repo_root cache_dir cache_urls checksums (OpamFile.URL.url urlf :: OpamFile.URL.mirrors urlf) @@| fun r -> match OpamRepository.report_fetch_result nv r with - | Not_available (_,m) -> Some m + | Not_available failure -> + Some failure | Up_to_date () | Result () -> None in error_opt @@| function @@ -285,8 +286,13 @@ let cache_command cli = (OpamPackage.Map.keys errors)); OpamConsole.errmsg "%s" (OpamStd.Format.itemize (fun (nv,el) -> + let reasons = + List.map (fun e -> + (OpamTypesBase.get_dl_failure_reason e).long_reason) + el + in Printf.sprintf "[%s] %s" (OpamPackage.to_string nv) - (String.concat "\n" el)) + (String.concat "\n" reasons)) (OpamPackage.Map.bindings errors)) ); diff --git a/src/client/opamCommands.ml b/src/client/opamCommands.ml index ff626d7a8b4..fe48fe15768 100644 --- a/src/client/opamCommands.ml +++ b/src/client/opamCommands.ml @@ -3336,9 +3336,10 @@ let pin ?(unpin_only=false) cli = ~cache_dir:(OpamRepositoryPath.download_cache OpamStateConfig.(!r.root_dir)) basename pin_cache_dir [] [url] @@| function - | Not_available (_,u) -> + | Not_available failure -> + let r = OpamTypesBase.get_dl_failure_reason failure in OpamConsole.error_and_exit `Sync_error - "Could not retrieve %s" u + "Could not retrieve %s" r.long_reason | Result _ | Up_to_date _ -> let pkgs = OpamAuxCommands.opams_of_dir ?locked ~recurse ?subpath @@ -3715,8 +3716,10 @@ let source cli = (OpamPackage.to_string nv) dir [] [url]) with - | Not_available (_,u) -> - OpamConsole.error_and_exit `Sync_error "%s is not available" u + | Not_available failure -> + let r = OpamTypesBase.get_dl_failure_reason failure in + OpamConsole.error_and_exit `Sync_error "%s is not available" + r.long_reason | Result _ | Up_to_date _ -> OpamConsole.formatted_msg "Successfully fetched %s development repo to %s\n" @@ -3726,8 +3729,11 @@ let source cli = (let job = let open OpamProcess.Job.Op in OpamUpdate.download_package_source t nv dir @@+ function - | Some (Not_available (_,s)), _ | _, (_, Not_available (_, s)) :: _ -> - OpamConsole.error_and_exit `Sync_error "Download failed: %s" s + | Some (Not_available failure), _ + | _, (_, Not_available failure) :: _ -> + let r = OpamTypesBase.get_dl_failure_reason failure in + OpamConsole.error_and_exit `Sync_error "Download failed: %s" + r.long_reason | None, _ | Some (Result _ | Up_to_date _), _ -> OpamAction.prepare_package_source t nv dir @@| function | None -> diff --git a/src/client/opamPinCommand.ml b/src/client/opamPinCommand.ml index 3ec2b4731e6..2ddad29759f 100644 --- a/src/client/opamPinCommand.ml +++ b/src/client/opamPinCommand.ml @@ -64,8 +64,6 @@ let read_opam_file_for_pinning ?locked ?(quiet=false) name f url = >>| OpamFile.OPAM.with_locked_opt locked -exception Fetch_Fail of string - let get_source_definition ?version ?subpath ?locked st nv url = let root = st.switch_global.root in let srcdir = OpamPath.Switch.pinned_package root st.switch nv.name in @@ -87,11 +85,11 @@ let get_source_definition ?version ?subpath ?locked st nv url = | _, _ -> url in OpamUpdate.fetch_dev_package url srcdir ?subpath nv @@| function - | Not_available (_,s) -> raise (Fetch_Fail s) + | Not_available _ as err -> err | Up_to_date _ | Result _ -> let srcdir = OpamFilename.SubPath.(srcdir /? subpath) in match OpamPinned.find_opam_file_in_source ?locked nv.name srcdir with - | None -> None + | None -> Result None | Some (f, locked) -> match read_opam_file_for_pinning nv.name ?locked f (OpamFile.URL.url url) with | None -> @@ -100,8 +98,8 @@ let get_source_definition ?version ?subpath ?locked st nv url = (OpamPath.Switch.Overlay.tmp_opam root st.switch nv.name) in OpamFilename.copy ~src:(OpamFile.filename f) ~dst; - None - | Some opam -> Some (fix opam) + Result None + | Some opam -> Result (Some (fix opam)) let copy_files st opam = let name = OpamFile.OPAM.name opam in @@ -530,16 +528,20 @@ and source_pin OpamFilename.remove (OpamFile.filename temp_file); let opam_opt = - try - opam_opt >>+ fun () -> - urlf >>= fun url -> + opam_opt >>+ fun () -> + urlf >>= fun url -> + match OpamProcess.Job.run @@ get_source_definition ?version ?subpath ?locked st nv url - with Fetch_Fail err -> + with + | Result o | Up_to_date o -> o + | Not_available failure -> if force then None else (OpamConsole.error_and_exit `Sync_error "Error getting source from %s:\n%s" (OpamStd.Option.to_string OpamUrl.to_string target_url) - (OpamStd.Format.itemize (fun x -> x) [err])); + (OpamStd.Format.itemize (fun x -> + (OpamTypesBase.get_dl_failure_reason x).long_reason) + [failure])) in let opam_opt = opam_opt >>| OpamFormatUpgrade.opam_file in @@ -828,9 +830,10 @@ let scan ~normalise ~recurse ?subpath url = ~cache_dir:(OpamRepositoryPath.download_cache OpamStateConfig.(!r.root_dir)) basename pin_cache_dir [] [url] @@| function - | Not_available (_,u) -> + | Not_available failure -> + let r = OpamTypesBase.get_dl_failure_reason failure in OpamConsole.error_and_exit `Sync_error - "Could not retrieve %s" u + "Could not retrieve %s" r.long_reason | Result _ | Up_to_date _ -> pins_of_dir pin_cache_dir, Some cleanup with e -> OpamStd.Exn.finalise e cleanup diff --git a/src/client/opamSolution.ml b/src/client/opamSolution.ml index 905d53cd82d..15138eb0efa 100644 --- a/src/client/opamSolution.ml +++ b/src/client/opamSolution.ml @@ -20,7 +20,7 @@ module PackageAction = OpamSolver.Action module PackageActionGraph = OpamSolver.ActionGraph -exception Fetch_fail of string +exception Fetch_fail of dl_failure let post_message ?(failed=false) st action = match action, failed with @@ -230,6 +230,8 @@ let display_error (n, error) = | Sys.Break | OpamParallel.Aborted -> () | Failure s -> disp "%s" s | OpamSystem.Process_error e -> disp "%s" (OpamProcess.string_of_result e) + | Fetch_fail failure -> + disp "%s" (get_dl_failure_reason failure).long_reason | e -> disp "%s" (Printexc.to_string e); if OpamConsole.debug () then @@ -632,10 +634,10 @@ let parallel_apply t | [] -> None in OpamAction.download_shared_source t url nvs) @@+ function - | None -> + | Result () | Up_to_date () -> store_time (); Done (`Successful (installed, removed)) - | Some (_short_error, long_error) -> - Done (`Exception (Fetch_fail long_error))) + | Not_available failure -> + Done (`Exception (Fetch_fail failure))) | `Build nv -> if assume_built && OpamPackage.Set.mem nv requested then @@ -762,7 +764,9 @@ let parallel_apply t ) OpamPackage.Map.empty results in if not (OpamPackage.Map.is_empty failed_downloads) then OpamJson.append "download-failures" - (`O (List.map (fun (nv, err) -> OpamPackage.to_string nv, `String err) + (`O (List.map (fun (nv, failure) -> + let err = (get_dl_failure_reason failure).long_reason in + OpamPackage.to_string nv, `String err) (OpamPackage.Map.bindings failed_downloads))); (* Report build/install/remove failures *) let j = diff --git a/src/format/opamTypes.mli b/src/format/opamTypes.mli index 26e818d642d..7c89431068b 100644 --- a/src/format/opamTypes.mli +++ b/src/format/opamTypes.mli @@ -48,13 +48,35 @@ type std_path = | Lib | Bin | Sbin | Share | Doc | Etc | Man | Toplevel | Stublibs +(** Download failure explanation *) +type dl_fail_reason = { + short_reason : string option; + long_reason : string; +} +(** The usage is: [short_reason] is displayed on normal mode + (nothing if [None]), and [long_reason] on verbose mode. *) + +(** Tool download failure infos *) +type 'a dl_tool_failure = { + dl_exit_code : int; + dl_url : string; + dl_reason : 'a; +} + +type curl_error = + | Curl_empty_response + | Curl_error_response of string + | Curl_generic_error of dl_fail_reason + +(** Download failure kind *) +type dl_failure = + | Generic_failure of dl_fail_reason + | Curl_failure of curl_error dl_tool_failure + (** Download result *) type 'a download = | Up_to_date of 'a - | Not_available of string option * string - (** Arguments are respectively the short and long version of an error message. - The usage is: the first argument is displayed on normal mode (nothing - if [None]), and the second one on verbose mode. *) + | Not_available of dl_failure | Result of 'a (** {2 Packages} *) diff --git a/src/format/opamTypesBase.ml b/src/format/opamTypesBase.ml index b74e32cd977..0449b54ca6c 100644 --- a/src/format/opamTypesBase.ml +++ b/src/format/opamTypesBase.ml @@ -345,3 +345,19 @@ let switch_selections_compare x let switch_selections_equal x y = switch_selections_compare x y = 0 + +let get_dl_failure_reason = function + | Generic_failure r -> r + | Curl_failure { dl_exit_code; dl_url; dl_reason } -> + let head_msg = + Printf.sprintf "curl failure while downloading %s\nExited with code %d\n" + dl_url dl_exit_code + in + match dl_reason with + | Curl_empty_response -> + { short_reason = Some "curl failure"; + long_reason = head_msg^"Empty response" } + | Curl_error_response e -> + { short_reason = Some "curl failure"; + long_reason = head_msg^"Returned code "^e } + | Curl_generic_error r -> { r with long_reason = head_msg^r.long_reason } diff --git a/src/format/opamTypesBase.mli b/src/format/opamTypesBase.mli index 068ed269147..bdf46973f2c 100644 --- a/src/format/opamTypesBase.mli +++ b/src/format/opamTypesBase.mli @@ -117,3 +117,6 @@ val char_of_separator: separator -> char (* Switch selections *) val switch_selections_compare : switch_selections -> switch_selections -> int val switch_selections_equal : switch_selections -> switch_selections -> bool + +(* Download error helper functions *) +val get_dl_failure_reason : dl_failure -> dl_fail_reason diff --git a/src/repository/opamDownload.ml b/src/repository/opamDownload.ml index 482b12eabcf..38f4e36373e 100644 --- a/src/repository/opamDownload.ml +++ b/src/repository/opamDownload.ml @@ -14,8 +14,9 @@ open OpamProcess.Job.Op let log fmt = OpamConsole.log "CURL" fmt -exception Download_fail of string option * string -let fail (s,l) = raise (Download_fail (s,l)) +exception Download_fail of dl_failure +let fail failure = raise (Download_fail failure) + let user_agent = CString (Printf.sprintf "opam/%s" (OpamVersion.(to_string current))) @@ -93,27 +94,35 @@ let tool_return url ret = match Lazy.force OpamRepositoryConfig.(!r.download_tool) with | _, `Default -> if OpamProcess.is_failure ret then - fail (Some "Download command failed", - Printf.sprintf "Download command failed: %s" - (OpamProcess.result_summary ret)) + fail (Generic_failure { + short_reason = Some "Download command failed"; + long_reason = Printf.sprintf "Download command failed: %s" + (OpamProcess.result_summary ret); }) else Done () | _, `Curl -> - if OpamProcess.is_failure ret then - fail (Some "Curl failed", Printf.sprintf "Curl failed: %s" - (OpamProcess.result_summary ret)); - match ret.OpamProcess.r_stdout with - | [] -> - fail (Some "curl empty response", - Printf.sprintf "curl: empty response while downloading %s" - (OpamUrl.to_string url)) - | l -> - let code = List.hd (List.rev l) in - let num = try int_of_string code with Failure _ -> 999 in - if num >= 400 then - fail (Some ("curl error code " ^ code), - Printf.sprintf "curl: code %s while downloading %s" - code (OpamUrl.to_string url)) - else Done () + let error = + if OpamProcess.is_failure ret then + Some (Curl_generic_error + { short_reason = Some "Curl failed"; + long_reason = Printf.sprintf "Curl failed: %s" + (OpamProcess.result_summary ret); }) + else match ret.OpamProcess.r_stdout with + | [] -> Some Curl_empty_response + | l -> + let code = List.hd (List.rev l) in + let num = try int_of_string code with Failure _ -> 999 in + if num >= 400 + then Some (Curl_error_response code) + else None + in + match error with + | Some dl_reason -> + fail (Curl_failure + { dl_exit_code = ret.OpamProcess.r_code; + dl_url = OpamUrl.to_string url; + dl_reason; + }) + | None -> Done () let download_command ~compress ?checksum ~url ~dst () = let cmd, args = @@ -156,17 +165,20 @@ let really_download download_command ~compress ?checksum ~url ~dst:tmp_dst () @@+ fun () -> if not (Sys.file_exists tmp_dst) then - fail (Some "Downloaded file not found", - "Download command succeeded, but resulting file not found") + fail (Generic_failure { + short_reason = Some "Downloaded file not found"; + long_reason = "Download command succeeded, but resulting file \ + not found"; }) else if Sys.file_exists dst && not overwrite then OpamSystem.internal_error "The downloaded file will overwrite %s." dst; if validate && OpamRepositoryConfig.(!r.force_checksums <> Some false) then OpamStd.Option.iter (fun cksum -> if not (OpamHash.check_file tmp_dst cksum) then - fail (Some "Bad checksum", - Printf.sprintf "Bad checksum, expected %s" - (OpamHash.to_string cksum))) + fail (Generic_failure { + short_reason = Some "Bad checksum"; + long_reason = Printf.sprintf "Bad checksum, expected %s" + (OpamHash.to_string cksum); })) checksum; OpamSystem.mv tmp_dst dst; Done () @@ -301,8 +313,10 @@ module SWHID = struct let rec aux max_tries = if max_tries <= 0 then Done (Not_available - (Some (fallback_err "max_tries"), - fallback_err "%d attempts tried; aborting" attempts)) + (Generic_failure { + short_reason = Some (fallback_err "max_tries"); + long_reason = fallback_err "%d attempts tried; aborting" + attempts; })) else get_dir hash @@+ function | Some (`Done fetch_url) -> Done (Result fetch_url) @@ -310,7 +324,10 @@ module SWHID = struct Unix.sleep 10; aux (max_tries - 1) | None | Some (`Failed | `Unknown) -> - Done (Not_available (None, fallback_err "Unknown swhid")) + Done (Not_available + (Generic_failure { + short_reason = None; + long_reason = fallback_err "Unknown swhid"; })) in aux max_tries @@ -342,21 +359,24 @@ module SWHID = struct let sources = OpamFilename.Op.(dir / "src") in OpamFilename.extract_job archive sources @@| function | Some e -> - Not_available ( - Some (fallback_err "archive extraction failure"), - fallback_err "archive extraction failure %s" - (match e with - | Failure s -> s - | OpamSystem.Process_error pe -> - OpamProcess.string_of_result pe - | e -> Printexc.to_string e)) + Not_available (Generic_failure { + short_reason = + Some (fallback_err "archive extraction failure"); + long_reason = fallback_err "archive extraction failure %s" + (match e with + | Failure s -> s + | OpamSystem.Process_error pe -> + OpamProcess.string_of_result pe + | e -> Printexc.to_string e); }) | None -> (match OpamSWHID.compute sources with | None -> - Not_available ( - Some (fallback_err "can't check archive validity"), - fallback_err - "error on swhid computation, can't check its validity") + Not_available (Generic_failure { + short_reason = + Some (fallback_err "can't check archive validity"); + long_reason = fallback_err + "error on swhid computation, can't check its validity"; + }) | Some computed -> if String.equal computed hash then (List.iter (fun (_nv, dst, _sp) -> @@ -365,23 +385,23 @@ module SWHID = struct dirnames; Result (Some "SWH fallback")) else - Not_available ( - Some (fallback_err "archive not valid"), - fallback_err - "archive corrupted, opam file swhid %S vs computed %S" - hash computed))) + Not_available (Generic_failure { + short_reason = Some (fallback_err "archive not valid"); + long_reason = fallback_err + "archive corrupted, opam file swhid %S vs \ + computed %S" hash computed; }))) else - Done (Not_available - (Some (fallback_err "skip retrieval"), - fallback_err "retrieval refused by user")) + Done (Not_available (Generic_failure { + short_reason = Some (fallback_err "skip retrieval"); + long_reason = fallback_err "retrieval refused by user"; })) else - Done (Not_available - (Some (fallback_err "unreachable"), - fallback_err "network failure or API down")) + Done (Not_available (Generic_failure { + short_reason = Some (fallback_err "unreachable"); + long_reason = fallback_err "network failure or API down"; })) else - Done (Not_available - (Some (fallback_err "no retrieval"), - fallback_err "Download tool permitting post request (%s) not \ - set as download tool" - (OpamStd.Format.pretty_list post_tools))) + Done (Not_available (Generic_failure { + short_reason = Some (fallback_err "no retrieval"); + long_reason = fallback_err "Download tool permitting \ + post request (%s) not set as download tool" + (OpamStd.Format.pretty_list post_tools); })) end diff --git a/src/repository/opamDownload.mli b/src/repository/opamDownload.mli index 5d936039c90..69d2bf333d1 100644 --- a/src/repository/opamDownload.mli +++ b/src/repository/opamDownload.mli @@ -13,7 +13,7 @@ open OpamTypes (** Configuration init and handling of downloading commands *) -exception Download_fail of string option * string +exception Download_fail of dl_failure (** downloads a file from an URL, using Curl, Wget, or a custom configured tool, to the given directory. Returns the downloaded filename. diff --git a/src/repository/opamHTTP.ml b/src/repository/opamHTTP.ml index 9c62d0ea231..4e6434b21c9 100644 --- a/src/repository/opamHTTP.ml +++ b/src/repository/opamHTTP.ml @@ -75,13 +75,20 @@ module B = struct OpamProcess.Job.catch (fun e -> OpamStd.Exn.fatal e; - let s,l = + let failure = let str = Printf.sprintf "%s (%s)" (OpamUrl.to_string remote_url) in match e with - | OpamDownload.Download_fail (s,l) -> s, str l - | _ -> Some "Download failed", str "download failed" + | OpamDownload.Download_fail ( + Generic_failure { short_reason; long_reason = l }) -> + Generic_failure { short_reason; long_reason = str l } + | OpamDownload.Download_fail failure -> failure + | _ -> + Generic_failure { + short_reason = Some "Download failed"; + long_reason = str "download failed, "^(Printexc.to_string e); + } in - Done (Not_available (s,l))) + Done (Not_available failure)) @@ fun () -> OpamDownload.download ~quiet:true ~overwrite:true ?checksum remote_url dirname @@+ fun local_file -> Done (Result (Some local_file)) diff --git a/src/repository/opamLocal.ml b/src/repository/opamLocal.ml index 77205c0940c..1265559568f 100644 --- a/src/repository/opamLocal.ml +++ b/src/repository/opamLocal.ml @@ -78,12 +78,14 @@ let rsync ?(args=[]) ?(exclude_vcdirs=true) src dst = ] in if not(remote || Sys.file_exists src) then - Done (Not_available (None, src)) + Done (Not_available ( + Generic_failure { short_reason = None; long_reason = src })) else if src = dst then Done (Up_to_date []) else if overlap src dst then (OpamConsole.error "Cannot sync %s into %s: they overlap" src dst; - Done (Not_available (None, src))) + Done (Not_available ( + Generic_failure { short_reason = None; long_reason = src }))) else ( OpamSystem.mkdir dst; let convert_path = Lazy.force convert_path in @@ -91,7 +93,8 @@ let rsync ?(args=[]) ?(exclude_vcdirs=true) src dst = ( rsync_arg :: args @ exclude_args @ [ "--delete"; "--delete-excluded"; convert_path src; convert_path dst; ]) @@| function - | None -> Not_available (None, src) + | None -> Not_available ( + Generic_failure { short_reason = None; long_reason = src }) | Some [] -> Up_to_date [] | Some lines -> Result lines ) @@ -104,13 +107,18 @@ let rsync_dirs ?args ?exclude_vcdirs url dst = if not (is_remote url) && not (OpamFilename.exists_dir (OpamFilename.Dir.of_string src_s)) then - Done (Not_available (None, Printf.sprintf "Directory %s does not exist" src_s)) + Done (Not_available + (Generic_failure { + short_reason = None; + long_reason = Printf.sprintf + "Directory %s does not exist" src_s; })) else rsync ?args ?exclude_vcdirs src_s dst_s @@| function | Not_available _ as na -> na | Result _ -> if OpamFilename.exists_dir dst then Result dst - else Not_available (None, dst_s) + else Not_available (Generic_failure + { short_reason = None; long_reason = dst_s }) | Up_to_date _ -> Up_to_date dst let rsync_file ?(args=[]) url dst = @@ -118,7 +126,8 @@ let rsync_file ?(args=[]) url dst = let dst_s = OpamFilename.to_string dst in log "rsync_file src=%s dst=%s" src_s dst_s; if not (is_remote url || OpamFilename.(exists (of_string src_s))) then - Done (Not_available (None, src_s)) + Done (Not_available (Generic_failure + { short_reason = None; long_reason = src_s })) else if src_s = dst_s then Done (Up_to_date dst) else @@ -127,11 +136,13 @@ let rsync_file ?(args=[]) url dst = call_rsync (fun () -> Sys.file_exists dst_s) ( rsync_arg :: args @ [ convert_path src_s; convert_path dst_s ]) @@| function - | None -> Not_available (None, src_s) + | None -> Not_available (Generic_failure + { short_reason = None; long_reason = src_s }) | Some [] -> Up_to_date dst | Some [_] -> if OpamFilename.exists dst then Result dst - else Not_available (None, src_s) + else Not_available (Generic_failure + { short_reason = None; long_reason = src_s }) | Some l -> OpamSystem.internal_error "unknown rsync output: {%s}" @@ -223,12 +234,14 @@ module B = struct if OpamFilename.exists filename then res (Some filename) else Not_available - (None, Printf.sprintf - "Could not find target file %s after rsync with %s. \ - Perhaps you meant %s/ ?" - (OpamUrl.basename remote_url) - (OpamUrl.to_string remote_url) - (OpamUrl.to_string remote_url)) + (Generic_failure { + short_reason = None; + long_reason = Printf.sprintf + "Could not find target file %s after rsync with %s. \ + Perhaps you meant %s/ ?" + (OpamUrl.basename remote_url) + (OpamUrl.to_string remote_url) + (OpamUrl.to_string remote_url); }) let revision _ = Done None diff --git a/src/repository/opamRepository.ml b/src/repository/opamRepository.ml index f321669e707..81b445aaba3 100644 --- a/src/repository/opamRepository.ml +++ b/src/repository/opamRepository.ml @@ -15,6 +15,9 @@ open OpamProcess.Job.Op let log fmt = OpamConsole.log "REPOSITORY" fmt let slog = OpamConsole.slog +let generic_failure msg = + Generic_failure { short_reason = Some msg; long_reason = msg } + let find_backend_by_kind = function | `http -> (module OpamHTTP.B: OpamRepositoryBackend.S) @@ -75,7 +78,7 @@ let fetch_from_cache = checksums); OpamFilename.remove file; let m = "cache CONFLICT" in - Done (Not_available (Some m, m)) + Done (Not_available (generic_failure m)) in let dl_from_cache_job root_cache_url checksum file = let url = cache_url root_cache_url checksum in @@ -92,7 +95,8 @@ let fetch_from_cache = | None -> (OpamLocal.rsync_file url file @@| function | Result _ | Up_to_date _-> () - | Not_available (s,l) -> raise (OpamDownload.Download_fail (s,l))) + | Not_available failure -> + raise (OpamDownload.Download_fail failure)) end | #OpamUrl.version_control -> failwith "Version control not allowed as cache URL" @@ -117,12 +121,16 @@ let fetch_from_cache = end else mismatch hit_file with Not_found -> match checksums with - | [] -> let m = "cache miss" in Done (Not_available (Some m, m)) + | [] -> + let m = "cache miss" in + Done (Not_available (generic_failure m)) | checksum::other_checksums -> let local_file = cache_file cache_dir checksum in let tmpfile = OpamFilename.add_extension local_file "tmp" in let rec try_cache_dl = function - | [] -> let m = "cache miss" in Done (Not_available (Some m, m)) + | [] -> + let m = "cache miss" in + Done (Not_available (generic_failure m)) | root_cache_url::other_caches -> OpamProcess.Job.catch (function Failure _ @@ -223,7 +231,7 @@ let pull_from_upstream then ret else let m = "Checksum mismatch" in - Not_available (Some m, m) + Not_available (generic_failure m) | (Result None | Up_to_date None) as ret -> ret | Not_available _ as na -> na @@ -239,9 +247,9 @@ let pull_from_mirrors label ?full_fetch ?working_dir ?subpath pull_from_upstream label ?full_fetch ?working_dir ?subpath cache_dir destdir checksums url @@+ function - | Not_available (_,s) -> + | Not_available (Generic_failure { long_reason; _ }) -> OpamConsole.warning "%s: download of %s failed (%s), trying mirror" - label (OpamUrl.to_string url) s; + label (OpamUrl.to_string url) long_reason; aux mirrors | r -> Done (url, r) in @@ -252,7 +260,7 @@ let pull_from_mirrors label ?full_fetch ?working_dir ?subpath label (OpamUrl.to_string url); OpamFilename.rmdir destdir; let m = "can't check directory checksum" in - url, Not_available (Some m, m) + url, Not_available (generic_failure m) | ret -> ret (* handle subpathes *) @@ -263,11 +271,19 @@ let pull_tree_t let fallback success = function | None -> success () | Some (Failure s) -> - Done (Not_available (Some s, "Could not extract archive:\n"^s)) + Done (Not_available + (Generic_failure { + short_reason = Some s; + long_reason = "Could not extract archive:\n"^s; })) | Some (OpamSystem.Process_error pe) -> - Done (Not_available (Some (OpamProcess.result_summary pe), - OpamProcess.string_of_result pe)) - | Some e -> Done (Not_available (None, Printexc.to_string e)) + Done (Not_available ( + Generic_failure { + short_reason = Some (OpamProcess.result_summary pe); + long_reason = OpamProcess.string_of_result pe; })) + | Some e -> Done (Not_available + (Generic_failure + { short_reason = None; + long_reason = Printexc.to_string e })) in match dirnames with | [ label, local_dirname, _subpath ] -> @@ -291,7 +307,9 @@ let pull_tree_t Done (Up_to_date label) with OpamSystem.Process_error r -> Done (Not_available - (Some label, OpamProcess.result_summary r)))) + (Generic_failure { + short_reason = Some label; + long_reason = OpamProcess.result_summary r; })))) dirnames in let text = @@ -310,22 +328,29 @@ let pull_tree_t let failing = OpamStd.List.filter_map (function | Result _ | Up_to_date _ -> None - | Not_available (Some s,l) -> Some (s,l) - | Not_available (None, _) -> assert false + | Not_available failure -> Some failure ) (copies ()) in if failing = [] then Done (Up_to_date msg) else let simple = Printf.sprintf "Failed to copy source of %s" - (OpamStd.Format.pretty_list (List.map fst failing)) + (OpamStd.Format.pretty_list (List.map (fun e -> + let r = OpamTypesBase.get_dl_failure_reason e in + OpamStd.Option.default r.long_reason r.short_reason) + failing)) in let long = Printf.sprintf "Failed to copy source of:\n%s" - (OpamStd.Format.itemize (fun (nv, msg) -> - Printf.sprintf "%s: %s" nv msg) + (OpamStd.Format.itemize (fun e -> + let r = OpamTypesBase.get_dl_failure_reason e in + match r.short_reason with + | Some nv -> + Printf.sprintf "%s: %s" nv r.long_reason + | None -> r.long_reason) failing) in - Done (Not_available (Some simple, long))) + Done (Not_available (Generic_failure { short_reason = Some simple; + long_reason = long }))) in let label = OpamStd.List.concat_map ", " (fun (x,_,_) -> x) dirnames in (match cache_dir with @@ -336,7 +361,7 @@ let pull_tree_t | None -> assert (cache_urls = []); let m = "no cache" in - Done (Not_available (Some m, m))) + Done (Not_available (generic_failure m))) @@+ function | Up_to_date (archive, _) -> extract_archive archive "cached" @@ -350,9 +375,10 @@ let pull_tree_t if checksums = [] && OpamRepositoryConfig.(!r.force_checksums = Some true) then Done ( - Not_available ( - Some ("missing checksum"), - label ^ ": Missing checksum, and `--require-checksums` was set.")) + Not_available (Generic_failure { + short_reason = Some ("missing checksum"); + long_reason = label ^ ": Missing checksum, and \ + `--require-checksums` was set."; })) else OpamFilename.with_tmp_dir_job @@ fun tmpdir -> let extract url archive = @@ -409,7 +435,7 @@ let pull_file label ?cache_dir ?(cache_urls=[]) ?(silent_hits=false) | None -> assert (cache_urls = []); let m = "no cache" in - Done (Not_available (Some m, m))) + Done (Not_available (generic_failure m))) @@+ function | Up_to_date (f, _) -> if not silent_hits then @@ -428,15 +454,19 @@ let pull_file label ?cache_dir ?(cache_urls=[]) ?(silent_hits=false) then Done ( Not_available - (Some "missing checksum", - label ^ ": Missing checksum, and `--require-checksums` was set.")) + (Generic_failure { + short_reason = Some "missing checksum"; + long_reason = label ^ ": Missing checksum, and \ + `--require-checksums` was set."; })) else OpamFilename.with_tmp_dir_job (fun tmpdir -> pull_from_mirrors label cache_dir tmpdir checksums remote_urls @@| function | _, Up_to_date _ -> assert false | _, Result (Some f) -> OpamFilename.move ~src:f ~dst:file; Result () - | _, Result None -> let m = "is a directory" in Not_available (Some m, m) + | _, Result None -> + let m = "is a directory" in + Not_available (generic_failure m) | _, (Not_available _ as na) -> na) let pull_file_to_cache label ~cache_dir ?(cache_urls=[]) checksums remote_urls = @@ -453,7 +483,9 @@ let pull_file_to_cache label ~cache_dir ?(cache_urls=[]) checksums remote_urls = @@| function | _, Up_to_date _ -> assert false | url, Result (Some _) -> Result (OpamUrl.to_string url) - | _, Result None -> let m = "is a directory" in Not_available (Some m, m) + | _, Result None -> + let m = "is a directory" in + Not_available (generic_failure m) | _, (Not_available _ as na) -> na) let packages repo_root = @@ -607,8 +639,9 @@ let report_fetch_result pkg = function (OpamConsole.colorise `green (OpamPackage.to_string pkg)) msg; Up_to_date () - | Not_available (s, l) -> - let msg = match s with None -> l | Some s -> s in + | Not_available failure as result -> + let r = OpamTypesBase.get_dl_failure_reason failure in + let msg = match r.short_reason with None -> r.long_reason | Some s -> s in OpamConsole.msg "[%s] fetching sources failed: %s\n" (OpamConsole.colorise `red (OpamPackage.to_string pkg)) msg; - Not_available (s, l) + result diff --git a/src/repository/opamVCS.ml b/src/repository/opamVCS.ml index b7ef4f8b754..e90be18ccd3 100644 --- a/src/repository/opamVCS.ml +++ b/src/repository/opamVCS.ml @@ -84,7 +84,9 @@ module Make (VCS: VCS) = struct (OpamFilename.Dir.to_string dirname) (OpamUrl.to_string url) (match e with Failure fw -> fw | _ -> Printexc.to_string e); - Done (Not_available (None, OpamUrl.to_string url))) + Done (Not_available (Generic_failure { + short_reason = None; + long_reason = OpamUrl.to_string url; }))) @@ fun () -> if VCS.exists dirname then VCS.clean dirname @@+ fun () -> diff --git a/src/state/opamFileTools.ml b/src/state/opamFileTools.ml index 75f25bc6d4d..def9d2be9dc 100644 --- a/src/state/opamFileTools.ml +++ b/src/state/opamFileTools.ml @@ -830,8 +830,9 @@ let t_lint ?check_extra_files ?(check_upstream=false) ?(all=false) t = | `http -> OpamProcess.Job.catch (function | Failure msg -> Done (Some msg) - | OpamDownload.Download_fail (s,l) -> - Done (Some (OpamStd.Option.default l s)) + | OpamDownload.Download_fail ( + Generic_failure { short_reason; long_reason }) -> + Done (Some (OpamStd.Option.default long_reason short_reason)) | e -> Done (Some (Printexc.to_string e))) @@ fun () -> OpamDownload.download ~overwrite:false url dir @@ -848,8 +849,9 @@ let t_lint ?check_extra_files ?(check_upstream=false) ?(all=false) t = OpamLocal.rsync_file url filename @@| function | Up_to_date f | Result f -> check_checksum f - | Not_available (_,src) -> - Some ("Source not found: "^src) + | Not_available failure -> + let r = OpamTypesBase.get_dl_failure_reason failure in + Some ("Source not found: "^r.long_reason) in cond 60 `Error "Upstream check failed" ~detail:(OpamStd.Option.to_list upstream_error) diff --git a/src/state/opamUpdate.ml b/src/state/opamUpdate.ml index 9fdf0f36750..6ab7e2b4355 100644 --- a/src/state/opamUpdate.ml +++ b/src/state/opamUpdate.ml @@ -578,13 +578,13 @@ let download_package_source_t st url nv_dirs = dirnames checksums (OpamFile.URL.url url :: OpamFile.URL.mirrors url)) @@+ function - | Not_available (_s,_l) as source_result + | Not_available _failure as source_result when OpamFile.Config.swh_fallback st.switch_global.config -> (OpamDownload.SWHID.archive_fallback url dirnames @@| function | Result None -> Some source_result | Result (Some r) -> Some (Result r) - | Not_available (s,l) -> Some (Not_available (s,l)) + | Not_available failure -> Some (Not_available failure) | Up_to_date _ -> assert false) | source_result -> Done (Some source_result) in diff --git a/tests/reftests/archive.test b/tests/reftests/archive.test index aa6fcc10680..986c2957fb3 100644 --- a/tests/reftests/archive.test +++ b/tests/reftests/archive.test @@ -459,7 +459,7 @@ The following actions will be performed: <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] Failed to get sources of no-checksum.1: missing checksum -OpamSolution.Fetch_fail("no-checksum.1: Missing checksum, and `--require-checksums` was set.") +no-checksum.1: Missing checksum, and `--require-checksums` was set. <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> @@ -493,7 +493,7 @@ The following actions will be performed: got md5=hash [ERROR] Failed to get sources of multiple-md5.1: Checksum mismatch -OpamSolution.Fetch_fail("Checksum mismatch") +Checksum mismatch <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> @@ -513,7 +513,7 @@ The following actions will be performed: got md5=hash [ERROR] Failed to get sources of multiple-md5.1: Checksum mismatch -OpamSolution.Fetch_fail("Checksum mismatch") +Checksum mismatch <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> @@ -552,7 +552,7 @@ The following actions will be performed: got md5=hash [ERROR] Failed to get sources of bad-md5.1: Checksum mismatch -OpamSolution.Fetch_fail("Checksum mismatch") +Checksum mismatch <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> @@ -572,7 +572,7 @@ The following actions will be performed: got md5=hash [ERROR] Failed to get sources of bad-md5.1: Checksum mismatch -OpamSolution.Fetch_fail("Checksum mismatch") +Checksum mismatch <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> @@ -628,7 +628,7 @@ The following actions will be performed: got sha256=hash [ERROR] Failed to get sources of good-md5-bad-sha256.1: Checksum mismatch -OpamSolution.Fetch_fail("Checksum mismatch") +Checksum mismatch <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> @@ -678,7 +678,7 @@ The following actions will be performed: got sha256=hash [ERROR] Failed to get sources of good-md5-bad-sha256.1: Checksum mismatch -OpamSolution.Fetch_fail("Checksum mismatch") +Checksum mismatch <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> @@ -701,7 +701,7 @@ The following actions will be performed: got sha256=hash [ERROR] Failed to get sources of good-md5-bad-sha256.1: Checksum mismatch -OpamSolution.Fetch_fail("Checksum mismatch") +Checksum mismatch <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> @@ -740,7 +740,7 @@ The following actions will be performed: got md5=hash [ERROR] Failed to get sources of good-sha256-bad-md5.1: Checksum mismatch -OpamSolution.Fetch_fail("Checksum mismatch") +Checksum mismatch <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> @@ -760,7 +760,7 @@ The following actions will be performed: got md5=hash [ERROR] Failed to get sources of good-sha256-bad-md5.1: Checksum mismatch -OpamSolution.Fetch_fail("Checksum mismatch") +Checksum mismatch <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> @@ -815,7 +815,7 @@ The following actions will be performed: got md5=hash [ERROR] Failed to get sources of clash-with-all-md5s.666: Checksum mismatch -OpamSolution.Fetch_fail("Checksum mismatch") +Checksum mismatch <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> @@ -881,7 +881,7 @@ The following actions will be performed: got md5=hash [ERROR] Failed to get sources of clash-with-all-md5s.666: Checksum mismatch -OpamSolution.Fetch_fail("Checksum mismatch") +Checksum mismatch <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> @@ -904,7 +904,7 @@ The following actions will be performed: got md5=hash [ERROR] Failed to get sources of clash-with-all-md5s.666: Checksum mismatch -OpamSolution.Fetch_fail("Checksum mismatch") +Checksum mismatch <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> diff --git a/tests/reftests/download.test b/tests/reftests/download.test index d39c21cc1b5..69596a6cec3 100644 --- a/tests/reftests/download.test +++ b/tests/reftests/download.test @@ -66,7 +66,9 @@ Processing 1/1: [foo.1: http] + curl "--another-args" "3" [ERROR] Failed to get sources of foo.1: Curl failed -OpamSolution.Fetch_fail("https://github.com/UnixJunkie/get_line/archive/v1.0.0.tar.gz (Curl failed: \"curl --another-args 3\" exited with code 2)") +curl failure while downloading https://github.com/UnixJunkie/get_line/archive/v1.0.0.tar.gz +Exited with code 2 +Curl failed: "curl --another-args 3" exited with code 2 <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> @@ -88,9 +90,11 @@ The following actions will be performed: <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> Processing 1/1: [foo.1: http] + curl "--another-args" "3" -[ERROR] Failed to get sources of foo.1: curl error code ***The curl is a lie*** [args: --another-args 3] +[ERROR] Failed to get sources of foo.1: curl failure -OpamSolution.Fetch_fail("https://github.com/UnixJunkie/get_line/archive/v1.0.0.tar.gz (curl: code ***The curl is a lie*** [args: --another-args 3] while downloading https://github.com/UnixJunkie/get_line/archive/v1.0.0.tar.gz)") +curl failure while downloading https://github.com/UnixJunkie/get_line/archive/v1.0.0.tar.gz +Exited with code 0 +Returned code ***The curl is a lie*** [args: --another-args 3] <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> @@ -108,9 +112,11 @@ The following actions will be performed: <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> Processing 1/1: [foo.1: http] + curl "--write-out" "%{http_code}\n" "--retry" "3" "--retry-delay" "2" "--user-agent" "opam/current" "-L" "-o" "${BASEDIR}/OPAM/download/.opam-switch/sources/foo.1/v1.0.0.tar.gz.part" "--" "https://github.com/UnixJunkie/get_line/archive/v1.0.0.tar.gz" -[ERROR] Failed to get sources of foo.1: curl error code ***The curl is a lie*** [args: --write-out %{http_code}\n --retry 3 --retry-delay 2 --user-agent opam/current -L -o ${BASEDIR}/OPAM/download/.opam-switch/sources/foo.1/v1.0.0.tar.gz.part -- https://github.com/UnixJunkie/get_line/archive/v1.0.0.tar.gz] +[ERROR] Failed to get sources of foo.1: curl failure -OpamSolution.Fetch_fail("https://github.com/UnixJunkie/get_line/archive/v1.0.0.tar.gz (curl: code ***The curl is a lie*** [args: --write-out %{http_code}\n --retry 3 --retry-delay 2 --user-agent opam/current -L -o ${BASEDIR}/OPAM/download/.opam-switch/sources/foo.1/v1.0.0.tar.gz.part -- https://github.com/UnixJunkie/get_line/archive/v1.0.0.tar.gz] while downloading https://github.com/UnixJunkie/get_line/archive/v1.0.0.tar.gz)") +curl failure while downloading https://github.com/UnixJunkie/get_line/archive/v1.0.0.tar.gz +Exited with code 0 +Returned code ***The curl is a lie*** [args: --write-out %{http_code}\n --retry 3 --retry-delay 2 --user-agent opam/current -L -o ${BASEDIR}/OPAM/download/.opam-switch/sources/foo.1/v1.0.0.tar.gz.part -- https://github.com/UnixJunkie/get_line/archive/v1.0.0.tar.gz] <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> @@ -128,9 +134,11 @@ The following actions will be performed: <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> Processing 1/1: [foo.1: http] + curl "--another-args" "3" -[ERROR] Failed to get sources of foo.1: curl error code ***The curl is a lie*** [args: --another-args 3] +[ERROR] Failed to get sources of foo.1: curl failure -OpamSolution.Fetch_fail("https://github.com/UnixJunkie/get_line/archive/v1.0.0.tar.gz (curl: code ***The curl is a lie*** [args: --another-args 3] while downloading https://github.com/UnixJunkie/get_line/archive/v1.0.0.tar.gz)") +curl failure while downloading https://github.com/UnixJunkie/get_line/archive/v1.0.0.tar.gz +Exited with code 0 +Returned code ***The curl is a lie*** [args: --another-args 3] <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> diff --git a/tests/reftests/extrasource.test b/tests/reftests/extrasource.test index fa65a343d65..8905586218a 100644 --- a/tests/reftests/extrasource.test +++ b/tests/reftests/extrasource.test @@ -563,7 +563,7 @@ The following actions will be performed: got md5=hash [ERROR] Failed to get extra source "i-am-a-patch" of multiple-md5.1: Checksum mismatch -OpamSolution.Fetch_fail("Checksum mismatch") +Checksum mismatch <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> @@ -583,7 +583,7 @@ The following actions will be performed: got md5=hash [ERROR] Failed to get extra source "i-am-a-patch" of multiple-md5.1: Checksum mismatch -OpamSolution.Fetch_fail("Checksum mismatch") +Checksum mismatch <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> @@ -618,7 +618,7 @@ The following actions will be performed: got md5=hash [ERROR] Failed to get extra source "i-am-a-patch" of bad-md5.1: Checksum mismatch -OpamSolution.Fetch_fail("Checksum mismatch") +Checksum mismatch <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> @@ -638,7 +638,7 @@ The following actions will be performed: got md5=hash [ERROR] Failed to get extra source "i-am-a-patch" of bad-md5.1: Checksum mismatch -OpamSolution.Fetch_fail("Checksum mismatch") +Checksum mismatch <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> @@ -690,7 +690,7 @@ The following actions will be performed: got sha256=hash [ERROR] Failed to get extra source "i-am-a-patch" of good-md5-bad-sha256.1: Checksum mismatch -OpamSolution.Fetch_fail("Checksum mismatch") +Checksum mismatch <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> @@ -740,7 +740,7 @@ The following actions will be performed: got sha256=hash [ERROR] Failed to get extra source "i-am-a-patch" of good-md5-bad-sha256.1: Checksum mismatch -OpamSolution.Fetch_fail("Checksum mismatch") +Checksum mismatch <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> @@ -763,7 +763,7 @@ The following actions will be performed: got sha256=hash [ERROR] Failed to get extra source "i-am-a-patch" of good-md5-bad-sha256.1: Checksum mismatch -OpamSolution.Fetch_fail("Checksum mismatch") +Checksum mismatch <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> @@ -798,7 +798,7 @@ The following actions will be performed: got md5=hash [ERROR] Failed to get extra source "i-am-a-patch" of good-sha256-bad-md5.1: Checksum mismatch -OpamSolution.Fetch_fail("Checksum mismatch") +Checksum mismatch <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> @@ -818,7 +818,7 @@ The following actions will be performed: got md5=hash [ERROR] Failed to get extra source "i-am-a-patch" of good-sha256-bad-md5.1: Checksum mismatch -OpamSolution.Fetch_fail("Checksum mismatch") +Checksum mismatch <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> @@ -853,7 +853,7 @@ The following actions will be performed: got md5=hash [ERROR] Failed to get extra source "i-am-a-patch" of clash-with-all-md5s.666: Checksum mismatch -OpamSolution.Fetch_fail("Checksum mismatch") +Checksum mismatch <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> @@ -919,7 +919,7 @@ The following actions will be performed: got md5=hash [ERROR] Failed to get extra source "i-am-a-patch" of clash-with-all-md5s.666: Checksum mismatch -OpamSolution.Fetch_fail("Checksum mismatch") +Checksum mismatch <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> @@ -942,7 +942,7 @@ The following actions will be performed: got md5=hash [ERROR] Failed to get extra source "i-am-a-patch" of clash-with-all-md5s.666: Checksum mismatch -OpamSolution.Fetch_fail("Checksum mismatch") +Checksum mismatch <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> diff --git a/tests/reftests/shared-fetch.test b/tests/reftests/shared-fetch.test index 209d951612f..30bfde169c6 100644 --- a/tests/reftests/shared-fetch.test +++ b/tests/reftests/shared-fetch.test @@ -271,7 +271,7 @@ The following actions will be performed: [ERROR] Failed to get sources of extra.3, intra.3, no-extra.3, out.3 (file://${BASEDIR}/shared.tgz): Checksum mismatch -> installed in.3 -OpamSolution.Fetch_fail("Checksum mismatch") +Checksum mismatch <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> diff --git a/tests/reftests/swhid.unix.test b/tests/reftests/swhid.unix.test index 3b0d6ced65b..326e5241016 100644 --- a/tests/reftests/swhid.unix.test +++ b/tests/reftests/swhid.unix.test @@ -39,7 +39,7 @@ The following actions will be performed: <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] Failed to get sources of snappy-ko.2: Download command failed -OpamSolution.Fetch_fail("https://fake.exe/url.tar.gz (Download command failed: \"curl --write-out %{http_code}\\n --retry 3 --retry-delay 2 --user-agent opam/current -L -o ${BASEDIR}/OPAM/fallback/.opam-switch/sources/snappy-ko.2/url.tar.gz.part -- https://fake.exe/url.tar.gz\" exited with code 6)") +https://fake.exe/url.tar.gz (Download command failed: "curl --write-out %{http_code}\n --retry 3 --retry-delay 2 --user-agent opam/current -L -o ${BASEDIR}/OPAM/fallback/.opam-switch/sources/snappy-ko.2/url.tar.gz.part -- https://fake.exe/url.tar.gz" exited with code 6) <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> @@ -68,7 +68,7 @@ The following actions will be performed: Processing 1/3: [snappy-swhid-dir.2: http] [ERROR] Failed to get sources of snappy-swhid-dir.2: Download command failed -OpamSolution.Fetch_fail("https://fake.exe/url.tar.gz (Download command failed: \"curl --write-out %{http_code}\\n --retry 3 --retry-delay 2 --user-agent opam/current -L -o ${BASEDIR}/OPAM/fallback/.opam-switch/sources/snappy-swhid-dir.2/url.tar.gz.part -- https://fake.exe/url.tar.gz\" exited with code 6)") +https://fake.exe/url.tar.gz (Download command failed: "curl --write-out %{http_code}\n --retry 3 --retry-delay 2 --user-agent opam/current -L -o ${BASEDIR}/OPAM/fallback/.opam-switch/sources/snappy-swhid-dir.2/url.tar.gz.part -- https://fake.exe/url.tar.gz" exited with code 6) <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> @@ -132,7 +132,7 @@ The following actions will be performed: Source https://fake.exe/url.tar.gz is not available. Do you want to try to retrieve it from Software Heritage cache (https://www.softwareheritage.org)? It may take few minutes. [y/n] y [ERROR] Failed to get sources of snappy-swhid-ko.2: SWH fallback: Unknown swhid -OpamSolution.Fetch_fail("SWH fallback: Unknown swhid") +SWH fallback: Unknown swhid <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> @@ -152,7 +152,7 @@ The following actions will be performed: <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> [ERROR] Failed to get sources of snappy-swhid-ko.2: SWH fallback: no retrieval -OpamSolution.Fetch_fail("SWH fallback: Download tool permitting post request (wget and curl) not set as download tool") +SWH fallback: Download tool permitting post request (wget and curl) not set as download tool <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>