ALPM
view release on metacpan or search on metacpan
dSP;
if(!logcb_ref) return;
/* convert log level bitflag to a string */
switch(lvl){
case ALPM_LOG_ERROR: str = "error"; break;
case ALPM_LOG_WARNING: str = "warning"; break;
case ALPM_LOG_DEBUG: str = "debug"; break;
case ALPM_LOG_FUNCTION: str = "function"; break;
default: str = "unknown"; break;
}
ENTER;
SAVETMPS;
/* We can't use sv_vsetpvfn because it doesn't like j's: %jd or %ji, etc... */
svlvl = sv_2mortal(newSVpv(str, 0));
vsnprintf(buf, 255, fmt, args);
svmsg = sv_2mortal(newSVpv(buf, 0));
lib/ALPM.pod view on Meta::CPAN
=back
=head2 fetch_pkgurl
$PATH | undef = $OBJ->fetch_pkgurl($URL)
=over 4
=item C<$URL>
The url to a package file which will be downloaded to our default
package cache location.
=item C<$PATH>
The path to our package file if the download succeeds.
=item C<undef>
If the download fails. Check L</strerror>.
lib/ALPM.pod view on Meta::CPAN
The path to a package file (i.e. pkg.tar.xz).
=item C<$FULL>
Full (1) or partial load (0). Trust me, don't install partial loads.
That happened with clyde once.
=item C<$SIGLEVEL>
Signature level hashref or the string C<"default">. See L</Signature Level>.
=item C<$PKG>
On success, an L<ALPM::Package> object.
=item C<undef>
On failure. Check L</strerror>.
=back
lib/ALPM.pod view on Meta::CPAN
=over 4
=item C<$NAME>
The name to use for the database (e.g. core, extra, community.)
=item C<$SIGLEVEL> I<(Optional>)
The signature level to use for the database, including the database file and each
package file downloaded from the database mirror. If none is specified, then the
signature level is set to C<'default'> which is equivalent to the signature level set with
the I<set_defsiglvl> method.
=item C<$DB>
On success, an L<ALPM::DB::Sync> object.
=item C<undef>
On failure. Check L</strerror>.
lib/ALPM.pod view on Meta::CPAN
=item B<ignorepkgs>* - a list of package names to ignore for upgrade
=item B<ignoregroups>* - a list of groups to ignore for upgrade
=item B<usesyslog> - if true, log to the system log as well
=item B<deltaratio> - accepts a decimal from 0 to 1
=item B<checkspace> - check for available diskspace
=item B<defsiglvl> - the default signature level. See L</Signature Level>.
This name was shortened from I<alpm_option_set_default_signature_level>.
You're welcome.
=back
=head2 Read-only options
=over
=item B<root> - path to the installation root
lib/ALPM.pod view on Meta::CPAN
=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.
Possible hash values include:
=over 4
=item C<"never">
No signature verification is performed.
lib/ALPM/Conf.pm view on Meta::CPAN
# The SetOption type in typemap croaks on error, no need to check.
_setopt($alpm, $opt, $val);
}
my $usesl = grep { /signatures/ } $alpm->caps;
for my $db (@$dbs){
my($r, $sl, $mirs) = @{$db}{'name', 'siglvl', 'mirrors'};
next if(!@$mirs);
_expurls($mirs, $opts->{'arch'}, $r);
$sl = 'default' if(!$usesl);
my $x = $alpm->register($r, $sl)
or die "Failed to register $r database: " . $alpm->strerror;
$x->add_server($_) for(@$mirs);
}
return $alpm;
}
sub parse
{
my($self) = @_;
=head2 --copy=I<suffix>
If this option is given, a copy of each file will be saved with
the given suffix that contains the suggested changes. This does
not require any external programs. Note that this does not
automagially add a dot between the original filename and the
suffix. If you want the dot, you have to include it in the option
argument.
If neither C<--patch> or C<--copy> are given, the default is to
simply print the diffs for each file. This requires either
C<Text::Diff> or a C<diff> program to be installed.
=head2 --diff=I<program>
Manually set the diff program and options to use. The default
is to use C<Text::Diff>, when installed, and output unified
context diffs.
=head2 --compat-version=I<version>
Tell F<ppport.h> to check for compatibility with the given
Perl version. The default is to check for compatibility with Perl
version 5.003. You can use this option to reduce the output
of F<ppport.h> if you intend to be backward compatible only
down to a certain Perl version.
=head2 --cplusplus
Usually, F<ppport.h> will detect C++ style comments and
replace them with C style comments for portability reasons.
Using this option instructs F<ppport.h> to leave C++
comments untouched.
Don't output any hints. Hints often contain useful portability
notes. Warnings will still be displayed.
=head2 --nochanges
Don't suggest any changes. Only give diagnostic output and hints
unless these are also deactivated.
=head2 --nofilter
Don't filter the list of input files. By default, files not looking
like source code (i.e. not *.xs, *.c, *.cc, *.cpp or *.h) are skipped.
=head2 --strip
Strip all script and documentation functionality from F<ppport.h>.
This reduces the size of F<ppport.h> dramatically and may be useful
if you want to include F<ppport.h> in smaller modules without
increasing their distribution size too much.
The stripped F<ppport.h> will have a C<--unstrip> option that allows
vnewSVpvf() NEED_vnewSVpvf NEED_vnewSVpvf_GLOBAL
warner() NEED_warner NEED_warner_GLOBAL
To avoid namespace conflicts, you can change the namespace of the
explicitly exported functions / variables using the C<DPPP_NAMESPACE>
macro. Just C<#define> the macro before including C<ppport.h>:
#define DPPP_NAMESPACE MyOwnNamespace_
#include "ppport.h"
The default namespace is C<DPPP_>.
=back
The good thing is that most of the above can be checked by running
F<ppport.h> on your source code. See the next section for
details.
=head1 EXAMPLES
To verify whether F<ppport.h> is needed for your module, whether you
case '\v' : octbuf[1] = 'v'; break;
case '\t' : octbuf[1] = 't'; break;
case '\r' : octbuf[1] = 'r'; break;
case '\n' : octbuf[1] = 'n'; break;
case '\f' : octbuf[1] = 'f'; break;
case '"' : if (dq == '"')
octbuf[1] = '"';
else
chsize = 1;
break;
default: chsize = my_snprintf(octbuf, sizeof octbuf,
pv < end && isDIGIT((U8)*(pv+readsize))
? "%c%03o" : "%c%o", esc, c);
}
} else {
chsize = 1;
}
}
if (max && wrote + chsize > max) {
break;
} else if (chsize > 1) {
t/00-ALPM.t view on Meta::CPAN
}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') };
done_testing;
$db = $alpm->localdb;
is $db->name, 'local';
## Make sure DBs are synced.
$_->update or die $alpm->strerror for($alpm->syncdbs);
checkdb('simpletest', qw/foo bar/);
checkdb('upgradetest', qw/foo replacebaz/);
## Check that register siglevel defaults to 'default' when not provided.
$db = $alpm->register('empty') or die 'register failed';
## Due to libalpm trickery, if the db's siglevel is set to default, then the siglevel
## that is retrieved is a copy of the handle's default siglevel.
$siglvl = $alpm->get_defsiglvl;
is_deeply $db->siglvl, $siglvl;
done_testing;
t/03-Package.t view on Meta::CPAN
$pkg = $db->find($pkgname) or die "$dbname/$pkgname package is missing";
$url .= q{/} . $pkg->filename;
print "$url\n";
if(($url =~ s{^file://}{}) != 1){
die 'package files are not locally hosted as expected';
}
return $url;
}
$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
{
char *cmp;
switch(mod){
case 0:
case ALPM_DEP_MOD_ANY: cmp = ""; break; /* ? */
case ALPM_DEP_MOD_EQ: cmp = "="; break;
case ALPM_DEP_MOD_GE: cmp = ">="; break;
case ALPM_DEP_MOD_LE: cmp = "<="; break;
case ALPM_DEP_MOD_GT: cmp = ">"; break;
case ALPM_DEP_MOD_LT: cmp = "<"; break;
default: cmp = "?";
}
return newSVpv(cmp, 0);
}
alpm_depmod_t
p2c_depmod(SV* mod)
{
char *cmp = SvPV_nolen(mod);
if(!cmp || strcmp(cmp, "") == 0) { return ALPM_DEP_MOD_ANY; }
}
return newRV_noinc((SV*)av);
}
/*
This deals with only raw bits, which is bad form, but I prefer the design.
If the alpm_siglevel_t bitflag enum was not so strange, I wouldn't have
chosen to do this.
The bit flags are separated into two halves with a special case of the
"default value" where bit 32 (the MSB) is on. Reading from LSB to MSB,
the package flags consist of the first four bits. 6 unused bits follow.
The database flags consist of the next four bits. 17 unused bits follow.
Finally, the bit flag for ALPM_USE_DEFAULT is the MSB.
Here is the form of the package and database bitmask. Remember the
database flags are shifted to the left by 10 places.
BIT DESCRIPTION
1 Signature checking is enabled for packages or databases respectively.
2 Signature checking is optional, used only when available.
3 MARGINAL_OK?
4 UNKNOWN_OK?
A setting of TrustAll in pacman.conf enables MARGINAL_OK and UNKNOWN_OK.
These two flags are not enabled separately from one another.
ALPM_SIG_USE_DEFAULT is the default value when set_default_siglevel is never
called but I have no idea what that could mean when this is the value of the default.
This seems to be a circular argument with no end.
*/
#define MASK_ENABLE 1
#define MASK_OPT 3
#define MASK_TRUSTALL 12
#define MASK_ALL 15
#define OFFSET_DB 10
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)
{
HV *hv;
if(sig & ALPM_SIG_USE_DEFAULT){
return newSVpv("default", 7);
}
hv = newHV();
hv_store(hv, "pkg", 3, truststring(sig & MASK_ALL), 0);
hv_store(hv, "db", 2, truststring((sig >> OFFSET_DB) & MASK_ALL), 0);
return newRV_noinc((SV*)hv);
}
static unsigned long
trustmask(char *str, STRLEN len)
alpm_siglevel_t
p2c_siglevel(SV *sig)
{
char *str;
STRLEN len;
alpm_siglevel_t ret;
HV *hv;
if(SvPOK(sig)){
str = SvPV(sig, len);
if(len == 7 && strncmp(str, "default", len) == 0){
return ALPM_SIG_USE_DEFAULT;
}else {
/* XXX: might not be null terminated? */
croak("Unrecognized global signature level string: %s", str);
}
}else if(SvROK(sig) && SvTYPE(SvRV(sig)) == SVt_PVHV){
hv = (HV*)SvRV(sig);
ret = fetch_trustmask(hv, "pkg");
ret |= fetch_trustmask(hv, "db") << OFFSET_DB;
return ret;
SV *
c2p_pkgfrom(alpm_pkgfrom_t from)
{
char *str;
switch(from){
case ALPM_PKG_FROM_FILE: str = "file"; break;
case ALPM_PKG_FROM_LOCALDB: str = "localdb"; break;
case ALPM_PKG_FROM_SYNCDB: str = "syncdb"; break;
default: str = "unknown"; break;
}
return newSVpv(str, 0);
}
SV *
c2p_pkgvalidation(alpm_pkgvalidation_t v)
{
char buf[128] = "";
int len;
update(db)
ALPM_SyncDB db
PREINIT:
int ret;
CODE:
ret = alpm_db_update(0, db);
switch(ret){
case 0: RETVAL = 1; break;
case 1: RETVAL = -1; break; /* DB did not need to be updated */
case -1: RETVAL = 0; break;
default: croak("Unrecognized return value of alpm_db_update");
}
OUTPUT:
RETVAL
negative_is_error
force_update(db)
ALPM_SyncDB db
CODE:
RETVAL = alpm_db_update(1, db);
OUTPUT:
xs/Options.xs view on Meta::CPAN
alpm_list_t *lst;
PPCODE:
lst = alpm_get_syncdbs(self);
if(lst == NULL && alpm_errno(self)) alpm_croak(self);
LIST2STACK(lst, c2p_syncdb);
ALPM_SigLevel
get_defsiglvl(self)
ALPM_Handle self
CODE:
RETVAL = alpm_option_get_default_siglevel(self);
OUTPUT:
RETVAL
SetOption
set_defsiglvl(self, siglvl)
ALPM_Handle self
SV* siglvl
CODE:
if(strcmp(SvPV_nolen(siglvl), "default") == 0){
croak("Default signature level cannot itself be set to default. You hear the sound of one hand clapping");
}else{
RETVAL = alpm_option_set_default_siglevel(self, p2c_siglevel(siglvl));
}
OUTPUT:
RETVAL
# EOF
( run in 0.585 second using v1.01-cache-2.11-cpan-0a6323c29d9 )