sample_images: Support sparse files.

The sample images are mostly sparse space. This patch stores those
files as sparse files in the .tar.bz2 files and simplifies the rules
to extract them directly onto the destination directory.

acp still doesn't support sparse files, so when these files get copied
to the /data partition, they won't be sparse files. Nevertheless, this
patch is still required.

Bug: 26955860
TEST=mmma showcommands system/update_engine; `du -hs` the intermediate files.

Change-Id: I24a2c1f7a28ee79cc545650e04705a22d7fc7cdb
diff --git a/Android.mk b/Android.mk
index 34fe4dd..20b9b5e 100644
--- a/Android.mk
+++ b/Android.mk
@@ -702,13 +702,10 @@
     $(eval LOCAL_MODULE_PATH := \
         $(TARGET_OUT_DATA_NATIVE_TESTS)/update_engine_unittests/gen) \
     $(eval LOCAL_MODULE_STEM := $(1)) \
-    $(eval my_gen := $(call local-intermediates-dir)/gen/$(1)) \
-    $(eval $(my_gen) : PRIVATE_CUSTOM_TOOL = \
-        tar -jxf $$< -C $$(dir $$@) $$(notdir $$@) && touch $$@) \
-    $(eval $(my_gen) : $(LOCAL_PATH)/sample_images/sample_images.tar.bz2 ; \
-        $$(transform-generated-source)) \
-    $(eval LOCAL_PREBUILT_MODULE_FILE := $(my_gen)) \
-    $(eval include $(BUILD_PREBUILT))
+    $(eval include $(BUILD_SYSTEM)/base_rules.mk) \
+    $(eval $(LOCAL_BUILT_MODULE) : \
+        $(LOCAL_PATH)/sample_images/sample_images.tar.bz2 ; \
+        tar -jxf $$< -C $$(dir $$@) $$(notdir $$@) && touch $$@)
 endef
 
 $(call ue-unittest-sample-image,disk_ext2_1k.img)
diff --git a/sample_images/generate_images.sh b/sample_images/generate_images.sh
index 1c2a83c..17bb11c 100755
--- a/sample_images/generate_images.sh
+++ b/sample_images/generate_images.sh
@@ -184,7 +184,7 @@
   # Generate the tarball and delete temporary images.
   echo "Packing tar file sample_images.tar.bz2"
   tar -jcf "${OUTPUT_DIR}/sample_images.tar.bz2" -C "${OUTPUT_DIR}" \
-    "${IMAGES[@]}"
+    --sparse "${IMAGES[@]}"
   cd "${OUTPUT_DIR}"
   rm "${IMAGES[@]}"
 }
diff --git a/sample_images/sample_images.tar.bz2 b/sample_images/sample_images.tar.bz2
index 83141ab..fe1a80a 100644
--- a/sample_images/sample_images.tar.bz2
+++ b/sample_images/sample_images.tar.bz2
Binary files differ