Linear theory of a gyrotron with weakly tapered external magnetic field