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 3 #255

Merged
merged 26 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1a229d0
enable error handler by default
adrelanos Oct 25, 2023
0ad48de
use `|| eend $?` consistently in `cleanup` function
adrelanos Oct 25, 2023
2cf99e2
remove obsolete uses of `eend $?`
adrelanos Nov 18, 2023
e0dc8d8
code simplification
adrelanos Oct 25, 2023
601c99c
fix `cleanup` function
adrelanos Oct 25, 2023
d2be7fb
fix `cleanup` function
adrelanos Oct 25, 2023
792af79
don't suppress stderr of rmdir "$MNTPOINT"
adrelanos Dec 7, 2023
bee27f0
fix use of `eend` in `cleanup` function
adrelanos Oct 25, 2023
105ae6f
adjust use of `dialog` for new error handling method
adrelanos Oct 25, 2023
53ed3b4
remove obsolete `|| return 1`
adrelanos Oct 25, 2023
fcaea6e
adjust stages executing for new error handling method
adrelanos Oct 25, 2023
ed17c95
code simplification of stages executing
adrelanos Oct 25, 2023
c59878b
trigger error handler as soon as possible
adrelanos Oct 25, 2023
6db61f4
chroot-script: properly quote stage execution code
adrelanos Oct 25, 2023
406f1e4
adjust options parsing for new error handling method
adrelanos Oct 25, 2023
521689a
adjust use of `dialog` for new error handling method
adrelanos Oct 25, 2023
4812ce4
syntax check before parsing config files
adrelanos Nov 18, 2023
d39c8df
ignore exit codes of umount during cleanup function
adrelanos Oct 26, 2023
cc96e88
the first `rmdir "$MNTPOINT"` needs `|| true`
adrelanos Dec 7, 2023
08f75f2
ignore non-zero exist codes of `modprobe loop` and `modprobe dm-mod`
adrelanos Nov 18, 2023
016c466
ci: enable `--debug`
adrelanos Nov 18, 2023
65e45e5
ignore exit code of blkid as it might fail on some file systems
adrelanos Dec 7, 2023
e11f706
improve error handling for EFI uuid
adrelanos Nov 19, 2023
7a3f1d9
not enabling stretch security repository
adrelanos Nov 22, 2023
14e8a82
style fix: always use "${MNTPOINT}"/boot/efi
adrelanos Dec 11, 2023
cc891df
fix error handling for unmounting on the arm64 architecture
adrelanos Dec 11, 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
33 changes: 17 additions & 16 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 @@ -104,8 +104,8 @@

# add security.debian.org:
case "$RELEASE" in
unstable|sid) ;; # no security pool available
jessie|stretch|buster)
unstable|sid|stretch) ;; # no security pool available
jessie|buster)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure this change makes sense? stretch is in between jessie and buster (see https://wiki.debian.org/DebianReleases)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, I am sure. The repository is defunct but not worth reporting upstream to Debian because that suite is end of life.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, but then at least jessie should be affected as well, nor? :)
Also see http://archive.debian.org/debian-security/dists/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory, I agree. It should also be affected. But in practice, it's not as I could see from the CI tests. I don't have an explanation why it is as is. I just noticed that oddly 1 Debian security repository for an EOL suite is broken.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Porting to archive.debian.org might fix this issue but lets consider that a separate issue that is not worth doing for an EOL suite? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that not enabling security repository for stretch didn't reduce the security or change installed packages.

  • Previously: the stretch build would just show an error message that the stretch repository is unavailable, ignore it, and proceed.
  • After this PR that enabled strict error checking: That resulted in a build failure so we at least know something is wrong. It only made this issue apparent. But the issue was there all along even if nobody noticed.This PR however didn't worsen anything. Well, could argue in theory if that stretch security repository ever comes back online then it's missing from these builds. If that is considered an issue then indeed code to make stretch use archive.debian.org might be required.

echo "Adding security.debian.org to sources.list."
echo "deb http://security.debian.org ${RELEASE}/updates $COMPONENTS" >> /etc/apt/sources.list
;;
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)
PACKAGES_FILE="/etc/debootstrap/packages"

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

if [ -z "${FILESYSTEM}" ] ; then
FILESYSTEM="$(blkid -o value -s TYPE /dev/disk/by-uuid/"${TARGET_UUID}")"
FILESYSTEM="$(blkid -o value -s TYPE /dev/disk/by-uuid/"${TARGET_UUID}")" || true
fi

case "${FILESYSTEM}" in
Expand All @@ -495,8 +495,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 @@ -621,7 +621,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 @@ -631,7 +631,7 @@
fi

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

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

efi_setup || return 1
efi_setup

if [ -n "$EFI" ] ; then
GRUB_PACKAGE=grub-efi-amd64
Expand Down Expand Up @@ -805,8 +805,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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leaving the comment here, since on GitHub one sadly can't seem to comment on the commit message itself, AFAICS: the change itself LGTM, though please use something like "chroot-script: properly quote stage execution code" in the commit message

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means I should leave most commit messages as is but modify this specific commit message?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be more than happy to get nice commit messages! This one only clearly jumped into my eye :) So please feel free and invited to the reword your commit messages (and also squash logically related commits!), so they tell a nice story when going through them, but also have a (somewhat) nice state/story for debian/changelog (the first line of each commit message message shows up there by default when I release a new version, see gbp dch!)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was about to suggest, I was hoping, all of these commits could be squashed into 1. These changes aren't really interesting for users. Just "improved error handling".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rewrote this commit message, grouped together and also improved other commit messages.

"$i"
stage "$i" 'done'
fi
done
# always execute the finalize stage:
Expand Down
Loading
Loading