2008-10-27 17:06:45 +00:00
|
|
|
/*
|
|
|
|
* Compare package and version strings
|
2008-10-28 15:51:58 +00:00
|
|
|
* @ 2008
|
2008-10-27 17:06:45 +00:00
|
|
|
* Author: pancake <youterm.com>
|
|
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2008-12-21 22:57:02 +00:00
|
|
|
#include <xbps_api.h>
|
2008-10-27 17:06:45 +00:00
|
|
|
|
2008-12-23 11:28:21 +00:00
|
|
|
int main(int argc, char **argv)
|
2008-10-27 17:06:45 +00:00
|
|
|
{
|
2008-12-23 11:28:21 +00: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 17:06:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#if UNIT_TEST
|
2008-10-28 15:51:58 +00: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 11:28:21 +00:00
|
|
|
return (xbps_cmpver_packages(argv[1], argv[2]) > 0)?1:0;
|
2008-10-27 17:06:45 +00:00
|
|
|
}
|