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