1 |
commit: a0c35ad8ee8f8f89ba6044dd5b44e9479c6a1775 |
2 |
Author: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org> |
3 |
AuthorDate: Sat Aug 3 11:41:09 2019 +0000 |
4 |
Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Aug 8 19:47:41 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a0c35ad8 |
7 |
|
8 |
savedconfig.eclass: Re-use configuration file scheme |
9 |
|
10 |
Make save_config() re-use configuration file scheme used |
11 |
by restore_config(). |
12 |
|
13 |
Fixes: https://bugs.gentoo.org/686348 |
14 |
Signed-off-by: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache.Org> |
15 |
Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org> |
16 |
|
17 |
eclass/savedconfig.eclass | 40 +++++++++++++++++++++++++++------------- |
18 |
1 file changed, 27 insertions(+), 13 deletions(-) |
19 |
|
20 |
diff --git a/eclass/savedconfig.eclass b/eclass/savedconfig.eclass |
21 |
index e0b1953d56d..f62a6055ffd 100644 |
22 |
--- a/eclass/savedconfig.eclass |
23 |
+++ b/eclass/savedconfig.eclass |
24 |
@@ -38,6 +38,13 @@ case ${EAPI} in |
25 |
*) die "EAPI=${EAPI:-0} is not supported" ;; |
26 |
esac |
27 |
|
28 |
+# @ECLASS-VARIABLE: _SAVEDCONFIG_CONFIGURATION_FILE |
29 |
+# @DEFAULT_UNSET |
30 |
+# @INTERNAL |
31 |
+# @DESCRIPTION: |
32 |
+# Path of configuration file, relative to /etc/portage/savedconfig, |
33 |
+# restored by restore_config() and saved by save_config(). |
34 |
+ |
35 |
# @FUNCTION: save_config |
36 |
# @USAGE: <config files to save> |
37 |
# @DESCRIPTION: |
38 |
@@ -51,20 +58,26 @@ save_config() { |
39 |
fi |
40 |
[[ $# -eq 0 ]] && die "Usage: save_config <files>" |
41 |
|
42 |
- local dest="/etc/portage/savedconfig/${CATEGORY}" |
43 |
+ local configfile |
44 |
+ if [[ -n ${_SAVEDCONFIG_CONFIGURATION_FILE} ]] ; then |
45 |
+ configfile="/etc/portage/savedconfig/${_SAVEDCONFIG_CONFIGURATION_FILE}" |
46 |
+ else |
47 |
+ configfile="/etc/portage/savedconfig/${CATEGORY}/${PF}" |
48 |
+ fi |
49 |
+ |
50 |
if [[ $# -eq 1 && -f $1 ]] ; then |
51 |
- # Just one file, so have the ${PF} be that config file |
52 |
- dodir "${dest}" |
53 |
- cp "$@" "${ED%/}/${dest}/${PF}" || die "failed to save $*" |
54 |
+ # Just one file, so have the ${configfile} be that config file |
55 |
+ dodir "${configfile%/*}" |
56 |
+ cp "$@" "${ED%/}/${configfile}" || die "failed to save $*" |
57 |
else |
58 |
- # A dir, or multiple files, so have the ${PF} be a dir |
59 |
+ # A dir, or multiple files, so have the ${configfile} be a dir |
60 |
# with all the saved stuff below it |
61 |
- dodir "${dest}/${PF}" |
62 |
- treecopy "$@" "${ED%/}/${dest}/${PF}" || die "failed to save $*" |
63 |
+ dodir "${configfile}" |
64 |
+ treecopy "$@" "${ED%/}/${configfile}" || die "failed to save $*" |
65 |
fi |
66 |
|
67 |
elog "Your configuration for ${CATEGORY}/${PF} has been saved in " |
68 |
- elog "/etc/portage/savedconfig/${CATEGORY}/${PF} for your editing pleasure." |
69 |
+ elog "\"${configfile}\" for your editing pleasure." |
70 |
elog "You can edit these files by hand and remerge this package with" |
71 |
elog "USE=savedconfig to customise the configuration." |
72 |
elog "You can rename this file/directory to one of the following for" |
73 |
@@ -76,7 +89,7 @@ save_config() { |
74 |
# @FUNCTION: restore_config |
75 |
# @USAGE: <config files to restore> |
76 |
# @DESCRIPTION: |
77 |
-# Restores the configuation saved ebuild previously potentially with user edits. |
78 |
+# Restores the package's configuration file probably with user edits. |
79 |
# You can restore a single file or a whole bunch, just make sure you call |
80 |
# restore_config with all of the files to restore at the same time. |
81 |
# |
82 |
@@ -107,10 +120,11 @@ restore_config() { |
83 |
[[ -r ${configfile} ]] || configfile=${base}/${CHOST}/${check} |
84 |
[[ -r ${configfile} ]] || configfile=${base}/${check} |
85 |
einfo "Checking existence of ${configfile} ..." |
86 |
- if [[ -r "${configfile}" ]]; then |
87 |
- einfo "found ${configfile}" |
88 |
- found=${configfile}; |
89 |
- break; |
90 |
+ if [[ -r "${configfile}" ]] ; then |
91 |
+ einfo "Found \"${configfile}\"" |
92 |
+ found=${configfile} |
93 |
+ _SAVEDCONFIG_CONFIGURATION_FILE=${configfile#${base}/} |
94 |
+ break |
95 |
fi |
96 |
done |
97 |
if [[ -f ${found} ]]; then |