summaryrefslogtreecommitdiff
path: root/Tools/msi/msilib.py
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/msi/msilib.py')
-rw-r--r--Tools/msi/msilib.py65
1 files changed, 25 insertions, 40 deletions
diff --git a/Tools/msi/msilib.py b/Tools/msi/msilib.py
index 6f49b4cf8c..5795d0ec6b 100644
--- a/Tools/msi/msilib.py
+++ b/Tools/msi/msilib.py
@@ -5,7 +5,7 @@ import win32com.client.gencache
import win32com.client
import pythoncom, pywintypes
from win32com.client import constants
-import re, string, os, sets, glob, subprocess, sys, _winreg, struct
+import re, string, os, sets, glob, subprocess, sys, _winreg, struct, _msi
try:
basestring
@@ -350,7 +350,7 @@ def gen_uuid():
class CAB:
def __init__(self, name):
self.name = name
- self.file = open(name+".txt", "wt")
+ self.files = []
self.filenames = sets.Set()
self.index = 0
@@ -369,51 +369,18 @@ class CAB:
if not logical:
logical = self.gen_id(dir, file)
self.index += 1
- if full.find(" ")!=-1:
- print >>self.file, '"%s" %s' % (full, logical)
- else:
- print >>self.file, '%s %s' % (full, logical)
+ self.files.append((full, logical))
return self.index, logical
def commit(self, db):
- self.file.close()
try:
os.unlink(self.name+".cab")
except OSError:
pass
- for k, v in [(r"Software\Microsoft\VisualStudio\7.1\Setup\VS", "VS7CommonBinDir"),
- (r"Software\Microsoft\VisualStudio\8.0\Setup\VS", "VS7CommonBinDir"),
- (r"Software\Microsoft\VisualStudio\9.0\Setup\VS", "VS7CommonBinDir"),
- (r"Software\Microsoft\Win32SDK\Directories", "Install Dir"),
- ]:
- try:
- key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, k)
- dir = _winreg.QueryValueEx(key, v)[0]
- _winreg.CloseKey(key)
- except (WindowsError, IndexError):
- continue
- cabarc = os.path.join(dir, r"Bin", "cabarc.exe")
- if not os.path.exists(cabarc):
- continue
- break
- else:
- print "WARNING: cabarc.exe not found in registry"
- cabarc = "cabarc.exe"
- cmd = r'"%s" -m lzx:21 n %s.cab @%s.txt' % (cabarc, self.name, self.name)
- p = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE,
- stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
- for line in p.stdout:
- if line.startswith(" -- adding "):
- sys.stdout.write(".")
- else:
- sys.stdout.write(line)
- sys.stdout.flush()
- if not os.path.exists(self.name+".cab"):
- raise IOError, "cabarc failed"
+ _msi.FCICreate(self.name+".cab", self.files)
add_data(db, "Media",
[(1, self.index, None, "#"+self.name, None, None)])
add_stream(db, self.name, self.name+".cab")
- os.unlink(self.name+".txt")
os.unlink(self.name+".cab")
db.Commit()
@@ -451,6 +418,12 @@ class Directory:
else:
self.absolute = physical
blogical = None
+ # initially assume that all files in this directory are unpackaged
+ # as files from self.absolute get added, this set is reduced
+ self.unpackaged_files = set()
+ for f in os.listdir(self.absolute):
+ if os.path.isfile(os.path.join(self.absolute, f)):
+ self.unpackaged_files.add(f)
add_data(db, "Directory", [(logical, blogical, default)])
def start_component(self, component = None, feature = None, flags = None, keyfile = None, uuid=None):
@@ -527,6 +500,11 @@ class Directory:
src = file
file = os.path.basename(file)
absolute = os.path.join(self.absolute, src)
+ if absolute.startswith(self.absolute):
+ # mark file as packaged
+ relative = absolute[len(self.absolute)+1:]
+ if relative in self.unpackaged_files:
+ self.unpackaged_files.remove(relative)
assert not re.search(r'[\?|><:/*]"', file) # restrictions on long names
if self.keyfiles.has_key(file):
logical = self.keyfiles[file]
@@ -572,10 +550,17 @@ class Directory:
return files
def remove_pyc(self):
- "Remove .pyc/.pyo files on uninstall"
+ "Remove .pyc/.pyo files from __pycache__ on uninstall"
+ directory = self.logical + "_pycache"
+ add_data(self.db, "Directory", [(directory, self.logical, "__PYCA~1|__pycache__")])
+ flags = 256 if Win64 else 0
+ add_data(self.db, "Component",
+ [(directory, gen_uuid(), directory, flags, None, None)])
+ add_data(self.db, "FeatureComponents", [(current_feature.id, directory)])
+ add_data(self.db, "CreateFolder", [(directory, directory)])
add_data(self.db, "RemoveFile",
- [(self.component+"c", self.component, "*.pyc", self.logical, 2),
- (self.component+"o", self.component, "*.pyo", self.logical, 2)])
+ [(self.component, self.component, "*.*", directory, 2),
+ ])
def removefile(self, key, pattern):
"Add a RemoveFile entry"