2009-02-05 14:46:09 +01:00
|
|
|
/*
|
2008-10-27 18:06:45 +01:00
|
|
|
* Compare package and version strings
|
2008-10-28 16:51:58 +01:00
|
|
|
* @ 2008
|
2008-10-27 18:06:45 +01:00
|
|
|
* Author: pancake <youterm.com>
|
|
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2008-12-21 23:57:02 +01:00
|
|
|
#include <xbps_api.h>
|
2008-10-27 18:06:45 +01:00
|
|
|
|
2008-12-23 12:28:21 +01:00
|
|
|
int main(int argc, char **argv)
|
2008-10-27 18:06:45 +01:00
|
|
|
{
|
2008-12-23 12:28:21 +01:00
|
|
|
if (argc<3) {
|
|
|
|
printf("Usage: xbps-cmpver [old] [new]\n");
|
|
|
|
printf(" xbpks-cmpver foo-1.2 foo-2.2 # $? = 1\n");
|
|
|
|
printf(" xbpks-cmpver foo-1.2 foo-1.2 # $? = 0\n");
|
|
|
|
return 1;
|
2008-10-27 18:06:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#if UNIT_TEST
|
2008-10-28 16:51:58 +01:00
|
|
|
printf("1.2 2.2 = %d\n", chkver("1.2", "2.2"));
|
|
|
|
printf("1.0 10.3 = %d\n", chkver("1.0", "10.3"));
|
|
|
|
printf("1.0 1.0 = %d\n", chkver("1.0", "1.0"));
|
|
|
|
printf("1.0 1.2 = %d\n", chkver("1.0", "1.2"));
|
|
|
|
printf("1.0.1 1.0.2 = %d\n", chkver("1.0.1", "1.0.2"));
|
|
|
|
printf("1.0beta 1.0rc1 = %d\n", chkver("1.0beta", "1.0rc1"));
|
|
|
|
#endif
|
|
|
|
|
2008-12-23 12:28:21 +01:00
|
|
|
return (xbps_cmpver_packages(argv[1], argv[2]) > 0)?1:0;
|
2008-10-27 18:06:45 +01:00
|
|
|
}
|