1 |
--- |
2 |
eclass/alternatives-2.eclass | 17 ++++++++++++----- |
3 |
1 file changed, 12 insertions(+), 5 deletions(-) |
4 |
|
5 |
diff --git a/eclass/alternatives-2.eclass b/eclass/alternatives-2.eclass |
6 |
index e15edfa..d9896f1 100644 |
7 |
--- a/eclass/alternatives-2.eclass |
8 |
+++ b/eclass/alternatives-2.eclass |
9 |
@@ -57,22 +57,26 @@ alternatives_for() { |
10 |
local alternative=${1} provider=${2} importance=${3} index src target ret=0 |
11 |
shift 3 |
12 |
|
13 |
- # make sure importance is a signed integer |
14 |
+ # Make sure importance is a signed integer |
15 |
if [[ -n ${importance} ]] && ! [[ ${importance} =~ ^[0-9]+(\.[0-9]+)*$ ]]; then |
16 |
eerror "Invalid importance (${importance}) detected" |
17 |
((ret++)) |
18 |
fi |
19 |
|
20 |
+ # Create alternative provider subdirectories under ALTERNATIVES_DIR if needed |
21 |
[[ -d "${ED}${ALTERNATIVES_DIR}/${alternative}/${provider}" ]] || dodir "${ALTERNATIVES_DIR}/${alternative}/${provider}" |
22 |
|
23 |
- # keep track of provided alternatives for use in pkg_{postinst,prerm}. keep a mapping between importance and |
24 |
- # provided alternatives and make sure the former is set to only one value |
25 |
+ # Keep track of provided alternatives for use in pkg_{postinst,prerm}. |
26 |
+ # Keep a mapping between importance and provided alternatives |
27 |
+ # and make sure the former is set to only one value. |
28 |
if ! has "${alternative}:${provider}" "${ALTERNATIVES_PROVIDED[@]}"; then |
29 |
+ # Add new provider and set its importance |
30 |
index=${#ALTERNATIVES_PROVIDED[@]} |
31 |
ALTERNATIVES_PROVIDED+=( "${alternative}:${provider}" ) |
32 |
ALTERNATIVES_IMPORTANCE[index]=${importance} |
33 |
[[ -n ${importance} ]] && echo "${importance}" > "${ED}${ALTERNATIVES_DIR}/${alternative}/${provider}/_importance" |
34 |
else |
35 |
+ # Set importance for existing provider |
36 |
for((index=0;index<${#ALTERNATIVES_PROVIDED[@]};index++)); do |
37 |
if [[ ${alternative}:${provider} == ${ALTERNATIVES_PROVIDED[index]} ]]; then |
38 |
if [[ -n ${ALTERNATIVES_IMPORTANCE[index]} ]]; then |
39 |
@@ -88,6 +92,7 @@ alternatives_for() { |
40 |
done |
41 |
fi |
42 |
|
43 |
+ # Process source-target pairs |
44 |
while (( $# >= 2 )); do |
45 |
src=${1//+(\/)/\/}; target=${2//+(\/)/\/} |
46 |
if [[ ${src} != /* ]]; then |
47 |
@@ -107,8 +112,9 @@ alternatives_for() { |
48 |
dodir "${ALTERNATIVES_DIR}/${alternative}/${provider}${src%/*}" |
49 |
dosym "${reltarget}" "${ALTERNATIVES_DIR}/${alternative}/${provider}${src}" |
50 |
|
51 |
- # say ${ED}/sbin/init exists and links to /bin/systemd (which doesn't exist yet) |
52 |
- # the -e test will fail, so check for -L also |
53 |
+ # The -e test will fail if existing symlink points to non-existing target, |
54 |
+ # so check for -L also. |
55 |
+ # Say ${ED}/sbin/init exists and links to /bin/systemd (which doesn't exist yet). |
56 |
if [[ -e ${ED}${src} || -L ${ED}${src} ]]; then |
57 |
local fulltarget=${target} |
58 |
[[ ${fulltarget} != /* ]] && fulltarget=${src%/*}/${fulltarget} |
59 |
@@ -122,6 +128,7 @@ alternatives_for() { |
60 |
shift 2 |
61 |
done |
62 |
|
63 |
+ # Stop if there were any errors |
64 |
[[ ${ret} -eq 0 ]] || die "Errors detected for ${provider}, provided for ${alternative}" |
65 |
} |
66 |
|
67 |
-- |
68 |
1.8.5.3 |