A tiny air bubble can be entrapped at the bottom of a solid sphere that impacts onto a liquid pool. The bubble forms due to the deformation of the liquid surface by a local pressure buildup inside the surrounding gas, as also observed during the impact of a liquid drop on a solid wall. Here, we perform a perturbation analysis to quantitatively predict the initial deformations of the free surface of a liquid pool as it is approached by a solid sphere. We study the natural limits where the gas can be treated as a viscous fluid (Stokes flow) or as an inviscid fluid (potential flow). For both cases we derive the spatiotemporal evolution of the pool surface, and recover some of the recently proposed scaling laws for bubble entrapment. On inserting typical experimental values for the impact parameters, we find that the bubble volume is mainly determined by the effect of gas viscosity.