Fermi-surface pockets in magnetic underdoped cuprates from first principles