mirror of
https://github.com/python/cpython.git
synced 2025-11-02 19:12:55 +00:00
Merged revisions 78996 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r78996 | martin.v.loewis | 2010-03-16 19:49:28 +0100 (Di, 16 Mär 2010) | 1 line Integrate merge.py into msi.py. ........
This commit is contained in:
parent
4ad70df5e7
commit
0077b65a9e
2 changed files with 79 additions and 87 deletions
|
|
@ -1,84 +0,0 @@
|
||||||
import msilib,os,win32com,tempfile,sys
|
|
||||||
PCBUILD="PCBuild"
|
|
||||||
certname = None
|
|
||||||
from config import *
|
|
||||||
|
|
||||||
Win64 = "amd64" in PCBUILD
|
|
||||||
|
|
||||||
mod_dir = os.path.join(os.environ["ProgramFiles"], "Common Files", "Merge Modules")
|
|
||||||
msi = None
|
|
||||||
if len(sys.argv)==2:
|
|
||||||
msi = sys.argv[1]
|
|
||||||
if Win64:
|
|
||||||
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
|
|
||||||
else:
|
|
||||||
modules = ["Microsoft_VC90_CRT_x86.msm","policy_9_0_Microsoft_VC90_CRT_x86.msm"]
|
|
||||||
if not msi: msi = "python-%s.msi" % full_current_version
|
|
||||||
for i, n in enumerate(modules):
|
|
||||||
modules[i] = os.path.join(mod_dir, n)
|
|
||||||
|
|
||||||
def merge(msi, feature, rootdir, modules):
|
|
||||||
cab_and_filecount = []
|
|
||||||
# Step 1: Merge databases, extract cabfiles
|
|
||||||
m = msilib.MakeMerge2()
|
|
||||||
m.OpenLog("merge.log")
|
|
||||||
print "Opened Log"
|
|
||||||
m.OpenDatabase(msi)
|
|
||||||
print "Opened DB"
|
|
||||||
for module in modules:
|
|
||||||
print module
|
|
||||||
m.OpenModule(module,0)
|
|
||||||
print "Opened Module",module
|
|
||||||
m.Merge(feature, rootdir)
|
|
||||||
print "Errors:"
|
|
||||||
for e in m.Errors:
|
|
||||||
print e.Type, e.ModuleTable, e.DatabaseTable
|
|
||||||
print " Modkeys:",
|
|
||||||
for s in e.ModuleKeys: print s,
|
|
||||||
print
|
|
||||||
print " DBKeys:",
|
|
||||||
for s in e.DatabaseKeys: print s,
|
|
||||||
print
|
|
||||||
cabname = tempfile.mktemp(suffix=".cab")
|
|
||||||
m.ExtractCAB(cabname)
|
|
||||||
cab_and_filecount.append((cabname, len(m.ModuleFiles)))
|
|
||||||
m.CloseModule()
|
|
||||||
m.CloseDatabase(True)
|
|
||||||
m.CloseLog()
|
|
||||||
|
|
||||||
# Step 2: Add CAB files
|
|
||||||
i = msilib.MakeInstaller()
|
|
||||||
db = i.OpenDatabase(msi, win32com.client.constants.msiOpenDatabaseModeTransact)
|
|
||||||
|
|
||||||
v = db.OpenView("SELECT LastSequence FROM Media")
|
|
||||||
v.Execute(None)
|
|
||||||
maxmedia = -1
|
|
||||||
while 1:
|
|
||||||
r = v.Fetch()
|
|
||||||
if not r: break
|
|
||||||
seq = r.IntegerData(1)
|
|
||||||
if seq > maxmedia:
|
|
||||||
maxmedia = seq
|
|
||||||
print "Start of Media", maxmedia
|
|
||||||
|
|
||||||
for cabname, count in cab_and_filecount:
|
|
||||||
stream = "merged%d" % maxmedia
|
|
||||||
msilib.add_data(db, "Media",
|
|
||||||
[(maxmedia+1, maxmedia+count, None, "#"+stream, None, None)])
|
|
||||||
msilib.add_stream(db, stream, cabname)
|
|
||||||
os.unlink(cabname)
|
|
||||||
maxmedia += count
|
|
||||||
# The merge module sets ALLUSERS to 1 in the property table.
|
|
||||||
# This is undesired; delete that
|
|
||||||
v = db.OpenView("DELETE FROM Property WHERE Property='ALLUSERS'")
|
|
||||||
v.Execute(None)
|
|
||||||
v.Close()
|
|
||||||
db.Commit()
|
|
||||||
|
|
||||||
merge(msi, "SharedCRT", "TARGETDIR", modules)
|
|
||||||
|
|
||||||
# certname (from config.py) should be (a substring of)
|
|
||||||
# the certificate subject, e.g. "Python Software Foundation"
|
|
||||||
if certname:
|
|
||||||
os.system('signtool sign /n "%s" /t http://timestamp.verisign.com/scripts/timestamp.dll %s' % (certname, msi))
|
|
||||||
|
|
@ -7,6 +7,7 @@ import uisample
|
||||||
from win32com.client import constants
|
from win32com.client import constants
|
||||||
from distutils.spawn import find_executable
|
from distutils.spawn import find_executable
|
||||||
from uuids import product_codes
|
from uuids import product_codes
|
||||||
|
import tempfile
|
||||||
|
|
||||||
# Settings can be overridden in config.py below
|
# Settings can be overridden in config.py below
|
||||||
# 0 for official python.org releases
|
# 0 for official python.org releases
|
||||||
|
|
@ -28,6 +29,8 @@ have_tcl = True
|
||||||
PCBUILD="PCbuild"
|
PCBUILD="PCbuild"
|
||||||
# msvcrt version
|
# msvcrt version
|
||||||
MSVCR = "90"
|
MSVCR = "90"
|
||||||
|
# Name of certificate in default store to sign MSI with
|
||||||
|
certname = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from config import *
|
from config import *
|
||||||
|
|
@ -220,7 +223,8 @@ def build_database():
|
||||||
# schema represents the installer 2.0 database schema.
|
# schema represents the installer 2.0 database schema.
|
||||||
# sequence is the set of standard sequences
|
# sequence is the set of standard sequences
|
||||||
# (ui/execute, admin/advt/install)
|
# (ui/execute, admin/advt/install)
|
||||||
db = msilib.init_database("python-%s%s.msi" % (full_current_version, msilib.arch_ext),
|
msiname = "python-%s%s.msi" % (full_current_version, msilib.arch_ext)
|
||||||
|
db = msilib.init_database(msiname,
|
||||||
schema, ProductName="Python "+full_current_version+productsuffix,
|
schema, ProductName="Python "+full_current_version+productsuffix,
|
||||||
ProductCode=product_code,
|
ProductCode=product_code,
|
||||||
ProductVersion=current_version,
|
ProductVersion=current_version,
|
||||||
|
|
@ -243,7 +247,7 @@ def build_database():
|
||||||
("ProductLine", "Python%s%s" % (major, minor)),
|
("ProductLine", "Python%s%s" % (major, minor)),
|
||||||
])
|
])
|
||||||
db.Commit()
|
db.Commit()
|
||||||
return db
|
return db, msiname
|
||||||
|
|
||||||
def remove_old_versions(db):
|
def remove_old_versions(db):
|
||||||
"Fill the upgrade table."
|
"Fill the upgrade table."
|
||||||
|
|
@ -1295,7 +1299,7 @@ def add_registry(db):
|
||||||
])
|
])
|
||||||
db.Commit()
|
db.Commit()
|
||||||
|
|
||||||
db = build_database()
|
db,msiname = build_database()
|
||||||
try:
|
try:
|
||||||
add_features(db)
|
add_features(db)
|
||||||
add_ui(db)
|
add_ui(db)
|
||||||
|
|
@ -1305,3 +1309,75 @@ try:
|
||||||
db.Commit()
|
db.Commit()
|
||||||
finally:
|
finally:
|
||||||
del db
|
del db
|
||||||
|
|
||||||
|
# Merge CRT into MSI file. This requires the database to be closed.
|
||||||
|
mod_dir = os.path.join(os.environ["ProgramFiles"], "Common Files", "Merge Modules")
|
||||||
|
if msilib.Win64:
|
||||||
|
modules = ["Microsoft_VC90_CRT_x86_x64.msm", "policy_9_0_Microsoft_VC90_CRT_x86_x64.msm"]
|
||||||
|
else:
|
||||||
|
modules = ["Microsoft_VC90_CRT_x86.msm","policy_9_0_Microsoft_VC90_CRT_x86.msm"]
|
||||||
|
|
||||||
|
for i, n in enumerate(modules):
|
||||||
|
modules[i] = os.path.join(mod_dir, n)
|
||||||
|
|
||||||
|
def merge(msi, feature, rootdir, modules):
|
||||||
|
cab_and_filecount = []
|
||||||
|
# Step 1: Merge databases, extract cabfiles
|
||||||
|
m = msilib.MakeMerge2()
|
||||||
|
m.OpenLog("merge.log")
|
||||||
|
m.OpenDatabase(msi)
|
||||||
|
for module in modules:
|
||||||
|
print module
|
||||||
|
m.OpenModule(module,0)
|
||||||
|
m.Merge(feature, rootdir)
|
||||||
|
print "Errors:"
|
||||||
|
for e in m.Errors:
|
||||||
|
print e.Type, e.ModuleTable, e.DatabaseTable
|
||||||
|
print " Modkeys:",
|
||||||
|
for s in e.ModuleKeys: print s,
|
||||||
|
print
|
||||||
|
print " DBKeys:",
|
||||||
|
for s in e.DatabaseKeys: print s,
|
||||||
|
print
|
||||||
|
cabname = tempfile.mktemp(suffix=".cab")
|
||||||
|
m.ExtractCAB(cabname)
|
||||||
|
cab_and_filecount.append((cabname, len(m.ModuleFiles)))
|
||||||
|
m.CloseModule()
|
||||||
|
m.CloseDatabase(True)
|
||||||
|
m.CloseLog()
|
||||||
|
|
||||||
|
# Step 2: Add CAB files
|
||||||
|
i = msilib.MakeInstaller()
|
||||||
|
db = i.OpenDatabase(msi, constants.msiOpenDatabaseModeTransact)
|
||||||
|
|
||||||
|
v = db.OpenView("SELECT LastSequence FROM Media")
|
||||||
|
v.Execute(None)
|
||||||
|
maxmedia = -1
|
||||||
|
while 1:
|
||||||
|
r = v.Fetch()
|
||||||
|
if not r: break
|
||||||
|
seq = r.IntegerData(1)
|
||||||
|
if seq > maxmedia:
|
||||||
|
maxmedia = seq
|
||||||
|
print "Start of Media", maxmedia
|
||||||
|
|
||||||
|
for cabname, count in cab_and_filecount:
|
||||||
|
stream = "merged%d" % maxmedia
|
||||||
|
msilib.add_data(db, "Media",
|
||||||
|
[(maxmedia+1, maxmedia+count, None, "#"+stream, None, None)])
|
||||||
|
msilib.add_stream(db, stream, cabname)
|
||||||
|
os.unlink(cabname)
|
||||||
|
maxmedia += count
|
||||||
|
# The merge module sets ALLUSERS to 1 in the property table.
|
||||||
|
# This is undesired; delete that
|
||||||
|
v = db.OpenView("DELETE FROM Property WHERE Property='ALLUSERS'")
|
||||||
|
v.Execute(None)
|
||||||
|
v.Close()
|
||||||
|
db.Commit()
|
||||||
|
|
||||||
|
merge(msiname, "SharedCRT", "TARGETDIR", modules)
|
||||||
|
|
||||||
|
# certname (from config.py) should be (a substring of)
|
||||||
|
# the certificate subject, e.g. "Python Software Foundation"
|
||||||
|
if certname:
|
||||||
|
os.system('signtool sign /n "%s" /t http://timestamp.verisign.com/scripts/timestamp.dll %s' % (certname, msiname))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue