Gentoo Archives: gentoo-dev

From: James Le Cuirot <chewi@g.o>
To: gentoo-dev <gentoo-dev@l.g.o>
Cc: James Le Cuirot <chewi@g.o>
Subject: [gentoo-dev] [PATCH 04/14] cdrom.eclass: Allow CDROM_NAMES changes before each cdrom_load_next_cd
Date: Mon, 17 Apr 2017 21:57:03
Message-Id: 20170417215359.30641-5-chewi@gentoo.org
In Reply to: [gentoo-dev] [PATCH] cdrom.eclass: Near rewrite by James Le Cuirot
1 This works around the lack of per-set disc names. Once the first disc
2 has been detected, ebuilds can adjust CDROM_NAMES to contain just the
3 names from the matched CDROM_SET.
4 ---
5 eclass/cdrom.eclass | 25 ++++++++++++++++---------
6 1 file changed, 16 insertions(+), 9 deletions(-)
7
8 diff --git a/eclass/cdrom.eclass b/eclass/cdrom.eclass
9 index 72250556e624..9724c66ca2ce 100644
10 --- a/eclass/cdrom.eclass
11 +++ b/eclass/cdrom.eclass
12 @@ -102,15 +102,7 @@ cdrom_get_cds() {
13 einfo "export CD_ROOT=/mnt/cdrom"
14 echo
15 else
16 - if [[ -n ${CDROM_NAMES} ]] ; then
17 - # Translate the CDROM_NAMES array into CDROM_NAME_#
18 - cdcnt=0
19 - while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]] ; do
20 - ((++cdcnt))
21 - export CDROM_NAME_${cdcnt}="${CDROM_NAMES[$((${cdcnt}-1))]}"
22 - done
23 - fi
24 -
25 + _cdrom_set_names
26 einfo "This package will need access to ${CDROM_TOTAL_CDS} cds."
27 cdcnt=0
28 while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]] ; do
29 @@ -152,6 +144,8 @@ cdrom_load_next_cd() {
30 local var
31 ((++CDROM_CURRENT_CD))
32
33 + _cdrom_set_names
34 +
35 unset CDROM_ROOT
36 var=CD_ROOT_${CDROM_CURRENT_CD}
37 [[ -z ${!var} ]] && var="CD_ROOT"
38 @@ -258,4 +252,17 @@ _cdrom_glob_match() {
39 )
40 }
41
42 +# @FUNCTION: _cdrom_set_names
43 +# @INTERNAL
44 +# @DESCRIPTION:
45 +# Populate CDROM_NAME_# variables with the CDROM_NAMES array.
46 +_cdrom_set_names() {
47 + if [[ -n ${CDROM_NAMES} ]] ; then
48 + local i
49 + for i in $(seq ${#CDROM_NAMES[@]}); do
50 + export CDROM_NAME_${i}="${CDROM_NAMES[$((${i} - 1))]}"
51 + done
52 + fi
53 +}
54 +
55 fi
56 --
57 2.11.0