Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: ulm@g.o
Subject: Re: [gentoo-dev] Re: RFD: split out some functions from eutils.eclass?
Date: Thu, 12 Jan 2012 06:49:35
Message-Id: 20120112074959.223cdd9d@pomiocik.lan
In Reply to: [gentoo-dev] Re: RFD: split out some functions from eutils.eclass? by Ulrich Mueller
1 On Wed, 11 Jan 2012 23:09:46 +0100
2 Ulrich Mueller <ulm@g.o> wrote:
3
4 > # @ECLASS: cdrom.eclass
5 > # @MAINTAINER:
6 > # games@g.o
7 > # @BLURB: Functions for cdrom handling
8 > # @DESCRIPTION:
9 > # Acquire cd(s) for those lovely cd-based emerges. Yes, this violates
10 > # the whole 'non-interactive' policy, but damnit I want CD support!
11
12 Maybe the eclass should now set PROPERTIES=interactive?
13
14 > cdrom_get_cds() {
15 > # first we figure out how many cds we're dealing with by
16 > # the # of files they gave us
17 > local cdcnt=0
18 > local f=
19 > for f in "$@" ; do
20 > ((++cdcnt))
21 > export CDROM_CHECK_${cdcnt}="$f"
22 > done
23 > export CDROM_TOTAL_CDS=${cdcnt}
24 > export CDROM_CURRENT_CD=1
25
26 Why are you exporting all that? I don't think that should be necessary
27 unless you subshell somewhere.
28
29 CDROM_CHECK=( "${@}" )
30 CDROM_TOTAL_CDS=${#} # (or ${#CDROM_CHECK[@]})
31
32 And then you can just refer to ${CDROM_CHECK[$i]} rather than using all
33 those ugly ${!...}.
34
35 > # now we see if the user gave use CD_ROOT ...
36 > # if they did, let's just believe them that it's correct
37 > if [[ -n ${CD_ROOT}${CD_ROOT_1} ]] ; then
38 > local var=
39 > cdcnt=0
40 > while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]] ; do
41 > ((++cdcnt))
42 > var="CD_ROOT_${cdcnt}"
43 > [[ -z ${!var} ]] && var="CD_ROOT"
44 > if [[ -z ${!var} ]] ; then
45 > eerror "You must either use just the
46 > CD_ROOT" eerror "or specify ALL the CD_ROOT_X variables."
47 > eerror "In this case, you will need" \
48 > "${CDROM_TOTAL_CDS} CD_ROOT_X
49 > variables." die "could not locate CD_ROOT_${cdcnt}"
50 > fi
51 > done
52 > export CDROM_ROOT=${CD_ROOT_1:-${CD_ROOT}}
53 > einfo "Found CD #${CDROM_CURRENT_CD} root at
54 > ${CDROM_ROOT}"
55
56 #1. You are using 1 in variable calls, I don't see a reason to use
57 longer ${CDROM_CURRENT_CD} in this one output case.
58
59 > export CDROM_SET=-1
60 > for f in ${CDROM_CHECK_1//:/ } ; do
61 > ((++CDROM_SET))
62
63 More when I get replies on these ones.
64
65 --
66 Best regards,
67 Michał Górny

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies