package dose3
Dose library (part of Mancoosi tools)
Install
Dune Dependency
Authors
Maintainers
Sources
dose3-6.1.tar.gz
md5=dedc2f58f2c2b59021f484abc6681d93
sha512=603462645bac190892a816ecb36ef7b9c52f0020f8d7710dc430e2db65122090fdedb24a8d2e03c32bf53a96515f5b51499603b839680d0a7a2146d6e0fb6e34
doc/src/dose3.doseparse/stdUtils.ml.html
Source file stdUtils.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
(**************************************************************************) (* This file is part of a library developed with the support of the *) (* Mancoosi Project. http://www.mancoosi.org *) (* *) (* Main author(s): Pietro Abate *) (* *) (* This library is free software: you can redistribute it and/or modify *) (* it under the terms of the GNU Lesser General Public License as *) (* published by the Free Software Foundation, either version 3 of the *) (* License, or (at your option) any later version. A special linking *) (* exception to the GNU Lesser General Public License applies to this *) (* library, see the COPYING file for more information. *) (**************************************************************************) open ExtLib open Dose_common include Util.Logging (struct let label = "doseparse.stdutils" end) let get_architectures native_edsp foreign_edsp native_opt foreign_opt = let cmd = "apt-config dump" in let arch = ref None in let archs = ref [] in let aux () = let out = Std.input_list (Unix.open_process_in cmd) in List.iter (fun s -> let (key, value) = ExtString.String.split s " " in if key = "APT::Architecture" then arch := Some (ExtString.String.slice ~first:1 ~last:(-2) value) else if key = "APT::Architectures::" || key = "APT::Architectures" then let s = ExtString.String.slice ~first:1 ~last:(-2) value in if s <> "" then archs := ExtString.String.slice ~first:1 ~last:(-2) value :: !archs) out ; debug "Automatically set native as %s and foreign archs as %s" (Option.get !arch) (String.concat "," !archs) in let (na, fa) = match ((native_edsp, foreign_edsp), (native_opt, foreign_opt)) with | ((None, []), (None, None)) -> aux () ; (!arch, List.filter (( <> ) (Option.get !arch)) !archs) (* EDSP 0.4 + no options *) | ((_, l), (Some a, None)) -> (Some a, l) (* EDSP 0.5 + overrride options *) | ((Some a, _), (None, Some l)) -> (Some a, l) (* EDSP 0.5 + overrride options *) | ((_, _), (Some a, Some l)) -> (Some a, l) (* EDSP 0.5 / 0.4 + overrride options *) | ((Some a, l), (None, None)) -> (Some a, l) (* EDSP 0.5 + no options *) | ((None, []), (None, _)) -> fatal "Native arch is missing while Foregin archs are specified" | (_, _) -> fatal "Unable to compute native and foreign arch information" in (match (na, fa) with | (Some a, l) when (native_edsp, foreign_edsp) = (None, []) || (native_edsp, foreign_edsp) = (Some a, l) -> notice "Setting Native Architecture to %s and Foreign Architectures to %s" a (String.concat "," l) | (Some a, l) -> info "Overriding EDSP. Setting Native Architecture to %s and Foreign \ Architectures to %s" a (String.concat "," l) | _ -> fatal "Error Setting Native Architecture") ; (na, fa) let pp_versions_table fmt (from_cudf, pkglist) = List.iter (fun pkg -> let (p, v) = from_cudf (pkg.Cudf.package, pkg.Cudf.version) in Format.fprintf fmt "%s=%d=%s@." p pkg.Cudf.version v) pkglist (* exit code policy : Exit codes 0-63 indicate a normal termination of the program, codes 64-127 indicate abnormal termination of the program (such as parse errors, I/O errors). In case of normal program termination: - exit code 0 indicates that all foreground packages are found installable; - exit code 1 indicates that at least one foreground package is found uninstallable. *) let if_application ?(alternatives = []) filename main = let normalize f = let bf = Filename.basename f in try if String.ends_with bf ".d.byte" then String.slice ~last:(String.find bf ".d.byte") bf else if String.ends_with bf ".p.native" then String.slice ~last:(String.find bf ".p.native") bf else Filename.chop_extension bf with Invalid_argument _ -> bf in let names = List.map normalize (filename :: alternatives) in let invoked_as = normalize Sys.argv.(0) in if List.exists (( = ) invoked_as) names then ( try if main () = 0 then exit 0 else exit 1 with | Unix.Unix_error (err, _, arg) -> Printf.eprintf "%s %s" (Unix.error_message err) arg ; Stdlib.exit 64 | exn -> Printexc.print_backtrace stderr ; Printf.eprintf "The applications raised this exception : " ; Printf.eprintf "%s\n" (Printexc.to_string exn) ; Stdlib.exit 64) else ( Printf.eprintf "you are using %s as a module and not as an executable\n" Sys.argv.(0) ; Printf.eprintf "%s can be run as an exactable if named : %s\n" Sys.argv.(0) (ExtString.String.join " , " names))
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>