1 |
commit: 93d41dcc49407c4885de474df0eaf7a83ee0babd |
2 |
Author: William Hubbs <williamh <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Oct 29 18:20:25 2011 +0000 |
4 |
Commit: William Hubbs <williamh <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Oct 29 20:55:47 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/udev-gentoo-scripts.git;a=commit;h=93d41dcc |
7 |
|
8 |
remove shell-compat-KV.sh helper |
9 |
|
10 |
This code is used only in the udev init script, so we can merge it into |
11 |
the script. The tests were also updated to support this. |
12 |
|
13 |
--- |
14 |
Makefile | 4 --- |
15 |
helpers/shell-compat-KV.sh | 47 -------------------------------------------- |
16 |
init.d/udev | 32 ++++++++++++++++++++++++++++- |
17 |
test/test_kv_to_int.sh | 2 +- |
18 |
4 files changed, 31 insertions(+), 54 deletions(-) |
19 |
|
20 |
diff --git a/Makefile b/Makefile |
21 |
index 028dcec..3fbfda4 100644 |
22 |
--- a/Makefile |
23 |
+++ b/Makefile |
24 |
@@ -13,16 +13,12 @@ HELPERS = \ |
25 |
helpers/net.sh \ |
26 |
helpers/write_root_link_rule |
27 |
|
28 |
-HELPERS_NOEXE = \ |
29 |
- helpers/shell-compat-KV.sh |
30 |
- |
31 |
all: |
32 |
@echo "Run make install DESTDIR=" |
33 |
|
34 |
install: |
35 |
@install -d $(DESTDIR)$(LIBUDEV) |
36 |
@install -m 0755 $(HELPERS) $(DESTDIR)$(LIBUDEV) |
37 |
- @install -m 0644 $(HELPERS_NOEXE) $(DESTDIR)$(LIBUDEV) |
38 |
@install -d $(DESTDIR)$(RULESDIR) |
39 |
@install -m 0644 rules.d/??-*.rules $(DESTDIR)$(RULESDIR) |
40 |
@install -d $(DESTDIR)$(CONFD) |
41 |
|
42 |
diff --git a/helpers/shell-compat-KV.sh b/helpers/shell-compat-KV.sh |
43 |
deleted file mode 100644 |
44 |
index af42edc..0000000 |
45 |
--- a/helpers/shell-compat-KV.sh |
46 |
+++ /dev/null |
47 |
@@ -1,47 +0,0 @@ |
48 |
-# Copyright 1999-2010 Gentoo Foundation |
49 |
-# Distributed under the terms of the GNU General Public License v2 |
50 |
- |
51 |
-# provides get_KV and KV_to_int as not all openrc-versions installed via ebuild have these |
52 |
- |
53 |
-cmd_exist() |
54 |
-{ |
55 |
- type "$1" >/dev/null 2>&1 |
56 |
-} |
57 |
- |
58 |
-# does exist in baselayout-1 |
59 |
-# does not exist in openrc, but is added by openrc-ebuild since some time |
60 |
-if ! cmd_exist KV_to_int; then |
61 |
- KV_to_int() { |
62 |
- [ -z $1 ] && return 1 |
63 |
- |
64 |
- local x=${1%%[!0-9.]*} y= z= |
65 |
- local KV_MAJOR=${x%%.*} |
66 |
- y=${x#*.} |
67 |
- [ "$x" = "$y" ] && y=0.0 |
68 |
- local KV_MINOR=${y%%.*} |
69 |
- z=${y#*.} |
70 |
- [ "$y" = "$z" ] && z=0 |
71 |
- local KV_MICRO=${z%%.*} |
72 |
- local KV_int=$((${KV_MAJOR} * 65536 + ${KV_MINOR} * 256 + ${KV_MICRO} )) |
73 |
- |
74 |
- # We make version 2.2.0 the minimum version we will handle as |
75 |
- # a sanity check ... if its less, we fail ... |
76 |
- [ "${KV_int}" -lt 131584 ] && return 1 |
77 |
- |
78 |
- echo "${KV_int}" |
79 |
- } |
80 |
-fi |
81 |
- |
82 |
-# same as KV_to_int |
83 |
-if ! cmd_exist get_KV; then |
84 |
- _RC_GET_KV_CACHE="" |
85 |
- get_KV() { |
86 |
- [ -z "${_RC_GET_KV_CACHE}" ] \ |
87 |
- && _RC_GET_KV_CACHE="$(uname -r)" |
88 |
- |
89 |
- echo "$(KV_to_int "${_RC_GET_KV_CACHE}")" |
90 |
- |
91 |
- return $? |
92 |
- } |
93 |
-fi |
94 |
- |
95 |
|
96 |
diff --git a/init.d/udev b/init.d/udev |
97 |
index ea10111..5e41bcc 100644 |
98 |
--- a/init.d/udev |
99 |
+++ b/init.d/udev |
100 |
@@ -27,8 +27,36 @@ depend() |
101 |
keyword -vserver -lxc |
102 |
} |
103 |
|
104 |
-# get_KV and KV_to_int |
105 |
-. /lib/udev/shell-compat-KV.sh |
106 |
+KV_to_int() |
107 |
+{ |
108 |
+ [ -z $1 ] && return 1 |
109 |
+ |
110 |
+ local x=${1%%[!0-9.]*} y= z= |
111 |
+ local KV_MAJOR=${x%%.*} |
112 |
+ y=${x#*.} |
113 |
+ [ "$x" = "$y" ] && y=0.0 |
114 |
+ local KV_MINOR=${y%%.*} |
115 |
+ z=${y#*.} |
116 |
+ [ "$y" = "$z" ] && z=0 |
117 |
+ local KV_MICRO=${z%%.*} |
118 |
+ local KV_int=$((${KV_MAJOR} * 65536 + ${KV_MINOR} * 256 + ${KV_MICRO} )) |
119 |
+ |
120 |
+ # We make version 2.2.0 the minimum version we will handle as |
121 |
+ # a sanity check ... if its less, we fail ... |
122 |
+ [ "${KV_int}" -lt 131584 ] && return 1 |
123 |
+ |
124 |
+ echo "${KV_int}" |
125 |
+} |
126 |
+ |
127 |
+_RC_GET_KV_CACHE="" |
128 |
+get_KV() |
129 |
+{ |
130 |
+ if [ -z "${_RC_GET_KV_CACHE}" ] ; then |
131 |
+ _RC_GET_KV_CACHE="$(uname -r)" |
132 |
+ fi |
133 |
+ echo "$(KV_to_int "${_RC_GET_KV_CACHE}")" |
134 |
+ return $? |
135 |
+} |
136 |
|
137 |
# FIXME |
138 |
# Instead of this script testing kernel version, udev itself should |
139 |
|
140 |
diff --git a/test/test_kv_to_int.sh b/test/test_kv_to_int.sh |
141 |
index 917f243..6bca65d 100755 |
142 |
--- a/test/test_kv_to_int.sh |
143 |
+++ b/test/test_kv_to_int.sh |
144 |
@@ -3,7 +3,7 @@ |
145 |
oneTimeSetUp() |
146 |
{ |
147 |
unset -f KV_to_int |
148 |
- . ../helpers/shell-compat-KV.sh |
149 |
+ . ../init.d/udev |
150 |
} |
151 |
|
152 |
check_kv() |