1 |
Add appropriate 'die' calls in most of the seemingly public APIs |
2 |
of the eclass that could be called by ebuilds and that are going to fail |
3 |
horribly when used on non-Linux systems. This means that |
4 |
e.g. 'kernel_is' calls need to be explicitly guarded in ebuilds, as we |
5 |
can't really reasonably return 'true' or 'false' if there is no Linux |
6 |
kernel in the first place. |
7 |
--- |
8 |
eclass/linux-info.eclass | 36 ++++++++++++++++++++++++++++++++++++ |
9 |
1 file changed, 36 insertions(+) |
10 |
|
11 |
diff --git a/eclass/linux-info.eclass b/eclass/linux-info.eclass |
12 |
index 0ba7ff7755c7..554de81d3acc 100644 |
13 |
--- a/eclass/linux-info.eclass |
14 |
+++ b/eclass/linux-info.eclass |
15 |
@@ -240,6 +240,10 @@ linux_config_qa_check() { |
16 |
ewarn "QA: You called $f before any linux_config_exists!" |
17 |
ewarn "QA: The return value of $f will NOT guaranteed later!" |
18 |
fi |
19 |
+ |
20 |
+ if ! use kernel_linux; then |
21 |
+ die "$f called on non-Linux system, please fix the ebuild" |
22 |
+ fi |
23 |
} |
24 |
|
25 |
# @FUNCTION: linux_config_src_exists |
26 |
@@ -290,6 +294,10 @@ linux_config_path() { |
27 |
# This function verifies that the current kernel is configured (it checks against the existence of .config) |
28 |
# otherwise it dies. |
29 |
require_configured_kernel() { |
30 |
+ if ! use kernel_linux; then |
31 |
+ die "${FUNCNAME}() called on non-Linux system, please fix the ebuild" |
32 |
+ fi |
33 |
+ |
34 |
if ! linux_config_src_exists; then |
35 |
qeerror "Could not find a usable .config in the kernel source directory." |
36 |
qeerror "Please ensure that ${KERNEL_DIR} points to a configured set of Linux sources." |
37 |
@@ -369,6 +377,10 @@ linux_chkconfig_string() { |
38 |
|
39 |
# Note: duplicated in kernel-2.eclass |
40 |
kernel_is() { |
41 |
+ if ! use kernel_linux; then |
42 |
+ die "${FUNCNAME}() called on non-Linux system, please fix the ebuild" |
43 |
+ fi |
44 |
+ |
45 |
# if we haven't determined the version yet, we need to. |
46 |
linux-info_get_any_version |
47 |
|
48 |
@@ -439,6 +451,10 @@ get_version_warning_done= |
49 |
# KBUILD_OUTPUT (in a decreasing priority list, we look for the env var, makefile var or the |
50 |
# symlink /lib/modules/${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}/build). |
51 |
get_version() { |
52 |
+ if ! use kernel_linux; then |
53 |
+ die "${FUNCNAME}() called on non-Linux system, please fix the ebuild" |
54 |
+ fi |
55 |
+ |
56 |
local tmplocal |
57 |
|
58 |
# no need to execute this twice assuming KV_FULL is populated. |
59 |
@@ -592,6 +608,10 @@ get_version() { |
60 |
# It gets the version of the current running kernel and the result is the same as get_version() if the |
61 |
# function can find the sources. |
62 |
get_running_version() { |
63 |
+ if ! use kernel_linux; then |
64 |
+ die "${FUNCNAME}() called on non-Linux system, please fix the ebuild" |
65 |
+ fi |
66 |
+ |
67 |
KV_FULL=$(uname -r) |
68 |
|
69 |
if [[ -f ${ROOT}/lib/modules/${KV_FULL}/source/Makefile && -f ${ROOT}/lib/modules/${KV_FULL}/build/Makefile ]]; then |
70 |
@@ -631,6 +651,10 @@ get_running_version() { |
71 |
# This attempts to find the version of the sources, and otherwise falls back to |
72 |
# the version of the running kernel. |
73 |
linux-info_get_any_version() { |
74 |
+ if ! use kernel_linux; then |
75 |
+ die "${FUNCNAME}() called on non-Linux system, please fix the ebuild" |
76 |
+ fi |
77 |
+ |
78 |
if ! get_version; then |
79 |
ewarn "Unable to calculate Linux Kernel version for build, attempting to use running version" |
80 |
if ! get_running_version; then |
81 |
@@ -647,6 +671,10 @@ linux-info_get_any_version() { |
82 |
# @DESCRIPTION: |
83 |
# This function verifies that the current kernel sources have been already prepared otherwise it dies. |
84 |
check_kernel_built() { |
85 |
+ if ! use kernel_linux; then |
86 |
+ die "${FUNCNAME}() called on non-Linux system, please fix the ebuild" |
87 |
+ fi |
88 |
+ |
89 |
# if we haven't determined the version yet, we need to |
90 |
require_configured_kernel |
91 |
|
92 |
@@ -676,6 +704,10 @@ check_kernel_built() { |
93 |
# @DESCRIPTION: |
94 |
# This function verifies that the current kernel support modules (it checks CONFIG_MODULES=y) otherwise it dies. |
95 |
check_modules_supported() { |
96 |
+ if ! use kernel_linux; then |
97 |
+ die "${FUNCNAME}() called on non-Linux system, please fix the ebuild" |
98 |
+ fi |
99 |
+ |
100 |
# if we haven't determined the version yet, we need too. |
101 |
require_configured_kernel |
102 |
|
103 |
@@ -832,6 +864,10 @@ check_extra_config() { |
104 |
} |
105 |
|
106 |
check_zlibinflate() { |
107 |
+ if ! use kernel_linux; then |
108 |
+ die "${FUNCNAME}() called on non-Linux system, please fix the ebuild" |
109 |
+ fi |
110 |
+ |
111 |
# if we haven't determined the version yet, we need to |
112 |
require_configured_kernel |
113 |
|
114 |
-- |
115 |
2.16.2 |