summaryrefslogtreecommitdiffstats
path: root/urpm/xml_info_pkg.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-01-11 17:26:52 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-01-11 17:26:52 +0000
commitd8314d9dd12f1bc40960ee9a498ded4ed9e917a3 (patch)
tree7c21d95e48ce824e36707cede847a1e014488306 /urpm/xml_info_pkg.pm
parent8d2124bcbfd6f1d206035c95b2c88054bfae8612 (diff)
downloadurpmi-d8314d9dd12f1bc40960ee9a498ded4ed9e917a3.tar
urpmi-d8314d9dd12f1bc40960ee9a498ded4ed9e917a3.tar.gz
urpmi-d8314d9dd12f1bc40960ee9a498ded4ed9e917a3.tar.bz2
urpmi-d8314d9dd12f1bc40960ee9a498ded4ed9e917a3.tar.xz
urpmi-d8314d9dd12f1bc40960ee9a498ded4ed9e917a3.zip
- 5.0
- urpmf, urpmq: o use xml info instead of hdlist when possible o "urpmq -l" is faster (3x) o "urpmf -l" is slower (1.5x) o "urpmf --sourcerpm" is much faster o see "xml-info" option in urpmi.cfg(5) to see when those files are downloaded o new require: perl module XML::LibXML - urpmq: o use rpm file instead of hdlist/xml-info when file is local o use URPM::Package->changelogs (need perl-URPM 3.06) - urpmi.update, urpmi.addmedia, urpmi.removemedia: o drop hdlist support replaced with xml media_info (this imply file-deps are correctly handled, see genhdlist2(1)) - urpmi.addmedia o new --xml-info option
Diffstat (limited to 'urpm/xml_info_pkg.pm')
-rw-r--r--urpm/xml_info_pkg.pm46
1 files changed, 46 insertions, 0 deletions
diff --git a/urpm/xml_info_pkg.pm b/urpm/xml_info_pkg.pm
new file mode 100644
index 00000000..ce0fb0cd
--- /dev/null
+++ b/urpm/xml_info_pkg.pm
@@ -0,0 +1,46 @@
+package urpm::xml_info_pkg;
+
+# proxy object: returns the xml info if available, otherwise redirects to URPM::Package
+
+sub new {
+ my ($class, $hash, $pkg) = @_;
+
+ $pkg and $hash->{pkg} = $pkg;
+
+ bless $hash, $class;
+}
+
+
+# only available in synthesis/hdlist
+sub id { $_[0]{pkg}->id }
+sub group { $_[0]{pkg}->group }
+sub size { $_[0]{pkg}->size }
+sub epoch { $_[0]{pkg}->epoch }
+sub buildhost { $_[0]{pkg}->buildhost }
+sub packager { $_[0]{pkg}->packager }
+sub summary { $_[0]{pkg}->summary }
+
+
+# can be directly available in xml_info
+sub url { exists $_[0]{url} ? $_[0]{url} : $_[0]{pkg}->url }
+sub licence { exists $_[0]{licence} ? $_[0]{licence} : $_[0]{pkg}->licence }
+sub sourcerpm { exists $_[0]{sourcerpm} ? $_[0]{sourcerpm} : $_[0]{pkg}->sourcerpm }
+sub description { exists $_[0]{description} ? $_[0]{description} : $_[0]{pkg}->description }
+
+sub changelogs { exists $_[0]{changelogs} ? @{$_[0]{changelogs}} : $_[0]{pkg}->changelogs }
+
+sub files { exists $_[0]{files} ? split("\n", $_[0]{files}) : $_[0]{pkg}->files }
+
+my $fullname_re = qr/^(.*)-([^\-]*)-([^\-]*)\.([^\.\-]*)$/;
+
+# available in both {pkg} and {fn}
+sub name { exists $_[0]{pkg} ? $_[0]{pkg}->name : $_[0]{fn} =~ $fullname_re && $1 }
+sub version { exists $_[0]{pkg} ? $_[0]{pkg}->version : $_[0]{fn} =~ $fullname_re && $2 }
+sub release { exists $_[0]{pkg} ? $_[0]{pkg}->release : $_[0]{fn} =~ $fullname_re && $3 }
+sub arch { exists $_[0]{pkg} ? $_[0]{pkg}->arch : $_[0]{fn} =~ $fullname_re && $4 }
+
+sub fullname { wantarray ? $_[0]{pkg}->fullname : $_[0]{fn} }
+sub filename { $_[0]{fn} . '.rpm' }
+
+
+1;