Attachment 'approx-add-model.patch'
Download 1 --- a/debian/approx.install
2 +++ b/debian/approx.install
3 @@ -3,3 +3,5 @@
4 approx-update usr/sbin
5 approx-import usr/sbin
6 etc/approx.conf etc/approx
7 +debian/config-model/Approx.pm usr/share/perl5/Config/Model
8 +debian/config-model/models/Approx.pl usr/share/perl5/Config/Model/models
9 --- /dev/null
10 +++ b/debian/config-model/Approx.pm
11 @@ -0,0 +1,90 @@
12 +# Copyright (c) 2009 Dominique Dumont.
13 +#
14 +# This file is part of Config-Model-Approx.
15 +#
16 +# Config-Model-Approx is free software; you can redistribute it and/or
17 +# modify it under the terms of the GNU Lesser Public License as
18 +# published by the Free Software Foundation; either version 2.1 of
19 +# the License, or (at your option) any later version.
20 +#
21 +# Config-Model-Approx is distributed in the hope that it will be useful,
22 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
23 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 +# Lesser Public License for more details.
25 +#
26 +# You should have received a copy of the GNU Lesser Public License
27 +# along with Config-Model; if not, write to the Free Software
28 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
29 +
30 +package Config::Model::Approx ;
31 +
32 +use strict ;
33 +use warnings ;
34 +
35 +use Carp ;
36 +use Log::Log4perl;
37 +use File::Copy ;
38 +use File::Path ;
39 +
40 +use vars qw($VERSION) ;
41 +
42 +$VERSION = '1.001' ;
43 +
44 +my $logger = Log::Log4perl::get_logger(__PACKAGE__);
45 +
46 +sub read {
47 + # keys are object , root, config_dir, io_handle, file
48 + my %args = @_ ;
49 +
50 + $logger->info("loading config file $args{file}") if defined $args{file};
51 +
52 + foreach ($args{io_handle}->getlines) {
53 + chomp;
54 + s/#.*//;
55 + s/\s+/=/; # translate file in string loadable by C::M::Loader
56 + next unless $_;
57 + my $load = s/^\$// ? $_ : "distributions:".$_;
58 + $args{object}->load($load) ;
59 + }
60 +
61 + return 1;
62 +}
63 +
64 +sub write {
65 + my %args = @_ ;
66 +
67 + $logger->info("writing config file $args{file}");
68 + my $node = $args{object} ;
69 + my $ioh = $args{io_handle} ;
70 +
71 + $ioh->print("# This file was written by Config::Model with Approx model\n");
72 + $ioh->print("# You may modify the content of this file. Configuration \n");
73 + $ioh->print("# modification will be preserved. Modification in the comments\n");
74 + $ioh->print("# will be discarded\n\n");
75 +
76 + # Using Config::Model::ObjTreeScanner would be overkill
77 + foreach my $elt ($node->get_element_name) {
78 + next if $elt eq 'distributions';
79 +
80 + # write some documentation in comments
81 + $ioh->print("# $elt:", $node->get_help(summary => $elt));
82 + my $upstream_default = $node->fetch_element($elt) -> fetch('upstream_default') ;
83 + $ioh->print(" ($upstream_default)") if defined $upstream_default;
84 + $ioh->print("\n") ;
85 +
86 + # write value
87 + my $v = $node->grab_value($elt) ;
88 + $ioh->printf("\$%-10s %s\n",$elt,$v) if defined $v ;
89 + $ioh->print("\n") ;
90 + }
91 +
92 + my $h = $node->fetch_element('distributions') ;
93 + $ioh->print("# ", $node->get_help(summary => 'distributions'),"\n");
94 + foreach my $dname ($h->get_all_indexes) {
95 + $ioh->printf("%-10s %s\n",$dname,
96 + $node->grab_value("distributions:$dname")
97 + ) ;
98 + }
99 + return 1;
100 +
101 +}
102 --- /dev/null
103 +++ b/debian/config-model/models/Approx.pl
104 @@ -0,0 +1,106 @@
105 +[
106 + {
107 + 'read_config' => [
108 + {
109 + 'file' => 'approx.conf',
110 + 'backend' => 'custom',
111 + 'class' => 'Config::Model::Approx',
112 + 'config_dir' => '/etc/approx'
113 + }
114 + ],
115 + 'name' => 'Approx',
116 + 'element' => [
117 + 'max_rate',
118 + {
119 + 'value_type' => 'uniline',
120 + 'summary' => 'maximum download rate from remote repositories',
121 + 'type' => 'leaf',
122 + 'description' => "Specifies the maximum download rate from remote repositories, in bytes per second (default: unlimited). The value may be suf\x{2010} fixed with \"K\", \"M\", or \"G\" to indicate kilobytes, megabytes, or gigabytes per second, respectively."
123 + },
124 + 'max_redirects',
125 + {
126 + 'value_type' => 'integer',
127 + 'summary' => 'maximum number of HTTP redirections',
128 + 'upstream_default' => '5',
129 + 'type' => 'leaf',
130 + 'description' => 'Specifies the maximum number of HTTP redirections that will be followed when downloading a remote file'
131 + },
132 + 'user',
133 + {
134 + 'value_type' => 'uniline',
135 + 'summary' => 'user that owns the files in the approx cache',
136 + 'upstream_default' => 'approx',
137 + 'type' => 'leaf'
138 + },
139 + 'group',
140 + {
141 + 'value_type' => 'uniline',
142 + 'summary' => 'group that owns the files in the approx cache',
143 + 'upstream_default' => 'approx',
144 + 'type' => 'leaf'
145 + },
146 + 'syslog',
147 + {
148 + 'value_type' => 'uniline',
149 + 'summary' => 'syslog(3) facility to use when logging',
150 + 'upstream_default' => 'daemon',
151 + 'type' => 'leaf'
152 + },
153 + 'pdiffs',
154 + {
155 + 'value_type' => 'boolean',
156 + 'summary' => 'support IndexFile diffs',
157 + 'upstream_default' => '1',
158 + 'type' => 'leaf'
159 + },
160 + 'offline',
161 + {
162 + 'value_type' => 'boolean',
163 + 'summary' => 'use cached files when offline',
164 + 'upstream_default' => '0',
165 + 'type' => 'leaf',
166 + 'description' => 'Specifies whether to deliver (possibly out-of-date) cached files when they cannot be downloaded from remote repositories'
167 + },
168 + 'max_wait',
169 + {
170 + 'value_type' => 'integer',
171 + 'summary' => 'max wait for concurrent file download',
172 + 'upstream_default' => '10',
173 + 'type' => 'leaf',
174 + 'description' => 'Specifies how many seconds an approx(8) process will wait for a concurrent download of a file to complete, before attempting to download the file itself'
175 + },
176 + 'verbose',
177 + {
178 + 'value_type' => 'boolean',
179 + 'upstream_default' => '0',
180 + 'type' => 'leaf',
181 + 'description' => 'Specifies whether informational messages should be printed in the log'
182 + },
183 + 'debug',
184 + {
185 + 'value_type' => 'boolean',
186 + 'upstream_default' => '0',
187 + 'type' => 'leaf',
188 + 'description' => 'Specifies whether debug messages should be printed in the log'
189 + },
190 + 'distributions',
191 + {
192 + 'cargo' => {
193 + 'value_type' => 'uniline',
194 + 'type' => 'leaf'
195 + },
196 + 'summary' => 'remote repositories',
197 + 'type' => 'hash',
198 + 'description' => 'The other name/value pairs are used to map distribution names to remote repositories. For example,
199 +
200 + debian => http://ftp.debian.org/debian
201 + security => http://security.debian.org/debian-security
202 +
203 +Use the distribution name as the key of the hash element and the URL as the value
204 +',
205 + 'index_type' => 'string'
206 + }
207 + ]
208 + }
209 + ]
210 +;
211 --- a/debian/control
212 +++ b/debian/control
213 @@ -12,7 +12,8 @@
214
215 Package: approx
216 Architecture: any
217 -Depends: ${shlibs:Depends}, ${misc:Depends}, ${F:OCamlDeps}, lsb-base (>= 3.2), adduser, bzip2, curl, openbsd-inetd | inet-superserver, update-inetd, libconfig-model-approx-perl
218 +Depends: ${shlibs:Depends}, ${misc:Depends}, ${F:OCamlDeps}, lsb-base (>= 3.2), adduser, bzip2, curl, openbsd-inetd | inet-superserver, update-inetd, libconfig-model-perl
219 +Conflicts: libconfig-model-approx-perl
220 Description: caching proxy server for Debian archive files
221 Approx is an HTTP-based proxy server for Debian-style package archives.
222 It fetches files from remote repositories on demand,
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.