grml-debootstrap
grml-debootstrap copied to clipboard
use rmdir with --ignore-fail-on-non-empty parameter
debootstrap failed because of a mistake of mine (on Debian buster). As a follow up issue, rmdir failed because the directory was not existing yet.
What do you think about adding --ignore-fail-on-non-empty
to all invocations of rmdir
?
+ RC=2
+ '[' 2 -ne 0 ']'
+ '[' -r /mnt/debootstrap.29459/debootstrap/debootstrap.log ']'
+ eend 2
+ local retval=2
+ shift
+ '[' 2 -gt 0 ']'
+ printf ' %s-> Failed (rc=%s)%s\n' '' 2 ''
-> Failed (rc=2)
+ return 2
+ bailout 2 debootstrap_system
+ cleanup
+ '[' -n '' ']'
+ '[' -n /var/cache/grml-debootstrap/stages_Whonix-Gateway-XFCE-15.0.0.0.0.raw ']'
+ einfo 'Removing /var/cache/grml-debootstrap/stages_Whonix-Gateway-XFCE-15.0.0.0.0.raw'
+ einfon 'Removing /var/cache/grml-debootstrap/stages_Whonix-Gateway-XFCE-15.0.0.0.0.raw\n'
+ '[' '' '!=' yes ']'
+ '[' einfon = ebegin ']'
+ printf ' %s*%s Removing /var/cache/grml-debootstrap/stages_Whonix-Gateway-XFCE-15.0.0.0.0.raw\n' '' ''
* Removing /var/cache/grml-debootstrap/stages_Whonix-Gateway-XFCE-15.0.0.0.0.raw
+ LAST_E_CMD=einfon
+ return 0
+ return 0
+ rmdir /var/cache/grml-debootstrap/stages_Whonix-Gateway-XFCE-15.0.0.0.0.raw
+ eend 0
+ local retval=0
+ shift
+ '[' 0 -gt 0 ']'
+ return 0
+ echo /mnt/debootstrap.29459
+ grep -q '/mnt/debootstrap\.'
+ rmdir /mnt/debootstrap.29459
++ error_handler
++ last_exit_code=1
++ last_bash_command='rmdir "$MNTPOINT" 2> /dev/null'
++ '[' yes = yes ']'
++ echo 'Unexpected non-zero exit code 1 in /usr/sbin/grml-debootstrap /usr/sbin/grml-debootstrap /usr/sbin/grml-debootstrap /usr/sbin/grml-debootstrap at line 253 316 1973 0 detected!
last bash command: rmdir "$MNTPOINT" 2> /dev/null'
Unexpected non-zero exit code 1 in /usr/sbin/grml-debootstrap /usr/sbin/grml-debootstrap /usr/sbin/grml-debootstrap /usr/sbin/grml-debootstrap at line 253 316 1973 0 detected!
last bash command: rmdir "$MNTPOINT" 2> /dev/null
++ '[' '!' yes = yes ']'
++ command -v bailout
++ bailout 1
++ cleanup
++ '[' -n '' ']'
++ '[' -n /var/cache/grml-debootstrap/stages_Whonix-Gateway-XFCE-15.0.0.0.0.raw ']'
++ einfo 'Removing /var/cache/grml-debootstrap/stages_Whonix-Gateway-XFCE-15.0.0.0.0.raw'
++ einfon 'Removing /var/cache/grml-debootstrap/stages_Whonix-Gateway-XFCE-15.0.0.0.0.raw\n'
++ '[' '' '!=' yes ']'
++ '[' einfon = ebegin ']'
++ printf ' %s*%s Removing /var/cache/grml-debootstrap/stages_Whonix-Gateway-XFCE-15.0.0.0.0.raw\n' '' ''
* Removing /var/cache/grml-debootstrap/stages_Whonix-Gateway-XFCE-15.0.0.0.0.raw
++ LAST_E_CMD=einfon
++ return 0
++ return 0
++ rmdir /var/cache/grml-debootstrap/stages_Whonix-Gateway-XFCE-15.0.0.0.0.raw
rmdir: failed to remove '/var/cache/grml-debootstrap/stages_Whonix-Gateway-XFCE-15.0.0.0.0.raw': No such file or directory
++ eend 1
++ local retval=1
++ shift
++ '[' 1 -gt 0 ']'
++ printf ' %s-> Failed (rc=%s)%s\n' '' 1 ''
-> Failed (rc=1)
++ return 1
++ echo /mnt/debootstrap.29459
++ grep -q '/mnt/debootstrap\.'
++ rmdir /mnt/debootstrap.29459
++ '[' -n /mnt/debootstrap.29459 ']'
++ grep -q /mnt/debootstrap.29459 /proc/mounts
++ for service in ssh mdadm
++ '[' -x /mnt/debootstrap.29459/etc/init.d/ssh ']'
++ for service in ssh mdadm
++ '[' -x /mnt/debootstrap.29459/etc/init.d/mdadm ']'
++ '[' -x /mnt/debootstrap.29459/bin/umount ']'
++ for ARG in /run/udev /sys /proc /proc /dev/pts /dev/pts /dev /dev
++ '[' -x /mnt/debootstrap.29459/bin/umount ']'
++ umount /mnt/debootstrap.29459//run/udev
++ for ARG in /run/udev /sys /proc /proc /dev/pts /dev/pts /dev /dev
++ '[' -x /mnt/debootstrap.29459/bin/umount ']'
++ umount /mnt/debootstrap.29459//sys
++ for ARG in /run/udev /sys /proc /proc /dev/pts /dev/pts /dev /dev
++ '[' -x /mnt/debootstrap.29459/bin/umount ']'
++ umount /mnt/debootstrap.29459//proc
++ for ARG in /run/udev /sys /proc /proc /dev/pts /dev/pts /dev /dev
++ '[' -x /mnt/debootstrap.29459/bin/umount ']'
++ umount /mnt/debootstrap.29459//proc
++ for ARG in /run/udev /sys /proc /proc /dev/pts /dev/pts /dev /dev
++ '[' -x /mnt/debootstrap.29459/bin/umount ']'
++ umount /mnt/debootstrap.29459//dev/pts
++ for ARG in /run/udev /sys /proc /proc /dev/pts /dev/pts /dev /dev
++ '[' -x /mnt/debootstrap.29459/bin/umount ']'
++ umount /mnt/debootstrap.29459//dev/pts
++ for ARG in /run/udev /sys /proc /proc /dev/pts /dev/pts /dev /dev
++ '[' -x /mnt/debootstrap.29459/bin/umount ']'
++ umount /mnt/debootstrap.29459//dev
++ for ARG in /run/udev /sys /proc /proc /dev/pts /dev/pts /dev /dev
++ '[' -x /mnt/debootstrap.29459/bin/umount ']'
++ umount /mnt/debootstrap.29459//dev
++ '[' -n '' ']'
++ '[' -n '' ']'
++ einfo 'Unmounting /mnt/debootstrap.29459'
++ einfon 'Unmounting /mnt/debootstrap.29459\n'
++ '[' '' '!=' yes ']'
++ '[' einfon = ebegin ']'
++ printf ' %s*%s Unmounting /mnt/debootstrap.29459\n' '' ''
* Unmounting /mnt/debootstrap.29459
++ LAST_E_CMD=einfon
++ return 0
++ return 0
++ umount /mnt/debootstrap.29459
++ eend 0
++ local retval=0
++ shift
++ '[' 0 -gt 0 ']'
++ return 0
++ '[' -n /var/cache/grml-debootstrap/stages_Whonix-Gateway-XFCE-15.0.0.0.0.raw ']'
++ echo -n 'Removing stages directory /var/cache/grml-debootstrap/stages_Whonix-Gateway-XFCE-15.0.0.0.0.raw: '
Removing stages directory /var/cache/grml-debootstrap/stages_Whonix-Gateway-XFCE-15.0.0.0.0.raw: ++ rm -rf /var/cache/grml-debootstrap/stages_Whonix-Gateway-XFCE-15.0.0.0.0.raw
++ echo done
done
++ grep -q '/mnt/debootstrap\.'
++ echo /mnt/debootstrap.29459
++ einfo 'Removing directory /mnt/debootstrap.29459'
++ einfon 'Removing directory /mnt/debootstrap.29459\n'
++ '[' '' '!=' yes ']'
++ '[' einfon = ebegin ']'
++ printf ' %s*%s Removing directory /mnt/debootstrap.29459\n' '' ''
* Removing directory /mnt/debootstrap.29459
++ LAST_E_CMD=einfon
++ return 0
++ return 0
++ rmdir /mnt/debootstrap.29459
++ eend 0
++ local retval=0
++ shift
++ '[' 0 -gt 0 ']'
++ return 0
++ '[' -n /home/user/whonix_binary/Whonix-Gateway-XFCE-15.0.0.0.0.raw ']'
++ einfo 'Removing loopback mount of file /home/user/whonix_binary/Whonix-Gateway-XFCE-15.0.0.0.0.raw.'
++ einfon 'Removing loopback mount of file /home/user/whonix_binary/Whonix-Gateway-XFCE-15.0.0.0.0.raw.\n'
++ '[' '' '!=' yes ']'
++ '[' einfon = ebegin ']'
++ printf ' %s*%s Removing loopback mount of file /home/user/whonix_binary/Whonix-Gateway-XFCE-15.0.0.0.0.raw.\n' '' ''
* Removing loopback mount of file /home/user/whonix_binary/Whonix-Gateway-XFCE-15.0.0.0.0.raw.
++ LAST_E_CMD=einfon
++ return 0
++ return 0
++ kpartx -d /home/user/whonix_binary/Whonix-Gateway-XFCE-15.0.0.0.0.raw
loop deleted : /dev/loop0
++ grep -q '^loop0p1 '
++ dmsetup ls
++ eend 0
++ local retval=0
++ shift
++ '[' 0 -gt 0 ']'
++ return 0
++ '[' -n 1 ']'
++ EXIT=1
++ '[' -n '' ']'
++ exit 1
What do you think about adding --ignore-fail-on-non-empty to all invocations of rmdir?
Usually one is running rmdir
by assuming that the directory is empty. I'm not sure if adding --ignore-fail-on-non-empty
to all the rmdir
calls within grml-debootstrap might not hide any underlying issues.
Is there any concrete example / steps to reproduce where a rmdir --ignore-fail-on-non-empty ...
usage would actually solve anything that's worth changing our current code?
This happens if $DEBOOTSTRAP
failed (which failed due to my configuration mistake). That erorr gets noticed by grml-debootstrap and it errors out. The failing rmdir happens as another follow up issue during bailout
which I found unnecessary.
For example if check4progs "${DEBOOTSTRAP}" || bailout 1
fails, bailout
would call cleanup
and error out and also wonder why rmdir failed on top of that.
I see, thanks for clarifying, I'll try to look into that.