From 5abc37b1651980a008601cd818fdd4c85902e0d1 Mon Sep 17 00:00:00 2001 From: Arfrever Frehtes Taifersar Arahesis Date: Fri, 9 Aug 2019 04:56:33 +0000 Subject: [PATCH] savedconfig.eclass: Fix handling of ${CTARGET} and ${CHOST}. Use configuration file schemes containing ${CTARGET} / ${CHOST} (e.g. /etc/portage/savedconfig/${CTARGET}/${CATEGORY}/${PN} or /etc/portage/savedconfig/${CHOST}/${CATEGORY}/${PN}) only when ${CTARGET} / ${CHOST} are not empty. Fixes: https://bugs.gentoo.org/686350 Signed-off-by: Arfrever Frehtes Taifersar Arahesis --- eclass/savedconfig.eclass | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/eclass/savedconfig.eclass b/eclass/savedconfig.eclass index b2be715630a..8ab42b5eed3 100644 --- a/eclass/savedconfig.eclass +++ b/eclass/savedconfig.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2019 Gentoo Authors +# Copyright 2007-2019 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: savedconfig.eclass @@ -113,24 +113,24 @@ restore_config() { use savedconfig || return - local found check checked configfile + local checked=() configfile found package_dependency_spec local base=${PORTAGE_CONFIGROOT%/}/etc/portage/savedconfig - for check in {${CATEGORY}/${PF},${CATEGORY}/${P},${CATEGORY}/${PN}}; do - configfile=${base}/${CTARGET:+"${CTARGET}/"}${check} - [[ -r ${configfile} ]] || configfile=${base}/${CHOST:+"${CHOST}/"}${check} - [[ -r ${configfile} ]] || configfile=${base}/${check} - [[ "${checked}" == *"${configfile} "* ]] && continue - einfo "Checking existence of \"${configfile}\" ..." - if [[ -r "${configfile}" ]] ; then - einfo "Found \"${configfile}\"" - found=${configfile} - _SAVEDCONFIG_CONFIGURATION_FILE=${configfile#${base}/} - break - fi - - checked+="${configfile} " + for package_dependency_spec in {${CATEGORY}/${PF},${CATEGORY}/${P},${CATEGORY}/${PN}}; do + for configfile in ${CTARGET:+"${base}/${CTARGET}/${package_dependency_spec}"} \ + ${CHOST:+"${base}/${CHOST}/${package_dependency_spec}"} \ + "${base}/${package_dependency_spec}"; do + has "${configfile}" "${checked[@]}" && continue + einfo "Checking existence of \"${configfile}\" ..." + if [[ -r ${configfile} ]] ; then + einfo "Found \"${configfile}\"" + found=${configfile} + _SAVEDCONFIG_CONFIGURATION_FILE=${configfile#${base}/} + break 2 + fi + + checked+=("${configfile}") + done done - if [[ -f ${found} ]]; then elog "Building using saved configfile \"${found}\"" if [ $# -gt 0 ]; then @@ -145,13 +145,13 @@ restore_config() { treecopy . "${dest}" || die "Failed to restore ${found} to $1" popd > /dev/null else - # maybe the user is screwing around with perms they shouldnt #289168 + # maybe the user is screwing around with perms they shouldn't #289168 if [[ ! -r ${base} ]] ; then eerror "Unable to read ${base} -- please check its permissions." die "Reading config files failed" fi ewarn "No saved config to restore - please remove USE=savedconfig or" - ewarn "provide a configuration file in ${PORTAGE_CONFIGROOT%/}/etc/portage/savedconfig/${CATEGORY}/${PN}" + ewarn "provide a configuration file in \"${base}/${CATEGORY}/${PN}\"" ewarn "Your config file(s) will not be used this time" fi } -- 2.22.0