Skip to content

Commit

Permalink
Merge remote-tracking branch 'adrelanos/clean-chroot' into clean-chroot
Browse files Browse the repository at this point in the history
  • Loading branch information
adrelanos committed Apr 25, 2024
2 parents 5f10d52 + 61db3a0 commit 0b5fb7b
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 37 deletions.
27 changes: 27 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
grml-debootstrap (0.107) unstable; urgency=medium

[ Antoine Beaupré ]
* [cfa1651] fix debootstrap error handler

-- Michael Prokop <[email protected]> Fri, 02 Feb 2024 12:31:41 +0100

grml-debootstrap (0.106) unstable; urgency=medium

[ Patrick Schleizer ]
- [1a229d0..cc891df] Improve error handling (PR #255)
* [81d7587] consistently use ESP label for the EFI system partition
* [9706bd9] improved error handling, removed RC=$? noops
* [48f3096] remove noops "eend $RC"
* [cbd20a0] consistently use same code path for umounting

[ Michael Prokop ]
* [19dc059] coding style: use '[' instead of 'test'
* [325a888] Install busybox On Debian/stretch as it's required for
initramfs. Thanks to Patrick Schleizer <[email protected]> for
spotting and reporting

[ Chris Hofstaedtler ]
* [090612a] ci: enable test-build on pushes to branches and periodic

-- Michael Prokop <[email protected]> Sat, 23 Dec 2023 20:00:42 +0100

grml-debootstrap (0.105) unstable; urgency=medium

The "farewell lenny, squeeze + wheezy; hello arm64" release
Expand Down
71 changes: 34 additions & 37 deletions grml-debootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ error_handler() {
last_bash_command="$BASH_COMMAND"
echo "Unexpected non-zero exit code $last_exit_code in ${BASH_SOURCE[*]} at line ${BASH_LINENO[*]} detected!
last bash command: $last_bash_command"
## Check if "bailout" function is already available.
if [ -r "$MNTPOINT/debootstrap/debootstrap.log" ] && \
[ -s "$MNTPOINT/debootstrap/debootstrap.log" ] ; then
einfo "Presenting last ten lines of debootstrap.log:"
tail -10 "${MNTPOINT}"/debootstrap/debootstrap.log
einfo "End of debootstrap.log"
fi
## Check if "bailout" function is available.
## This is not the case in chroot-script.
if command -v bailout >/dev/null 2>&1; then
bailout 1
else
Expand Down Expand Up @@ -234,6 +241,32 @@ check4progs(){
}
# }}}

# unmount mountpoint {{{
try_umount() {
local tries=$1
local mountpoint="$2"

if ! mountpoint "$mountpoint" &>/dev/null ; then
return 0
fi

for (( try=1; try<=tries; try++ )); do
if [[ ${try} -eq ${tries} ]]; then
# Last time, show errors this time
umount "${mountpoint}" && return 0
else
# Not last time, hide errors until fatal
if umount "${mountpoint}" 2>/dev/null ; then
return 0
else
sleep 1
fi
fi
done
return 1 # Tried enough
}
# }}}

# helper functions {{{
cleanup() {
if [ -n "$CHROOT_VARIABLES" ] ; then
Expand Down Expand Up @@ -1717,16 +1750,6 @@ debootstrap_system() {
# shellcheck disable=SC2086
"$DEBOOTSTRAP" $ARCHCMD $DEBOOTSTRAP_OPT "$RELEASE" "$MNTPOINT" "$MIRROR"
fi

if [ $RC -ne 0 ] ; then
if [ -r "$MNTPOINT/debootstrap/debootstrap.log" ] && \
[ -s "$MNTPOINT/debootstrap/debootstrap.log" ] ; then
einfo "Presenting last ten lines of debootstrap.log:"
tail -10 "${MNTPOINT}"/debootstrap/debootstrap.log
einfo "End of debootstrap.log"
fi
fi

}
# }}}

Expand Down Expand Up @@ -2049,32 +2072,6 @@ execute_post_scripts() {
}
# }}}

# unmount mountpoint {{{
try_umount() {
local tries=$1
local mountpoint="$2"

if ! mountpoint "$mountpoint" &>/dev/null ; then
return 0
fi

for (( try=1; try<=tries; try++ )); do
if [[ ${try} -eq ${tries} ]]; then
# Last time, show errors this time
umount "${mountpoint}" && return 0
else
# Not last time, hide errors until fatal
if umount "${mountpoint}" 2>/dev/null ; then
return 0
else
sleep 1
fi
fi
done
return 1 # Tried enough
}
# }}}

# execute chroot-script {{{
chrootscript() {
if ! [ -r "$MNTPOINT/bin/chroot-script" ] ; then
Expand Down

0 comments on commit 0b5fb7b

Please sign in to comment.