[Pkg-ocaml-maint-commits] [SCM] approx upstream and debian packaging branch, upstream, updated. upstream/3.5-46-gd97ea77
Eric Cooper
ecc at cmu.edu
Wed Jul 14 03:09:58 UTC 2010
The following commit has been merged in the upstream branch:
commit 233ecea0618cdde07db80204d94d779e234d1aae
Author: Eric Cooper <ecc at cmu.edu>
Date: Thu Jun 24 18:12:15 2010 -0400
support multiple config files and alternate cache location
closes: #519497, #580663
diff --git a/config.ml b/config.ml
index 5ee4d69..eb37644 100644
--- a/config.ml
+++ b/config.ml
@@ -5,11 +5,34 @@
open Config_file
open Util
-let version = "4.3"
+let version = "4.4"
-let config_file = "/etc/approx/approx.conf"
+let default_config = "/etc/approx/approx.conf"
-let cache_dir = "/var/cache/approx"
+let extract_config_files () =
+ let rec loop configs args = function
+ | "-c" :: f :: rest | "--config" :: f :: rest ->
+ loop (f :: configs) args rest
+ | x :: rest ->
+ loop configs (x :: args) rest
+ | [] -> List.rev configs, List.rev args
+ in
+ loop [default_config] [] (List.tl (Array.to_list Sys.argv))
+
+let config_files, arguments = extract_config_files ()
+
+let server_config =
+ ["version", version;
+ "host", Unix.gethostname ();
+ "config", String.concat " " config_files]
+
+let () =
+ List.iter (fun file -> try read file with Sys_error _ -> ()) config_files
+
+let params = []
+
+let cache_dir = get "$cache" ~default: "/var/cache/approx"
+let params = ("$cache", cache_dir) :: params
let split_cache_path path =
if is_prefix cache_dir path then
@@ -25,47 +48,60 @@ let shorten path =
else
path
-let () = try read config_file with Sys_error _ -> ()
-
let max_rate = get "$max_rate" ~default: "unlimited"
+let params = ("$max_rate", max_rate) :: params
+
let max_redirects = get_int "$max_redirects" ~default: 5
+let params = ("$max_redirects", string_of_int max_redirects) :: params
let user = get "$user" ~default: "approx"
+let params = ("$user", user) :: params
+
let group = get "$group" ~default: "approx"
+let params = ("$group", group) :: params
+
let syslog = get "$syslog" ~default: "daemon"
+let params = ("$syslog", syslog) :: params
let pdiffs = get_bool "$pdiffs" ~default: true
+let params = ("$pdiffs", string_of_bool pdiffs) :: params
+
let offline = get_bool "$offline" ~default: false
+let params = ("$offline", string_of_bool offline) :: params
+
let max_wait = get_int "$max_wait" ~default: 10 (* seconds *)
+let params = ("$max_wait", string_of_int max_wait) :: params
let debug = get_bool "$debug" ~default: false
-let verbose = get_bool "$verbose" ~default: false || debug
+let params = ("$debug", string_of_bool debug) :: params
-let collect k v (r, s) =
- if k.[0] = '$' then r, (k, v) :: s
- else (k, v) :: r, s
+let verbose = get_bool "$verbose" ~default: false || debug
+let params = ("$verbose", string_of_bool verbose) :: params
-let repositories, parameters = fold collect ([], [])
+let repos = fold (fun k v l -> if k.[0] <> '$' then (k, v) :: l else l) []
let sort_config = List.sort (fun x y -> compare (fst x) (fst y))
-let repository_table =
- String.concat "\n"
+let section str =
+ "<tr><td colspan=\"2\"><h2>" ^ str ^ "</h2></td></tr>\n"
+
+let repository_table items =
+ String.concat ""
(List.map
(fun (k, v) ->
"<tr><td>" ^ k ^ "</td>\
- <td><a href=\"" ^ v ^ "\">" ^ v ^ "</a></td></tr>")
- (sort_config repositories))
+ <td><a href=\"" ^ v ^ "\">" ^ v ^ "</a></td></tr>\n")
+ (sort_config items))
-let parameter_table =
- String.concat "\n"
+let parameter_table items =
+ String.concat ""
(List.map
- (fun (k, v) -> "<tr><td>" ^ k ^ "</td><td>" ^ v ^ "</td></tr>")
- (sort_config parameters))
+ (fun (k, v) -> "<tr><td>" ^ k ^ "</td><td>" ^ v ^ "</td></tr>\n")
+ (sort_config items))
let css =
- "body { margin: 12pt }\n\
- td { padding-left: 12pt }\n\
+ "body { margin: 24pt }\n\
+ td { padding-right: 18pt }\n\
td h2 { padding-top: 18pt }\n"
let index =
@@ -73,16 +109,14 @@ let index =
<head>\n\
<title>approx server</title>\n\
<style type=\"text/css\">\n" ^
- css ^
+ css ^
"</style>\n\
</head>\n\
<body>\n\
- <h1>approx " ^ version ^ "</h1>\n\
- <table>\n\
- <tr><td colspan=\"2\"><h2>Repository Mappings</h2></td></tr>\n" ^
- repository_table ^
- "<tr><td colspan=\"2\"><h2>Configuration Parameters</h2></td></tr>\n" ^
- parameter_table ^
+ <table>\n" ^
+ section "approx server" ^ parameter_table server_config ^
+ section "Repository Mappings" ^ repository_table repos ^
+ section "Configuration Parameters" ^ parameter_table params ^
"</table>\n\
</body>\n\
</html>"
diff --git a/config.mli b/config.mli
index b71e24d..6856f56 100644
--- a/config.mli
+++ b/config.mli
@@ -3,19 +3,10 @@
Released under the GNU General Public License *)
val version : string
-val config_file : string
-val cache_dir : string
-(* Extract the distribution and relative filename
- from the absolute pathname of a file in the cache.
- Example: split_pathname "/var/cache/approx/debian/pool/main/..."
- returns ("debian", "pool/main/...") *)
+val arguments : string list (* without config file args *)
-val split_cache_path : string -> string * string
-
-(* Remove cache directory prefix from a pathname, if present *)
-
-val shorten : string -> string
+val cache_dir : string
val max_rate : string (* bytes/second with optional K, M, or G suffix *)
val max_redirects : int
@@ -31,7 +22,15 @@ val max_wait : int (* seconds *)
val verbose : bool
val debug : bool
-(* A simple HTML index for the server,
- listing the repository mappings and configuration parameters *)
+val index : string (* simple HTML index for the server *)
-val index : string
+(* Extract the distribution and relative filename
+ from the absolute pathname of a file in the cache.
+ Example: split_pathname "/var/cache/approx/debian/pool/main/..."
+ returns ("debian", "pool/main/...") *)
+
+val split_cache_path : string -> string * string
+
+(* Remove cache directory prefix from a pathname, if present *)
+
+val shorten : string -> string
diff --git a/doc/FAQ b/doc/FAQ
index 797cfe5..de6f3a5 100644
--- a/doc/FAQ
+++ b/doc/FAQ
@@ -1,15 +1,3 @@
-Changing the location of the approx cache
-
- Move your cache where you want it, then
- replace the /var/cache/approx directory by a symlink:
-
- mv /var/cache/approx /somewhere
- ln -s /somewhere/approx /var/cache/approx
-
- You should use a subdirectory for the cache, not a top-level
- filesystem with a lost+found directory in it, to avoid complaints from
- the approx-gc program.
-
Changing the temporary directory used by approx
The TMPDIR environment variable can be used to specify the temporary
@@ -19,8 +7,9 @@ Changing the temporary directory used by approx
Exporting a local package repository
This is supported with file URLs. Note that the syntax for file URLs
- requires 3 leading slashes (two for the URL syntax, and one for the root
- of the pathname). So you can add something like this to /etc/approx.conf:
+ requires 3 leading slashes (two for the URL syntax, and one for
+ the root of the pathname). So you can add something like this
+ to /etc/approx/approx.conf:
local file:///my/local/repo
diff --git a/doc/approx-gc.8 b/doc/approx-gc.8
index 7b189b7..0ad30b7 100644
--- a/doc/approx-gc.8
+++ b/doc/approx-gc.8
@@ -1,8 +1,8 @@
.\" approx: proxy server for Debian archive files
-.\" Copyright (C) 2009 Eric C. Cooper <ecc at cmu.edu>
+.\" Copyright (C) 2010 Eric C. Cooper <ecc at cmu.edu>
.\" Released under the GNU General Public License
.\" -*- nroff -*-
-.TH APPROX-GC 8 "March 2009"
+.TH APPROX-GC 8 "June 2010"
.\" Please adjust this date whenever revising the manpage.
.SH NAME
@@ -40,6 +40,10 @@ may take several minutes to finish.
.SH OPTIONS
.TP
+.BR \-c " file, " \-\^\-config " file"
+Specify an additional configuration file.
+May be used multiple times.
+.TP
.BR \-f ", " \-\^\-fast
Don't perform checksum validation.
.TP
@@ -77,7 +81,7 @@ and related programs.
.TP
.I /var/cache/approx
.br
-Cache directory for archive files.
+Default cache directory for archive files.
.SH SEE ALSO
.IR approx.conf (5),
diff --git a/doc/approx-import.8 b/doc/approx-import.8
index 1447725..eaf602b 100644
--- a/doc/approx-import.8
+++ b/doc/approx-import.8
@@ -1,8 +1,8 @@
.\" approx: proxy server for Debian archive files
-.\" Copyright (C) 2009 Eric C. Cooper <ecc at cmu.edu>
+.\" Copyright (C) 2010 Eric C. Cooper <ecc at cmu.edu>
.\" Released under the GNU General Public License
.\" -*- nroff -*-
-.TH APPROX-IMPORT 8 "March 2009"
+.TH APPROX-IMPORT 8 "June 2010"
.\" Please adjust this date whenever revising the manpage.
.SH NAME
@@ -43,6 +43,9 @@ user.
.SH OPTIONS
.TP
+.BR \-c " file, " \-\^\-config " file"
+Specify an additional configuration file.
+May be used multiple times.
.TP
.BR \-s ", " \-\^\-simulate
Process files but do not actually copy them into the cache.
@@ -79,7 +82,7 @@ and related programs.
.TP
.I /var/cache/approx
.br
-Cache directory for archive files.
+Default cache directory for archive files.
.SH SEE ALSO
.IR approx.conf (5),
diff --git a/doc/approx-update.8 b/doc/approx-update.8
index 10e13cc..c2ee105 100644
--- a/doc/approx-update.8
+++ b/doc/approx-update.8
@@ -1,8 +1,8 @@
.\" approx: proxy server for Debian archive files
-.\" Copyright (C) 2009 Eric C. Cooper <ecc at cmu.edu>
+.\" Copyright (C) 2010 Eric C. Cooper <ecc at cmu.edu>
.\" Released under the GNU General Public License
.\" -*- nroff -*-
-.TH APPROX-UPDATE 8 "March 2009"
+.TH APPROX-UPDATE 8 "June 2010"
.\" Please adjust this date whenever revising the manpage.
.SH NAME
@@ -22,6 +22,10 @@ cache by downloading and applying pdiffs.
.SH OPTIONS
.TP
+.BR \-c " file, " \-\^\-config " file"
+Specify an additional configuration file.
+May be used multiple times.
+.TP
.BR \-k ", " \-\^\-keep ", " \-s ", " \-\^\-simulate
Don't download, update, or remove any files in the cache.
.TP
@@ -57,7 +61,7 @@ and related programs.
.TP
.I /var/cache/approx
.br
-Cache directory for archive files.
+Default cache directory for archive files.
.SH SEE ALSO
.IR approx.conf (5),
diff --git a/doc/approx.8 b/doc/approx.8
index e040970..bd03324 100644
--- a/doc/approx.8
+++ b/doc/approx.8
@@ -1,8 +1,8 @@
.\" approx: proxy server for Debian archive files
-.\" Copyright (C) 2009 Eric C. Cooper <ecc at cmu.edu>
+.\" Copyright (C) 2010 Eric C. Cooper <ecc at cmu.edu>
.\" Released under the GNU General Public License
.\" -*- nroff -*-
-.TH APPROX 8 "March 2009"
+.TH APPROX 8 "June 2010"
.\" Please adjust this date whenever revising the manpage.
.SH NAME
@@ -11,6 +11,7 @@ approx \- proxy server for Debian archive files
.SH SYNOPSIS
.PP
.B approx
+[\fIOPTION\fP]...
.SH DESCRIPTION
.B approx
@@ -30,6 +31,12 @@ Debian packages. The
.BR approx-gc (8)
program removes these from the cache.
+.SH OPTIONS
+.TP
+.BR \-c " file, " \-\^\-config " file"
+Specify an additional configuration file.
+May be used multiple times.
+
.SH USAGE
.PP
.B approx
@@ -103,7 +110,7 @@ and related programs.
.TP
.I /var/cache/approx
.br
-Cache directory for archive files.
+Default cache directory for archive files.
.SH SEE ALSO
.IR approx.conf (5),
diff --git a/doc/approx.conf.5 b/doc/approx.conf.5
index 1523b87..dd8ec70 100644
--- a/doc/approx.conf.5
+++ b/doc/approx.conf.5
@@ -1,8 +1,8 @@
.\" approx: proxy server for Debian archive files
-.\" Copyright (C) 2009 Eric C. Cooper <ecc at cmu.edu>
+.\" Copyright (C) 2010 Eric C. Cooper <ecc at cmu.edu>
.\" Released under the GNU General Public License
.\" -*- nroff -*-
-.TH APPROX.CONF 5 "March 2009"
+.TH APPROX.CONF 5 "June 2010"
.\" Please adjust this date when revising the manpage.
.SH NAME
@@ -20,6 +20,12 @@ Comments start with a "#" character and continue to the end of the line.
.PP
Names that begin with the "$" character are reserved for use as
configuration parameters. The following parameters are currently defined:
+.IP $cache
+Specifies the location of the approx cache directory
+(default:
+.IR /var/cache/approx ).
+It and all its subdirectories must be owned by the approx server
+(see also the $user and $group parameters, below.)
.IP $max_rate
Specifies the maximum download rate from remote repositories,
in bytes per second (default: unlimited).
diff --git a/gc.ml b/gc.ml
index 666b799..341def2 100644
--- a/gc.ml
+++ b/gc.ml
@@ -29,14 +29,14 @@ let quiet = ref false
let verbose = ref false
let () =
- for i = 1 to Array.length Sys.argv - 1 do
- match Sys.argv.(i) with
- | "-f" | "--fast" -> no_checksum := true
- | "-k" | "--keep" | "-s" | "--simulate" -> simulate := true
- | "-q" | "--quiet" -> quiet := true
- | "-v" | "--verbose" -> verbose := true
- | _ -> usage ()
- done
+ List.iter
+ (function
+ | "-f" | "--fast" -> no_checksum := true
+ | "-k" | "--keep" | "-s" | "--simulate" -> simulate := true
+ | "-q" | "--quiet" -> quiet := true
+ | "-v" | "--verbose" -> verbose := true
+ | _ -> usage ())
+ arguments
let no_checksum = !no_checksum
let simulate = !simulate
diff --git a/import.ml b/import.ml
index 450bc63..99357fb 100644
--- a/import.ml
+++ b/import.ml
@@ -23,15 +23,15 @@ let verbose = ref false
let files = ref []
let () =
- for i = 1 to Array.length Sys.argv - 1 do
- match Sys.argv.(i) with
- | "-k" | "--keep" | "-s" | "--simulate" -> simulate := true
- | "-q" | "--quiet" -> quiet := true
- | "-v" | "--verbose" -> verbose := true
- | arg ->
- if arg.[0] = '-' then usage ()
- else files := arg :: !files
- done
+ List.iter
+ (function
+ | "-k" | "--keep" | "-s" | "--simulate" -> simulate := true
+ | "-q" | "--quiet" -> quiet := true
+ | "-v" | "--verbose" -> verbose := true
+ | arg ->
+ if arg.[0] = '-' then usage ()
+ else files := arg :: !files)
+ arguments
let simulate = !simulate
let quiet = !quiet
diff --git a/update.ml b/update.ml
index 5f629d6..663ee4c 100644
--- a/update.ml
+++ b/update.ml
@@ -23,13 +23,13 @@ let quiet = ref false
let verbose = ref false
let () =
- for i = 1 to Array.length Sys.argv - 1 do
- match Sys.argv.(i) with
- | "-k" | "--keep" | "-s" | "--simulate" -> simulate := true
- | "-q" | "--quiet" -> quiet := true
- | "-v" | "--verbose" -> verbose := true
- | _ -> usage ()
- done
+ List.iter
+ (function
+ | "-k" | "--keep" | "-s" | "--simulate" -> simulate := true
+ | "-q" | "--quiet" -> quiet := true
+ | "-v" | "--verbose" -> verbose := true
+ | _ -> usage ())
+ arguments
let simulate = !simulate
let quiet = !quiet
--
approx upstream and debian packaging
More information about the Pkg-ocaml-maint-commits
mailing list