Project

General

Profile

« Previous | Next » 

Revision e5f96a2c

Added by Stilez y over 8 years ago

use wrapped version of pkg info -e instead

View differences:

src/etc/inc/pkg-utils.inc
393 393
		 */
394 394

  
395 395
		// pkg info errors if none match, unlike pkg search, so test it will work beforehand...
396
		$tmp1 = $tmp2 = '';
397
		$tmprc = pkg_exec("info -e -R --raw-format json-compact " . $pkgs, $tmp1, $tmp2);
398
		
399
		if ($tmprc == 0) {
400
			// ok, packages match, so pkg info can be safely called
396
		if (
397

  
398
	$extra_param = "";
399
	if ($local_only) {
400
		$extra_param = "-U ";
401
	}
402

  
403
	if ($lock) {
404
		mark_subsystem_dirty('pkg');
405
	}
406

  
407
	if (!$installed_only) {
408
		// repo catalog search (either remote or local_only)
409
		$rc = pkg_exec("search {$extra_param}-R --raw-format json-compact " . $pkgs, $out, $err);
410
	}
411
	if ($installed_only || ($local_only && $rc != 0)) {
412
		/* use pkg info if (1) installed pkg search or (2) local catalog copy search requested + failed.
413
		 *
414
		 * The local repo catalog copy may be cleared if a previous call to pkg search couldn't get the
415
		 * remote repo catalog.
416
		 *
417
		 * If the calling code would have accepted local copy info (which isn't assumed up to date) then it
418
		 * makes sense to fall back on pkg info to at least return the known info about installed pkgs (pkg
419
		 * info should still work), instead of failing and returning no info at all. For example, this
420
		 * enables offline view + management of installed pkgs.
421
		 */
422

  
423
		// pkg info errors if none match, unlike pkg search, so test it will work beforehand
424
		// is_package_installed() is a wrapper for pkg info -e <pattern> which is what we need here.
425
		if (is_package_installed($pkgs)) {
426
			// ok, 1 or more packages match, so pkg info can be safely called to get the pkg list
401 427
			$rc = pkg_exec("info -R --raw-format json-compact " . $pkgs, $out, $err);
402 428
		} // else we already have empty values for $out etc which are correct if none matched
403 429
	}

Also available in: Unified diff