summaryrefslogtreecommitdiffstats
path: root/febootstrap_package_handlers.mli
blob: c28d81fac5a41f5f06d511a35fcdfaedd8a8538f (plain)
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
(* febootstrap 3
 * Copyright (C) 2009-2010 Red Hat Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 *)

(** Generic package handler code. *)

type package_handler = {
  ph_detect : unit -> bool;
  (** Detect if the current system uses this package manager. *)

  ph_resolve_dependencies_and_download : string list -> string list;
  (** [ph_resolve_dependencies_and_download pkgs]
      Take a list of package names, and using the package manager
      resolve those to a list of all the packages that are required
      including dependencies.  Download the full list of packages and
      dependencies into a tmpdir.  Return the list of full filenames.

      Note this should also process the [excludes] list. *)

  ph_list_files : string -> (string * file_type) list;
  (** [ph_list_files pkg] lists the files and file metadata in the
      package called [pkg] (a package file). *)

  ph_get_file_from_package : string -> string -> string;
  (** [ph_get_file_from_package pkg file] extracts the
      single named file [file] from [pkg].  The path of the
      extracted file is returned. *)
}

(* These file types are inspired by the metadata specifically
 * stored by RPM.  We should look at what other package formats
 * can use too.
 *)
and file_type = {
  ft_dir : bool;               (** Is a directory. *)
  ft_config : bool;            (** Is a configuration file. *)
  ft_ghost : bool;             (** Is a ghost (created empty) file. *)
  ft_mode : int;               (** File mode. *)
  ft_size : int;	       (** File size. *)
}

val register_package_handler : string -> package_handler -> unit
  (** Register a package handler. *)

val check_system : unit -> unit
  (** Check which package manager this system uses. *)

val get_package_handler : unit -> package_handler
  (** Get the selected package manager for this system. *)

val get_package_handler_name : unit -> string
  (** Get the name of the selected package manager for this system. *)