Lines 1-4
Link Here
|
1 |
# Copyright 1999-2011 Gentoo Foundation |
1 |
# Copyright 2007-2019 Gentoo Authors |
2 |
# Distributed under the terms of the GNU General Public License v2 |
2 |
# Distributed under the terms of the GNU General Public License v2 |
3 |
|
3 |
|
4 |
# @ECLASS: savedconfig.eclass |
4 |
# @ECLASS: savedconfig.eclass |
Lines 33-38
inherit portability
Link Here
|
33 |
|
33 |
|
34 |
IUSE="savedconfig" |
34 |
IUSE="savedconfig" |
35 |
|
35 |
|
|
|
36 |
# @ECLASS-VARIABLE: _SAVEDCONFIG_CONFIGURATION_FILE |
37 |
# @DEFAULT_UNSET |
38 |
# @INTERNAL |
39 |
# @DESCRIPTION: |
40 |
# Path of configuration file, relative to /etc/portage/savedconfig, |
41 |
# restored by restore_config() and saved by save_config(). |
42 |
|
36 |
# @FUNCTION: save_config |
43 |
# @FUNCTION: save_config |
37 |
# @USAGE: <config files to save> |
44 |
# @USAGE: <config files to save> |
38 |
# @DESCRIPTION: |
45 |
# @DESCRIPTION: |
Lines 49-68
save_config() {
Link Here
|
49 |
# Be lazy in our EAPI compat |
56 |
# Be lazy in our EAPI compat |
50 |
: ${ED:=${D}} |
57 |
: ${ED:=${D}} |
51 |
|
58 |
|
52 |
local dest="/etc/portage/savedconfig/${CATEGORY}" |
59 |
local configfile |
|
|
60 |
if [[ -n ${_SAVEDCONFIG_CONFIGURATION_FILE} ]]; then |
61 |
configfile="/etc/portage/savedconfig/${_SAVEDCONFIG_CONFIGURATION_FILE}" |
62 |
else |
63 |
configfile="/etc/portage/savedconfig/${CATEGORY}/${PF}" |
64 |
fi |
65 |
|
53 |
if [[ $# -eq 1 && -f $1 ]] ; then |
66 |
if [[ $# -eq 1 && -f $1 ]] ; then |
54 |
# Just one file, so have the ${PF} be that config file |
67 |
# Just one file, so have the ${configfile} be that config file |
55 |
dodir "${dest}" |
68 |
dodir "${configfile%/*}" |
56 |
cp "$@" "${ED}/${dest}/${PF}" || die "failed to save $*" |
69 |
cp "$@" "${ED}/${configfile}" || die "failed to save $*" |
57 |
else |
70 |
else |
58 |
# A dir, or multiple files, so have the ${PF} be a dir |
71 |
# A dir, or multiple files, so have the ${configfile} be a dir |
59 |
# with all the saved stuff below it |
72 |
# with all the saved stuff below it |
60 |
dodir "${dest}/${PF}" |
73 |
dodir "${configfile}" |
61 |
treecopy "$@" "${ED}/${dest}/${PF}" || die "failed to save $*" |
74 |
treecopy "$@" "${ED}/${configfile}" || die "failed to save $*" |
62 |
fi |
75 |
fi |
63 |
|
76 |
|
64 |
elog "Your configuration for ${CATEGORY}/${PF} has been saved in " |
77 |
elog "Your configuration for ${CATEGORY}/${PF} has been saved in " |
65 |
elog "/etc/portage/savedconfig/${CATEGORY}/${PF} for your editing pleasure." |
78 |
elog "\"${configfile}\" for your editing pleasure." |
66 |
elog "You can edit these files by hand and remerge this package with" |
79 |
elog "You can edit these files by hand and remerge this package with" |
67 |
elog "USE=savedconfig to customise the configuration." |
80 |
elog "USE=savedconfig to customise the configuration." |
68 |
elog "You can rename this file/directory to one of the following for" |
81 |
elog "You can rename this file/directory to one of the following for" |
Lines 74-80
save_config() {
Link Here
|
74 |
# @FUNCTION: restore_config |
87 |
# @FUNCTION: restore_config |
75 |
# @USAGE: <config files to restore> |
88 |
# @USAGE: <config files to restore> |
76 |
# @DESCRIPTION: |
89 |
# @DESCRIPTION: |
77 |
# Restores the configuation saved ebuild previously potentially with user edits. |
90 |
# Restores the configuration saved ebuild previously potentially with user edits. |
78 |
# You can restore a single file or a whole bunch, just make sure you call |
91 |
# You can restore a single file or a whole bunch, just make sure you call |
79 |
# restore_config with all of the files to restore at the same time. |
92 |
# restore_config with all of the files to restore at the same time. |
80 |
# |
93 |
# |
Lines 99-114
restore_config() {
Link Here
|
99 |
use savedconfig || return |
112 |
use savedconfig || return |
100 |
|
113 |
|
101 |
local found check configfile |
114 |
local found check configfile |
102 |
local base=${PORTAGE_CONFIGROOT}/etc/portage/savedconfig |
115 |
local base=${PORTAGE_CONFIGROOT%/}/etc/portage/savedconfig |
103 |
for check in {${CATEGORY}/${PF},${CATEGORY}/${P},${CATEGORY}/${PN}}; do |
116 |
for check in {${CATEGORY}/${PF},${CATEGORY}/${P},${CATEGORY}/${PN}}; do |
104 |
configfile=${base}/${CTARGET}/${check} |
117 |
configfile=${base}/${CTARGET}/${check} |
105 |
[[ -r ${configfile} ]] || configfile=${base}/${CHOST}/${check} |
118 |
[[ -r ${configfile} ]] || configfile=${base}/${CHOST}/${check} |
106 |
[[ -r ${configfile} ]] || configfile=${base}/${check} |
119 |
[[ -r ${configfile} ]] || configfile=${base}/${check} |
107 |
einfo "Checking existence of ${configfile} ..." |
120 |
einfo "Checking existence of ${configfile} ..." |
108 |
if [[ -r "${configfile}" ]]; then |
121 |
if [[ -r "${configfile}" ]]; then |
109 |
einfo "found ${configfile}" |
122 |
einfo "Found ${configfile}" |
110 |
found=${configfile}; |
123 |
found=${configfile} |
111 |
break; |
124 |
_SAVEDCONFIG_CONFIGURATION_FILE=${configfile#${base}/} |
|
|
125 |
break |
112 |
fi |
126 |
fi |
113 |
done |
127 |
done |
114 |
if [[ -f ${found} ]]; then |
128 |
if [[ -f ${found} ]]; then |
115 |
- |
|
|