Kaydet (Commit) f4803aa6 authored tarafından Benjamin Peterson's avatar Benjamin Peterson

set svn:eol-style on various files

üst d22557cf
This diff is collapsed.
import msilib,os,win32com,tempfile,sys import msilib,os,win32com,tempfile,sys
PCBUILD="PCBuild" PCBUILD="PCBuild"
certname = None certname = None
from config import * from config import *
Win64 = "amd64" in PCBUILD Win64 = "amd64" in PCBUILD
mod_dir = os.path.join(os.environ["ProgramFiles"], "Common Files", "Merge Modules") mod_dir = os.path.join(os.environ["ProgramFiles"], "Common Files", "Merge Modules")
msi = None msi = None
if len(sys.argv)==2: if len(sys.argv)==2:
msi = sys.argv[1] msi = sys.argv[1]
if Win64: if Win64:
modules = ["Microsoft_VC90_CRT_x86_x64.msm", "policy_9_0_Microsoft_VC90_CRT_x86_x64.msm"] modules = ["Microsoft_VC90_CRT_x86_x64.msm", "policy_9_0_Microsoft_VC90_CRT_x86_x64.msm"]
if not msi: msi = "python-%s.amd64.msi" % full_current_version if not msi: msi = "python-%s.amd64.msi" % full_current_version
else: else:
modules = ["Microsoft_VC90_CRT_x86.msm","policy_9_0_Microsoft_VC90_CRT_x86.msm"] modules = ["Microsoft_VC90_CRT_x86.msm","policy_9_0_Microsoft_VC90_CRT_x86.msm"]
if not msi: msi = "python-%s.msi" % full_current_version if not msi: msi = "python-%s.msi" % full_current_version
for i, n in enumerate(modules): for i, n in enumerate(modules):
modules[i] = os.path.join(mod_dir, n) modules[i] = os.path.join(mod_dir, n)
def merge(msi, feature, rootdir, modules): def merge(msi, feature, rootdir, modules):
cab_and_filecount = [] cab_and_filecount = []
# Step 1: Merge databases, extract cabfiles # Step 1: Merge databases, extract cabfiles
m = msilib.MakeMerge2() m = msilib.MakeMerge2()
m.OpenLog("merge.log") m.OpenLog("merge.log")
print "Opened Log" print "Opened Log"
m.OpenDatabase(msi) m.OpenDatabase(msi)
print "Opened DB" print "Opened DB"
for module in modules: for module in modules:
print module print module
m.OpenModule(module,0) m.OpenModule(module,0)
print "Opened Module",module print "Opened Module",module
m.Merge(feature, rootdir) m.Merge(feature, rootdir)
print "Errors:" print "Errors:"
for e in m.Errors: for e in m.Errors:
print e.Type, e.ModuleTable, e.DatabaseTable print e.Type, e.ModuleTable, e.DatabaseTable
print " Modkeys:", print " Modkeys:",
for s in e.ModuleKeys: print s, for s in e.ModuleKeys: print s,
print print
print " DBKeys:", print " DBKeys:",
for s in e.DatabaseKeys: print s, for s in e.DatabaseKeys: print s,
print print
cabname = tempfile.mktemp(suffix=".cab") cabname = tempfile.mktemp(suffix=".cab")
m.ExtractCAB(cabname) m.ExtractCAB(cabname)
cab_and_filecount.append((cabname, len(m.ModuleFiles))) cab_and_filecount.append((cabname, len(m.ModuleFiles)))
m.CloseModule() m.CloseModule()
m.CloseDatabase(True) m.CloseDatabase(True)
m.CloseLog() m.CloseLog()
# Step 2: Add CAB files # Step 2: Add CAB files
i = msilib.MakeInstaller() i = msilib.MakeInstaller()
db = i.OpenDatabase(msi, win32com.client.constants.msiOpenDatabaseModeTransact) db = i.OpenDatabase(msi, win32com.client.constants.msiOpenDatabaseModeTransact)
v = db.OpenView("SELECT LastSequence FROM Media") v = db.OpenView("SELECT LastSequence FROM Media")
v.Execute(None) v.Execute(None)
maxmedia = -1 maxmedia = -1
while 1: while 1:
r = v.Fetch() r = v.Fetch()
if not r: break if not r: break
seq = r.IntegerData(1) seq = r.IntegerData(1)
if seq > maxmedia: if seq > maxmedia:
maxmedia = seq maxmedia = seq
print "Start of Media", maxmedia print "Start of Media", maxmedia
for cabname, count in cab_and_filecount: for cabname, count in cab_and_filecount:
stream = "merged%d" % maxmedia stream = "merged%d" % maxmedia
msilib.add_data(db, "Media", msilib.add_data(db, "Media",
[(maxmedia+1, maxmedia+count, None, "#"+stream, None, None)]) [(maxmedia+1, maxmedia+count, None, "#"+stream, None, None)])
msilib.add_stream(db, stream, cabname) msilib.add_stream(db, stream, cabname)
os.unlink(cabname) os.unlink(cabname)
maxmedia += count maxmedia += count
# The merge module sets ALLUSERS to 1 in the property table. # The merge module sets ALLUSERS to 1 in the property table.
# This is undesired; delete that # This is undesired; delete that
v = db.OpenView("DELETE FROM Property WHERE Property='ALLUSERS'") v = db.OpenView("DELETE FROM Property WHERE Property='ALLUSERS'")
v.Execute(None) v.Execute(None)
v.Close() v.Close()
db.Commit() db.Commit()
merge(msi, "SharedCRT", "TARGETDIR", modules) merge(msi, "SharedCRT", "TARGETDIR", modules)
# certname (from config.py) should be (a substring of) # certname (from config.py) should be (a substring of)
# the certificate subject, e.g. "Python Software Foundation" # the certificate subject, e.g. "Python Software Foundation"
if certname: if certname:
os.system('signtool sign /n "%s" /t http://timestamp.verisign.com/scripts/timestamp.dll %s' % (certname, msi)) os.system('signtool sign /n "%s" /t http://timestamp.verisign.com/scripts/timestamp.dll %s' % (certname, msi))
"""This script generates a Python codec module from a Windows Code Page. """This script generates a Python codec module from a Windows Code Page.
It uses the function MultiByteToWideChar to generate a decoding table. It uses the function MultiByteToWideChar to generate a decoding table.
""" """
import ctypes import ctypes
from ctypes import wintypes from ctypes import wintypes
from gencodec import codegen from gencodec import codegen
import unicodedata import unicodedata
def genwinmap(codepage): def genwinmap(codepage):
MultiByteToWideChar = ctypes.windll.kernel32.MultiByteToWideChar MultiByteToWideChar = ctypes.windll.kernel32.MultiByteToWideChar
MultiByteToWideChar.argtypes = [wintypes.UINT, wintypes.DWORD, MultiByteToWideChar.argtypes = [wintypes.UINT, wintypes.DWORD,
wintypes.LPCSTR, ctypes.c_int, wintypes.LPCSTR, ctypes.c_int,
wintypes.LPWSTR, ctypes.c_int] wintypes.LPWSTR, ctypes.c_int]
MultiByteToWideChar.restype = ctypes.c_int MultiByteToWideChar.restype = ctypes.c_int
enc2uni = {} enc2uni = {}
for i in range(32) + [127]: for i in range(32) + [127]:
enc2uni[i] = (i, 'CONTROL CHARACTER') enc2uni[i] = (i, 'CONTROL CHARACTER')
for i in range(256): for i in range(256):
buf = ctypes.create_unicode_buffer(2) buf = ctypes.create_unicode_buffer(2)
ret = MultiByteToWideChar( ret = MultiByteToWideChar(
codepage, 0, codepage, 0,
chr(i), 1, chr(i), 1,
buf, 2) buf, 2)
assert ret == 1, "invalid code page" assert ret == 1, "invalid code page"
assert buf[1] == '\x00' assert buf[1] == '\x00'
try: try:
name = unicodedata.name(buf[0]) name = unicodedata.name(buf[0])
except ValueError: except ValueError:
try: try:
name = enc2uni[i][1] name = enc2uni[i][1]
except KeyError: except KeyError:
name = '' name = ''
enc2uni[i] = (ord(buf[0]), name) enc2uni[i] = (ord(buf[0]), name)
return enc2uni return enc2uni
def genwincodec(codepage): def genwincodec(codepage):
import platform import platform
map = genwinmap(codepage) map = genwinmap(codepage)
encodingname = 'cp%d' % codepage encodingname = 'cp%d' % codepage
code = codegen("", map, encodingname) code = codegen("", map, encodingname)
# Replace first lines with our own docstring # Replace first lines with our own docstring
code = '''\ code = '''\
"""Python Character Mapping Codec %s generated on Windows: """Python Character Mapping Codec %s generated on Windows:
%s with the command: %s with the command:
python Tools/unicode/genwincodec.py %s python Tools/unicode/genwincodec.py %s
"""#" """#"
''' % (encodingname, ' '.join(platform.win32_ver()), codepage ''' % (encodingname, ' '.join(platform.win32_ver()), codepage
) + code.split('"""#"', 1)[1] ) + code.split('"""#"', 1)[1]
print code print code
if __name__ == '__main__': if __name__ == '__main__':
import sys import sys
genwincodec(int(sys.argv[1])) genwincodec(int(sys.argv[1]))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment