remicollet/rpminfo


Mirror of https://git.remirepo.net/cgit/tools/php-rpminfo.git/

License: Other

Language: C


RPM information extension for PHP

Retrieve RPM information from PHP code using librpm.

Notice: this is a experimental extension, a work in progress, so don't expect a stable API yet.


Sources

Build

You need the rpm development files (rpm-devel) version >= 4.11.3.

From the sources tree

$ phpize
$ ./configure --enable-rpminfo
$ make
$ make test

Usage

rpmvercmp

int rpmvercmp(string evr1, string evr2);

Allow to compare 2 EVR (epoch:version-release) strings. The return value is < 0 if evr1 < evr2, > 0 if evr1 > evr2, 0 if equal.

$ php -a
php > var_dump(rpmvercmp("1.0", "1.1"));
int(-1)
php > var_dump(rpmvercmp("1:1.0", "1.1"));
int(1)

rpminfo

array rpminfo(string path [, bool full  [, string &error]]);

Retrieve information from a rpm file, reading its metadata. If given error will be used to store error message instead of raising a warning. 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] => 
)

php > var_dump(rpminfo("missing.rpm"));
Warning: rpminfo(): Can't open 'missing.rpm': No such file or directory in php shell code on line 1
bool(false)

php > var_dump(rpminfo("missing.rpm", false, $error));
bool(false)
php > echo $error;
Can't open 'missing.rpm': No such file or directory

rpmdbinfo

array rpmdbinfo(string path [, bool full ]);

Retrieve information from rpm database about an installed package. The return value is an array of hash tables, or false if it fails.

$ php -a
php > print_r(rpmdbinfo("php"));
Array
(
    [0] => Array
        (
            [Name] => php
            [Version] => 7.2.2
            [Release] => 1.fc27.remi
            [Arch] => x86_64
        )
)

LICENSE

Author: Remi Collet

This extension is licensed under The PHP License, version 3.01


History

Created as a PoC, for fun, see history on https://blog.remirepo.net/post/2018/01/26/About-repomanage-performance-regression

Project Statistics

Sourcerank 3
Repository Size 52.7 KB
Stars 0
Forks 0
Watchers 1
Open issues 0
Dependencies 0
Contributors 1
Tags 15
Created
Last updated
Last pushed

Top Contributors See all

Remi Collet

Recent Tags See all

v0.6.0 June 18, 2021
v0.5.1 September 23, 2020
v0.5.0 April 07, 2020
v0.4.2 March 25, 2020
v0.4.1 March 18, 2020
v0.4.0 March 13, 2020
v0.3.1 March 12, 2020
v0.3.0 March 12, 2020
v0.2.3 March 11, 2020
v0.2.2 March 11, 2020
v0.2.1 February 12, 2018
v0.2.0 February 08, 2018
v0.1.2 February 08, 2018
v0.1.1 January 26, 2018
v0.1.0 January 26, 2018

Something wrong with this page? Make a suggestion

Last synced: 2018-02-12 16:53:15 UTC

Login to resync this repository