RPi-Distro / pi-gen

Tool used to create the official Raspberry Pi OS images
BSD 3-Clause "New" or "Revised" License
2.65k stars 1.65k forks source link

Expand trap cleanup function #773

Closed tdewey-rpi closed 6 months ago

tdewey-rpi commented 7 months ago

Add a function to unmount the bindmounts in the chroot, and unmount the image and stage in progress, in the event of a trap.

tdewey-rpi commented 7 months ago

Wait, what? I can't see why this has brought in those other two commits....

tdewey-rpi commented 7 months ago

Paging @XECDesign for a view.

tdewey-rpi commented 6 months ago

Confirmed I see this more gracefully handling fatal errors

XECDesign commented 6 months ago

Is off_chroot needed?

I believe the unmount "${WORK_DIR}/${STAGE}" line should already do everything the off_chroot function would've done.

The on in on_chroot maybe should've been in. The idea is that you pipe commands into it and it runs in the chroot environment.

Or have I missed something?

tdewey-rpi commented 6 months ago

Is off_chroot needed?

I believe the unmount "${WORK_DIR}/${STAGE}" line should already do everything the off_chroot function would've done.

The on in on_chroot maybe should've been in. The idea is that you pipe commands into it and it runs in the chroot environment.

Or have I missed something?

I found without this, I was still getting sub-mounts mounted on abort - which then caused trouble when I tried delete the workdir and re-try my build.

RE: naming:

Completely my fault for misreading. Happy to rename.

XECDesign commented 6 months ago

This version, which also includes #771, works for me without off_chroot with failures introduced in various sub-stages and also in export-image while the img file is attached.

Rebased off the master branch, since that's what gets merge into arm64

The current git history is just for testing and clarity, so I've converted it to a draft for now

XECDesign commented 6 months ago

Also, thanks! This has been a long overdue addition.

tdewey-rpi commented 6 months ago

@XECDesign Yours to merge, I lack the powers for now.

XECDesign commented 6 months ago

I was waiting to hear back from #771. To keep a sensible git history, I want to squash those commits first, then rebase and squash this.

Will be sorted a bit later today.