Depending on how long it's been leaking, you need to worry about mold and wood rot.
We just had our roof replaced, because our last roof was replaced in 1977. In the San Jose area, we paid over $13,000 for the new roof which included replacing all the pipes and cover for the chimney, and wood rot repair.
They had to remove two layers of old roof.
They placed a plywood foundation before adding the new roof.
The contractor did an excellent job, and I have recommended them on Angie's List.