Flash stock recovery OTA and back root again

I’m and happy Galaxy Nexus owner, I use the stock ROM but I like to use some of the root superpowers.

Problem, a system update is pending but I have a custom recovery (TeamWin) image for maguro that stops me from getting it installed.

Solution (lenghty but easy steps if you have a recent Andoid SDK installed on GNU/Linux):

  1. get the stock image
  2. unpack the tgz and unzip the recovery.img contained in the zip file.
  3. connect your phone and run: adb reboot bootloader
  4. when the fastboot is ready, run: sudo fastboot devices to check if everything is ok and then run: sudo fastboot flash recovery ~/Downloads/yakju-jwr66y/recovery.img
  5. power off (not sure, but sometime the just flashed partition is not bootable)
  6. boot normally and, when asked, complete the OTA
  7. download the SuperSU binary on the phone (to root it again later)
  8. reboot again in the bootloader with: adb reboot bootloader
  9. flash your custom recovery image again with: sudo fastboot flash recovery ~/Downloads/yakju-jwr66y/openrecovery-twrp-2.6.3.0-maguro.img
  10. power off
  11. while pressing both UP and DOWN volume buttons, press the POWER button to start the device in bootloader mode
  12. start the recovery and install the SuperSU zip

Well done! You have updated you stock image and you have recovered the superpowers!