merge_factory_usbimg.sh: improvement for low disk space under /tmp

Previously, make_image_resource.sh will generate a file under /tmp and
use it to format the output image. In merge_factory_usbimg.sh, it also
invokes make_image_resource.sh 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.

BUG=chrome-os-partner:36725
TEST=./merge_factory_usbimg.sh -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
        method.

Change-Id: Ie55ed3325205d80fa3356e6fb2dd8aa5518a379e
Reviewed-on: https://chromium-review.googlesource.com/282975
Tested-by: Bowgo Tsai <bowgotsai@chromium.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Commit-Queue: Bowgo Tsai <bowgotsai@chromium.org>
2 files changed