 +								pm_unlink_s $package ;;
 +						esac
 +					fi
-+				unset port_ver
-+				continue
++					unset port_ver
++					continue
 +				fi
  				if [ ! -d "${pdb}/${pkg_dir}" ]; then
  					echo "	===>>> $pkg_dir is not installed"

 	pattern=`globstrip $1`
 
-	glob_dirs=`find $pdb -maxdepth 1 -type d -name ${pattern}\*`
+	if [ -z "${use_pkgng}" ]; then
+		glob_dirs=`find $pdb -maxdepth 1 -type d -name ${pattern}\*`
+	else
+		glob_dirs=`pkg query -g "%n-%v" ${pattern}\*`

 		fi
 		[ -n "$ro_upg_port" ] && ro_opd=`origin_from_pdb $ro_upg_port`
 	esac
@@ -3498,7 +3657,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
-			case `pkg_version -t $upg_port $latest_pv` in
+			if [ -z "$use_pkgng" ]; then
+				pkg_version="pkg_version"
+			else
+				pkg_version="pkg version"
