| Server IP : 81.2.241.106 / Your IP : 216.73.216.165 Web Server : Apache/2.4.67 (Debian) System : Linux tranq-f.bakta.org 5.10.0-45-amd64 #1 SMP Debian 5.10.259-1 (2026-07-02) x86_64 User : lisky ( 1002) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /usr/share/doc/libapt-pkg-perl/examples/ |
Upload File : |
#!/usr/bin/perl
#
# Example: apt-config in perl. See apt-config(8).
#
use AptPkg::Config '$_config';
(my $self = $0) =~ s#.*/##;
# initialise the global config object with the default values
$_config->init;
# parse the command line
@ARGV = $_config->parse_cmdline([
[ 'h', 'help', 'help' ],
[ 'v', 'version', 'version' ],
[ 'c', 'config-file', '', 'ConfigFile' ],
[ 'o', 'option', '', 'ArbItem' ],
], @ARGV);
if (my $v_opt = $_config->get_bool('version') or # --version
$_config->get_bool('help') or # --help
!@ARGV) # no args
{
# we don't have the PACKAGE/VERSION &c apt-config has... punt
print "$self (using AptPkg $AptPkg::VERSION, built for ",
"$_config->{APT::Architecture})\n";
print <<EOT unless $v_opt;
Usage: $self [options] command
$self is a simple tool to read the APT config file
Commands:
shell - Shell mode
dump - Show the configuration
Options:
-h This help text.
-c=? Read this configuration file
-o=? Set an arbitrary configuration option, eg -o dir::cache=/tmp
EOT
exit;
}
# dispatch args
my $op = shift;
if ($op eq 'dump')
{
$_config->dump;
exit;
}
die "$self: invalid operation `$op'\n" unless $op eq 'shell';
while (@ARGV)
{
my $var = shift;
my $cname = shift or die "$self: arguments not in pairs\n";
local $_;
# check if the caller has requested a directory path in the old format
$cname .= 'd' if $cname =~ m#/$#;
$_ = $_config->get($cname) if $_config->exists($cname);
next unless defined;
if (m#[^\w@+,./:=-]#)
{
# quote
s/'/'\\''/g;
$_ = "'$_" unless s/^'//;
$_ = "$_'" unless s/'$//;
}
print "$var=$_\n";
}