  			\<)	use_package=up_newer
  				pm_v "===>>> Available package ($latest_pv)"
  				pm_v "       is newer than installed ($upg_port)" ;;
-@@ -3541,7 +3764,12 @@
+@@ -3541,7 +3763,12 @@
  			pm_v "===>>> There is a package available ($latest_pv)"
  		fi
  	elif [ -n "$latest_pv" ]; then

 		[ -f "${LOCALBASE_COMPAT}/${file##*/}" ] &&
 			files="${files}${LOCALBASE_COMPAT}/${file##*/} "
 	done
@@ -3844,7 +4085,8 @@
 	/bin/unlink $dist_list_temp ; unset ds dist_list_temp
 fi
 

 			fi
 			origin=`origin_from_pdb $port` ;;
 		esac
@@ -3032,11 +3236,15 @@
 	case "$argv" in
 	'')	echo '' ; no_valid_port ;;
 	$pd/*)	portdir=${argv#$pd/} ;;
-	$pdb/*)	upg_port=${argv#$pdb/} ;;
+	$pdb/*)	if [ -z "$use_pkgng" ]; then
+			upg_port=${argv#$pdb/}
+		else
+			echo '' ; no_valid_port
+		fi ;;
 	/*)	echo '' ; no_valid_port ;;
 	*/*)	portdir=$argv ;;
 	\.)	portdir=${PWD##*/ports/} ;; # Not always $pd, could be symlink
-	*)	[ -d "$pdb/$argv" ] && upg_port=$argv ;;
+	*)	[ -z "$use_pkgng" -a -d "$pdb/$argv" ] && upg_port=$argv ;;
 	esac
 
 	if [ -z "$portdir" -a -z "$upg_port" ]; then
@@ -3069,7 +3277,7 @@
 
 	case "$arg2" in
 	*/*)	ro_opd=$arg2 ; ro_upg_port=`iport_from_origin $ro_opd` ;;
-	*)	if [ -d "$pdb/$arg2" ]; then
+	*)	if [ -z "$use_pkgng" -a -d "$pdb/$arg2" ]; then
 			ro_upg_port=$arg2
 		else
 			find_glob_dirs $arg2 && ro_upg_port=${glob_dirs#$pdb/}
@@ -3080,9 +3288,18 @@
 	unset arg2
 
 	if [ -z "$ro_upg_port" ]; then
-		if ! grep -ql "DEPORIGIN:$ro_opd$" $pdb/*/+CONTENTS; then
+		if [ -z "$use_pkgng" ]; then
+			grep -ql "DEPORIGIN:$ro_opd$" $pdb/*/+CONTENTS
+		else
+			pkg query -a "%do" | grep -q "^$ro_opd$"
+		fi
+		if [ "$?" -eq 1 ]; then
 			echo ''
-			echo "===>>> The second argument to -o can be a port in $pdb,"
+			if [ -z "$use_pkgng" ]; then
+				echo "===>>> The second argument to -o can be a port in $pdb,"
+			else
+				echo "===>>> The second argument to -o can be a package name,"
+			fi
 			echo "       or a port directory from $pd"
 			echo ''
 			echo "       $ro_opd does not seem to be installed,"
@@ -3525,7 +3742,12 @@
 		pm_v "===>>> Available package ($latest_pv) matches the current version"
 	elif [ -n "$latest_pv" -a -n "$PM_PACKAGES_NEWER" ]; then
 		if [ -n "$upg_port" ]; then
