Gentoo Archives: gentoo-commits

From: "Ulrich Mueller (ulm)" <ulm@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in eclass: eutils.eclass
Date: Tue, 31 Jan 2012 06:55:47
Message-Id: 20120131065537.92DF42004B@flycatcher.gentoo.org
1 ulm 12/01/31 06:55:37
2
3 Modified: eutils.eclass
4 Log:
5 Revert previous commit, because cdrom.eclass sets PROPERTIES=interactive.
6
7 Revision Changes Path
8 1.380 eclass/eutils.eclass
9
10 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/eutils.eclass?rev=1.380&view=markup
11 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/eutils.eclass?rev=1.380&content-type=text/plain
12 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/eutils.eclass?r1=1.379&r2=1.380
13
14 Index: eutils.eclass
15 ===================================================================
16 RCS file: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v
17 retrieving revision 1.379
18 retrieving revision 1.380
19 diff -u -r1.379 -r1.380
20 --- eutils.eclass 31 Jan 2012 06:44:00 -0000 1.379
21 +++ eutils.eclass 31 Jan 2012 06:55:37 -0000 1.380
22 @@ -1,6 +1,6 @@
23 # Copyright 1999-2012 Gentoo Foundation
24 # Distributed under the terms of the GNU General Public License v2
25 -# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.379 2012/01/31 06:44:00 ulm Exp $
26 +# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.380 2012/01/31 06:55:37 ulm Exp $
27
28 # @ECLASS: eutils.eclass
29 # @MAINTAINER:
30 @@ -18,7 +18,7 @@
31 if [[ ${___ECLASS_ONCE_EUTILS} != "recur -_+^+_- spank" ]] ; then
32 ___ECLASS_ONCE_EUTILS="recur -_+^+_- spank"
33
34 -inherit multilib cdrom user
35 +inherit multilib portability user
36
37 DESCRIPTION="Based on the ${ECLASS} eclass"
38
39 @@ -1155,6 +1155,221 @@
40 assert "failure unpacking (${filetype}) makeself ${shrtsrc} ('${ver}' +${skip})"
41 }
42
43 +# @FUNCTION: cdrom_get_cds
44 +# @USAGE: <file on cd1> [file on cd2] [file on cd3] [...]
45 +# @DESCRIPTION:
46 +# Aquire cd(s) for those lovely cd-based emerges. Yes, this violates
47 +# the whole 'non-interactive' policy, but damnit I want CD support !
48 +#
49 +# With these cdrom functions we handle all the user interaction and
50 +# standardize everything. All you have to do is call cdrom_get_cds()
51 +# and when the function returns, you can assume that the cd has been
52 +# found at CDROM_ROOT.
53 +#
54 +# The function will attempt to locate a cd based upon a file that is on
55 +# the cd. The more files you give this function, the more cds
56 +# the cdrom functions will handle.
57 +#
58 +# Normally the cdrom functions will refer to the cds as 'cd #1', 'cd #2',
59 +# etc... If you want to give the cds better names, then just export
60 +# the appropriate CDROM_NAME variable before calling cdrom_get_cds().
61 +# Use CDROM_NAME for one cd, or CDROM_NAME_# for multiple cds. You can
62 +# also use the CDROM_NAME_SET bash array.
63 +#
64 +# For those multi cd ebuilds, see the cdrom_load_next_cd() function.
65 +cdrom_get_cds() {
66 + # first we figure out how many cds we're dealing with by
67 + # the # of files they gave us
68 + local cdcnt=0
69 + local f=
70 + for f in "$@" ; do
71 + ((++cdcnt))
72 + export CDROM_CHECK_${cdcnt}="$f"
73 + done
74 + export CDROM_TOTAL_CDS=${cdcnt}
75 + export CDROM_CURRENT_CD=1
76 +
77 + # now we see if the user gave use CD_ROOT ...
78 + # if they did, let's just believe them that it's correct
79 + if [[ -n ${CD_ROOT}${CD_ROOT_1} ]] ; then
80 + local var=
81 + cdcnt=0
82 + while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]] ; do
83 + ((++cdcnt))
84 + var="CD_ROOT_${cdcnt}"
85 + [[ -z ${!var} ]] && var="CD_ROOT"
86 + if [[ -z ${!var} ]] ; then
87 + eerror "You must either use just the CD_ROOT"
88 + eerror "or specify ALL the CD_ROOT_X variables."
89 + eerror "In this case, you will need ${CDROM_TOTAL_CDS} CD_ROOT_X variables."
90 + die "could not locate CD_ROOT_${cdcnt}"
91 + fi
92 + done
93 + export CDROM_ROOT=${CD_ROOT_1:-${CD_ROOT}}
94 + einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}"
95 + export CDROM_SET=-1
96 + for f in ${CDROM_CHECK_1//:/ } ; do
97 + ((++CDROM_SET))
98 + [[ -e ${CDROM_ROOT}/${f} ]] && break
99 + done
100 + export CDROM_MATCH=${f}
101 + return
102 + fi
103 +
104 + # User didn't help us out so lets make sure they know they can
105 + # simplify the whole process ...
106 + if [[ ${CDROM_TOTAL_CDS} -eq 1 ]] ; then
107 + einfo "This ebuild will need the ${CDROM_NAME:-cdrom for ${PN}}"
108 + echo
109 + einfo "If you do not have the CD, but have the data files"
110 + einfo "mounted somewhere on your filesystem, just export"
111 + einfo "the variable CD_ROOT so that it points to the"
112 + einfo "directory containing the files."
113 + echo
114 + einfo "For example:"
115 + einfo "export CD_ROOT=/mnt/cdrom"
116 + echo
117 + else
118 + if [[ -n ${CDROM_NAME_SET} ]] ; then
119 + # Translate the CDROM_NAME_SET array into CDROM_NAME_#
120 + cdcnt=0
121 + while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]] ; do
122 + ((++cdcnt))
123 + export CDROM_NAME_${cdcnt}="${CDROM_NAME_SET[$((${cdcnt}-1))]}"
124 + done
125 + fi
126 +
127 + einfo "This package will need access to ${CDROM_TOTAL_CDS} cds."
128 + cdcnt=0
129 + while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]] ; do
130 + ((++cdcnt))
131 + var="CDROM_NAME_${cdcnt}"
132 + [[ ! -z ${!var} ]] && einfo " CD ${cdcnt}: ${!var}"
133 + done
134 + echo
135 + einfo "If you do not have the CDs, but have the data files"
136 + einfo "mounted somewhere on your filesystem, just export"
137 + einfo "the following variables so they point to the right place:"
138 + einfon ""
139 + cdcnt=0
140 + while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]] ; do
141 + ((++cdcnt))
142 + echo -n " CD_ROOT_${cdcnt}"
143 + done
144 + echo
145 + einfo "Or, if you have all the files in the same place, or"
146 + einfo "you only have one cdrom, you can export CD_ROOT"
147 + einfo "and that place will be used as the same data source"
148 + einfo "for all the CDs."
149 + echo
150 + einfo "For example:"
151 + einfo "export CD_ROOT_1=/mnt/cdrom"
152 + echo
153 + fi
154 +
155 + export CDROM_SET=""
156 + export CDROM_CURRENT_CD=0
157 + cdrom_load_next_cd
158 +}
159 +
160 +# @FUNCTION: cdrom_load_next_cd
161 +# @DESCRIPTION:
162 +# Some packages are so big they come on multiple CDs. When you're done reading
163 +# files off a CD and want access to the next one, just call this function.
164 +# Again, all the messy details of user interaction are taken care of for you.
165 +# Once this returns, just read the variable CDROM_ROOT for the location of the
166 +# mounted CD. Note that you can only go forward in the CD list, so make sure
167 +# you only call this function when you're done using the current CD.
168 +cdrom_load_next_cd() {
169 + local var
170 + ((++CDROM_CURRENT_CD))
171 +
172 + unset CDROM_ROOT
173 + var=CD_ROOT_${CDROM_CURRENT_CD}
174 + [[ -z ${!var} ]] && var="CD_ROOT"
175 + if [[ -z ${!var} ]] ; then
176 + var="CDROM_CHECK_${CDROM_CURRENT_CD}"
177 + _cdrom_locate_file_on_cd ${!var}
178 + else
179 + export CDROM_ROOT=${!var}
180 + fi
181 +
182 + einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}"
183 +}
184 +
185 +# this is used internally by the cdrom_get_cds() and cdrom_load_next_cd()
186 +# functions. this should *never* be called from an ebuild.
187 +# all it does is try to locate a give file on a cd ... if the cd isn't
188 +# found, then a message asking for the user to insert the cdrom will be
189 +# displayed and we'll hang out here until:
190 +# (1) the file is found on a mounted cdrom
191 +# (2) the user hits CTRL+C
192 +_cdrom_locate_file_on_cd() {
193 + local mline=""
194 + local showedmsg=0 showjolietmsg=0
195 +
196 + while [[ -z ${CDROM_ROOT} ]] ; do
197 + local i=0
198 + local -a cdset=(${*//:/ })
199 + if [[ -n ${CDROM_SET} ]] ; then
200 + cdset=(${cdset[${CDROM_SET}]})
201 + fi
202 +
203 + while [[ -n ${cdset[${i}]} ]] ; do
204 + local dir=$(dirname ${cdset[${i}]})
205 + local file=$(basename ${cdset[${i}]})
206 +
207 + local point= node= fs= foo=
208 + while read point node fs foo ; do
209 + [[ " cd9660 iso9660 udf " != *" ${fs} "* ]] && \
210 + ! [[ ${fs} == "subfs" && ",${opts}," == *",fs=cdfss,"* ]] \
211 + && continue
212 + point=${point//\040/ }
213 + [[ ! -d ${point}/${dir} ]] && continue
214 + [[ -z $(find "${point}/${dir}" -maxdepth 1 -iname "${file}") ]] && continue
215 + export CDROM_ROOT=${point}
216 + export CDROM_SET=${i}
217 + export CDROM_MATCH=${cdset[${i}]}
218 + return
219 + done <<< "$(get_mounts)"
220 +
221 + ((++i))
222 + done
223 +
224 + echo
225 + if [[ ${showedmsg} -eq 0 ]] ; then
226 + if [[ ${CDROM_TOTAL_CDS} -eq 1 ]] ; then
227 + if [[ -z ${CDROM_NAME} ]] ; then
228 + einfo "Please insert+mount the cdrom for ${PN} now !"
229 + else
230 + einfo "Please insert+mount the ${CDROM_NAME} cdrom now !"
231 + fi
232 + else
233 + if [[ -z ${CDROM_NAME_1} ]] ; then
234 + einfo "Please insert+mount cd #${CDROM_CURRENT_CD} for ${PN} now !"
235 + else
236 + local var="CDROM_NAME_${CDROM_CURRENT_CD}"
237 + einfo "Please insert+mount the ${!var} cdrom now !"
238 + fi
239 + fi
240 + showedmsg=1
241 + fi
242 + einfo "Press return to scan for the cd again"
243 + einfo "or hit CTRL+C to abort the emerge."
244 + echo
245 + if [[ ${showjolietmsg} -eq 0 ]] ; then
246 + showjolietmsg=1
247 + else
248 + ewarn "If you are having trouble with the detection"
249 + ewarn "of your CD, it is possible that you do not have"
250 + ewarn "Joliet support enabled in your kernel. Please"
251 + ewarn "check that CONFIG_JOLIET is enabled in your kernel."
252 + ebeep 5
253 + fi
254 + read || die "something is screwed with your system"
255 + done
256 +}
257 +
258 # @FUNCTION: strip-linguas
259 # @USAGE: [<allow LINGUAS>|<-i|-u> <directories of .po files>]
260 # @DESCRIPTION: