Add debug mode to apply script

Change-Id: I5499b574c10c7a2753c79cfae420df262b1494fa