Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add leapp debug tools to initramfs upgrade module #997

Merged
merged 2 commits into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
# script read at startup by login shells
# in the initramfs this is read for example by the emergency shell

# set the environment file, containing shell commands to execute at startup of
# interactive shells
if [ -f "$HOME/.shrc" ]; then
ENV="$HOME/.shrc"; export ENV
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

# shell commands to execute on interactive shell startup
. leapp_debug_tools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/sh
# library containing some useful functions for debugging in initramfs

# mounts the sysroot
leapp_dbg_mount() {
systemctl start sysroot.mount
matejmatuska marked this conversation as resolved.
Show resolved Hide resolved
mount -o remount,rw /sysroot
}

# source programs from $NEWROOT, mount if not mounted
leapp_dbg_source() {
systemctl is-active sysroot.mount --quiet || {
echo "sysroot not mounted, mounting...";
leapp_dbg_mount || return 1
}

for dir in /bin /sbin; do
export PATH="$PATH:${NEWROOT}$dir"
matejmatuska marked this conversation as resolved.
Show resolved Hide resolved
done

export LD_LIBRARY_PATH=/sysroot/lib64
}

# chroot into $NEWROOT
leapp_dbg_chroot() {
matejmatuska marked this conversation as resolved.
Show resolved Hide resolved
systemctl is-active sysroot.mount --quiet || {
echo "sysroot not mounted, mounting...";
leapp_dbg_mount || return 1
}

for dir in /sys /run /proc /dev /dev/pts; do
mount --bind $dir "$NEWROOT$dir"
done || {
echo "Failed to mount some directories" || return 1
}

chroot "$NEWROOT" sh -c "mount -a; /bin/bash"
for dir in /sys /run /proc /dev/pts /dev; do
umount "$NEWROOT$dir"
done
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ install() {
inst_script "${_moddir}/initrd-system-upgrade-generator" \
"${generatordir}/initrd-system-upgrade-generator"

inst_script "${_moddir}/leapp_debug_tools.sh" "/bin/leapp_debug_tools.sh"
inst_script "${_moddir}/.profile" "/.profile"
inst_script "${_moddir}/.shrc" "/.shrc"

## upgrade shell service
#sysinit_wantsdir="${_initdir}${unitdir}/sysinit.target.wants"
#mkdir -p "$sysinit_wantsdir"
Expand Down