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

improve error handling 2 #248

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7a08502
enable error handler by default
adrelanos Oct 25, 2023
2e57676
use `|| eend $?` consistently in `cleanup` function
adrelanos Oct 25, 2023
e5facba
remove obsolete uses of `eend $?`
adrelanos Nov 18, 2023
b7f461f
code simplification
adrelanos Oct 25, 2023
39ba0c2
fix `cleanup` function
adrelanos Oct 25, 2023
715399e
fix, show info message when deleting `$MNTPOINT` in all cases
adrelanos Oct 25, 2023
7166798
fix `cleanup` function
adrelanos Oct 25, 2023
b68d194
don't suppress stderr of rmdir "$MNTPOINT"
adrelanos Oct 25, 2023
f55c41c
fix use of `eend` in `cleanup` function
adrelanos Oct 25, 2023
04912ca
adjust use of `dialog` for new error handling method
adrelanos Oct 25, 2023
e07397c
remove obsolete `|| return 1`
adrelanos Oct 25, 2023
8dbfaaa
adjust stages executing for new error handling method
adrelanos Oct 25, 2023
47906ce
code simplification
adrelanos Oct 25, 2023
bfc1582
trigger error handler as soon as possible
adrelanos Oct 25, 2023
169d7eb
quotes
adrelanos Oct 25, 2023
60e639e
adjust options parsing for new error handling method
adrelanos Oct 25, 2023
e32e872
adjust use of `dialog` for new error handling method
adrelanos Oct 25, 2023
8980a73
syntax check before parsing config files
adrelanos Nov 18, 2023
56a6505
suppress exit codes for umount just in case attempts
adrelanos Oct 26, 2023
9df6c36
the first `rmdir "$MNTPOINT"` needs `|| true`
adrelanos Nov 8, 2023
d133e98
drop `-q` from modprobe for better debug output
adrelanos Nov 18, 2023
e957fa8
ignore non-zero exist codes of `modprobe loop`
adrelanos Nov 18, 2023
df8df97
ignore non-zero exist codes of `modprobe dm-mod`
adrelanos Nov 18, 2023
199accc
enable `--debug` during tests
adrelanos Nov 18, 2023
1cb7d7c
debugging blkid
adrelanos Nov 19, 2023
04ff4ee
debugging blkid
adrelanos Nov 19, 2023
7a39b11
ignore blkid exit code
adrelanos Nov 19, 2023
a816156
improve error handling for EFI uuid
adrelanos Nov 19, 2023
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
34 changes: 20 additions & 14 deletions chroot-script
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
# shellcheck disable=SC2317 # shellcheck has trouble understanding the code flow in this file

# error_handler {{{
if [ "$REPORT_TRAP_ERR" = "yes" ] || [ "$FAIL_TRAP_ERR" = "yes" ]; then
set -e
set -E
set -o pipefail
trap "error_handler" ERR
fi
set -e
set -E
set -o pipefail
trap "error_handler" ERR
# }}}

bash -n /etc/debootstrap/config
# shellcheck source=config
. /etc/debootstrap/config || exit 1
bash -n /etc/debootstrap/variables
# shellcheck source=tests/shellcheck-stub-debootstrap-variables
. /etc/debootstrap/variables || exit 1

Expand Down Expand Up @@ -260,7 +260,7 @@
debconf-set-selections < /etc/debootstrap/debconf-selections
}

if [ "$PACKAGES" = 'yes' ] ; then

Check warning on line 263 in chroot-script

View workflow job for this annotation

GitHub Actions / shellcheck grml-debootstrap

[shellcheck] reported by reviewdog 🐶 Possible misspelling: PACKAGES may not be assigned. Did you mean KPACKAGE? [SC2153](https://github.com/koalaman/shellcheck/wiki/SC2153) Raw Output: ./chroot-script:263:9:info:Possible misspelling: PACKAGES may not be assigned. Did you mean KPACKAGE? [SC2153](https://github.com/koalaman/shellcheck/wiki/SC2153)

Check warning on line 263 in chroot-script

View workflow job for this annotation

GitHub Actions / shellcheck grml-debootstrap

[shellcheck] reported by reviewdog 🐶 Possible misspelling: PACKAGES may not be assigned. Did you mean KPACKAGE? [SC2153](https://github.com/koalaman/shellcheck/wiki/SC2153) Raw Output: ./chroot-script:263:9:info:Possible misspelling: PACKAGES may not be assigned. Did you mean KPACKAGE? [SC2153](https://github.com/koalaman/shellcheck/wiki/SC2153)
PACKAGES_FILE="/etc/debootstrap/packages"

if [ "$ARCH" = 'arm64' ]; then
Expand Down Expand Up @@ -480,7 +480,12 @@
local rootfs_mount_options=""

if [ -z "${FILESYSTEM}" ] ; then
FILESYSTEM="$(blkid -o value -s TYPE /dev/disk/by-uuid/"${TARGET_UUID}")"
## Debugging.
ls -la /dev/disk/by-uuid/"${TARGET_UUID}" || true
test -r /dev/disk/by-uuid/"${TARGET_UUID}" || true
blkid /dev/disk/by-uuid/"${TARGET_UUID}" || true

FILESYSTEM="$(blkid -o value -s TYPE /dev/disk/by-uuid/"${TARGET_UUID}")" || true
fi

case "${FILESYSTEM}" in
Expand All @@ -496,8 +501,8 @@
fi

if [ -n "$EFI" ] ; then
# shellcheck disable=SC2086
echo "UUID=$(blkid -o value -s UUID $EFI) /boot/efi vfat umask=0077 0 1" >> /etc/fstab
UUID_EFI="$(blkid -o value -s UUID "$EFI")"
echo "UUID=$UUID_EFI /boot/efi vfat umask=0077 0 1" >> /etc/fstab
fi

cat >> /etc/fstab << EOF
Expand Down Expand Up @@ -623,7 +628,7 @@

mkdir -p /boot/efi
echo "Mounting $EFI on /boot/efi"
mount "$EFI" /boot/efi || return 1
mount "$EFI" /boot/efi

# if efivarfs kernel module is loaded, but efivars isn't,
# then we need to mount efivarfs for efibootmgr usage
Expand All @@ -633,7 +638,7 @@
fi

echo "Invoking efibootmgr"
efibootmgr || return 1
efibootmgr
}

# grub configuration/installation {{{
Expand Down Expand Up @@ -680,7 +685,7 @@
return 0
fi

efi_setup || return 1
efi_setup

if [ -n "$EFI" ] ; then
GRUB_PACKAGE=grub-efi-amd64
Expand Down Expand Up @@ -807,8 +812,9 @@
initrd grub_install passwords \
custom_scripts upgrade_system remove_apt_cache services \
remove_chrootmirror; do
if stage $i ; then
$i && stage $i 'done' || exit 1
if stage "$i" ; then
"$i"
stage "$i" 'done'
fi
done
# always execute the finalize stage:
Expand Down
Loading
Loading