Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 49561ad

Browse files
committed
Replace cabarc with FCICreate.
1 parent 9f59fa5 commit 49561ad

1 file changed

Lines changed: 4 additions & 36 deletions

File tree

Tools/msi/msilib.py

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import win32com.client
66
import pythoncom, pywintypes
77
from win32com.client import constants
8-
import re, string, os, sets, glob, subprocess, sys, _winreg, struct
8+
import re, string, os, sets, glob, subprocess, sys, _winreg, struct, _msi
99

1010
try:
1111
basestring
@@ -350,7 +350,7 @@ def gen_uuid():
350350
class CAB:
351351
def __init__(self, name):
352352
self.name = name
353-
self.file = open(name+".txt", "wt")
353+
self.files = []
354354
self.filenames = sets.Set()
355355
self.index = 0
356356

@@ -369,47 +369,15 @@ def append(self, full, file, logical = None):
369369
if not logical:
370370
logical = self.gen_id(dir, file)
371371
self.index += 1
372-
if full.find(" ")!=-1:
373-
print >>self.file, '"%s" %s' % (full, logical)
374-
else:
375-
print >>self.file, '%s %s' % (full, logical)
372+
self.files.append((full, logical))
376373
return self.index, logical
377374

378375
def commit(self, db):
379-
self.file.close()
380376
try:
381377
os.unlink(self.name+".cab")
382378
except OSError:
383379
pass
384-
for k, v in [(r"Software\Microsoft\VisualStudio\7.1\Setup\VS", "VS7CommonBinDir"),
385-
(r"Software\Microsoft\VisualStudio\8.0\Setup\VS", "VS7CommonBinDir"),
386-
(r"Software\Microsoft\VisualStudio\9.0\Setup\VS", "VS7CommonBinDir"),
387-
(r"Software\Microsoft\Win32SDK\Directories", "Install Dir"),
388-
]:
389-
try:
390-
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, k)
391-
dir = _winreg.QueryValueEx(key, v)[0]
392-
_winreg.CloseKey(key)
393-
except (WindowsError, IndexError):
394-
continue
395-
cabarc = os.path.join(dir, r"Bin", "cabarc.exe")
396-
if not os.path.exists(cabarc):
397-
continue
398-
break
399-
else:
400-
print "WARNING: cabarc.exe not found in registry"
401-
cabarc = "cabarc.exe"
402-
cmd = r'"%s" -m lzx:21 n %s.cab @%s.txt' % (cabarc, self.name, self.name)
403-
p = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE,
404-
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
405-
for line in p.stdout:
406-
if line.startswith(" -- adding "):
407-
sys.stdout.write(".")
408-
else:
409-
sys.stdout.write(line)
410-
sys.stdout.flush()
411-
if not os.path.exists(self.name+".cab"):
412-
raise IOError, "cabarc failed"
380+
_msi.FCICreate(self.name+".cab", self.files)
413381
add_data(db, "Media",
414382
[(1, self.index, None, "#"+self.name, None, None)])
415383
add_stream(db, self.name, self.name+".cab")

0 commit comments

Comments
 (0)