1 |
commit: 5a4baf2fc4f4a1610069e0dafa85ec39aeca8496 |
2 |
Author: Reinis Danne <rei4dan <AT> gmail <DOT> com> |
3 |
AuthorDate: Mon Jan 20 17:14:18 2014 +0000 |
4 |
Commit: Reinis Danne <rei4dan <AT> gmail <DOT> com> |
5 |
CommitDate: Tue Jan 21 19:55:21 2014 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/sci.git;a=commit;h=5a4baf2f |
7 |
|
8 |
alternatives-2.eclass: Minor comment changes |
9 |
|
10 |
--- |
11 |
eclass/alternatives-2.eclass | 17 ++++++++++++----- |
12 |
1 file changed, 12 insertions(+), 5 deletions(-) |
13 |
|
14 |
diff --git a/eclass/alternatives-2.eclass b/eclass/alternatives-2.eclass |
15 |
index bc60108..132620e 100644 |
16 |
--- a/eclass/alternatives-2.eclass |
17 |
+++ b/eclass/alternatives-2.eclass |
18 |
@@ -61,22 +61,26 @@ alternatives_for() { |
19 |
local alternative=${1} provider=${2} importance=${3} index src target ret=0 |
20 |
shift 3 |
21 |
|
22 |
- # make sure importance is a signed integer |
23 |
+ # Make sure importance is a signed integer |
24 |
if [[ -n ${importance} ]] && ! [[ ${importance} =~ ^[0-9]+(\.[0-9]+)*$ ]]; then |
25 |
eerror "Invalid importance (${importance}) detected" |
26 |
((ret++)) |
27 |
fi |
28 |
|
29 |
+ # Create alternative provider subdirectories under ALTERNATIVES_DIR if needed |
30 |
[[ -d "${ED}${ALTERNATIVES_DIR}/${alternative}/${provider}" ]] || dodir "${ALTERNATIVES_DIR}/${alternative}/${provider}" |
31 |
|
32 |
- # keep track of provided alternatives for use in pkg_{postinst,prerm}. keep a mapping between importance and |
33 |
- # provided alternatives and make sure the former is set to only one value |
34 |
+ # Keep track of provided alternatives for use in pkg_{postinst,prerm}. |
35 |
+ # Keep a mapping between importance and provided alternatives |
36 |
+ # and make sure the former is set to only one value. |
37 |
if ! has "${alternative}:${provider}" "${ALTERNATIVES_PROVIDED[@]}"; then |
38 |
+ # Add new provider and set its importance |
39 |
index=${#ALTERNATIVES_PROVIDED[@]} |
40 |
ALTERNATIVES_PROVIDED+=( "${alternative}:${provider}" ) |
41 |
ALTERNATIVES_IMPORTANCE[index]=${importance} |
42 |
[[ -n ${importance} ]] && echo "${importance}" > "${ED}${ALTERNATIVES_DIR}/${alternative}/${provider}/_importance" |
43 |
else |
44 |
+ # Set importance for existing provider |
45 |
for((index=0;index<${#ALTERNATIVES_PROVIDED[@]};index++)); do |
46 |
if [[ ${alternative}:${provider} == ${ALTERNATIVES_PROVIDED[index]} ]]; then |
47 |
if [[ -n ${ALTERNATIVES_IMPORTANCE[index]} ]]; then |
48 |
@@ -92,6 +96,7 @@ alternatives_for() { |
49 |
done |
50 |
fi |
51 |
|
52 |
+ # Process source-target pairs |
53 |
while (( $# >= 2 )); do |
54 |
src=${1//+(\/)/\/}; target=${2//+(\/)/\/} |
55 |
if [[ ${src} != /* ]]; then |
56 |
@@ -111,8 +116,9 @@ alternatives_for() { |
57 |
dodir "${ALTERNATIVES_DIR}/${alternative}/${provider}${src%/*}" |
58 |
dosym "${reltarget}" "${ALTERNATIVES_DIR}/${alternative}/${provider}${src}" |
59 |
|
60 |
- # say ${ED}/sbin/init exists and links to /bin/systemd (which doesn't exist yet) |
61 |
- # the -e test will fail, so check for -L also |
62 |
+ # The -e test will fail if existing symlink points to non-existing target, |
63 |
+ # so check for -L also. |
64 |
+ # Say ${ED}/sbin/init exists and links to /bin/systemd (which doesn't exist yet). |
65 |
if [[ -e ${ED}${src} || -L ${ED}${src} ]]; then |
66 |
local fulltarget=${target} |
67 |
[[ ${fulltarget} != /* ]] && fulltarget=${src%/*}/${fulltarget} |
68 |
@@ -126,6 +132,7 @@ alternatives_for() { |
69 |
shift 2 |
70 |
done |
71 |
|
72 |
+ # Stop if there were any errors |
73 |
[[ ${ret} -eq 0 ]] || die "Errors detected for ${provider}, provided for ${alternative}" |
74 |
} |