Gentoo Archives: gentoo-commits

From: Thomas Deutschmann <whissi@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/genkernel:master commit in: doc/, defaults/, /
Date: Fri, 28 Aug 2020 20:18:53
Message-Id: 1598632555.8c19b84644d3a0b7f70b101b9c83931280028eb7.whissi@gentoo
1 commit: 8c19b84644d3a0b7f70b101b9c83931280028eb7
2 Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
3 AuthorDate: Fri Aug 28 13:16:36 2020 +0000
4 Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
5 CommitDate: Fri Aug 28 16:35:55 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=8c19b846
7
8 defaults/linuxrc: Always preserve log
9
10 Now that we are using UDEV and have to preserve /run, we can also
11 use /run to always store log from initramfs.
12
13 This will make debugging easier because user don't have to explicit
14 enable logging (disabling is still possible).
15
16 Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>
17
18 defaults/initrd.defaults | 4 +--
19 defaults/initrd.scripts | 74 +-----------------------------------------------
20 defaults/linuxrc | 39 ++++---------------------
21 doc/genkernel.8.txt | 13 +--------
22 gen_initramfs.sh | 10 ++-----
23 5 files changed, 12 insertions(+), 128 deletions(-)
24
25 diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults
26 index e4c861b..e310f19 100644
27 --- a/defaults/initrd.defaults
28 +++ b/defaults/initrd.defaults
29 @@ -74,9 +74,7 @@ GK_BOOTFONT_DISABLED=0
30 GK_DEBUGMODE_STATEFILE="/tmp/debug.enabled"
31 GK_HW_LOAD_ALL_MODULES=0
32 GK_HW_USE_MODULES_LOAD=0
33 -GK_INIT_LOG='/tmp/init.log'
34 -GK_INIT_LOG_COPYTO=
35 -GK_INIT_LOG_COPYTO_DEFAULT='/genkernel-boot.log'
36 +GK_INIT_LOG='/run/initramfs/init.log'
37 GK_INIT_LOG_DISABLED='/tmp/no-init.log'
38 GK_INIT_LOG_PREFIX=
39 GK_NET_DHCP_PIDFILE='/var/run/udhcpc.pid'
40
41 diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
42 index b579e4f..ee7ca2c 100644
43 --- a/defaults/initrd.scripts
44 +++ b/defaults/initrd.scripts
45 @@ -1177,78 +1177,6 @@ crypt_filter() {
46 fi
47 }
48
49 -preserve_log() {
50 - is_log_enabled || return
51 - [ ! -s "${GK_INIT_LOG}" ] && return
52 - [ -z "${GK_INIT_LOG_COPYTO}" ] && return
53 -
54 - local have_errors=0
55 -
56 - local logfile_target="${CHROOT}/${GK_INIT_LOG_COPYTO#/}"
57 - if ! echo "${logfile_target}" | grep -qE '^.*/[A-Za-z0-9._-]+$'
58 - then
59 - # The test above will make sure that a filename was given
60 - # so we can be sure that dirname() will always return a
61 - # path.
62 - warn_msg "gk.log.keep value '${GK_INIT_LOG_COPYTO}' is invalid; Will copy log to '${GK_INIT_LOG_COPYTO_DEFAULT}' instead ..."
63 - logfile_target="${CHROOT}/${GK_INIT_LOG_COPYTO_DEFAULT#/}"
64 - fi
65 -
66 - local fail_msg="Failed to copy '${GK_INIT_LOG}' to '${logfile_target}'"
67 - local logfile_target_dir="$(dirname "${logfile_target}")"
68 -
69 - if [ -z "${logfile_target_dir}" ]
70 - then
71 - bad_msg "${fail_msg}: Failed to determine dirname of '${logfile_target}'!"
72 - return 1
73 - fi
74 -
75 - log_msg "Determining mountpoint of '${logfile_target}' ..."
76 -
77 - local logfile_mountpoint="${logfile_target_dir}"
78 - while [ true ]
79 - do
80 - if run mountpoint "${logfile_mountpoint}" 1>/dev/null 2>&1
81 - then
82 - if run mount -o remount,rw "${logfile_mountpoint}" 1>/dev/null 2>&1
83 - then
84 - break
85 - else
86 - bad_msg "${fail_msg}: 'mount -o remount,rw \"${logfile_mountpoint}\"' failed!"
87 - return 1
88 - fi
89 - fi
90 -
91 - logfile_mountpoint="$(dirname "${logfile_mountpoint}")"
92 - if [ "${logfile_mountpoint}" = "/" ]
93 - then
94 - # Stop here
95 - bad_msg "${fail_msg}: Failed to determine mountpoint for '${logfile_target}'!"
96 - return 1
97 - fi
98 - done
99 -
100 - if [ ! -d "${logfile_target_dir}" ]
101 - then
102 - if ! run mkdir -p "${logfile_target_dir}" 2>/dev/null
103 - then
104 - bad_msg "${fail_msg}: Failed to create '${logfile_target_dir}'!"
105 - return 1
106 - fi
107 - fi
108 -
109 - good_msg "gk.log.keep set; Copying '${GK_INIT_LOG}' to '${logfile_target}' ..."
110 - if ! run cp -f "${GK_INIT_LOG}" "${logfile_target}" 2>/dev/null
111 - then
112 - bad_msg "${fail_msg}!"
113 - fi
114 -
115 - if ! run mount -o remount,ro "${logfile_mountpoint}" 1>/dev/null 2>&1
116 - then
117 - bad_msg "Failed to re-mount ${logfile_mountpoint} read-only!"
118 - fi
119 -}
120 -
121 process_initramfs_mounts() {
122 local fslist=
123
124 @@ -2388,7 +2316,7 @@ start_sshd() {
125 run touch /var/log/lastlog
126
127 good_msg "Starting dropbear sshd ..." ${QUIET}
128 - run dropbear -p ${GK_SSHD_PORT} -R -P "${GK_SSHD_PIDFILE}" 2>/var/log/dropbear.log
129 + run dropbear -p ${GK_SSHD_PORT} -R -P "${GK_SSHD_PIDFILE}" 2>/run/initramfs/dropbear.log
130 if [ $? -eq 0 ]
131 then
132 if [ "${GK_PROMPT_TIMEOUT}" = '0' ]
133
134 diff --git a/defaults/linuxrc b/defaults/linuxrc
135 index afb91d8..a4ed811 100644
136 --- a/defaults/linuxrc
137 +++ b/defaults/linuxrc
138 @@ -35,6 +35,12 @@ mount -t proc -o noexec,nosuid,nodev proc /proc >/dev/null 2>&1
139 mount -o remount,rw / >/dev/null 2>&1
140 mount -t tmpfs -o rw,nosuid,nodev,relatime,mode=755 none /run 2>&1
141
142 +if [ ! -d /run/initramfs ]
143 +then
144 + mkdir -p /run/initramfs
145 + chmod 0750 /run/initramfs
146 +fi
147 +
148 # Prevent superfluous printks from being printed to the console
149 echo 1 > /proc/sys/kernel/printk
150
151 @@ -306,37 +312,6 @@ do
152 fi
153 unset tmp_disabled
154 ;;
155 - gk.log.keep=*)
156 - case "${x#*=}" in
157 - [Tt][Rr][Uu][Ee])
158 - GK_INIT_LOG_COPYTO="${GK_INIT_LOG_COPYTO_DEFAULT}"
159 - ;;
160 - [Yy][Ee][Ss])
161 - GK_INIT_LOG_COPYTO="${GK_INIT_LOG_COPYTO_DEFAULT}"
162 - ;;
163 - [Yy])
164 - GK_INIT_LOG_COPYTO="${GK_INIT_LOG_COPYTO_DEFAULT}"
165 - ;;
166 - 1)
167 - GK_INIT_LOG_COPYTO="${GK_INIT_LOG_COPYTO_DEFAULT}"
168 - ;;
169 - [Ff][Aa][Ll][Ss][Ee])
170 - GK_INIT_LOG_COPYTO=
171 - ;;
172 - [Nn][Oo])
173 - GK_INIT_LOG_COPYTO=
174 - ;;
175 - [Nn])
176 - GK_INIT_LOG_COPYTO=
177 - ;;
178 - 0)
179 - GK_INIT_LOG_COPYTO=
180 - ;;
181 - *)
182 - GK_INIT_LOG_COPYTO=${x#*=}
183 - ;;
184 - esac
185 - ;;
186 gk.sshd.port=*)
187 tmp_port=${x#*=}
188 if is_int "${tmp_port}"
189 @@ -1338,8 +1313,6 @@ fi
190 # Run debug shell if requested
191 rundebugshell "before entering switch_root"
192
193 -preserve_log
194 -
195 # init_opts is set in the environment by the kernel when it parses the command line
196 init=${REAL_INIT:-/sbin/init}
197 if ! mountpoint "${CHROOT}" 1>/dev/null 2>&1
198
199 diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt
200 index 2625d6f..d8b9e09 100644
201 --- a/doc/genkernel.8.txt
202 +++ b/doc/genkernel.8.txt
203 @@ -827,20 +827,9 @@ when not set. This will allow remote user to provide answer through
204
205 *gk.log.disabled*=<...>::
206 By default, any shown message and external command calls will be logged
207 - to '/tmp/init.log' in initramfs. This boolean option allows you to
208 + to '/run/initramfs/init.log'. This boolean option allows you to
209 disable logging for some reason.
210
211 -*gk.log.keep*=<...>::
212 -When set to a boolean value, genkernel will preserve '/tmp/init.log',
213 -see above, and copy file to '/genkernel-boot.log' on *root* device.
214 -You can also set your own file like '/root/my-genkernel-boot.log' to
215 -copy log to a custom path.
216 -
217 -NOTE: The default file '/genkernel-boot.log' on *root* was chosen because
218 -genkernel's initramfs will only mount root filesystem by default. If you
219 -want to store the log file in '/var/log/genkernel-boot.log' for example
220 -make sure that this mountpoint is accessible, see *initramfs.mounts*.
221 -
222 *gk.userinteraction.disabled*=<...>::
223 By default, genkernel will prompt on errors. In case this is not wanted
224 or desired, e.g. for a kiosk system, this boolean option will disable
225
226 diff --git a/gen_initramfs.sh b/gen_initramfs.sh
227 index 9852719..27e98fc 100755
228 --- a/gen_initramfs.sh
229 +++ b/gen_initramfs.sh
230 @@ -294,7 +294,7 @@ append_base_layout() {
231 lib/dracut \
232 mnt \
233 proc \
234 - run/lock \
235 + run \
236 sbin \
237 sys \
238 tmp \
239 @@ -303,13 +303,11 @@ append_base_layout() {
240 usr/lib \
241 usr/sbin \
242 var/log \
243 + var/run/lock \
244 ; do
245 mkdir -p "${TDIR}"/${mydir} || gen_die "Failed to create '${TDIR}/${mydir}'!"
246 done
247
248 - ln -s ../run var/run || gen_die "Failed to create symlink '${TDIR}/var/run' to '${TDIR}/run'!"
249 - ln -s ../run/lock var/lock || gen_die "Failed to create symlink '${TDIR}/var/lock' to '${TDIR}/run/lock'!"
250 -
251 chmod 1777 "${TDIR}"/tmp || gen_die "Failed to chmod of '${TDIR}/tmp' to 1777!"
252
253 # In general, we don't really need lib{32,64} anymore because we now
254 @@ -476,7 +474,7 @@ append_busybox() {
255 done
256
257 # Set up a few default symlinks
258 - local required_applets='[ ash sh mknod mount uname echo cut cat'
259 + local required_applets='[ ash sh mkdir mknod mount uname echo cut cat touch'
260 local required_applet=
261 for required_applet in ${required_applets}
262 do
263 @@ -773,8 +771,6 @@ append_dmraid() {
264
265 unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}"
266
267 - mkdir -p "${TDIR}"/run/lock/dmraid || gen_die "Failed to create '${TDIR}/run/lock/dmraid'!"
268 -
269 cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
270
271 # Delete unneeded files