patches: automatically apply patches before building

Change-Id: I52360ef9741d81d21a87bec639cb31305f006969