I wrote some cool stuff in the last two days.
1) I reverse engineered the partition.xml file or Xiaomi MI2 that's used by ptool.py to generate files that can can be flash by fastboot or MiFlash.
2) I used 1) to generate singleboot partition layouts that can be easily flashed
3) I wrote a flashtool that can be used in Linux
4) I wrote a script that generates MiFlash packages, that flash core partitions like bootloaders only, without touch ROM or storage, so we have a small recovery package that's fast to download and install.
5) Additionally I replaced the bootloader binary in these packages with the opensource bootloader from GRUB4Android, to add some features. Also I'll replace stock recovery with TWRP.
I'll publish a build later.