(** This module implements various Debian standards pertaining to their repository, packages formats, version numbers, filenames, and so on. @author David S. Fox *) exception Missing_Packages_File of string exception Revision_Strip_Failed of string exception Bad_package_name of string exception Bad_package_data exception Parse_error of int exception Process_Killed of int exception Process_Stopped of int exception Process_Error of int (** {6 Temporary Directory} *) (** [tmpdir] returns the name of a temporary directory for unpacking debs, creating it if necessary. @return directory name *) val tmpdir : unit -> string (** [rmtmp] deletes the temporary directory created by tmpdir. *) val rmtmp : unit -> unit (** {2 Deb File Names} *) (** [evr_split version] splits the [version] number @return (epoch, version, revision) *) val evr_split : string -> string * string * string (** [evr_split ext version] finds the string [ext] in the [version] number and increments the number following it. if [ext] does not appear it is added with the number '1'. If there is no revision number a dash is added before [ext], if there is a '.' is added. @return incremented version *) val version_incr : string -> string -> string (** {2 Revision Strip} *) (** [revision_strip ext path] strips the string [ext] and any digits that follow it from the pathname [path]. If the remaining revision number is empty the "-" is stripped too. If there was a "." before [ext] that is removed as well: revision_strip "cnr" "package-3.5.cnr1_i386.deb" -> "package-3.5_i386.deb" *) val revision_strip : string -> string -> string (** These functions [version_strip], [debname_strip], [debpath_strip] apply [revision_strip] to a full version number, a filename, and a full pathname respectively. *) val debname_strip : string -> string -> string val version_strip : string -> string -> string val debpath_strip : string -> string -> string val debpath_join : string * string * string * string * string -> string val debpath_join2 : string * string * string * string * string -> string val debname_split2 : string -> string * string * string * string val debpath_split : string -> string * string * string * string * string val debpath_split2 : string -> string * string * string * string * string (** {2 Version Numbers} *) (** [version_compare v1 v2] returns an integer expressing the sign of the "difference" between the two version numbers - if v1 is less than (older than) v2 the result will be negative. *) val version_compare : string -> string -> int (* uses dpkg *) exception Bad_version_number module Version : sig val compare : string -> string -> int end val my_version_compare : string -> string -> int (* re-implementation *) (** {2 Control Filest} *) type control = (string * (string * string)) list type cmp = LT | LE | EQ | GE | GT type rel = Name of string | NameCmpVer of string * cmp * string | Alt of rel list | Conc of rel list | NoRel val canon : rel -> rel val parse_relation : ?arch:string -> string -> rel val maprel : (rel -> rel) -> rel -> rel val eq_to_ge : rel -> rel val eq_to_le : rel -> rel val eq_to_range : rel -> rel val string_of_rel : rel -> string val string_of_rel_debug : rel -> string val iter_rel : (string -> unit) -> rel -> unit val depfields : string list (* Fields to use parse_relation on *) (** Read a binary deb's control file and Create a Package index entry for it from that and its path. *) val make_package_index_entry : (* control poolroot filename *) control -> string -> string -> control val make_packages_entry : (* control poolroot filename *) control -> string -> string -> string val fix_category : string -> string (* Convert a Packages entry into a list of attribute, value pairs. *) val parse_control : Lexing.lexbuf -> control val parse_control_text : (string -> (string*string) -> unit) -> string -> unit val try_parse_control : string -> control val update_control : control -> control -> control val augment_control : control -> control -> control val format_control : control -> string val filter_control : string list -> control -> control val filter_from_control : string list -> control -> control (** {2 Changelog File} *) (** type changelog_entry = string * string * string list * string * string * string * string *) type changelog_entry = { name: string; version: string; distribs: string list; urgency: string; text: string; uploader: string; date: string} val parse_changelog : Lexing.lexbuf -> changelog_entry (** {2 Deb Building} *) type rulespec = Clean of (changelog_entry -> unit) | Build of (changelog_entry -> unit) | Install of string * (string -> changelog_entry -> unit) val rules : rulespec list -> unit (** {2 Repository} *) (* (section, [arch1; arch2 ...]) *) type section = string * string list (* (pool, dist, [section1; section2 ...]) *) type source = string * string * section list (** {2 New Source Types} *) type n_sourcetype = BINARY | SOURCE type n_source = {typ : n_sourcetype; root : string; dist : string; sects: string list} (**************************************************) (* call (f pool dist sections) for each dist in sources. A dist corresponds to a line in the sources.list file. *) val iter_dists_of_sources : (string * string * section list -> unit) -> source list -> unit val map_dists_of_sources : (string * string * section list -> 'd) -> source list -> 'd list val iter_sections_of_sources : (string * string * string * string list -> unit) -> source list -> unit val map_sections_of_sources : (string * string * string * string list -> 'e) -> source list -> 'e list val iter_architectures_of_sources : (string * string * string * string -> unit) -> source list -> unit val map_architectures_of_sources : (string * string * string * string -> 'e) -> source list -> 'e list val iter_binary_indexes_of_sources : (string * string * string * string * string -> unit) -> source list -> unit val map_binary_indexes_of_sources : (string * string * string * string * string -> 'a) -> source list -> 'a list val iter_packages_of_index : (control -> unit) -> Lexing.lexbuf -> unit val map_packages_of_index : (control -> 'a) -> Lexing.lexbuf -> 'a list (* for_all_packages f root sources, calls (f pool dist dir text) *) val iter_packages_of_sources_old : (string * string * string * string * string * control -> unit) -> string -> source list -> unit val iter_packages_of_sources : (string * string * string * string * string * control -> unit) -> source list -> unit val iter_source_packages_of_sources_old : (string * string * string * string * control -> unit) -> string -> source list -> unit val iter_source_packages_of_sources : (string * string * string * string * control -> unit) -> source list -> unit (* [find_dists root] returns a list of dist names *) val find_dists : string -> string list (* [find_sources root dist archlist] -> source list *) val find_sources_old : string -> string -> string list -> source list (* [find_sources root dist archlist] -> source list *) val find_sources_new : string -> string -> string list -> source list (* [iter_sources distf sectf archf sources] calls (distf pool dist) for each dist, (sectf pool dist sect) for each section, (archf pool dist sect arch) for each architecture. *) val iter_sources : (string -> string -> unit) -> (string -> string -> string -> string -> unit) -> (string -> string -> string -> string -> string -> unit) -> source list -> unit (** {2 Operations on Debs} *) exception Unpack_failure of string val unpack : string -> string list