From 702d21b778b6e3a0d962b64a86735f824e9252c5 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 12 Feb 2018 14:44:22 +0100 Subject: retrieve array of int from metadata, allow dependency retrieval --- examples/librpm.php | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'examples/librpm.php') diff --git a/examples/librpm.php b/examples/librpm.php index 90082e0..b012e54 100644 --- a/examples/librpm.php +++ b/examples/librpm.php @@ -7,6 +7,28 @@ namespace Remi\RPM; abstract class Common { protected $info = NULL; + protected function _dep(Array $names, Array $flags, Array $vers) { + $ret = []; + $signs = [ + RPMSENSE_EQUAL => ' = ', + RPMSENSE_LESS => ' < ', + RPMSENSE_GREATER => ' > ', + RPMSENSE_LESS | RPMSENSE_EQUAL => ' <= ', + RPMSENSE_GREATER | RPMSENSE_EQUAL => ' >= ', + ]; + + if (count($names) == count($vers) && count($vers) == count($flags)) { + for ($i=0 ; $iinfo['Arch']; } return $ret; + case 'Requires': + if (isset($this->info['Requirename'])) { + return $this->_dep($this->info['Requirename'], $this->info['Requireflags'], $this->info['Requireversion']); + } + case 'Conflicts': + if (isset($this->info['Conflictname'])) { + return $this->_dep($this->info['Conflictname'], $this->info['Conflictflags'], $this->info['Conflictversion']); + } + case 'Obsoletes': + if (isset($this->info['Obsoletename'])) { + return $this->_dep($this->info['Obsoletename'], $this->info['Obsoleteflags'], $this->info['Obsoleteversion']); + } + case 'Provides': + if (isset($this->info['Providename'])) { + return $this->_dep($this->info['Providename'], $this->info['Provideflags'], $this->info['Provideversion']); + } default: if (isset($this->info[$name])) { return $this->info[$name]; @@ -76,3 +114,12 @@ class Package extends Common { } } + +/* +$a = new File(dirname(__DIR__).'/tests/bidon.rpm'); +echo "Requires: "; print_r($a->Requires); +echo "Provides: "; print_r($a->Provides); +echo "Conflicts: "; print_r($a->Conflicts); +echo "Obsoletes: "; print_r($a->Obsoletes); +*/ + -- cgit