summaryrefslogtreecommitdiff
path: root/eclass/savedconfig.eclass
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2019-08-18 18:16:17 +0100
committerV3n3RiX <venerix@redcorelinux.org>2019-08-18 18:16:17 +0100
commitfc637fb28da700da71ec2064d65ca5a7a31b9c6c (patch)
tree326613a08f25851c388715e205576a2e7d25dc4f /eclass/savedconfig.eclass
parentb24bd25253fe093f722ab576d29fdc41d04cb1ee (diff)
gentoo resync : 18.08.2019
Diffstat (limited to 'eclass/savedconfig.eclass')
-rw-r--r--eclass/savedconfig.eclass58
1 files changed, 38 insertions, 20 deletions
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: <config files to save>
# @DESCRIPTION:
@@ -51,20 +58,26 @@ save_config() {
fi
[[ $# -eq 0 ]] && die "Usage: save_config <files>"
- 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: <config files to restore>
# @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
}