patch shim initramfs
This commit is contained in:
parent
77b9e1a9c9
commit
fc4c6b5e51
|
@ -0,0 +1,44 @@
|
||||||
|
#!/bin/busybox sh
|
||||||
|
# Copyright 2015 The Chromium OS Authors. All rights reserved.
|
||||||
|
# Use of this source code is governed by a BSD-style license that can be
|
||||||
|
# found in the LICENSE file.
|
||||||
|
#
|
||||||
|
# To bootstrap the factory installer on rootfs. This file must be executed as
|
||||||
|
# PID=1 (exec).
|
||||||
|
# Note that this script uses the busybox shell (not bash, not dash).
|
||||||
|
|
||||||
|
#original: https://chromium.googlesource.com/chromiumos/platform/initramfs/+/refs/heads/main/factory_shim/bootstrap.sh
|
||||||
|
|
||||||
|
set +x
|
||||||
|
|
||||||
|
invoke_terminal() {
|
||||||
|
local tty="$1"
|
||||||
|
local title="$2"
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
# Copied from factory_installer/factory_shim_service.sh.
|
||||||
|
echo "${title}" >>${tty}
|
||||||
|
setsid sh -c "exec script -afqc '$*' /dev/null <${tty} >>${tty} 2>&1 &"
|
||||||
|
}
|
||||||
|
|
||||||
|
enable_debug_console() {
|
||||||
|
local tty="$1"
|
||||||
|
info -e '\033[1;33m[cros_debug] enabled on '${tty}'.\033[m'
|
||||||
|
invoke_terminal "${tty}" "[Bootstrap Debug Console]" "/bin/busybox sh"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
main() {
|
||||||
|
# Setup environment.
|
||||||
|
#kill_frecon
|
||||||
|
#tty_init
|
||||||
|
|
||||||
|
info "...:::||| Bootstrapping ChromeOS Factory Shim |||:::..."
|
||||||
|
info "TTY: ${TTY}, LOG: ${LOG_TTY}, INFO: ${INFO_TTY}, DEBUG: ${DEBUG_TTY}"
|
||||||
|
echo "idk please work"
|
||||||
|
|
||||||
|
enable_debug_console "/dev/pts/0"
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
|
sleep 1d
|
|
@ -0,0 +1,30 @@
|
||||||
|
#!/bin/busybox sh
|
||||||
|
# Copyright 2015 The Chromium OS Authors. All rights reserved.
|
||||||
|
# Use of this source code is governed by a BSD-style license that can be
|
||||||
|
# found in the LICENSE file.
|
||||||
|
#
|
||||||
|
# /init script for use in factory install shim.
|
||||||
|
# Note that this script uses the busybox shell (not bash, not dash).
|
||||||
|
|
||||||
|
#original: https://chromium.googlesource.com/chromiumos/platform/initramfs/+/refs/heads/main/factory_shim/init
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
|
. /lib/init.sh
|
||||||
|
|
||||||
|
setup_environment() {
|
||||||
|
initialize
|
||||||
|
|
||||||
|
# Install additional utility programs.
|
||||||
|
/bin/busybox --install /bin || true
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
setup_environment
|
||||||
|
# In case an error is not handled by bootstrapping, stop here
|
||||||
|
# so that an operator can see installation stop.
|
||||||
|
exec bootstrap.sh || sleep 1d
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
|
exit 1
|
5
build.sh
5
build.sh
|
@ -56,10 +56,13 @@ echo "extracting initramfs cpio archive"
|
||||||
initramfs_dir=/tmp/shim_initramfs
|
initramfs_dir=/tmp/shim_initramfs
|
||||||
rm -rf $initramfs_dir
|
rm -rf $initramfs_dir
|
||||||
cat $cpio_file | cpio -D $initramfs_dir -imd --quiet
|
cat $cpio_file | cpio -D $initramfs_dir -imd --quiet
|
||||||
|
|
||||||
echo "shim initramfs extracted to ${initramfs_dir}"
|
echo "shim initramfs extracted to ${initramfs_dir}"
|
||||||
|
|
||||||
|
#leave /tmp
|
||||||
cd $previous_dir
|
cd $previous_dir
|
||||||
|
|
||||||
|
echo "patching initramfs"
|
||||||
|
exec ./patch_initramfs.sh $initramfs_dir
|
||||||
|
|
||||||
echo "cleaning up loop devices"
|
echo "cleaning up loop devices"
|
||||||
losetup -d $shim_loop
|
losetup -d $shim_loop
|
|
@ -0,0 +1,15 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#patch the shim initramfs to add the bootloader
|
||||||
|
|
||||||
|
set -e
|
||||||
|
if [ "$DEBUG" ]; then
|
||||||
|
set -x
|
||||||
|
fi
|
||||||
|
|
||||||
|
initramfs_path=$(realpath $1)
|
||||||
|
|
||||||
|
rm "${initramfs_path}/init" -f
|
||||||
|
cp bootloader/init.sh "${initramfs_path}/sbin/init"
|
||||||
|
cp bootloader/bootstrap.sh "${initramfs_path}/sbin/bootstrap.sh"
|
||||||
|
chmod +x "${initramfs_path}/sbin/*.sh"
|
Loading…
Reference in New Issue