diff --git a/releasetools/flashfiles_from_target_files.sh b/releasetools/flashfiles_from_target_files.sh index 523538b..8e5cad4 100755 --- a/releasetools/flashfiles_from_target_files.sh +++ b/releasetools/flashfiles_from_target_files.sh @@ -1,37 +1,74 @@ #!/bin/bash +echo "========================" echo "Preparing flashfiles - New Method" echo "No more Zip. We use tar + pigz" - -echo "========================" -echo "Images / Files to be packed" -echo "========================" -echo "acpio.img" -echo "boot.img" -echo "bootloader.img" -echo "config.img" -echo "flash.json" -echo "gpt.bin" -echo "installer.cmd" -echo "installer.efi " -echo "odm.img " -echo "startup.nsh " -echo "super_empty.img " -echo "super.img " -echo "vbmeta.img " -echo "vendor_boot.img " echo "========================" -#tar +## PRE-REQUISITE flashfile=`basename $1` flashfile_dir=`echo $flashfile | sed 's/\.tar\.gz//g'` PRODUCT_OUT=`dirname $1` +VARIANT=`grep -i "ro.system.build.type=" $PRODUCT_OUT/system/build.prop | cut -d '=' -f2` +TARGET=`grep -i "ro.build.product=" $PRODUCT_OUT/system/build.prop | cut -d '=' -f2` +echo "========================" +echo "Images / Files to be packed" +echo "========================" +IMAGES_TUPLE=`./device/intel/build/releasetools/flash_cmd_generator.py device/intel/project-celadon/$TARGET/flashfiles.ini $TARGET $VARIANT | tail -1` +c=-2 +for i in $IMAGES_TUPLE +do + if [[ $c -gt 0 && `expr $c % 2` == 1 ]]; then + i=`echo ${i::-3} | sed "s/'//g"` + echo $i + j="$j $i" + fi + c=$((c+1)) +done + +IMAGES=`echo $j | xargs -n1 | sort -u` +echo "========================" +echo "Generating Tar ..." +echo "========================" cd $PRODUCT_OUT rm -rf $flashfile_dir mkdir $flashfile_dir -cp acpio.img boot.img bootloader.img config.img gpt.bin installer.cmd efi/installer.efi odm.img efi/startup.nsh super_empty.img ./obj/PACKAGING/super.img_intermediates/super.img vbmeta.img vendor_boot.img $flashfile_dir/. + +for i in $IMAGES +do + echo "Adding $i" + if [[ $i == "super.img" ]]; then + SUPER_IMG=true + cp ./obj/PACKAGING/super.img_intermediates/super.img $flashfile_dir/. + else + if [[ $i == "installer.efi" ]]; then + cp efi/installer.efi $flashfile_dir/. + else + if [[ $i == "startup.nsh" ]]; then + cp efi/startup.nsh $flashfile_dir/. + else + cp $i $flashfile_dir/. + fi + fi + fi +done + +echo "========================" +echo "Generate installer.cmd" +echo "========================" +./device/intel/build/releasetools/flash_cmd_generator.py device/intel/project-celadon/$TARGET/flashfiles.ini $TARGET $VARIANT | sed '$d' | sed '$d' | sed -n '/installer.cmd/,$p' | sed '1d' > $flashfile_dir/installer.cmd + +echo "========================" +echo "Generate flash.json" +echo "========================" +./device/intel/build/releasetools/flash_cmd_generator.py device/intel/project-celadon/$TARGET/flashfiles.ini $TARGET $VARIANT | sed -n '/installer.cmd/q;p' | sed '1d' > $flashfile_dir/flash.json + +if [[ $SUPER_IMG == "true" ]]; then + rm -f $flashfile_dir/system.img $flashfile_dir/vendor.img $flashfile_dir/product.img +fi + tar -cvf - $flashfile_dir/ | /usr/bin/pigz > $flashfile echo "========================"