Fix .exe installer signing.

This commit is contained in:
Bastian Kleineidam 2012-12-20 14:14:33 +01:00
parent b45d3453ba
commit ceb2eb4e32

View file

@ -256,6 +256,7 @@ class InnoScript:
def create(self, pathname=r"dist\omt.iss"): def create(self, pathname=r"dist\omt.iss"):
"""Create Inno script.""" """Create Inno script."""
print("*** creating the inno setup script ***")
self.pathname = pathname self.pathname = pathname
self.distfilebase = "%s-%s" % (self.name, self.version) self.distfilebase = "%s-%s" % (self.name, self.version)
self.distfile = self.distfilebase + ".exe" self.distfile = self.distfilebase + ".exe"
@ -298,19 +299,37 @@ class InnoScript:
def compile (self): def compile (self):
"""Compile Inno script with iscc.exe.""" """Compile Inno script with iscc.exe."""
print("*** compiling the inno setup script ***")
progpath = get_nt_platform_vars()[0] progpath = get_nt_platform_vars()[0]
cmd = r'%s\Inno Setup 5\iscc.exe' % progpath cmd = r'%s\Inno Setup 5\iscc.exe' % progpath
subprocess.check_call([cmd, self.pathname]) subprocess.check_call([cmd, self.pathname])
def sign (self): def sign (self):
"""Sign InnoSetup installer with local self-signed certificate.""" """Sign InnoSetup installer with local self-signed certificate."""
print("*** signing the inno setup installer ***")
pfxfile = r'C:\dosage.pfx' pfxfile = r'C:\dosage.pfx'
if os.path.isfile(pfxfile): if os.path.isfile(pfxfile):
cmd = ['signtool.exe', 'sign', '/f', pfxfile, self.distfile] path = get_windows_sdk_path()
signtool = os.path.join(path, "bin", "signtool.exe")
if os.path.isfile(signtool):
cmd = [signtool, 'sign', '/f', pfxfile, self.distfile]
subprocess.check_call(cmd) subprocess.check_call(cmd)
else:
print("No signed installer: signtool.exe not found.")
else: else:
print("No signed installer: certificate %s not found." % pfxfile) print("No signed installer: certificate %s not found." % pfxfile)
def get_windows_sdk_path():
try:
import _winreg as winreg
except ImportError:
import winreg
sub_key = r"Software\Microsoft\Microsoft SDKs\Windows"
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, sub_key) as key:
name = "CurrentInstallFolder"
return winreg.QueryValueEx(key, name)[0]
return None
try: try:
from py2exe.build_exe import py2exe as py2exe_build from py2exe.build_exe import py2exe as py2exe_build
@ -329,9 +348,7 @@ try:
script = InnoScript(lib_dir, dist_dir, self.windows_exe_files, script = InnoScript(lib_dir, dist_dir, self.windows_exe_files,
self.console_exe_files, self.service_exe_files, self.console_exe_files, self.service_exe_files,
self.comserver_files, self.lib_files) self.comserver_files, self.lib_files)
print("*** creating the inno setup script ***")
script.create() script.create()
print("*** compiling the inno setup script ***")
script.compile() script.compile()
script.sign() script.sign()
except ImportError: except ImportError: