restore_config() is documented to support these configuration file name schemes: ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CTARGET}/${CATEGORY}/${PF} ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CHOST}/${CATEGORY}/${PF} ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CATEGORY}/${PF} ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CTARGET}/${CATEGORY}/${P} ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CHOST}/${CATEGORY}/${P} ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CATEGORY}/${P} ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CTARGET}/${CATEGORY}/${PN} ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CHOST}/${CATEGORY}/${PN} ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CATEGORY}/${PN} However variants with ${CTARGET} and ${CHOST} are used even when ${CTARGET} / ${CHOST} are empty. ${CTARGET} is usually empty, so effectively ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CATEGORY}/${PF} is used before ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CHOST}/${CATEGORY}/${PF} etc.
Created attachment 577334 [details, diff] Patch
I missed this one an proposed my own solution https://archives.gentoo.org/gentoo-dev/message/d9669ce53038803b5560445cbf35ab47 instead.
Pushed, https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=59e3009e8893e44ebb52abefe8fb1fbcd2adf57c
Unfortunately your commit does not solve the original problem and does not satisfy suggestion from the title of this bug. (Your commit makes unrelated cosmetic improvements.) Example situation: ${CTARGET} is empty ${CHOST} is non-empty ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CHOST}/${CATEGORY}/${PN} exists ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CATEGORY}/${PN} exists Other configuration files do not exist Both before and after your commit, ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CATEGORY}/${PN} is used. With my patch, ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CHOST}/${CATEGORY}/${PN} would be used. The order of checked configuration files is documented in eclass: # ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CTARGET}/${CATEGORY}/${PF} # ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CHOST}/${CATEGORY}/${PF} # ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CATEGORY}/${PF} # ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CTARGET}/${CATEGORY}/${P} # ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CHOST}/${CATEGORY}/${P} # ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CATEGORY}/${P} # ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CTARGET}/${CATEGORY}/${PN} # ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CHOST}/${CATEGORY}/${PN} # ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CATEGORY}/${PN}
Created attachment 586286 [details, diff] Patch Updated patch. "checked" variable changed to an array, so checking of elements can be done easier using has() function. Quoting of one path added.
Problem was that checked file path always contained CTARGET and CHOST, even when empty resulted in "//", bug 575164. Before that change: > >>> Preparing source in /var/tmp/portage/sys-kernel/linux-firmware-20190717/work/linux-firmware-20190717 ... > * Checking existence of /etc/portage/savedconfig//sys-kernel/linux-firmware-20190717 ... > ^^ > * found /etc/portage/savedconfig//sys-kernel/linux-firmware-20190717 > ^^ > * Building using saved configfile /etc/portage/savedconfig//sys-kernel/linux-firmware-20190717 > ^^ > * Removing all files not listed in config ... > >>> Source prepared. And now: USE=savedconfig, without any saved config: > >>> Preparing source in /var/tmp/portage/sys-kernel/linux-firmware-20190726-r2/work/linux-firmware-20190726 ... > * Checking existence of "/etc/portage/savedconfig/sys-kernel/linux-firmware-20190726-r2" ... > * Checking existence of "/etc/portage/savedconfig/sys-kernel/linux-firmware-20190726" ... > * Checking existence of "/etc/portage/savedconfig/sys-kernel/linux-firmware" ... > * No saved config to restore - please remove USE=savedconfig or > * provide a configuration file in /etc/portage/savedconfig/sys-kernel/linux-firmware > * Your config file(s) will not be used this time > * Removing all files not listed in config ... > >>> Source prepared. USE=savedconfig, with existing /etc/portage/savedconfig/sys-kernel/linux-firmware-20190726-r2 > >>> Preparing source in /var/tmp/portage/sys-kernel/linux-firmware-20190726-r2/work/linux-firmware-20190726 ... > * Checking existence of "/etc/portage/savedconfig/sys-kernel/linux-firmware-20190726-r2" ... > * Found "/etc/portage/savedconfig/sys-kernel/linux-firmware-20190726-r2" > * Building using saved configfile "/etc/portage/savedconfig/sys-kernel/linux-firmware-20190726-r2" > * Removing all files not listed in config ... > >>> Source prepared. And when you debug eclass you see that $CHOST and $CTARGET checks are working: > + for check in {${CATEGORY}/${PF},${CATEGORY}/${P},${CATEGORY}/${PN}} > + configfile=/etc/portage/savedconfig/my-ctarget/sys-kernel/linux-firmware-20190726-r2 > + [[ -r /etc/portage/savedconfig/my-ctarget/sys-kernel/linux-firmware-20190726-r2 ]] > + configfile=/etc/portage/savedconfig/my-chost/sys-kernel/linux-firmware-20190726-r2 > + [[ -r /etc/portage/savedconfig/my-chost/sys-kernel/linux-firmware-20190726-r2 ]] > + configfile=/etc/portage/savedconfig/sys-kernel/linux-firmware-20190726-r2 I see no problem.
This bug is about wrong order of checked files, not about cosmetic things in output. When ${CHOST} is non-empty and ${CTARGET} is empty, then the following paths should be checked in this order: ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CHOST}/${CATEGORY}/${PF} ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CATEGORY}/${PF} ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CHOST}/${CATEGORY}/${P} ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CATEGORY}/${P} ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CHOST}/${CATEGORY}/${PN} ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CATEGORY}/${PN} But current code checks paths in this order: ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CATEGORY}/${PF} ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CHOST}/${CATEGORY}/${PF} ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CATEGORY}/${P} ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CHOST}/${CATEGORY}/${P} ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CATEGORY}/${PN} ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CHOST}/${CATEGORY}/${PN}