From fc637fb28da700da71ec2064d65ca5a7a31b9c6c Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Sun, 18 Aug 2019 18:16:17 +0100 Subject: gentoo resync : 18.08.2019 --- eclass/savedconfig.eclass | 58 +++++++++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 20 deletions(-) (limited to 'eclass/savedconfig.eclass') diff --git a/eclass/savedconfig.eclass b/eclass/savedconfig.eclass index e0b1953d56d0..b2be715630af 100644 --- a/eclass/savedconfig.eclass +++ b/eclass/savedconfig.eclass @@ -38,6 +38,13 @@ case ${EAPI} in *) die "EAPI=${EAPI:-0} is not supported" ;; esac +# @ECLASS-VARIABLE: _SAVEDCONFIG_CONFIGURATION_FILE +# @DEFAULT_UNSET +# @INTERNAL +# @DESCRIPTION: +# Path of configuration file, relative to /etc/portage/savedconfig, +# restored by restore_config() and saved by save_config(). + # @FUNCTION: save_config # @USAGE: # @DESCRIPTION: @@ -51,20 +58,26 @@ save_config() { fi [[ $# -eq 0 ]] && die "Usage: save_config " - local dest="/etc/portage/savedconfig/${CATEGORY}" + local configfile + if [[ -n ${_SAVEDCONFIG_CONFIGURATION_FILE} ]] ; then + configfile="/etc/portage/savedconfig/${_SAVEDCONFIG_CONFIGURATION_FILE}" + else + configfile="/etc/portage/savedconfig/${CATEGORY}/${PF}" + fi + if [[ $# -eq 1 && -f $1 ]] ; then - # Just one file, so have the ${PF} be that config file - dodir "${dest}" - cp "$@" "${ED%/}/${dest}/${PF}" || die "failed to save $*" + # Just one file, so have the ${configfile} be that config file + dodir "${configfile%/*}" + cp "$@" "${ED%/}/${configfile}" || die "failed to save $*" else - # A dir, or multiple files, so have the ${PF} be a dir + # A dir, or multiple files, so have the ${configfile} be a dir # with all the saved stuff below it - dodir "${dest}/${PF}" - treecopy "$@" "${ED%/}/${dest}/${PF}" || die "failed to save $*" + dodir "${configfile}" + treecopy "$@" "${ED%/}/${configfile}" || die "failed to save $*" fi elog "Your configuration for ${CATEGORY}/${PF} has been saved in " - elog "/etc/portage/savedconfig/${CATEGORY}/${PF} for your editing pleasure." + elog "\"${configfile}\" for your editing pleasure." elog "You can edit these files by hand and remerge this package with" elog "USE=savedconfig to customise the configuration." elog "You can rename this file/directory to one of the following for" @@ -76,7 +89,7 @@ save_config() { # @FUNCTION: restore_config # @USAGE: # @DESCRIPTION: -# Restores the configuation saved ebuild previously potentially with user edits. +# Restores the package's configuration file probably with user edits. # You can restore a single file or a whole bunch, just make sure you call # restore_config with all of the files to restore at the same time. # @@ -100,28 +113,33 @@ restore_config() { use savedconfig || return - local found check configfile + local found check checked configfile local base=${PORTAGE_CONFIGROOT%/}/etc/portage/savedconfig for check in {${CATEGORY}/${PF},${CATEGORY}/${P},${CATEGORY}/${PN}}; do - configfile=${base}/${CTARGET}/${check} - [[ -r ${configfile} ]] || configfile=${base}/${CHOST}/${check} + configfile=${base}/${CTARGET:+"${CTARGET}/"}${check} + [[ -r ${configfile} ]] || configfile=${base}/${CHOST:+"${CHOST}/"}${check} [[ -r ${configfile} ]] || configfile=${base}/${check} - einfo "Checking existence of ${configfile} ..." - if [[ -r "${configfile}" ]]; then - einfo "found ${configfile}" - found=${configfile}; - break; + [[ "${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} " done + if [[ -f ${found} ]]; then - elog "Building using saved configfile ${found}" + elog "Building using saved configfile \"${found}\"" if [ $# -gt 0 ]; then cp -pPR "${found}" "$1" || die "Failed to restore ${found} to $1" else die "need to know the restoration filename" fi elif [[ -d ${found} ]]; then - elog "Building using saved config directory ${found}" + elog "Building using saved config directory \"${found}\"" local dest=${PWD} pushd "${found}" > /dev/null treecopy . "${dest}" || die "Failed to restore ${found} to $1" @@ -133,7 +151,7 @@ restore_config() { 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 ${PORTAGE_CONFIGROOT%/}/etc/portage/savedconfig/${CATEGORY}/${PN}" ewarn "Your config file(s) will not be used this time" fi } -- cgit v1.2.3