Project

General

Profile

« Previous | Next » 

Revision 8df1877b

Added by Renato Botelho over 9 years ago

Add pkg_version_compare()

View differences:

src/etc/inc/pkg-utils.inc
283 283
	return proc_close($process);
284 284
}
285 285

  
286
/* Compare 2 pkg versions and return:
287
 * '=' - versions are the same
288
 * '>' - $v1 > $v2
289
 * '<' - $v1 < $v2
290
 * '?' - Error
291
 */
292
function pkg_version_compare($v1, $v2) {
293
	if (empty($v1) || empty($v2)) {
294
		return '?';
295
	}
296

  
297
	$rc = pkg_exec("version -t '{$v1}' '{$v2}'", $stdout, $stderr);
298

  
299
	if ($rc != 0) {
300
		return '?';
301
	}
302

  
303
	return str_replace("\n", "", $stdout);
304
}
305

  
286 306
/* Check if package is installed */
287 307
function is_pkg_installed($pkg_name) {
288 308
	global $g;

Also available in: Unified diff