From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 19C1E138335 for ; Thu, 8 Aug 2019 19:47:57 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 16E46E07FE; Thu, 8 Aug 2019 19:47:56 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id E6CD0E07FE for ; Thu, 8 Aug 2019 19:47:55 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B169E3496B9 for ; Thu, 8 Aug 2019 19:47:54 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 59B0F2A5 for ; Thu, 8 Aug 2019 19:47:52 +0000 (UTC) From: "Thomas Deutschmann" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Thomas Deutschmann" Message-ID: <1565293661.a0c35ad8ee8f8f89ba6044dd5b44e9479c6a1775.whissi@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/savedconfig.eclass X-VCS-Directories: eclass/ X-VCS-Committer: whissi X-VCS-Committer-Name: Thomas Deutschmann X-VCS-Revision: a0c35ad8ee8f8f89ba6044dd5b44e9479c6a1775 X-VCS-Branch: master Date: Thu, 8 Aug 2019 19:47:52 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: fb426182-b4be-435b-ba10-dd2e5404f6dd X-Archives-Hash: 4b84508086b2b1e3ec734a9a17fa0350 commit: a0c35ad8ee8f8f89ba6044dd5b44e9479c6a1775 Author: Arfrever Frehtes Taifersar Arahesis Apache Org> AuthorDate: Sat Aug 3 11:41:09 2019 +0000 Commit: Thomas Deutschmann gentoo org> CommitDate: Thu Aug 8 19:47:41 2019 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a0c35ad8 savedconfig.eclass: Re-use configuration file scheme Make save_config() re-use configuration file scheme used by restore_config(). Fixes: https://bugs.gentoo.org/686348 Signed-off-by: Arfrever Frehtes Taifersar Arahesis Apache.Org> Signed-off-by: Thomas Deutschmann gentoo.org> eclass/savedconfig.eclass | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/eclass/savedconfig.eclass b/eclass/savedconfig.eclass index e0b1953d56d..f62a6055ffd 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. # @@ -107,10 +120,11 @@ restore_config() { [[ -r ${configfile} ]] || configfile=${base}/${CHOST}/${check} [[ -r ${configfile} ]] || configfile=${base}/${check} einfo "Checking existence of ${configfile} ..." - if [[ -r "${configfile}" ]]; then - einfo "found ${configfile}" - found=${configfile}; - break; + if [[ -r "${configfile}" ]] ; then + einfo "Found \"${configfile}\"" + found=${configfile} + _SAVEDCONFIG_CONFIGURATION_FILE=${configfile#${base}/} + break fi done if [[ -f ${found} ]]; then