/usr/share/pyshared/cx_Freeze/windist.py is in cx-freeze 4.3.1-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | import distutils.command.bdist_msi
import distutils.errors
import distutils.util
import msilib
import os
__all__ = [ "bdist_msi" ]
# force the remove existing products action to happen first since Windows
# installer appears to be braindead and doesn't handle files shared between
# different "products" very well
sequence = msilib.sequence.InstallExecuteSequence
for index, info in enumerate(sequence):
if info[0] == 'RemoveExistingProducts':
sequence[index] = (info[0], info[1], 1450)
class bdist_msi(distutils.command.bdist_msi.bdist_msi):
user_options = distutils.command.bdist_msi.bdist_msi.user_options + [
('add-to-path=', None, 'add target dir to PATH environment variable'),
('upgrade-code=', None, 'upgrade code to use'),
('initial-target-dir=', None, 'initial target directory'),
('target-name=', None, 'name of the file to create'),
('directories=', None, 'list of 3-tuples of directories to create'),
('data=', None, 'dictionary of data indexed by table name')
]
x = y = 50
width = 370
height = 300
title = "[ProductName] Setup"
modeless = 1
modal = 3
def add_config(self, fullname):
if self.add_to_path:
msilib.add_data(self.db, 'Environment',
[("E_PATH", "Path", r"[~];[TARGETDIR]", "TARGETDIR")])
if self.directories:
msilib.add_data(self.db, "Directory", self.directories)
msilib.add_data(self.db, 'CustomAction',
[("A_SET_TARGET_DIR", 256 + 51, "TARGETDIR",
self.initial_target_dir)])
msilib.add_data(self.db, 'InstallExecuteSequence',
[("A_SET_TARGET_DIR", 'TARGETDIR=""', 401)])
msilib.add_data(self.db, 'InstallUISequence',
[("PrepareDlg", None, 140),
("A_SET_TARGET_DIR", 'TARGETDIR=""', 401),
("SelectDirectoryDlg", "not Installed", 1230),
("MaintenanceTypeDlg",
"Installed and not Resume and not Preselected", 1250),
("ProgressDlg", None, 1280)
])
for index, executable in enumerate(self.distribution.executables):
if executable.shortcutName is not None \
and executable.shortcutDir is not None:
baseName = os.path.basename(executable.targetName)
msilib.add_data(self.db, "Shortcut",
[("S_APP_%s" % index, executable.shortcutDir,
executable.shortcutName, "TARGETDIR",
"[TARGETDIR]%s" % baseName, None, None, None,
None, None, None, None)])
for tableName, data in self.data.items():
msilib.add_data(self.db, tableName, data)
def add_cancel_dialog(self):
dialog = msilib.Dialog(self.db, "CancelDlg", 50, 10, 260, 85, 3,
self.title, "No", "No", "No")
dialog.text("Text", 48, 15, 194, 30, 3,
"Are you sure you want to cancel [ProductName] installation?")
button = dialog.pushbutton("Yes", 72, 57, 56, 17, 3, "Yes", "No")
button.event("EndDialog", "Exit")
button = dialog.pushbutton("No", 132, 57, 56, 17, 3, "No", "Yes")
button.event("EndDialog", "Return")
def add_error_dialog(self):
dialog = msilib.Dialog(self.db, "ErrorDlg", 50, 10, 330, 101, 65543,
self.title, "ErrorText", None, None)
dialog.text("ErrorText", 50, 9, 280, 48, 3, "")
for text, x in [("No", 120), ("Yes", 240), ("Abort", 0),
("Cancel", 42), ("Ignore", 81), ("Ok", 159), ("Retry", 198)]:
button = dialog.pushbutton(text[0], x, 72, 81, 21, 3, text, None)
button.event("EndDialog", "Error%s" % text)
def add_exit_dialog(self):
dialog = distutils.command.bdist_msi.PyDialog(self.db, "ExitDialog",
self.x, self.y, self.width, self.height, self.modal,
self.title, "Finish", "Finish", "Finish")
dialog.title("Completing the [ProductName] installer")
dialog.back("< Back", "Finish", active = False)
dialog.cancel("Cancel", "Back", active = False)
dialog.text("Description", 15, 235, 320, 20, 0x30003,
"Click the Finish button to exit the installer.")
button = dialog.next("Finish", "Cancel", name = "Finish")
button.event("EndDialog", "Return")
def add_fatal_error_dialog(self):
dialog = distutils.command.bdist_msi.PyDialog(self.db, "FatalError",
self.x, self.y, self.width, self.height, self.modal,
self.title, "Finish", "Finish", "Finish")
dialog.title("[ProductName] installer ended prematurely")
dialog.back("< Back", "Finish", active = False)
dialog.cancel("Cancel", "Back", active = False)
dialog.text("Description1", 15, 70, 320, 80, 0x30003,
"[ProductName] setup ended prematurely because of an error. "
"Your system has not been modified. To install this program "
"at a later time, please run the installation again.")
dialog.text("Description2", 15, 155, 320, 20, 0x30003,
"Click the Finish button to exit the installer.")
button = dialog.next("Finish", "Cancel", name = "Finish")
button.event("EndDialog", "Exit")
def add_files(self):
db = self.db
cab = msilib.CAB("distfiles")
f = msilib.Feature(db, "default", "Default Feature", "Everything", 1,
directory="TARGETDIR")
f.set_current()
rootdir = os.path.abspath(self.bdist_dir)
root = msilib.Directory(db, cab, None, rootdir, "TARGETDIR",
"SourceDir")
db.Commit()
todo = [root]
while todo:
dir = todo.pop()
for file in os.listdir(dir.absolute):
if os.path.isdir(os.path.join(dir.absolute, file)):
newDir = msilib.Directory(db, cab, dir, file, file,
"%s|%s" % (dir.make_short(file), file))
todo.append(newDir)
else:
dir.add_file(file)
cab.commit(db)
def add_files_in_use_dialog(self):
dialog = distutils.command.bdist_msi.PyDialog(self.db, "FilesInUse",
self.x, self.y, self.width, self.height, 19, self.title,
"Retry", "Retry", "Retry", bitmap = False)
dialog.text("Title", 15, 6, 200, 15, 0x30003,
r"{\DlgFontBold8}Files in Use")
dialog.text("Description", 20, 23, 280, 20, 0x30003,
"Some files that need to be updated are currently in use.")
dialog.text("Text", 20, 55, 330, 50, 3,
"The following applications are using files that need to be "
"updated by this setup. Close these applications and then "
"click Retry to continue the installation or Cancel to exit "
"it.")
dialog.control("List", "ListBox", 20, 107, 330, 130, 7,
"FileInUseProcess", None, None, None)
button = dialog.back("Exit", "Ignore", name = "Exit")
button.event("EndDialog", "Exit")
button = dialog.next("Ignore", "Retry", name = "Ignore")
button.event("EndDialog", "Ignore")
button = dialog.cancel("Retry", "Exit", name = "Retry")
button.event("EndDialog", "Retry")
def add_maintenance_type_dialog(self):
dialog = distutils.command.bdist_msi.PyDialog(self.db,
"MaintenanceTypeDlg", self.x, self.y, self.width, self.height,
self.modal, self.title, "Next", "Next", "Cancel")
dialog.title("Welcome to the [ProductName] Setup Wizard")
dialog.text("BodyText", 15, 63, 330, 42, 3,
"Select whether you want to repair or remove [ProductName].")
group = dialog.radiogroup("RepairRadioGroup", 15, 108, 330, 60, 3,
"MaintenanceForm_Action", "", "Next")
group.add("Repair", 0, 18, 300, 17, "&Repair [ProductName]")
group.add("Remove", 0, 36, 300, 17, "Re&move [ProductName]")
dialog.back("< Back", None, active = False)
button = dialog.next("Finish", "Cancel")
button.event("[REINSTALL]", "ALL",
'MaintenanceForm_Action="Repair"', 5)
button.event("[Progress1]", "Repairing",
'MaintenanceForm_Action="Repair"', 6)
button.event("[Progress2]", "repairs",
'MaintenanceForm_Action="Repair"', 7)
button.event("Reinstall", "ALL",
'MaintenanceForm_Action="Repair"', 8)
button.event("[REMOVE]", "ALL",
'MaintenanceForm_Action="Remove"', 11)
button.event("[Progress1]", "Removing",
'MaintenanceForm_Action="Remove"', 12)
button.event("[Progress2]", "removes",
'MaintenanceForm_Action="Remove"', 13)
button.event("Remove", "ALL",
'MaintenanceForm_Action="Remove"', 14)
button.event("EndDialog", "Return",
'MaintenanceForm_Action<>"Change"', 20)
button = dialog.cancel("Cancel", "RepairRadioGroup")
button.event("SpawnDialog", "CancelDlg")
def add_prepare_dialog(self):
dialog = distutils.command.bdist_msi.PyDialog(self.db, "PrepareDlg",
self.x, self.y, self.width, self.height, self.modeless,
self.title, "Cancel", "Cancel", "Cancel")
dialog.text("Description", 15, 70, 320, 40, 0x30003,
"Please wait while the installer prepares to guide you through"
"the installation.")
dialog.title("Welcome to the [ProductName] installer")
text = dialog.text("ActionText", 15, 110, 320, 20, 0x30003,
"Pondering...")
text.mapping("ActionText", "Text")
text = dialog.text("ActionData", 15, 135, 320, 30, 0x30003, None)
text.mapping("ActionData", "Text")
dialog.back("Back", None, active = False)
dialog.next("Next", None, active = False)
button = dialog.cancel("Cancel", None)
button.event("SpawnDialog", "CancelDlg")
def add_progress_dialog(self):
dialog = distutils.command.bdist_msi.PyDialog(self.db, "ProgressDlg",
self.x, self.y, self.width, self.height, self.modeless,
self.title, "Cancel", "Cancel", "Cancel", bitmap = False)
dialog.text("Title", 20, 15, 200, 15, 0x30003,
r"{\DlgFontBold8}[Progress1] [ProductName]")
dialog.text("Text", 35, 65, 300, 30, 3,
"Please wait while the installer [Progress2] [ProductName].")
dialog.text("StatusLabel", 35, 100 ,35, 20, 3, "Status:")
text = dialog.text("ActionText", 70, 100, self.width - 70, 20, 3,
"Pondering...")
text.mapping("ActionText", "Text")
control = dialog.control("ProgressBar", "ProgressBar", 35, 120, 300,
10, 65537, None, "Progress done", None, None)
control.mapping("SetProgress", "Progress")
dialog.back("< Back", "Next", active = False)
dialog.next("Next >", "Cancel", active = False)
button = dialog.cancel("Cancel", "Back")
button.event("SpawnDialog", "CancelDlg")
def add_properties(self):
metadata = self.distribution.metadata
props = [
('DistVersion', metadata.get_version()),
('DefaultUIFont', 'DlgFont8'),
('ErrorDialog', 'ErrorDlg'),
('Progress1', 'Install'),
('Progress2', 'installs'),
('MaintenanceForm_Action', 'Repair'),
('ALLUSERS', '1')
]
email = metadata.author_email or metadata.maintainer_email
if email:
props.append(("ARPCONTACT", email))
if metadata.url:
props.append(("ARPURLINFOABOUT", metadata.url))
if self.upgrade_code is not None:
props.append(("UpgradeCode", self.upgrade_code))
msilib.add_data(self.db, 'Property', props)
def add_select_directory_dialog(self):
dialog = distutils.command.bdist_msi.PyDialog(self.db,
"SelectDirectoryDlg", self.x, self.y, self.width, self.height,
self.modal, self.title, "Next", "Next", "Cancel")
dialog.title("Select destination directory")
dialog.back("< Back", None, active = False)
button = dialog.next("Next >", "Cancel")
button.event("SetTargetPath", "TARGETDIR", ordering = 1)
button.event("SpawnWaitDialog", "WaitForCostingDlg", ordering = 2)
button.event("EndDialog", "Return", ordering = 3)
button = dialog.cancel("Cancel", "DirectoryCombo")
button.event("SpawnDialog", "CancelDlg")
dialog.control("DirectoryCombo", "DirectoryCombo", 15, 70, 272, 80,
393219, "TARGETDIR", None, "DirectoryList", None)
dialog.control("DirectoryList", "DirectoryList", 15, 90, 308, 136, 3,
"TARGETDIR", None, "PathEdit", None)
dialog.control("PathEdit", "PathEdit", 15, 230, 306, 16, 3,
"TARGETDIR", None, "Next", None)
button = dialog.pushbutton("Up", 306, 70, 18, 18, 3, "Up", None)
button.event("DirectoryListUp", "0")
button = dialog.pushbutton("NewDir", 324, 70, 30, 18, 3, "New", None)
button.event("DirectoryListNew", "0")
def add_text_styles(self):
msilib.add_data(self.db, 'TextStyle',
[("DlgFont8", "Tahoma", 9, None, 0),
("DlgFontBold8", "Tahoma", 8, None, 1),
("VerdanaBold10", "Verdana", 10, None, 1),
("VerdanaRed9", "Verdana", 9, 255, 0)
])
def add_ui(self):
self.add_text_styles()
self.add_error_dialog()
self.add_fatal_error_dialog()
self.add_cancel_dialog()
self.add_exit_dialog()
self.add_user_exit_dialog()
self.add_files_in_use_dialog()
self.add_wait_for_costing_dialog()
self.add_prepare_dialog()
self.add_select_directory_dialog()
self.add_progress_dialog()
self.add_maintenance_type_dialog()
def add_upgrade_config(self, sversion):
if self.upgrade_code is not None:
msilib.add_data(self.db, 'Upgrade',
[(self.upgrade_code, None, sversion, None, 513, None,
"REMOVEOLDVERSION"),
(self.upgrade_code, sversion, None, None, 257, None,
"REMOVENEWVERSION")
])
def add_user_exit_dialog(self):
dialog = distutils.command.bdist_msi.PyDialog(self.db, "UserExit",
self.x, self.y, self.width, self.height, self.modal,
self.title, "Finish", "Finish", "Finish")
dialog.title("[ProductName] installer was interrupted")
dialog.back("< Back", "Finish", active = False)
dialog.cancel("Cancel", "Back", active = False)
dialog.text("Description1", 15, 70, 320, 80, 0x30003,
"[ProductName] setup was interrupted. Your system has not "
"been modified. To install this program at a later time, "
"please run the installation again.")
dialog.text("Description2", 15, 155, 320, 20, 0x30003,
"Click the Finish button to exit the installer.")
button = dialog.next("Finish", "Cancel", name = "Finish")
button.event("EndDialog", "Exit")
def add_wait_for_costing_dialog(self):
dialog = msilib.Dialog(self.db, "WaitForCostingDlg", 50, 10, 260, 85,
self.modal, self.title, "Return", "Return", "Return")
dialog.text("Text", 48, 15, 194, 30, 3,
"Please wait while the installer finishes determining your "
"disk space requirements.")
button = dialog.pushbutton("Return", 102, 57, 56, 17, 3, "Return",
None)
button.event("EndDialog", "Exit")
def finalize_options(self):
distutils.command.bdist_msi.bdist_msi.finalize_options(self)
name = self.distribution.get_name()
fullname = self.distribution.get_fullname()
if self.initial_target_dir is None:
if distutils.util.get_platform() == "win-amd64":
programFilesFolder = "ProgramFiles64Folder"
else:
programFilesFolder = "ProgramFilesFolder"
self.initial_target_dir = r"[%s]\%s" % (programFilesFolder, name)
if self.add_to_path is None:
self.add_to_path = False
if self.target_name is None:
self.target_name = fullname
if not self.target_name.lower().endswith(".msi"):
platform = distutils.util.get_platform().replace("win-", "")
self.target_name = "%s-%s.msi" % (self.target_name, platform)
if not os.path.isabs(self.target_name):
self.target_name = os.path.join(self.dist_dir, self.target_name)
if self.directories is None:
self.directories = []
if self.data is None:
self.data = {}
def initialize_options(self):
distutils.command.bdist_msi.bdist_msi.initialize_options(self)
self.upgrade_code = None
self.add_to_path = None
self.initial_target_dir = None
self.target_name = None
self.directories = None
self.data = None
def run(self):
if not self.skip_build:
self.run_command('build')
install = self.reinitialize_command('install', reinit_subcommands = 1)
install.prefix = self.bdist_dir
install.skip_build = self.skip_build
install.warn_dir = 0
distutils.log.info("installing to %s", self.bdist_dir)
install.ensure_finalized()
install.run()
self.mkpath(self.dist_dir)
fullname = self.distribution.get_fullname()
if os.path.exists(self.target_name):
os.unlink(self.target_name)
metadata = self.distribution.metadata
author = metadata.author or metadata.maintainer or "UNKNOWN"
version = metadata.get_version()
sversion = "%d.%d.%d" % \
distutils.version.StrictVersion(version).version
self.db = msilib.init_database(self.target_name, msilib.schema,
self.distribution.metadata.name, msilib.gen_uuid(), sversion,
author)
msilib.add_tables(self.db, msilib.sequence)
self.add_properties()
self.add_config(fullname)
self.add_upgrade_config(sversion)
self.add_ui()
self.add_files()
self.db.Commit()
if not self.keep_temp:
distutils.dir_util.remove_tree(self.bdist_dir,
dry_run = self.dry_run)
|