Gentoo Archives: gentoo-dev

From: David Seifert <soap@g.o>
To: gentoo-dev@l.g.o
Cc: base-system@g.o
Subject: Re: [gentoo-dev] [PATCH] savedconfig.eclass: clean up ED and EROOT usage
Date: Thu, 23 May 2019 23:16:15
Message-Id: 7a2d793a623cc5f8a699e90a97da73986eaa72cf.camel@gentoo.org
In Reply to: [gentoo-dev] [PATCH] savedconfig.eclass: clean up ED and EROOT usage by Mike Gilbert
1 On Thu, 2019-05-23 at 11:15 -0400, Mike Gilbert wrote:
2 > Avoid assigning these variables in EAPIs where they are already
3 > defined.
4 > Also make them local variables to avoid polluting the global
5 > environment.
6 >
7 > Closes: https://bugs.gentoo.org/685382
8 > ---
9 > eclass/savedconfig.eclass | 18 ++++++++++--------
10 > 1 file changed, 10 insertions(+), 8 deletions(-)
11 >
12 > diff --git a/eclass/savedconfig.eclass b/eclass/savedconfig.eclass
13 > index 1e9ac6c80b4d..9bd308685b2d 100644
14 > --- a/eclass/savedconfig.eclass
15 > +++ b/eclass/savedconfig.eclass
16 > @@ -46,19 +46,20 @@ save_config() {
17 > fi
18 > [[ $# -eq 0 ]] && die "Usage: save_config <files>"
19 >
20 > - # Be lazy in our EAPI compat
21 > - : ${ED:=${D}}
22 > + case ${EAPI:-0} in
23 > + 0|1|2) local ED=${D}
24 > + esac
25 >
26 > local dest="/etc/portage/savedconfig/${CATEGORY}"
27 > if [[ $# -eq 1 && -f $1 ]] ; then
28 > # Just one file, so have the ${PF} be that config file
29 > dodir "${dest}"
30 > - cp "$@" "${ED}/${dest}/${PF}" || die "failed to save
31 > $*"
32 > + cp "$@" "${ED%/}/${dest}/${PF}" || die "failed to save
33 > $*"
34 > else
35 > # A dir, or multiple files, so have the ${PF} be a dir
36 > # with all the saved stuff below it
37 > dodir "${dest}/${PF}"
38 > - treecopy "$@" "${ED}/${dest}/${PF}" || die "failed to
39 > save $*"
40 > + treecopy "$@" "${ED%/}/${dest}/${PF}" || die "failed to
41 > save $*"
42 > fi
43 >
44 > elog "Your configuration for ${CATEGORY}/${PF} has been saved
45 > in "
46 > @@ -99,7 +100,7 @@ restore_config() {
47 > use savedconfig || return
48 >
49 > local found check configfile
50 > - local base=${PORTAGE_CONFIGROOT}/etc/portage/savedconfig
51 > + local base=${PORTAGE_CONFIGROOT%/}/etc/portage/savedconfig
52 > for check in
53 > {${CATEGORY}/${PF},${CATEGORY}/${P},${CATEGORY}/${PN}}; do
54 > configfile=${base}/${CTARGET}/${check}
55 > [[ -r ${configfile} ]] ||
56 > configfile=${base}/${CHOST}/${check}
57 > @@ -143,10 +144,11 @@ savedconfig_pkg_postinst() {
58 > # are worse :/.
59 >
60 > if use savedconfig ; then
61 > - # Be lazy in our EAPI compat
62 > - : ${EROOT:=${ROOT}}
63 > + case ${EAPI:-0} in
64 > + 0|1|2) local EROOT=${ROOT}
65 > + esac
66 >
67 > - find
68 > "${EROOT}/etc/portage/savedconfig/${CATEGORY}/${PF}" \
69 > + find
70 > "${EROOT%/}/etc/portage/savedconfig/${CATEGORY}/${PF}" \
71 > -exec touch {} + 2>/dev/null
72 > fi
73 > }
74
75 Given that there are no ebuilds in the tree using this eclass and being
76 in EAPI 0, 1 or 2 (
77 https://qa-reports.gentoo.org/output/eapi-per-eclass/savedconfig.eclass/
78 ), wouldn't it make more sense to just whitelist EAPI >= 4 and clean up
79 this backwards compatibility cruft instead?

Replies