pgrpm -- Rpm functions for postgresql This module provides functions (and operators) to compare version using rpm behaviour. A version for rpm is a string containing alphanumerics values; rpm use a special semantic to compare rpm version, taking care of epoch (put at begining with ':'), spliting the string into a version and a release (separated by a '-'), and comparing number part as number, string part as normal string, in fews words this means 10.1-1 < 10-2 < 9.1-1. INSTALL: Requirement: - rpm devellopment files - postgres devellopment files - postgres contrib makefile Build: make Install: make install To finally install the function in postgres server run the pgrpm.sql: psql -U postgres -f pgrpm.sql If you are upgrading, you may prefer to use pgrpm-update.sql, it is likelly the same script but run 'CREATE FUNCTION or REPLACE' and 'DROP OPERATOR' before creation. If you want to be sure no existing operators or functions be overwritten, don't use it. PROVIDED DATA TYPE: pgrpm will created a new data type called 'rpmheader'. This is a string representation of a rpmheader like rpm does to fill the rpmdb. Internnaly, this data follow same rules than 'bytea' type. Pgrpm provide basic function to query the header, of course selecting the itself is not really usefull. PROVIDED FUNCTIONS: text rpmtag(int) Return the tagName corresponding to the given internal value int rpmtag(text) Return the internal value for given tag name bool rpmdepmatch(INT, TEXT, INT, TEXT); bool rpmdepmatch(TEXT, INT, TEXT, TEXT, INT, TEXT) Compare dependancies (sense flag, version and name, sense flag, version) and return true if match. int rpmvercmp(text, text) Compare two version, return 1 if first is higher, 0 if equal, -1 if first is lesser bool rpmvercmpeq(text, text) Return TRUE if both are equal bool rpmvercmpne(text, text) Return TRUE if version differ bool rpmvercmpgt(text, text) Return TRUE if first is greater bool rpmvercmpget(text, text) Return TRUE if first is greater or equal bool rpmvercmplt(text, text) Return TRUE is first is lesser bool rpmvercmplet(text, text) Return TRUE is first is lesser or equal int rpmsenseflag(TEXT) TEXT rpmsenseflag(int) Convert sense flags to a human value (<=> instead integer) text rpmfileflag(int) Convert fileflags to a human value text rpmfilemode(int) Convert file mode like ls -l does. rpmheader rpmheader_in(cstring) cstring rpmheader_out(rpmheader) Those functions are use to insert or dump a header, it follow same rules than bytea. I don't think you would use these functions but there are here to be able to dump your database. header rpmheaderfromfile(TEXT) Return a rpmheader from a the rpmfile given as argument. Remember the function is run by the backend, so the file should readable by the postgresql server. text rpmqueryformat(rpmheader, text) Perform a query on the header like rpm --queryformat does. See rpm documentation text rpmtagn(rpmheader, INT, INT) text rpmtagn(rpmheader, TEXT, INT) Return an entry of a tag from the header. This is usefull to retrieve a simple information from the header like tag NAME, VERSION, ect... First entry is 0. text rpmtag(rpmheader, INT) text rpmtag(rpmheader, TEXT) Short-cut to rpmtagn(<header>, <tag>, 0). bytea rpmquery(rpmheader, int) bytea rpmquery(rpmheader, text) Return the tag value found inside the header. All tag are return to a string values. _rpmdeps rpmquerydeps(rpmheader, text) Return a setof for each dep of 'type'. The first letter of type should be: - Requires - Provides - Conflicts - Obsoletes - Triggers _rpmfiles rpmqueryfiles(rpmheader) Return a setof for each files in the header. PROVIDED OPERATORS: a == b TRUE if a equal b a <=> b TRUE if a not equal b a << b TRUE if a lesser than b a <<= b TRUE if a lesser or equal to b a >> b TRUE if a greater than b a >>= b TRUE if a greater or equal to b BUGS AND ISSUE: - my english is horrible: I know, patch welcome - you need to have rpmlib available on your system AUTHOR: Olivier Thauvin <olivier.thauvin@aerov.jussieu.fr> Special thanks to erinmargault for the spelling check. Thanks to Olivier Blin (code factor). Thanks to Jeff Johnson for its RPM5 compatibility patch. This project is hosted by PgFoundry: http://pgfoundry.org/projects/pgrpm/ $Id: README.pgrpm,v 1.9 2008/07/18 13:34:34 nanardon Exp $