Metric tensor formulation of strain in density-functional perturbation theory