1 |
commit: 9ead931af140020d4f5f2fed47a17da5dc8cfe24 |
2 |
Author: Fabio Erculiani <lxnay <AT> sabayon <DOT> org> |
3 |
AuthorDate: Thu Apr 25 10:45:19 2013 +0000 |
4 |
Commit: Fabio Erculiani <lxnay <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Apr 29 09:54:47 2013 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=9ead931a |
7 |
|
8 |
linuxrc: use "quiet" cmdline argument for a really quiet initramfs initialization |
9 |
|
10 |
"quiet" is already used by the kernel to avoid printing messages on the |
11 |
console unless they are errors or warnings. Genkernel should do the same |
12 |
wrt its initramfs initialization code. |
13 |
This has also the advantage of improving the boot speed. |
14 |
|
15 |
--- |
16 |
defaults/initrd.scripts | 34 ++++++++++++++++++++++------------ |
17 |
defaults/linuxrc | 35 +++++++++++++++++------------------ |
18 |
doc/genkernel.8.txt | 4 ++++ |
19 |
3 files changed, 43 insertions(+), 30 deletions(-) |
20 |
|
21 |
diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts |
22 |
old mode 100755 |
23 |
new mode 100644 |
24 |
index ff724b5..c1969d1 |
25 |
--- a/defaults/initrd.scripts |
26 |
+++ b/defaults/initrd.scripts |
27 |
@@ -16,15 +16,16 @@ modules_scan() { |
28 |
local loaded |
29 |
|
30 |
MODS=$(cat /etc/modules/${1} 2>/dev/null) |
31 |
- [ -n "${MODS}" ] && echo -ne "${BOLD} ::${NORMAL} " |
32 |
- [ -n "${MODS}" ] && echo -ne "Loading from ${1}: " |
33 |
+ [ -n "${MODS}" ] && [ -z "${QUIET}" ] && \ |
34 |
+ echo -ne "${BOLD} ::${NORMAL} Loading from ${1}: " |
35 |
|
36 |
for x in ${MODS} |
37 |
do |
38 |
MLOAD=$(echo ${MLIST} | sed -e "s/.*${x}.*/${x}/") |
39 |
if [ "${MLOAD}" = "${x}" ] # Only module to no-load |
40 |
then |
41 |
- echo -e "${BOLD} ::${NORMAL} Skipping ${x}..." |
42 |
+ [ -z "${QUIET}" ] && \ |
43 |
+ echo -e "${BOLD} ::${NORMAL} Skipping ${x}..." |
44 |
elif [ "${MLOAD}" = "${MLIST}" ] |
45 |
then |
46 |
if [ -n "${DEBUG}" ]; then |
47 |
@@ -33,17 +34,21 @@ modules_scan() { |
48 |
fi |
49 |
modprobe ${x} > /dev/null 2>&1 |
50 |
loaded=${?} |
51 |
+ |
52 |
[ -n "${DEBUG}" -a "${loaded}" = "0" ] && \ |
53 |
echo "loaded" |
54 |
[ -n "${DEBUG}" -a "${loaded}" != "0" ] && \ |
55 |
echo "not loaded" |
56 |
+ |
57 |
[ -z "${DEBUG}" -a "${loaded}" = "0" ] && \ |
58 |
+ [ -z "${QUIET}" ] && \ |
59 |
echo -en "${x} " |
60 |
else |
61 |
- echo -e "${BOLD} ::${NORMAL} Skipping ${x}..." |
62 |
+ [ -z "${QUIET}" ] && \ |
63 |
+ echo -e "${BOLD} ::${NORMAL} Skipping ${x}..." |
64 |
fi |
65 |
done |
66 |
- [ -n "${MODS}" ] && echo |
67 |
+ [ -n "${MODS}" ] && [ -z "${QUIET}" ] && echo |
68 |
} |
69 |
|
70 |
uppercase(){ |
71 |
@@ -377,7 +382,9 @@ test_success() { |
72 |
# $1 string |
73 |
# $2 hide flag |
74 |
|
75 |
-good_msg() { |
76 |
+good_msg() { |
77 |
+ [ -n "${QUIET}" ] && [ -z "${DEBUG}" ] && return 0 |
78 |
+ |
79 |
msg_string=$1 |
80 |
msg_string="${msg_string:-...}" |
81 |
[ "$2" != 1 ] && echo -e "${GOOD}>>${NORMAL}${BOLD} ${msg_string} ${NORMAL}" |
82 |
@@ -424,12 +431,15 @@ prompt_user(){ |
83 |
eval local oldvalue='$'${1} |
84 |
|
85 |
[ $# != 2 -a $# != 3 ] && \ |
86 |
- bad_msg "Bad invocation of function prompt_user, please file a bug \ |
87 |
- report with this message" && exit 1 |
88 |
+ bad_msg "Bad invocation of function prompt_user." |
89 |
+ bad_msg "Please file a bug report with this message" && exit 1 |
90 |
[ -n "${3}" ] && local explnt=" or : ${3}" || local explnt="." |
91 |
- |
92 |
+ |
93 |
bad_msg "Could not find the ${2} in ${oldvalue}${explnt}" |
94 |
- echo ' Please specify another value or: press Enter for the same, type "shell" for a shell, or "q" to skip...' |
95 |
+ bad_msg "Please specify another value or:" |
96 |
+ bad_msg "- press Enter for the same" |
97 |
+ bad_msg '- type "shell" for a shell' |
98 |
+ bad_msg '- type "q" to skip...' |
99 |
echo -n "${2}(${oldvalue}) :: " |
100 |
read ${1} |
101 |
case `eval echo '$'${1}` in |
102 |
@@ -440,7 +450,7 @@ prompt_user(){ |
103 |
;; |
104 |
'shell') |
105 |
eval ${1}'='${oldvalue} |
106 |
- echo "To leave and try again just press <Ctrl>+D" |
107 |
+ warn_msg "To leave and try again just press <Ctrl>+D" |
108 |
run_shell |
109 |
;; |
110 |
'') |
111 |
@@ -600,7 +610,7 @@ chooseKeymap() { |
112 |
splash set_msg "Set keymap to ${keymap}" |
113 |
elif [ -z "${keymap}" ] |
114 |
then |
115 |
- echo |
116 |
+ good_msg |
117 |
good_msg "Keeping default keymap" |
118 |
splash set_msg "Keeping default keymap" |
119 |
else |
120 |
|
121 |
diff --git a/defaults/linuxrc b/defaults/linuxrc |
122 |
old mode 100755 |
123 |
new mode 100644 |
124 |
index ba9c5d5..1d26aaf |
125 |
--- a/defaults/linuxrc |
126 |
+++ b/defaults/linuxrc |
127 |
@@ -31,8 +31,6 @@ then |
128 |
[ -e /linuxrc ] && rm /linuxrc |
129 |
fi |
130 |
|
131 |
-quiet_kmsg |
132 |
- |
133 |
CMDLINE=$(cat /proc/cmdline) |
134 |
# Scan CMDLINE for any specified real_root= or cdroot arguments |
135 |
FAKE_ROOT='' |
136 |
@@ -41,6 +39,7 @@ FAKE_ROOTFLAGS='' |
137 |
INIT_OPTS='' |
138 |
ROOTFSTYPE='auto' |
139 |
CRYPT_SILENT=0 |
140 |
+QUIET='' |
141 |
|
142 |
mkdir -p /etc/cmdline /etc/modprobe.d |
143 |
for x in ${CMDLINE} |
144 |
@@ -118,6 +117,9 @@ do |
145 |
ZPOOL_FORCE=-f |
146 |
fi |
147 |
;; |
148 |
+ quiet) |
149 |
+ QUIET=1 |
150 |
+ ;; |
151 |
# Debug Options |
152 |
debug) |
153 |
DEBUG='yes' |
154 |
@@ -270,6 +272,8 @@ do |
155 |
esac |
156 |
done |
157 |
|
158 |
+quiet_kmsg |
159 |
+ |
160 |
if [ "${CDROOT}" = '0' ] |
161 |
then |
162 |
if [ -z "${REAL_ROOT}" -a "${FAKE_ROOT}" != "/dev/ram0" ] |
163 |
@@ -457,17 +461,13 @@ then |
164 |
|
165 |
if [ "${REAL_ROOT}" = '' ] |
166 |
then |
167 |
- echo -n -e "${WARN}>>${NORMAL}${BOLD} No bootable medium found. Waiting for new devices" |
168 |
- |
169 |
+ warn_msg "No bootable medium found. Waiting for new devices..." |
170 |
COUNTER=0 |
171 |
while [ ${COUNTER} -lt 3 ]; do |
172 |
sleep 3 |
173 |
- echo -n '.' |
174 |
let COUNTER=${COUNTER}+1 |
175 |
done |
176 |
- |
177 |
sleep 1 |
178 |
- echo -e "${NORMAL}" |
179 |
bootstrapCD |
180 |
fi |
181 |
|
182 |
@@ -909,43 +909,42 @@ fi |
183 |
|
184 |
verbose_kmsg |
185 |
|
186 |
-echo -ne "${GOOD}>>${NORMAL}${BOLD} Booting (initramfs)${NORMAL}" |
187 |
+good_msg "Booting (initramfs)" |
188 |
|
189 |
cd "${CHROOT}" |
190 |
mkdir "${CHROOT}/proc" "${CHROOT}/sys" "${CHROOT}/run" 2>/dev/null |
191 |
-echo -ne "${BOLD}.${NORMAL}" |
192 |
|
193 |
# If devtmpfs is mounted, try move it to the new root |
194 |
-# If that fails, try to unmount all possible mounts of devtmpfs as stuff breaks otherwise |
195 |
+# If that fails, try to unmount all possible mounts of |
196 |
+# devtmpfs as stuff breaks otherwise |
197 |
for fs in /dev /sys /proc |
198 |
do |
199 |
if grep -qs "$fs" /proc/mounts |
200 |
then |
201 |
if ! mount --move $fs "${CHROOT}"$fs |
202 |
then |
203 |
- umount $fs || echo '*: Failed to move and unmount the ramdisk $fs!' |
204 |
+ umount $fs || \ |
205 |
+ bad_msg "Failed to move and unmount the ramdisk $fs!" |
206 |
fi |
207 |
fi |
208 |
done |
209 |
|
210 |
if [ ! -e "${CHROOT}/dev/console" ] || [ ! -e "${CHROOT}/dev/null" ] |
211 |
then |
212 |
- echo -ne "${BAD}>>${NORMAL}${BOLD} ERROR: your real /dev is missing files required to boot (console and null)${NORMAL}" |
213 |
+ bad_msg "ERROR: your real /dev is missing console and null" |
214 |
elif [ -e /etc/initrd.splash -a ! -e "${CHROOT}/dev/tty1" ] |
215 |
then |
216 |
- echo -ne "${BAD}>>${NORMAL}${BOLD} ERROR: your real /dev is missing tty1, which is required for splash${NORMAL}" |
217 |
+ bad_msg "ERROR: your real /dev is missing tty1, required for splash" |
218 |
fi |
219 |
|
220 |
-echo -e "${BOLD}.${NORMAL}" |
221 |
- |
222 |
exec /sbin/switch_root -c "/dev/console" "${CHROOT}" "${REAL_INIT:-/sbin/init}" "${INIT_OPTS}" |
223 |
|
224 |
# If we get here, something bad has happened |
225 |
splash 'verbose' |
226 |
|
227 |
-echo "A fatal error has probably occured since ${REAL_INIT:-/sbin/init} did not" |
228 |
-echo "boot correctly. Trying to open a shell..." |
229 |
-echo |
230 |
+bad_msg "A fatal error has occured since ${REAL_INIT:-/sbin/init} did not" |
231 |
+bad_msg "boot correctly. Trying to open a shell..." |
232 |
+ |
233 |
exec /bin/bash |
234 |
exec /bin/sh |
235 |
exec /bin/ash |
236 |
|
237 |
diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt |
238 |
index 54d26d2..f1cc814 100644 |
239 |
--- a/doc/genkernel.8.txt |
240 |
+++ b/doc/genkernel.8.txt |
241 |
@@ -493,6 +493,10 @@ which the ramdisk scripts would recognize. |
242 |
switch_root into "<CHROOT>/<SUBDIR>" instead of "<CHROOT>/". |
243 |
<CHROOT> is "/newroot" (or "/union") usually. |
244 |
|
245 |
+*quiet*:: |
246 |
+ Do not print anything but error and warning messages during |
247 |
+ the execution of the initramfs init scripts. |
248 |
+ |
249 |
*debug*:: |
250 |
Drop into a debug shell early in the process. |