ammended with ideas from ppcoind pkgbuild