[gentoo-dev] [PATCH eutils 1/2] Add dointo && newinto.

August 16th, 2012 - 04:30 pm ET by Michał Górny | Report spam
eutils.eclass | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)

diff --git a/eutils.eclass b/eutils.eclass
index eb8c8f7..119fc32 100644
a/eutils.eclass
+++ b/eutils.eclass
@@ -650,6 +650,43 @@ edos2unix() {
sed -i 's/$//' -- "$@" || die
}

+# @FUNCTION: dointo
+# @USAGE: <directory> <file> [...]
+# @DESCRIPTION:
+# Install all specified <file>s into <directory>. This doesn't modify global
+# 'insinto' path. Alike doins, calls 'die' on failure in EAPI 4+; in earlier
+# EAPIs, returns false in that case.
+dointo() {
+ [[ ${#} -gt 2 ]] || die 'Synopsis: dointo <directory> <file> [...]'
+
+ local directory=${1}
+ shift
+
+ (
+ insinto "${directory}"
+ doins "${@}"
+ )
+}
+
+# @FUNCTION: newinto
+# @USAGE: <directory> <file> <new-name>
+# @DESCRIPTION:
+# Install the specified <file> into <directory>, renaming it to <new-name>.
+# This doesn't modify global 'insinto' path. Alike doins, calls 'die' on failure
+# in EAPI 4+; in earlier EAPIs, returns false in that case.
+newinto() {
+ [[ ${#} -eq 3 ]] || die 'Synopsis: newinto <directory> <file> <new-name>'
+
+ local directory=${1}
+ local f=${2}
+ local new_name=${3}
+
+ (
+ insinto "${directory}"
+ newins "${f}" "${new_name}"
+ )
+}
+
# @FUNCTION: make_desktop_entry
# @USAGE: make_desktop_entry(<command>, [name], [icon], [type], [fields])
# @DESCRIPTION:
1.7.11.1
email Follow the discussionReplies 13 repliesReplies Make a reply

Similar topics

Replies

#1 Michał Górny
August 16th, 2012 - 04:30 pm ET | Report spam
I will provide patches for more if the functions are accepted.

eutils.eclass | 24 ++++++
1 file changed, 6 insertions(+), 18 deletions(-)

diff --git a/eutils.eclass b/eutils.eclass
index 119fc32..f59b7ae 100644
a/eutils.eclass
+++ b/eutils.eclass
@@ -871,12 +871,8 @@ make_desktop_entry() {
fi
[[ -n ${fields} ]] && printf '%b' "${fields}" >> "${desktop}"

- (
- # wrap the env here so that the 'insinto' call
- # doesn't corrupt the env of the caller
- insinto /usr/share/applications
- doins "${desktop}"
- ) || die "installing desktop file failed"
+ dointo /usr/share/applications "${desktop}" \
+ || die "installing desktop file failed"
}

# @FUNCTION: validate_desktop_entries
@@ -932,12 +928,7 @@ make_session_desktop() {
Type=XSession
EOF

- (
- # wrap the env here so that the 'insinto' call
- # doesn't corrupt the env of the caller
- insinto /usr/share/xsessions
- doins "${desktop}"
- )
+ dointo /usr/share/xsessions "${desktop}"
}

# @FUNCTION: domenu
@@ -973,12 +964,9 @@ domenu() {
# @DESCRIPTION:
# Like all other new* functions, install the specified menu as newname.
newmenu() {
- (
- # wrap the env here so that the 'insinto' call
- # doesn't corrupt the env of the caller
- insinto /usr/share/applications
- newins "$@"
- )
+ [[ ${#} -eq 2 ]] || die 'Synopsis: newmenu <menu> <newname>'
+
+ newinto /usr/share/applications "${@}"
}

# @FUNCTION: _iconins
1.7.11.1
Replies Reply to this message
#2 Ulrich Mueller
August 16th, 2012 - 04:40 pm ET | Report spam
On Thu, 16 Aug 2012, Micha³ Górny wrote:









+dointo() {
+ [[ ${#} -gt 2 ]] || die 'Synopsis: dointo <directory> <file> [...]'
+
+ local directory=${1}
+ shift
+
+ (
+ insinto "${directory}"



Shouldn't there be checking for errors here, for the case that insinto
fails?

+ doins "${@}"
+ )
+}



Ulrich
Replies Reply to this message
#3 Diego Elio Pettenò
August 16th, 2012 - 04:40 pm ET | Report spam
On 16/08/2012 13:19, Michał Górny wrote:
eutils.eclass | 37 +++++++++++++++++++++++++++++++++++++



I would say "no", and let's queue this for the next EAPI.

The reason being we have everything ${foo}into {new,do}${foo}, provided
by EAPI and utils as well, why should foo=ins be different now?

Diego Elio Pettenò — Flameeyes
http://blog.flameeyes.eu/
Replies Reply to this message
#4 Diego Elio Pettenò
August 16th, 2012 - 04:50 pm ET | Report spam
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)

On 16/08/2012 13:45, Michał Górny wrote:

We can remove it from eutils when it gets into EAPI (i.e. make
conditional to older EAPIs). This will keep things both usable
and clean.



I still don't like it — I definitely don't like changing the approach
midway and halfway.

So my 2 cents here keep saying "no".

Diego Elio Pettenò — Flameeyes
— http://blog.flameeyes.eu/




Replies Reply to this message
#5 Michał Górny
August 16th, 2012 - 04:50 pm ET | Report spam

On Thu, 16 Aug 2012 13:29:50 -0700
Diego Elio Pettenò wrote:

On 16/08/2012 13:19, Michał Górny wrote:
> eutils.eclass | 37 +++++++++++++++++++++++++++++++++++++

I would say "no", and let's queue this for the next EAPI.

The reason being we have everything ${foo}into {new,do}${foo},
provided by EAPI and utils as well, why should foo=ins be different
now?



I'd be happy to see that in a new EAPI but please note that a lot
of eclasses inlines that thing right now.

We can remove it from eutils when it gets into EAPI (i.e. make
conditional to older EAPIs). This will keep things both usable
and clean.

Best regards,
Michał Górny



Replies Reply to this message
Help Create a new topicNext page Replies Make a reply
Search Make your own search