Add script to fix msi generation

The generated msi will be modified so it can be installed by any user.
master
Lertsenem 2020-07-22 20:44:48 +02:00
parent bc663474f6
commit 37eccfeaf4
1 changed files with 69 additions and 0 deletions

View File

@ -1,5 +1,7 @@
import distutils, distutils.util import distutils, distutils.util
import msilib
import os import os
import pathlib
import setuptools import setuptools
import sys import sys
@ -59,6 +61,73 @@ if os.name == "nt":
], ],
) )
# -------------------------------------------------------------------------
# Modifications to allow for a non-admin-required msi
print("modifying final msi '{}' for standard user installation" \
.format(msi_filepath))
if not msi_filepath.exists():
print("msi file does not exist")
else:
try:
db = msilib.OpenDatabase(
str(msi_filepath),
msilib.MSIDBOPEN_TRANSACT,
)
si = db.GetSummaryInformation(20)
cur_wc = si.GetProperty(msilib.PID_WORDCOUNT)
si.SetProperty(
msilib.PID_WORDCOUNT,
cur_wc | 0b1000,
)
si.SetProperty(
msilib.PID_AUTHOR,
"{} - {}" \
.format(
lokrez.version.ENTITY,
lokrez.version.AUTHOR,
),
)
si.Persist()
# Install for the current user only
vi = db.OpenView(
"DELETE FROM `Property` WHERE `Property`.`Property` = " \
"'ALLUSERS'",
)
vi.Execute(None)
vi.Close()
# Add the manufacturer name
vi = db.OpenView(
"UPDATE `Property` SET `Property`.`Value`='{} - {}' WHERE " \
"`Property`.`Property` = 'Manufacturer'" \
.format(
lokrez.version.ENTITY,
lokrez.version.AUTHOR,
),
)
vi.Execute(None)
vi.Close()
# Update Path env variable for the user only
vi = db.OpenView(
"UPDATE `Environment` SET `Environment`.`Name`='=-Path' " \
"WHERE `Environment`.`Environment` = 'E_PATH'",
)
vi.Execute(None)
vi.Close()
db.Commit()
db.Close()
except Exception as e:
print("fail")
print(str(e))
print(e.args)
raise
sys.exit(0) sys.exit(0)
# Linux build # Linux build