ALPM
view release on metacpan or search on metacpan
* RELEASE (0.08): Uploaded to CPAN.
* typemap (find_group): Fix a bug with group type conversion.
This caused ALPM::DB::find_group() to croak instead of (properly)
returning undef when given a group name that didn't exist.
Reported by Andre Schmidt. Thanks!
2010-05-24 Justin Davis <juster@cpan.org>
* ALPM.xs (ALPM::Package): Renamed compute_requiredby method to
requiredby.
2010-05-02 Justin Davis <juster@cpan.org>
* t/04-FakeRepos.t: Add support for .pkg.tar.xz package files.
* lib/ALPM/LoadConfig.pm: Add support for UseDelta setting in
pacman.conf.
2010-01-25 Justin Davis <jrcd83@gmail.com>
#!/usr/bin/perl -s
##
# Prints local packages which are not required by any other local package.
# Pass the -i switch to only print implicitly installed packages.
# Pass the -e switch to only print explicitly installed packages.
# Pass neither to print both.
use ALPM::Conf qw(/etc/pacman.conf);
die q{You can't use both -i and -e} if $i && $e;
for my $pkg ($alpm->localdb->pkgs){
next if(@{$pkg->requiredby} > 0);
if($i || $e){
next if($pkg->reason ne ($i ? 'implicit' : 'explicit'));
}
push @dangles, $pkg->name;
}
print map { "$_\n" } sort @dangles;
lib/ALPM.pod view on Meta::CPAN
An L<ALPM::Package> object.
=item reason
A hashref that is identical to a dependency. See L</Dependency>.
=back
=head2 Signature Level
Signature levels describe the level of security which is required for packages files
and by databases files. Different degrees of signature checking can be used for
either type of file. The signature checking is performed after the file is downloaded
in order to verify the original packager. B<When gpg is not available an invalid argument
error will be raised from libalpm if you try to set the siglevel.>
A "siglvl" can either be the string C<"default"> or a hash reference. A value of C<"default">
can be used when registering a database to instruct libalpm to use the default siglevel
that is set by I<set_defsiglvl>. A siglvl hashref must contain a C<"pkg"> key
and a C<"db"> key. Other keys are ignored.
lib/ALPM.pod view on Meta::CPAN
=over 4
=item C<"never">
No signature verification is performed.
=item C<"optional">
Signatures are optional. They are checked if they are available.
=item C<"required">
Signatures are required.
=back
The string C<"trustall">, preceded by a space, can be added to C<"optional"> or
C<"required"> options to specify that signatures from anyone are to be trusted.
Here are some example siglevels:
$alpm->set_defsiglvl({ 'pkg' => 'never', 'db' => 'never' });
$alpm->set_defsiglvl({ 'pkg' => 'optional', 'db' => 'required trustall' });
$alpm->set_defsiglvl({ 'pkg' => 'required', 'db' => 'optional' });
=head1 ERRORS
In previous version of this module, errors were thrown automatically. Since then,
errors are no longer stored in a global variable (like UNIX's errno) but are instead
stored inside of the libalpm handle structure. In order to preserve the old functionality
I will have to either store a copy of the ALPM object inside every other object or use
the internal C representation which I'm technically not supposed to know.
Whatever. I'm too lazy for either of those. What this means for you is you really really
lib/ALPM/Conf.pm view on Meta::CPAN
@types = qw/pkg/;
}elsif(s/^Database//){
@types = qw/db/;
}
if(/^Never$/){
$opt->{$_} = 'never' for(@types);
}elsif(/^Optional$/){
$opt->{$_} = 'optional' for(@types);
}elsif(/^Required$/){
$opt->{$_} = 'required' for(@types);
}elsif(/^TrustedOnly$/){
;
}elsif(/^TrustAll$/){
for my $t (@types){
$opt->{$t} = 'optional' unless(defined $opt->{$t});
$opt->{$t} .= ' trustall';
}
}else{
die "Unknown SigLevel option: $_\n";
}
lib/ALPM/Package.pod view on Meta::CPAN
=item * files
=item * backup
=item * has_scriptlet
=item * download_size
=item * changelog
=item * requiredby
=item * optionalfor
=item * db
=item * checkmd5sum
=item * origin
=item * validation
mydiff(\*PATCH, $filename, $c);
}
else {
fallback:
info("Suggested changes:");
mydiff(\*STDOUT, $filename, $c);
}
}
else {
my $s = $file{changes} == 1 ? '' : 's';
info("$file{changes} potentially required change$s detected");
}
}
else {
info("Looks good");
}
}
close PATCH if $patch_opened;
exit 0;
t/00-ALPM.t view on Meta::CPAN
##
# Initialize ALPM then set and check a few options.
# Checks add/remove on what we can.
# Then create the test repositories.
use Test::More;
BEGIN { use_ok('ALPM') };
## I could not hack this into the Makefile so we initialize
## test repositories here so the modules required are
## only needed when running the tests.
if(system 'perl' => 't/preptests.pl'){
die 'failed to initialize our test root/packages/repos';
}
$ENV{'LANGUAGE'} = 'en_US';
$r = 't/root';
$alpm = ALPM->new($r, "$r/db");
t/00-ALPM.t view on Meta::CPAN
next unless($k =~ s/s$//);
is meth("remove_$k", $v[0]), 1, "remove_$k reported success";
@w = meth("get_${k}s");
ok @w == (@v - 1), "$v[0] removed from ${k}s";
}
# TODO: Test SigLevels more in a later test.
is_deeply $alpm->get_defsiglvl, { 'pkg' => 'never', 'db' => 'never' };
if(grep { /signatures/ } @caps){
$siglvl = { 'pkg' => 'optional', 'db' => 'required' };
ok $alpm->set_defsiglvl($siglvl);
is_deeply $alpm->get_defsiglvl, $siglvl;
$siglvl = { 'pkg' => 'never', 'db' => 'optional trustall' };
ok $alpm->set_defsiglvl($siglvl);
is_deeply $alpm->get_defsiglvl, $siglvl;
}else{
$siglvl = { 'pkg' => 'never', 'db' => 'required' };
eval { $alpm->set_defsiglvl($siglvl); };
if($@ =~ /^ALPM Error: wrong or NULL argument passed/){
pass q{can set siglevel to "never" without GPGME};
}else{
fail 'should not be able to set complicated siglevel without GPGME';
}
}
ok not eval { $alpm->set_defsiglvl('default') };
t/03-Package.t view on Meta::CPAN
$msg = 'load the simpletest/foo package file';
$pkg = $alpm->load_pkgfile(pkgpath('simpletest', 'foo'), 1, 'default');
if($pkg){
pass $msg;
}else{
fail $msg;
die $alpm->strerror;
}
my @methnames = qw{ requiredby name version desc
url builddate installdate packager
arch arch size isize reason
licenses groups depends optdepends
conflicts provides deltas replaces
files backup };
for my $mname (@methnames) {
my $method_ref = $ALPM::Package::{$mname};
ok $method_ref, "$mname is a package method";
my $result = $method_ref->($pkg);
static
SV* truststring(unsigned long siglvl)
{
SV *str;
if(!(siglvl & MASK_ENABLE)){
return newSVpv("never", 0);
}else if(!(~siglvl & MASK_OPT)){
str = newSVpv("optional", 0);
}else{
str = newSVpv("required", 0);
}
if(!(~siglvl & MASK_TRUSTALL)){
sv_catpv(str, " trustall");
}
return str;
}
/* converts siglevel bitflags into a string (default/never) or hashref of strings */
SV*
c2p_siglevel(alpm_siglevel_t sig)
trustmask(char *str, STRLEN len)
{
unsigned long flags;
if(len == 5 && strncmp(str, "never", 5) == 0){
return 0;
}
if(len < 8){
goto badstr;
}else if(strncmp(str, "required", 8) == 0){
flags = MASK_ENABLE;
}else if(strncmp(str, "optional", 8) == 0){
flags = MASK_OPT;
}else {
goto badstr;
}
if(len == 8){
/* Conveniently, the strings "required" and "optional" are both 8 characters long. */
return flags;
}else if(len != 17 || strncmp(str + 8, " trustall", 8) != 0){
goto badstr;
}
return flags | MASK_TRUSTALL;
badstr:
croak("Unrecognized signature level string: %s", str);
}
xs/Package.xs view on Meta::CPAN
}
OUTPUT:
RETVAL
MODULE=ALPM PACKAGE=ALPM::Package PREFIX=alpm_pkg_compute_
StringListFree
pkg_compute(pkg)
ALPM_Package pkg
INTERFACE:
alpm_pkg_compute_requiredby
alpm_pkg_compute_optionalfor
MODULE=ALPM PACKAGE=ALPM::Package PREFIX=alpm_pkg_
negative_is_error
alpm_pkg_checkmd5sum(pkg)
ALPM_Package pkg
int
alpm_pkg_has_scriptlet(pkg)
( run in 0.490 second using v1.01-cache-2.11-cpan-0a6323c29d9 )