  			\<)	use_package=up_newer
  				pm_v "===>>> Available package ($latest_pv)"
  				pm_v "       is newer than installed ($upg_port)" ;;
-@@ -3514,7 +3680,12 @@
+@@ -3514,7 +3678,12 @@
  			pm_v "===>>> There is a package available ($latest_pv)"
  		fi
  	elif [ -n "$latest_pv" ]; then
 -		case `pkg_version -t $new_port $latest_pv` in
-+		if [ -z "${use_pkgng}" ]; then
++		if [ -z "$use_pkgng" ]; then
 +			pkg_version="pkg_version"
 +		else
 +			pkg_version="pkg version"

 		\<)	# Could happen if ports tree is out of date
 			use_package=up_old_tree
 			pm_v "===>>> Available package ($latest_pv)"
@@ -3613,7 +3784,12 @@
 		    grep -v ^$LOCALBASE_COMPAT > $ldconfig_out
 
 		unset temp

 origin_from_pdb () {
 	local o
 
-	o=`grep -m1 '@comment ORIGIN:' $pdb/$1/+CONTENTS 2>/dev/null` && {
-		echo ${o#@comment ORIGIN:}; return 0; }
+	if [ -z "$use_pkgng" ]; then
+		o=`grep -m1 '@comment ORIGIN:' $pdb/$1/+CONTENTS 2>/dev/null` && {
+			echo ${o#@comment ORIGIN:}; return 0; }
+	else
+		pkg query "%o" $1; return 0;
+	fi
