diff options
-rw-r--r-- | URPM.pm | 11 | ||||
-rw-r--r-- | URPM.xs | 49 | ||||
-rw-r--r-- | t/parse.t | 3 |
3 files changed, 61 insertions, 2 deletions
@@ -562,6 +562,12 @@ Returns whether this package is compatible with the current machine's architecture. 0 means not compatible. The lower the result is, the preferred the package is. +=item $package->is_platform_compat() + +Return whether this package is compatible with the current machine's +platform configuration (/etc/rpm/platform). 0 mean not compatible. +The lower the result is the preferred the package is. + =item $package->license() =item $package->name() @@ -751,6 +757,11 @@ Sets rpm verbosity level. $level is an integer between 2 (RPMMESS_CRIT) and 7 =item rpmErrorWriteTo($fd) +=item platformscore($platform) + +Return the score of $platform according computer's configuration. +0 mean not compatible, lower is prefered. + =back =head1 COPYRIGHT @@ -1352,7 +1352,7 @@ Pkg_is_arch_compat(pkg) RETVAL = rpmMachineScore(RPM_MACHTABLE_INSTARCH, arch); #endif *eos = '@'; - free(platform); + _free(platform); } else if (pkg->h && headerIsEntry(pkg->h, RPMTAG_SOURCERPM)) { char *arch = get_name(pkg->h, RPMTAG_ARCH); #ifdef RPM_448 @@ -1367,6 +1367,40 @@ Pkg_is_arch_compat(pkg) OUTPUT: RETVAL +int +Pkg_is_platform_compat(pkg) + URPM::Package pkg + INIT: + char * platform = NULL; + CODE: +#ifdef RPM_448 + read_config_files(0); + if (pkg->h && headerIsEntry(pkg->h, RPMTAG_PLATFORM)) { + int_32 count, type; + (void) headerGetEntry(pkg->h, RPMTAG_PLATFORM, &type, (void **) &platform, &count); + RETVAL = rpmPlatformScore(platform, NULL, 0); + platform = headerFreeData(platform, type); + } else if (pkg->info) { + char *arch; + char *eos; + + get_fullname_parts(pkg, NULL, NULL, NULL, &arch, &eos); + *eos = 0; + platform = rpmExpand(arch, "-%{_real_vendor}-", eos, "%{?_gnu}", NULL); + RETVAL = rpmPlatformScore(platform, NULL, 0); + *eos = '@'; + _free(platform); + } else { +#else + croak("is_platform_compat() is availlable only since rpm 4.4.8"); + { /* to match last } and avoid another #ifdef for it */ +#endif + RETVAL = 0; + } + + OUTPUT: + RETVAL + void Pkg_summary(pkg) URPM::Package pkg @@ -3636,6 +3670,19 @@ Urpm_import_pubkey(...) OUTPUT: RETVAL +int +Urpm_platformscore(platform) + const char * platform + CODE: +#ifdef RPM_448 + RETVAL=rpmPlatformScore(platform, NULL, 0); +#else + croak("platformscore() is availlable only since rpm 4.4.8"); + RETVAL=0 +#endif + OUTPUT: + RETVAL + void Urpm_stream2header(fp) FILE *fp @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 40; +use Test::More tests => 41; use MDV::Packdrakeng; use URPM; use URPM::Build; @@ -72,6 +72,7 @@ is($pkg->get_tag(1001), '1.0', 'version'); is($pkg->get_tag(1002), '1mdk', 'release'); is($pkg->queryformat("%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}"), "test-rpm-1.0-1mdk.noarch", q/get headers from hdlist/); +ok($pkg->is_platform_compat() > 0, "can evaluate platform score"); my $headers = eval { [ $b->parse_rpms_build_headers(rpms => [ "RPMS/noarch/test-rpm-1.0-1mdk.noarch.rpm" ], dir => 'headers') ] }; |