improvement for low disk space under /tmp

Previously, will generate a file under /tmp and
use it to format the output image. In, it also
invokes to generate a resource imgae under /tmp.
This will have error when there is not enough space left under /tmp.
This CL mitigates this by mounting the output image under a loop device,
then format the loop device, which consumes less space under /tmp.

When merging usb images, some intermediary files will be put under
/tmp. It now shows error message for users to specify $TMPDIR to another
path when the merged usb image cannot be generated, which is likely not
enough space left under /tmp.

It also removes --tmpdir option when using command 'mktemp' because it
will try $TMPDIR and then /tmp by default.

TEST=./ -f output.bin usbimg1.bin usbimg2.bin
     a. Check it will throw error message when there is not enough
        space under /tmp to generate the merged usb image.
     b. Check it consumes less space under /tmp compared to original

Change-Id: Ie55ed3325205d80fa3356e6fb2dd8aa5518a379e
Tested-by: Bowgo Tsai <>
Reviewed-by: Hung-Te Lin <>
Commit-Queue: Bowgo Tsai <>
2 files changed