Density-functional perturbation theory for quasi-harmonic calculations