# HG changeset patch # User Franz Glasner # Date 1553179738 -3600 # Node ID ffd5f575edd50356e845d96f536455c2dbb31c8f # Parent 0ae7697702b39ec95c59000095a2adc83b1c1e4b FIX: Work around the bug in "pkg rquery -i" not asking the port's INDEX file. Parse the index file directly. diff -r 0ae7697702b3 -r ffd5f575edd5 bin/check-ports --- a/bin/check-ports Thu Mar 21 12:34:47 2019 +0100 +++ b/bin/check-ports Thu Mar 21 15:48:58 2019 +0100 @@ -43,6 +43,14 @@ # : ${PORTS_DIRECT_INSTALLED_REPO:=unknown-repository} +# +# For the workaround of the bug in pkg rquery -I +# +: ${PORTSDIR:=/usr/ports} +: ${INDEXDIR:=${PORTSDIR}} +: ${INDEXFILE:=INDEX-11} + + get_remote_repo_versions() { local _repo _data _rv @@ -96,14 +104,39 @@ } get_immediate_index_version() { - local _name _val _rv + local _package _line _fqpn _n _lines + + _package=$1 - _name=$1 +# _val=$(pkg rquery -I "${_package}" | cut -f 1 -d '|') +# _rv=$? +# immediate_index_version=${_val##*-} +# return ${_rv} - _val=$(pkg rquery -I "${_name}" | cut -f 1 -d '|') - _rv=$? - immediate_index_version=${_val##*-} - return ${_rv} + if [ -r "${INDEXDIR}/${INDEXFILE}" ] ; then + # + # Note: Direct piping does not set immediate_index_version at return correctly + # "_line" is set correctly and parsing works, but the return 0 seems to kill + # some of the previous effects. + # + # "grep" does a fast pre-selection, reading, parsing and comparing is done for + # exact matching. + # + _lines=$(egrep '^'"${_package}" "${INDEXDIR}/${INDEXFILE}") + while read _line ; do + _fqpn="${_line%%|*}" + _n=${_fqpn%-*} + if [ "${_package}" = "${_n}" ] ; then + immediate_index_version="${_fqpn##*-}" + return 0 + fi + done <