.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "AptPkg::Config 3pm" .TH AptPkg::Config 3pm "2021-02-15" "perl v5.32.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" AptPkg::Config \- APT configuration interface .SH "SYNOPSIS" .IX Header "SYNOPSIS" use AptPkg::Config; .SH "DESCRIPTION" .IX Header "DESCRIPTION" The AptPkg::Config module provides an interface to \fB\s-1APT\s0\fR's configuration mechanism. .PP Provides a configuration file and command line parser for a tree-oriented configuration environment. .SS "AptPkg::Config" .IX Subsection "AptPkg::Config" The AptPkg::Config package implements the \fB\s-1APT\s0\fR Configuration class. .PP A global instance of the libapt-pkg _config instance is provided as \&\f(CW$AptPkg::Config::_config\fR, and may be imported. .PP The following methods are implemented: .IP "get(\fI\s-1KEY\s0\fR, [\fI\s-1DEFAULT\s0\fR])" 4 .IX Item "get(KEY, [DEFAULT])" Fetch the value of \fI\s-1KEY\s0\fR from the configuration object, returning undef if not found (or \fI\s-1DEFAULT\s0\fR if given). .Sp If the key ends in ::, an array of values is returned in an array context, or a string containing the values separated by spaces in a scalar context. .Sp A trailing /f, /d, /b or /i causes file, directory, boolean or integer interpretation (the underlying \s-1XS\s0 call is FindAny). .IP "get_file(\fI\s-1KEY\s0\fR, [\fI\s-1DEFAULT\s0\fR]), get_dir(\fI\s-1KEY\s0\fR, [\fI\s-1DEFAULT\s0\fR])" 4 .IX Item "get_file(KEY, [DEFAULT]), get_dir(KEY, [DEFAULT])" Variants of get which prepend the directory value from the parent key. The get_dir method additionally appends a `/'. .Sp For example, given the configuration file: .Sp .Vb 1 \& foo "/some/dir/" { bar "value"; } .Ve .Sp then: .Sp .Vb 3 \& $conf\->get("foo::bar") # "value" \& $conf\->get_file("foo::bar") # "/some/dir/value" \& $conf\->get_dir("foo::bar") # "/some/dir/value/" .Ve .IP "get_bool(\fI\s-1KEY\s0\fR, [\fI\s-1DEFAULT\s0\fR])" 4 .IX Item "get_bool(KEY, [DEFAULT])" Another get variant, which returns true (1) if the value contains any of: .Sp .Vb 1 \& 1 yes true with on enable .Ve .Sp otherwise false (''). .IP "set(\fI\s-1KEY\s0\fR, \fI\s-1VALUE\s0\fR)" 4 .IX Item "set(KEY, VALUE)" Set configuration entry \fI\s-1KEY\s0\fR to \fI\s-1VALUE\s0\fR. Returns \fI\s-1VALUE\s0\fR. Note that empty parent entries may be created for \fI\s-1KEY\s0\fRs containing ::. .IP "exists(\fI\s-1KEY\s0\fR)" 4 .IX Item "exists(KEY)" Test if \fI\s-1KEY\s0\fR exists in the configuration. .IP "dump" 4 .IX Item "dump" Principally for debugging, output the contents of the configuration object to stderr. .IP "read_file(\fI\s-1FILE\s0\fR, [\fI\s-1AS_SECTIONAL\s0\fR, [\fI\s-1DEPTH\s0\fR]])" 4 .IX Item "read_file(FILE, [AS_SECTIONAL, [DEPTH]])" Load the contents of \fI\s-1FILE\s0\fR into the object. The format of the file is described in \fBapt.conf\fR\|(5). .Sp If the \fI\s-1AS_SECTIONAL\s0\fR argument is true, then the file is parsed as a BIND-style config. That is: .Sp .Vb 1 \& foo "bar" { baz "quux"; } .Ve .Sp is interpreted as if it were: .Sp .Vb 1 \& foo::bar { baz "quux"; } .Ve .Sp The \fI\s-1DEPTH\s0\fR argument may be used to restrict the number of nested include directives processed. .IP "read_dir(\fI\s-1DIR\s0\fR, [\fI\s-1AS_SECTIONAL\s0\fR, [\fI\s-1DEPTH\s0\fR]])" 4 .IX Item "read_dir(DIR, [AS_SECTIONAL, [DEPTH]])" Load configuration from all files in \fI\s-1DIR\s0\fR. .IP "init" 4 .IX Item "init" Initialise the configuration object with some default values for the libapt-pkg library and reads the default configuration file /etc/apt/apt.conf (or as given by the environment variable \s-1APT_CONFIG\s0) if it exists. .IP "system" 4 .IX Item "system" Return the AptPkg::System object appropriate for this system. .IP "parse_cmdline(\fI\s-1DEFS\s0\fR, [\fI\s-1ARG\s0\fR, ...])" 4 .IX Item "parse_cmdline(DEFS, [ARG, ...])" Parse the arguments given by \fI\s-1ARG\s0\fRs based on the contents of \fI\s-1DEFS\s0\fR and returns the list of remaining arguments. .Sp Note, the function does not return if there are errors processing the args. Use eval to trap such errors. .Sp \&\fI\s-1DEFS\s0\fR is a reference to an array containing a set argument definition arrays. The elements of each definition define: the short argument character, the long argument string, the configuration key and the optional argument type (defaults to Boolean). .Sp Valid argument types are defined by the strings: .Sp .Vb 6 \& HasArg takes an argument value (\-f foo) \& IntLevel defines an integer value (\-q \-q, \-qq, \-q2, \-q=2) \& Boolean true/false (\-d, \-d=true, \-d=yes, \-\-no\-d, \-d=false, etc) \& InvBoolean same as Boolean but false with no specified sense (\-d) \& ConfigFile load the specified configuration file \& ArbItem arbitrary configuration string of the form key=value .Ve .Sp The configuration key in the last two cases is ignored, and for the rest gives the key into which the value is placed. .Sp Single case equivalents also work (has_arg == HasArg). .Sp Example: .Sp .Vb 6 \& @files = $conf\->parse_cmndline([ \& [ \*(Aqh\*(Aq, \*(Aqhelp\*(Aq, \*(Aqhelp\*(Aq ], \& [ \*(Aqv\*(Aq, \*(Aqversion\*(Aq, \*(Aqversion\*(Aq ], \& [ \*(Aqc\*(Aq, \*(Aqconfig\-file\*(Aq, \*(Aq\*(Aq, ConfigFile ], \& [ \*(Aqo\*(Aq, \*(Aqoption\*(Aq, \*(Aq\*(Aq, ArbItem ], \& ], @ARGV); .Ve .PP The module uses AptPkg::hash to provide a hash-like access to the object, so that \f(CW$conf\fR\->{key} is equivalent to using the get/set methods. .PP Additionally inherits the constructor (new) and keys methods from that module. .PP Methods of the internal \s-1XS\s0 object (AptPkg::_config) such as Find may also be used. See AptPkg. .SS "AptPkg::Config::Iter" .IX Subsection "AptPkg::Config::Iter" Iterator object for AptPkg::Config which is returned by the keys method. .IP "new(\fI\s-1XS_OBJ\s0\fR, [\fI\s-1ROOT\s0\fR])" 4 .IX Item "new(XS_OBJ, [ROOT])" Constructor, which is invoked by the keys method. \fI\s-1ROOT\s0\fR, if given determines the subset of the tree to walk (may be given as an argument to keys). .IP "next" 4 .IX Item "next" Returns the current key and advances to the next. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBAptPkg::System\fR\|(3pm), \fBAptPkg\fR\|(3pm), \fBAptPkg::hash\fR\|(3pm). .SH "AUTHOR" .IX Header "AUTHOR" Brendan O'Dea