'This writes the PkgInfo file from the data stored in Info.plist.'

def _WritePkgInfo(self, info_plist):

    plist = plistlib.readPlist(info_plist)
    if (not plist):
        return
    package_type = plist['CFBundlePackageType']
    if (package_type != 'APPL'):
        return
    signature_code = plist.get('CFBundleSignature', '????')
    if (len(signature_code) != 4):
        signature_code = ('?' * 4)
    dest = os.path.join(os.path.dirname(info_plist), 'PkgInfo')
    fp = open(dest, 'w')
    fp.write(('%s%s' % (package_type, signature_code)))
    fp.close()
