Makepkg sources the PKGBUILD twice (once when initially run, and the second time under fakeroot). Any non-standard functions placed in the PKGBUILD will be run twice as well.