Gentoo Archives: gentoo-dev

From: Thomas Deutschmann <whissi@g.o>
To: gentoo-dev@l.g.o
Cc: Arfrever@××××××.Org, base-system@g.o
Subject: [gentoo-dev] [PATCH v2 3/3] savedconfig.eclass: Only check config file candidate once
Date: Wed, 07 Aug 2019 20:55:33
Message-Id: 20190807205427.17241-3-whissi@gentoo.org
In Reply to: [gentoo-dev] [PATCH v2 1/3] savedconfig.eclass: Re-use configuration file scheme by Thomas Deutschmann
1 Due to the injection of $CTARGET and $CHOST in file path
2 we could end up with an already checked config file candidate
3 if $CTARGET or $CHOST isn't used.
4
5 This commit will make sure that we don't check the same file twice.
6
7 Signed-off-by: Thomas Deutschmann <whissi@g.o>
8 ---
9 eclass/savedconfig.eclass | 12 ++++++++----
10 1 file changed, 8 insertions(+), 4 deletions(-)
11
12 diff --git a/eclass/savedconfig.eclass b/eclass/savedconfig.eclass
13 index 1ea464271aff..b2be715630af 100644
14 --- a/eclass/savedconfig.eclass
15 +++ b/eclass/savedconfig.eclass
16 @@ -113,20 +113,24 @@ restore_config() {
17
18 use savedconfig || return
19
20 - local found check configfile
21 + local found check checked configfile
22 local base=${PORTAGE_CONFIGROOT%/}/etc/portage/savedconfig
23 for check in {${CATEGORY}/${PF},${CATEGORY}/${P},${CATEGORY}/${PN}}; do
24 - configfile=${base}/${CTARGET}/${check}
25 - [[ -r ${configfile} ]] || configfile=${base}/${CHOST}/${check}
26 + configfile=${base}/${CTARGET:+"${CTARGET}/"}${check}
27 + [[ -r ${configfile} ]] || configfile=${base}/${CHOST:+"${CHOST}/"}${check}
28 [[ -r ${configfile} ]] || configfile=${base}/${check}
29 - einfo "Checking existence of ${configfile} ..."
30 + [[ "${checked}" == *"${configfile} "* ]] && continue
31 + einfo "Checking existence of \"${configfile}\" ..."
32 if [[ -r "${configfile}" ]] ; then
33 einfo "Found \"${configfile}\""
34 found=${configfile}
35 _SAVEDCONFIG_CONFIGURATION_FILE=${configfile#${base}/}
36 break
37 fi
38 +
39 + checked+="${configfile} "
40 done
41 +
42 if [[ -f ${found} ]]; then
43 elog "Building using saved configfile \"${found}\""
44 if [ $# -gt 0 ]; then
45 --
46 2.22.0