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.debian/sources.ml.html
Source file sources.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 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435
(**************************************************************************************) (* Copyright (C) 2009 Pietro Abate <pietro.abate@pps.jussieu.fr> *) (* Copyright (C) 2009 Mancoosi Project *) (* *) (* 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. *) (**************************************************************************************) (** Representation of a parsed source description item. all fields are string *) open ExtLib open Dose_common include Util.Logging (struct let label = "dose_deb.sources" end) class source ?(name = ("Package", None)) ?(version = ("Version", None)) ?(architecture = ("Architecture", None)) ?(build_depends = ("Build-Depends", None)) ?(build_depends_indep = ("Build-Depends-Indep", None)) ?(build_depends_arch = ("Build-Depends-Arch", None)) ?(build_conflicts = ("Build-Conflicts", None)) ?(build_conflicts_indep = ("Build-Conflicts-Indep", None)) ?(build_conflicts_arch = ("Build-Conflicts-Arch", None)) par = object val name : string * Dose_pef.Packages_types.name = let f = Dose_pef.Packages.parse_s ~required:true Dose_pef.Packages.parse_name in Dose_pef.Packages.get_field_value ~parse:f ~par ~field:name val version : string * Dose_pef.Packages_types.version = let f = Dose_pef.Packages.parse_s ~required:true Dose_pef.Packages.parse_version in Dose_pef.Packages.get_field_value ~parse:f ~par ~field:version val architecture : string * Dose_pef.Packages_types.architecture list = let f = Dose_pef.Packages.parse_s ~required:true Dose_pef.Packages.parse_archlist in Dose_pef.Packages.get_field_value ~parse:f ~par ~field:architecture val build_depends : string * Dose_pef.Packages_types.builddepsformula = let f = Dose_pef.Packages.parse_s ~default:[] Dose_pef.Packages.parse_builddepsformula in Dose_pef.Packages.get_field_value ~parse:f ~par ~field:build_depends val build_depends_indep : string * Dose_pef.Packages_types.builddepsformula = let f = Dose_pef.Packages.parse_s ~default:[] Dose_pef.Packages.parse_builddepsformula in Dose_pef.Packages.get_field_value ~parse:f ~par ~field:build_depends_indep val build_depends_arch : string * Dose_pef.Packages_types.builddepsformula = let f = Dose_pef.Packages.parse_s ~default:[] Dose_pef.Packages.parse_builddepsformula in Dose_pef.Packages.get_field_value ~parse:f ~par ~field:build_depends_arch val build_conflicts : string * Dose_pef.Packages_types.builddepslist = let f = Dose_pef.Packages.parse_s ~default:[] Dose_pef.Packages.parse_builddepslist in Dose_pef.Packages.get_field_value ~parse:f ~par ~field:build_conflicts val build_conflicts_indep : string * Dose_pef.Packages_types.builddepslist = let f = Dose_pef.Packages.parse_s ~default:[] Dose_pef.Packages.parse_builddepslist in Dose_pef.Packages.get_field_value ~parse:f ~par ~field:build_conflicts_indep val build_conflicts_arch : string * Dose_pef.Packages_types.builddepslist = let f = Dose_pef.Packages.parse_s ~default:[] Dose_pef.Packages.parse_builddepslist in Dose_pef.Packages.get_field_value ~parse:f ~par ~field:build_conflicts_arch method name = snd name method version = snd version method architecture = snd architecture method build_depends = snd build_depends method build_depends_indep = snd build_depends_indep method build_depends_arch = snd build_depends_arch method build_conflicts = snd build_conflicts method build_conflicts_indep = snd build_conflicts_indep method build_conflicts_arch = snd build_conflicts_arch method pp oc = Dose_pef.Printer.pp_string_wl oc name ; Dose_pef.Printer.pp_string_wl oc version ; Dose_pef.Printer.pp_string_list_wl ~sep:" " oc architecture ; Dose_pef.Printer.pp_builddepformula_wl oc build_depends ; Dose_pef.Printer.pp_builddeplist_wl oc build_conflicts ; Dose_pef.Printer.pp_builddepformula_wl oc build_depends_indep ; Dose_pef.Printer.pp_builddeplist_wl oc build_conflicts_indep ; Dose_pef.Printer.pp_builddepformula_wl oc build_depends_arch ; Dose_pef.Printer.pp_builddeplist_wl oc build_conflicts_arch ; Printf.fprintf oc "\n" end (* Relationships between source and binary packages * http://www.debian.org/doc/debian-policy/ch-relationships.html * Build-Depends, Build-Depends-Indep, Build-Conflicts, Build-Conflicts-Indep *) let parse_package_stanza filter buildarchlist par = let p () = let pkg = new source par in let matchsource sourcearchlist buildarchlist = List.exists (fun arch -> List.exists (fun source -> Architecture.src_matches_arch source arch) sourcearchlist) buildarchlist in let sourcearchlist = pkg#architecture in if buildarchlist = [] then pkg else if matchsource sourcearchlist buildarchlist then pkg else raise (Dose_pef.Packages.IgnorePackage "Source Architecture Mismatch") in try if Option.is_none filter then Some (p ()) else if (Option.get filter) par then Some (p ()) else None with | Dose_pef.Packages.IgnorePackage s -> let n = Dose_pef.Packages.parse_s ~default:"?" Dose_pef.Packages.parse_name "Package" par in let v = Dose_pef.Packages.parse_s ~default:"?" Dose_pef.Packages.parse_version "Version" par in let a = Dose_pef.Packages.parse_s ~default:"?" Dose_pef.Packages.parse_string "Architecture" par in debug "Ignoring Source Package (%s,%s,%s) : %s" n v a s ; None | Format822.ParseError (cl, f, err) -> let n = Dose_pef.Packages.parse_s ~default:"?" Dose_pef.Packages.parse_name "Package" par in let v = Dose_pef.Packages.parse_s ~default:"?" Dose_pef.Packages.parse_version "Version" par in let a = Dose_pef.Packages.parse_s ~default:"?" Dose_pef.Packages.parse_string "Architecture" par in let c = Printf.sprintf "Parser Error in Source Package (%s,%s,%s)" n v a in raise (Format822.ParseError (c :: cl, f, err)) (** parse a debian Sources file from channel *) let parse_sources_in ?filter ?(archs = []) fname ic = info "Parsing Sources file %s..." fname ; let stanza_parser = parse_package_stanza filter archs in Format822.parse_from_ch (Dose_pef.Packages.packages_parser fname stanza_parser) ic (** parse a debian Sources file. [~archs] determines which which architectures should be considered while parsing the Souces file. if ~arch is [] then all archs are cosidered *) let input_raw ?filter ?(archs = []) = let module Set = Set.Make (struct type t = source let compare = compare end) in let module M = Format822.RawInput (Set) in M.input_raw (parse_sources_in ?filter ~archs) let sep = ":" (* as per policy, if the first arch restriction contains a ! * then we assume that all archs on the lists are bang-ed. * cf: http://www.debian.org/doc/debian-policy/ch-relationships.html 7.1 *) let matcharch hostarch = function | [] -> true | (true, _) :: _ as al -> List.exists (fun (_, a) -> Architecture.src_matches_arch a hostarch) al | (false, _) :: _ as al -> List.for_all (fun (_, a) -> not (Architecture.src_matches_arch a hostarch)) al (* the nested build profiles formula is given in disjunctive normal form *) let matchprofile profiles = function | [] -> true | ll -> List.exists (List.for_all (fun (c, p) -> c = List.mem p profiles)) ll (* given archs, profile and a dependency with an architecture and profile list, * decide whether to select or drop that dependency *) let select hostarch profiles (v, al, pl) = if matcharch hostarch al && matchprofile profiles pl then Some v else None (* XXX src2pkg could be skip using the same trick we use in opam, * where dependencies are giltered at parsing time *) (* the package name is encodes as src:<package-name> *) let src2pkg ?(dropalternatives = false) ?(profiles = []) ?(noindep = false) ?(noarch = false) ?(src = "src") buildarch hostarch srcpkg = let conflicts l = List.filter_map (select hostarch profiles) l in (* imitate sbuild behaviour and drop all alternatives except those that have * the same name as the first. Search for RESOLVE_ALTERNATIVES in * lib/Sbuild/ResolverBase.pm in the sbuild sources *) let dropalt l = match l with | [] -> [] | [p] -> [p] | hd :: _ -> List.filter (fun p -> fst p = fst hd) l in let depends ll = List.filter_map (fun l -> match List.filter_map (select hostarch profiles) l with | [] -> None | l -> Some (if dropalternatives then dropalt l else l)) ll in let extras_profiles = match profiles with | [] -> [] | _ -> [("profiles", String.join " " profiles)] in let depends_indep = if noindep then [] else srcpkg#build_depends_indep in let conflicts_indep = if noindep then [] else srcpkg#build_conflicts_indep in let depends_arch = if noarch then [] else srcpkg#build_depends_arch in let conflicts_arch = if noarch then [] else srcpkg#build_conflicts_arch in (* when crossbuilding (host != build), implicitly depend on build-essential * and crossbuild-essential-$hostarch. When compiling natively, implicitly * depend on build-essential *) let build_essential = if buildarch <> hostarch then [ [(("build-essential", Some buildarch), None)]; [(("crossbuild-essential-" ^ hostarch, Some buildarch), None)] ] else [[(("build-essential", Some buildarch), None)]] in new Packages.package ~name:("", Some (src ^ sep ^ srcpkg#name)) ~version:("", Some srcpkg#version) ~architecture:("", Some (String.concat "," srcpkg#architecture)) ~source:("", Some (srcpkg#name, Some srcpkg#version)) ~depends: ( "", Some (build_essential @ depends (depends_indep @ srcpkg#build_depends @ depends_arch)) ) ~conflicts: ( "", Some (conflicts (conflicts_indep @ srcpkg#build_conflicts @ conflicts_arch)) ) ~extras:([], Some (extras_profiles @ [("Type", src)])) [] (* given archs, profile and a dependency with an architecture and profile list, * decide whether to select or drop that dependency *) (** transform a list of sources packages into dummy binary packages. * This function preserve the order *) let sources2packages ?(dropalternatives = false) ?(profiles = []) ?(noindep = false) ?(noarch = false) ?(src = "src") buildarch hostarch = List.map (src2pkg ~dropalternatives ~profiles ~noindep ~noarch ~src buildarch hostarch) (** Check if a package is of "Type" source as encoded by the function sources2packages *) let is_source ?(src = "src") pkg = List.mem ("Type", src) pkg#extras exception MismatchSrc of Cudf.package list exception NotfoundSrc (** [get_src_package universe binpkg] returns the source package associate with the given binary package. precondition : the package has "type" bin and the universe contains packages of "type" src encoded with sources2packages. Raise MismatchSrc if there exists a source package with the same name but with a different version . Raise NotfoundSrc if the univese does not contain either a source package associated with the binary package or a source package with the same name but different version. *) let get_src_package universe binpkg = let sn = CudfAdd.encode ("src:" ^ CudfAdd.get_property "source" binpkg) in let sv = int_of_string (CudfAdd.get_property "sourceversion" binpkg) in try Cudf.lookup_package universe (sn, sv) with Not_found -> ( let name = CudfAdd.decode sn in let number = CudfAdd.get_property "sourcenumber" binpkg in match Cudf.lookup_packages universe sn with | [] -> debug "Cannot find source package %s %s associated to the binary package %s" name number (CudfAdd.string_of_package binpkg) ; raise NotfoundSrc | othersl -> let othersrcnumbers = List.map (fun othersrc -> CudfAdd.get_property "number" othersrc) othersl in debug "Cannot find source package %s %s associated to the binary package %s" name number (CudfAdd.string_of_package binpkg) ; debug "There exist other versions (%s) of the source package %s in the \ repository" (String.concat " , " othersrcnumbers) name ; raise (MismatchSrc othersl)) (** Returns an hash table that associates source packages (encoded by the function sources2packages) to binary packages in the universe. It is possible that a source package is not associated with any binary packages. *) let srcbin_table universe = let h = CudfAdd.Cudf_hashtbl.create (Cudf.universe_size universe) in let aux binpkg = if CudfAdd.get_property "type" binpkg = "bin" then try let srcpkg = get_src_package universe binpkg in try let l = CudfAdd.Cudf_hashtbl.find h srcpkg in l := binpkg :: !l with Not_found -> CudfAdd.Cudf_hashtbl.add h srcpkg (ref [binpkg]) with | NotfoundSrc -> () (* this binary is not associated to any src *) | MismatchSrc sl -> (* we add the src to the table, but we do not associate to any binary *) List.iter (fun srcpkg -> if not (CudfAdd.Cudf_hashtbl.mem h srcpkg) then CudfAdd.Cudf_hashtbl.add h srcpkg (ref [])) sl in Cudf.iter_packages aux universe ; h (** Returns the list of binary packages associated to a package of "Type" source encoded by the function sources2packages. The table h associated each source with a list of binaries *) let get_bin_packages h srcpkg = try !(CudfAdd.Cudf_hashtbl.find h srcpkg) with Not_found -> let sn = CudfAdd.decode srcpkg.Cudf.package in let sv = CudfAdd.get_property "number" srcpkg in debug "Source package %s %s not associated with any binary package" sn sv ; raise Not_found (** Returns the set of binary packages generated by the packages in srclist. The function get_bin_packages gets a source package and returns the set of packages associated to it. If the source package is not known, then it is ignored. *) let binset get_bin_packages srclist = List.fold_left (fun acc srcpkg -> try CudfAdd.Cudf_set.union acc (CudfAdd.to_set (get_bin_packages srcpkg)) with Not_found -> acc) CudfAdd.Cudf_set.empty srclist
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>