File: clflags.ml

package info (click to toggle)
ben 1.14
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 672 kB
  • sloc: ml: 4,116; sh: 345; javascript: 78; ansic: 39; makefile: 29; python: 18
file content (61 lines) | stat: -rw-r--r-- 2,907 bytes parent folder | download
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
(**************************************************************************)
(*  Copyright © 2009-2013 Stéphane Glondu <steph@glondu.net>              *)
(*            © 2010-2013 Mehdi Dogguy <mehdi@dogguy.org>                 *)
(*                                                                        *)
(*  This program is free software: you can redistribute it and/or modify  *)
(*  it under the terms of the GNU Affero General Public License as        *)
(*  published by the Free Software Foundation, either version 3 of the    *)
(*  License, or (at your option) any later version, with the additional   *)
(*  exemption that compiling, linking, and/or using OpenSSL is allowed.   *)
(*                                                                        *)
(*  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     *)
(*  Affero General Public License for more details.                       *)
(*                                                                        *)
(*  You should have received a copy of the GNU Affero General Public      *)
(*  License along with this program.  If not, see                         *)
(*  <http://www.gnu.org/licenses/>.                                       *)
(**************************************************************************)

open Ben.Core

let get_env_default var default = try Sys.getenv var with Not_found -> default
let show_version = ref false
let dry_run = ref false
let verbose = ref false
let cache_dir = ref (get_env_default "BEN_CACHE_DIR" (Sys.getcwd ()))
let cache_file = ref "ben.cache"
let use_cache = ref false
let use_benrc = ref true
let media_dir = ref (get_env_default "BEN_MEDIA_DIR" "/usr/share/ben/media")
let mirror_binaries = ref "http://deb.debian.org/debian"
let mirror_sources = ref "http://deb.debian.org/debian"
let mirror = mirror_binaries
let suite = ref "unstable"
let components = ref (None : string list option)
let preferred_compression_format = ref Ben.Compression.default
let quiet = ref false
let update = ref false

let get_config config key =
  try StringMap.find key config
  with Not_found -> Ben.Error.raise (Ben.Error.Missing_configuration_item key)

let set_cache_file name =
  let basename = Filename.basename name in
  if Filename.is_relative name then cache_file := name
  else
    let dirname = Filename.dirname name in
    cache_dir := dirname;
    cache_file := basename

let get_cache_file () = Filename.concat !cache_dir !cache_file
(* Let the system generate an error if the file is missing *)

let progress fmt =
  if !quiet then Printf.ifprintf stderr fmt
  else Printf.fprintf stderr (fmt ^^ "%!")

let debian_architectures = ref (None : string list option)
let ignored_architectures = ref ([] : string list)