summaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2018-01-26 13:29:22 +0100
committerRemi Collet <remi@remirepo.net>2018-01-26 13:29:22 +0100
commit5aedac010fa0ec10e31ee39c81688830d1e0e3ea (patch)
treef2fcb3e61f0b955f95a7416b2f0a4ed9c8c6a9d4 /README.md
parent70afefed1c8156cff03e254ab4a20cff955007e4 (diff)
rewrite README.md
Diffstat (limited to 'README.md')
-rw-r--r--README.md92
1 files changed, 66 insertions, 26 deletions
diff --git a/README.md b/README.md
index 1584173..d572920 100644
--- a/README.md
+++ b/README.md
@@ -1,43 +1,83 @@
-rpminfo
-=======
+# RPM information extension for PHP
-Experimental wrapper for librpm
+Retrieve RPM information from PHP code using librpm.
-For now, only expose
+**Notice**: this is a experimental extension, a work in progress, so don't expect a stable API yet.
- int rpmvercmp(string evr1, string evr2);
- array rpminfo(string path [, bool full ]);
+----
+# Build
-Mostly a PoC build for fun because of
+You need the rpm development files (rpm-devel) version >= 4.11.3.
-https://bugzilla.redhat.com/1537981
-performance issue: dnf repomanage is really slow
+From the sources tree
+ $ phpize
+ $ ./configure --enable-rpminfo
+ $ make
+ $ make test
-Some benchmark results (find 15 old RPMs among 5000)
+----
-# DNF on Fedora 27
+# Usage
- $ time dnf repomanage --old --keep 5 .
- ...
- real 0m15,971s
+## rpmvercmp
-# DNF on Fedora 25
+ int rpmvercmp(string evr1, string evr2);
- $ time dnf repomanage --old --keep 5 .
- ...
- real 0m0,269s
+Allow to compare 2 EVR (epoch:version-release) strings. The return value is < 0 if evr1 < evr2, > 0 if evr1 > evr2, 0 if equal.
-# YUM on RHEL / CentOS
+ $ php -a
+ php > var_dump(rpmvercmp("1.0", "1.1"));
+ int(-1)
+ php > var_dump(rpmvercmp("1:1.0", "1.1"));
+ int(1)
- $ time repomanage --old --keep 5 .
- ...
- real 0m5.519s
-# PHP script
+## rpminfo
- $ time php repomanage.php --old --keep 5 .
- ...
- real 0m0,135s
+ array rpminfo(string path [, bool full ]);
+Retrieve information from a rpm file, reading its metadata.
+The return value is a hash table, or false if it fails.
+
+ $ php -a
+ php > print_r(rpminfo("tests/bidon.rpm"));
+ Array
+ (
+ [Name] => bidon
+ [Version] => 1
+ [Release] => 1.fc25.remi
+ [Arch] => x86_64
+ )
+ php > print_r(rpminfo("tests/bidon.rpm", true));
+ Array
+ (
+ [Headeri18ntable] => C
+ [Sigsize] => 2304
+ [Sigmd5] => 644819c3566819b1e10a5c97943de094
+ [Sha1header] => 0a86742fe53973ac9ab4611187a83ffb44f1de5a
+ [Sha256header] => 9aab7242a80212ad1fe4fdd3b250c0c4f176c0b3fb1355c0d62ff094fc3f7da0
+ [Name] => bidon
+ [Version] => 1
+ [Release] => 1.fc25.remi
+ [Summary] => Bidon
+ [Description] => A dummy package
+ ...
+ [IsSource] =>
+ )
+
+----
+
+# LICENSE
+
+Author: Remi Collet
+
+This extension is licensed under [The PHP License, version 3.01](http://www.php.net/license/3_01.txt)
+
+-----
+
+# History
+
+Created as a PoC, for fun, see history on
+https://blog.remirepo.net/post/2018/01/26/About-repomanage-performance-regression