How do I repair this kind of drywall damage?
Looks like plaster on wood or plywood.

From what I can see:


Make sure the water leak is fixed (second photo).
Remove any loose plaster.
Not sure what the surface is.  Scuff it up so new material will stick. 
May want to apply some sort of bonding primer, or possibly staple some thin mesh up to give the new plaster or spackling good support.
Apply plaster or spackling, working it in well to get good adhesion.  Make sure you get something that mentions adhesion on the label.
Your choice of learning to create a matching texture, or (around here) there is spray texture available (though you would have to mask or taper the old plaster).  Looks like "knockdown" texture.  Probably need to practice on a piece of scrap wood or cardboard.
Use a stain-blocking primer.