1 |
CD_ROOT was intended to be a power user feature so the eclass didn't |
2 |
try very hard to check the validity of the given location. This |
3 |
difference in behaviour ultimately made the eclass larger and more |
4 |
confusing. |
5 |
|
6 |
It now uses the same matching loop as the regular case, making it |
7 |
simpler and more consistent. The only differences are that it doesn't |
8 |
show information or prompts about inserting discs and it dies |
9 |
immediately if a match cannot be found. |
10 |
--- |
11 |
eclass/cdrom.eclass | 126 +++++++++++++++++++--------------------------------- |
12 |
1 file changed, 46 insertions(+), 80 deletions(-) |
13 |
|
14 |
diff --git a/eclass/cdrom.eclass b/eclass/cdrom.eclass |
15 |
index 95bf48829e14..f4ea2ff36400 100644 |
16 |
--- a/eclass/cdrom.eclass |
17 |
+++ b/eclass/cdrom.eclass |
18 |
@@ -48,44 +48,16 @@ fi |
19 |
# |
20 |
# For those multi cd ebuilds, see the cdrom_load_next_cd() function. |
21 |
cdrom_get_cds() { |
22 |
- # first we figure out how many cds we're dealing with by |
23 |
- # the # of files they gave us |
24 |
- local cdcnt=0 |
25 |
- local f= |
26 |
- export CDROM_CURRENT_CD=1 CDROM_CHECKS=( "${@}" ) |
27 |
+ unset CDROM_SET |
28 |
+ export CDROM_CURRENT_CD=0 CDROM_CHECKS=( "${@}" ) |
29 |
|
30 |
- # now we see if the user gave use CD_ROOT ... |
31 |
- # if they did, let's just believe them that it's correct |
32 |
+ # If the user has set CD_ROOT or CD_ROOT_1, don't bother informing |
33 |
+ # them about which discs are needed as they presumably already know. |
34 |
if [[ -n ${CD_ROOT}${CD_ROOT_1} ]] ; then |
35 |
- local var= |
36 |
- cdcnt=0 |
37 |
- while [[ ${cdcnt} -lt ${#} ]] ; do |
38 |
- ((++cdcnt)) |
39 |
- var="CD_ROOT_${cdcnt}" |
40 |
- [[ -z ${!var} ]] && var="CD_ROOT" |
41 |
- if [[ -z ${!var} ]] ; then |
42 |
- eerror "You must either use just the CD_ROOT" |
43 |
- eerror "or specify ALL the CD_ROOT_X variables." |
44 |
- eerror "In this case, you will need" \ |
45 |
- "${#} CD_ROOT_X variables." |
46 |
- die "could not locate CD_ROOT_${cdcnt}" |
47 |
- fi |
48 |
- done |
49 |
- export CDROM_ROOT=${CD_ROOT_1:-${CD_ROOT}} |
50 |
- einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}" |
51 |
- export CDROM_SET=-1 |
52 |
- IFS=: |
53 |
- for f in ${CDROM_CHECKS[0]} ; do |
54 |
- unset IFS |
55 |
- ((++CDROM_SET)) |
56 |
- export CDROM_MATCH=$(_cdrom_glob_match "${CDROM_ROOT}" "${f}") |
57 |
- [[ -n ${CDROM_MATCH} ]] && return |
58 |
- done |
59 |
- fi |
60 |
+ : |
61 |
|
62 |
- # User didn't help us out so lets make sure they know they can |
63 |
- # simplify the whole process ... |
64 |
- if [[ ${#} -eq 1 ]] ; then |
65 |
+ # Single disc info. |
66 |
+ elif [[ ${#} -eq 1 ]] ; then |
67 |
einfo "This ebuild will need the ${CDROM_NAME:-cdrom for ${PN}}" |
68 |
echo |
69 |
einfo "If you do not have the CD, but have the data files" |
70 |
@@ -96,6 +68,8 @@ cdrom_get_cds() { |
71 |
einfo "For example:" |
72 |
einfo "export CD_ROOT=/mnt/cdrom" |
73 |
echo |
74 |
+ |
75 |
+ # Multi disc info. |
76 |
else |
77 |
_cdrom_set_names |
78 |
einfo "This package may need access to ${#} cds." |
79 |
@@ -120,8 +94,7 @@ cdrom_get_cds() { |
80 |
echo |
81 |
fi |
82 |
|
83 |
- export CDROM_SET="" |
84 |
- export CDROM_CURRENT_CD=0 |
85 |
+ # Scan for the first disc. |
86 |
cdrom_load_next_cd |
87 |
} |
88 |
|
89 |
@@ -135,57 +108,48 @@ cdrom_get_cds() { |
90 |
# in the CD list, so make sure you only call this function when you're |
91 |
# done using the current CD. |
92 |
cdrom_load_next_cd() { |
93 |
- local var |
94 |
- ((++CDROM_CURRENT_CD)) |
95 |
- |
96 |
- _cdrom_set_names |
97 |
+ local showedmsg=0 showjolietmsg=0 |
98 |
|
99 |
unset CDROM_ROOT |
100 |
- var=CD_ROOT_${CDROM_CURRENT_CD} |
101 |
- [[ -z ${!var} ]] && var="CD_ROOT" |
102 |
- if [[ -z ${!var} ]] ; then |
103 |
- _cdrom_locate_file_on_cd "${CDROM_CHECKS[${CDROM_CURRENT_CD}]}" |
104 |
- else |
105 |
- export CDROM_ROOT=${!var} |
106 |
- fi |
107 |
- |
108 |
- einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}" |
109 |
-} |
110 |
- |
111 |
-# this is used internally by the cdrom_get_cds() and cdrom_load_next_cd() |
112 |
-# functions. this should *never* be called from an ebuild. |
113 |
-# all it does is try to locate a give file on a cd ... if the cd isn't |
114 |
-# found, then a message asking for the user to insert the cdrom will be |
115 |
-# displayed and we'll hang out here until: |
116 |
-# (1) the file is found on a mounted cdrom |
117 |
-# (2) the user hits CTRL+C |
118 |
-_cdrom_locate_file_on_cd() { |
119 |
- local mline="" |
120 |
- local showedmsg=0 showjolietmsg=0 |
121 |
+ ((++CDROM_CURRENT_CD)) |
122 |
|
123 |
- while [[ -z ${CDROM_ROOT} ]] ; do |
124 |
- local i=0 cdset |
125 |
- IFS=: read -a cdset <<< "${*}" |
126 |
+ _cdrom_set_names |
127 |
|
128 |
- if [[ -n ${CDROM_SET} ]] ; then |
129 |
- cdset=( "${cdset[${CDROM_SET}]}" ) |
130 |
- fi |
131 |
+ while true ; do |
132 |
+ local i cdset |
133 |
+ : CD_ROOT_${CDROM_CURRENT_CD} |
134 |
+ export CDROM_ROOT=${CD_ROOT:-${!_}} |
135 |
+ IFS=: read -a cdset <<< "${CDROM_CHECKS[$((${CDROM_CURRENT_CD} - 1))]}" |
136 |
+ |
137 |
+ for i in $(seq ${CDROM_SET:-0} ${CDROM_SET:-$((${#cdset[@]} - 1))}); do |
138 |
+ local f=${cdset[${i}]} point= node= fs= opts= |
139 |
+ |
140 |
+ if [[ -z ${CDROM_ROOT} ]] ; then |
141 |
+ while read point node fs opts ; do |
142 |
+ has "${fs}" cd9660 iso9660 udf || continue |
143 |
+ point=${point//\040/ } |
144 |
+ export CDROM_MATCH=$(_cdrom_glob_match "${point}" "${f}") |
145 |
+ [[ -z ${CDROM_MATCH} ]] && continue |
146 |
+ export CDROM_ROOT=${point} |
147 |
+ done <<< "$(get_mounts)" |
148 |
+ else |
149 |
+ export CDROM_MATCH=$(_cdrom_glob_match "${CDROM_ROOT}" "${f}") |
150 |
+ fi |
151 |
|
152 |
- while [[ -n ${cdset[${i}]} ]] ; do |
153 |
- local point= node= fs= foo= |
154 |
- while read point node fs foo ; do |
155 |
- [[ " cd9660 iso9660 udf " != *" ${fs} "* ]] && continue |
156 |
- point=${point//\040/ } |
157 |
- export CDROM_MATCH=$(_cdrom_glob_match "${point}" "${cdset[${i}]}") |
158 |
- [[ -z ${CDROM_MATCH} ]] && continue |
159 |
- export CDROM_ROOT=${point} |
160 |
+ if [[ -n ${CDROM_MATCH} ]] ; then |
161 |
+ export CDROM_ABSMATCH=${CDROM_ROOT}/${CDROM_MATCH} |
162 |
export CDROM_SET=${i} |
163 |
- return |
164 |
- done <<< "$(get_mounts)" |
165 |
- |
166 |
- ((++i)) |
167 |
+ break 2 |
168 |
+ fi |
169 |
done |
170 |
|
171 |
+ # If we get here then we were unable to locate a match. If |
172 |
+ # CDROM_ROOT is non-empty then this implies that a CD_ROOT |
173 |
+ # variable was given and we should therefore abort immediately. |
174 |
+ if [[ -n ${CDROM_ROOT} ]] ; then |
175 |
+ die "unable to locate CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}" |
176 |
+ fi |
177 |
+ |
178 |
echo |
179 |
if [[ ${showedmsg} -eq 0 ]] ; then |
180 |
if [[ ${#CDROM_CHECKS[@]} -eq 1 ]] ; then |
181 |
@@ -218,6 +182,8 @@ _cdrom_locate_file_on_cd() { |
182 |
fi |
183 |
read || die "something is screwed with your system" |
184 |
done |
185 |
+ |
186 |
+ einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}" |
187 |
} |
188 |
|
189 |
# @FUNCTION: _cdrom_glob_match |
190 |
-- |
191 |
2.11.0 |