mod_image_for_recovery: change return trap to EXIT

copy_stateful() sets a RETURN trap that deletes a folder. Then there
are 2 calls of safe_umount function on two different mountpoints.

In bash 4.3 the RETURN trap doesn’t get executed, when those
functions return, so the trap executes after copy_stateful exits.
In bash 4.4 the trap does get executed when each of them gets
executed. As a result, the second attempt to remove said folder
fails, and the script stops execution.

This CL changes trap type to EXIT and directly deletes the folder at
the end of the function to ensure that we still does clean up on
error and on successful execution, and do not delete the folder

TEST=ran script manually, `cros tryjob -g '2713386 2713867 2713564 2717166'  arkham-release-tryjob`

Change-Id: I0860122bb81bd128bc63ae89f330b3044d06175a
Tested-by: Sergey Frolov <>
Reviewed-by: Mike Frysinger <>
Reviewed-by: Nicholas Verne <>
Commit-Queue: Mike Frysinger <>
2 files changed