#!/bin/bash

PATCH=puya.patch

for DIR in ~/.platformio/packages/framework-arduinoespressif8266*/; do

  #not applied yet? (in upstream or otherwise)
  if ! grep FLASH_QUIRK_WRITE_0_TO_1 $DIR/cores/esp8266/Esp.cpp >/dev/null; then
    echo "Patching $DIR"
    patch -p1 -d $DIR < $PATCH
  fi
done
