Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
changeset 151:27b7454140be
Determine INDEXDIR and INDEXFILE dynamically from the packager configuration via "pkg config"
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sun, 03 Nov 2019 19:37:43 +0100 |
| parents | 937c96ffe358 |
| children | 29e708b524e1 |
| files | Makefile sbin/check-ports |
| diffstat | 2 files changed, 25 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Sun Nov 03 18:06:31 2019 +0100 +++ b/Makefile Sun Nov 03 19:37:43 2019 +0100 @@ -43,7 +43,6 @@ ${SED} -i "" -e "s|@@VERSION@@|${PORTVERSION}|" ${WRKSRC}/${_rp} ${SED} -i "" -e "s|@@HGREVISION@@|${HGREVISION}|" ${WRKSRC}/${_rp} ${SED} -i "" -e "s|@@ETCDIR@@|${ETCDIR}|" ${WRKSRC}/${_rp} - ${SED} -i "" -e "s|@@INDEXFILE@@|${INDEXFILE}|" ${WRKSRC}/${_rp} ${SED} -i "" -e "s|@@PKGORIGIN@@|${PKGORIGIN}|" ${WRKSRC}/${_rp} .endfor ${MKDIR} ${WRKSRC}/etc
--- a/sbin/check-ports Sun Nov 03 18:06:31 2019 +0100 +++ b/sbin/check-ports Sun Nov 03 19:37:43 2019 +0100 @@ -67,8 +67,6 @@ # For the workaround of the bug in pkg rquery -I # : ${PORTSDIR:=/usr/ports} -: ${INDEXDIR:=${PORTSDIR}} -: ${INDEXFILE:=@@INDEXFILE@@} test_exists_local_index() { @@ -82,6 +80,25 @@ } +get_index_directory() { + : 'Ask the packager configuration for the `INDEXDIR` and/or `PORTSDIR` + configuration value: either `INDEXDIR` or -- if `INDEXDIR` is empty -- + `PORTSDIR` is used. + + Output (stdout) + the directory where the index database file lives + + ' + local _dir + + _dir="$(pkg config INDEXDIR)" + if [ -z "${_dir}" ]; then + _dir="$(pkg config PORTSDIR)" + fi + printf '%s' "${_dir}" +} + + get_immediate_index_version() { : 'Determine for package `_package` the version of the package in the local ports index. @@ -89,10 +106,6 @@ Args: _package: the package name to search for - Input (Globals): - INDEXDIR: the directory where to search the index file - INDEXFILE: the name of the index file - Returns: 0 on success, 1 on errors or if the package is not in the local ports index @@ -102,6 +115,7 @@ ' local _package _line _fqpn _n _lines + local _indexdir _indexfile _package="$1" @@ -110,7 +124,10 @@ # immediate_index_version=${_val##*-} # return ${_rv} - if [ -r "${INDEXDIR}/${INDEXFILE}" ] ; then + _indexdir="$(get_index_directory)" + _indexfile="$(pkg config INDEXFILE)" + + 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 @@ -119,7 +136,7 @@ # "grep" does a fast pre-selection, reading, parsing and comparing is done for # exact matching. # - _lines=$(egrep '^'"${_package}" "${INDEXDIR}/${INDEXFILE}") + _lines=$(egrep '^'"${_package}" "${_indexdir}/${_indexfile}") while read _line ; do _fqpn="${_line%%|*}" _n=${_fqpn%-*}
