refact: msi, version and build date, check (#7775)
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
0e6fa37ae4
commit
c75778943f
@ -180,7 +180,8 @@ def gen_upgrade_info():
|
|||||||
def func(lines, index_start):
|
def func(lines, index_start):
|
||||||
indent = g_indent_unit * 3
|
indent = g_indent_unit * 3
|
||||||
|
|
||||||
major, _, _ = g_version.split(".")
|
vs = g_version.split(".")
|
||||||
|
major = vs[0]
|
||||||
upgrade_id = uuid.uuid4()
|
upgrade_id = uuid.uuid4()
|
||||||
to_insert_lines = [
|
to_insert_lines = [
|
||||||
f'{indent}<Upgrade Id="{upgrade_id}">\n',
|
f'{indent}<Upgrade Id="{upgrade_id}">\n',
|
||||||
@ -325,7 +326,8 @@ def gen_custom_ARPSYSTEMCOMPONENT_True(args, dist_dir):
|
|||||||
f'{indent}<RegistryValue Type="expandable" Name="UninstallString" Value="MsiExec.exe /X [ProductCode]" />\n'
|
f'{indent}<RegistryValue Type="expandable" Name="UninstallString" Value="MsiExec.exe /X [ProductCode]" />\n'
|
||||||
)
|
)
|
||||||
|
|
||||||
major, minor, build = g_version.split(".")
|
vs = g_version.split(".")
|
||||||
|
major, minor, build = vs[0], vs[1], vs[2]
|
||||||
lines_new.append(
|
lines_new.append(
|
||||||
f'{indent}<RegistryValue Type="string" Name="Version" Value="{g_version}" />\n'
|
f'{indent}<RegistryValue Type="string" Name="Version" Value="{g_version}" />\n'
|
||||||
)
|
)
|
||||||
@ -391,23 +393,31 @@ def gen_content_between_tags(filename, tag_start, tag_end, func):
|
|||||||
|
|
||||||
def init_global_vars(dist_dir, app_name, args):
|
def init_global_vars(dist_dir, app_name, args):
|
||||||
dist_app = dist_dir.joinpath(app_name + ".exe")
|
dist_app = dist_dir.joinpath(app_name + ".exe")
|
||||||
|
|
||||||
def read_process_output(args):
|
def read_process_output(args):
|
||||||
process = subprocess.Popen(f'{dist_app} {args}', stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
|
process = subprocess.Popen(
|
||||||
|
f"{dist_app} {args}",
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.STDOUT,
|
||||||
|
shell=True,
|
||||||
|
)
|
||||||
output, _ = process.communicate()
|
output, _ = process.communicate()
|
||||||
return output.decode('utf-8').strip()
|
return output.decode("utf-8").strip()
|
||||||
|
|
||||||
global g_version
|
global g_version
|
||||||
global g_build_date
|
global g_build_date
|
||||||
g_version = args.version.replace("-", ".")
|
g_version = args.version.replace("-", ".")
|
||||||
if g_version == "":
|
if g_version == "":
|
||||||
g_version = read_process_output('--version')
|
g_version = read_process_output("--version")
|
||||||
if g_version == "":
|
version_pattern = re.compile(r"\d+\.\d+\.\d+.*")
|
||||||
print(f"Error: version not found in {dist_app}")
|
if not version_pattern.match(g_version):
|
||||||
|
print(f"Error: version {g_version} not found in {dist_app}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
g_build_date = read_process_output('--build-date')
|
g_build_date = read_process_output("--build-date")
|
||||||
if g_build_date == "":
|
build_date_pattern = re.compile(r"\d{4}-\d{2}-\d{2} \d{2}:\d{2}")
|
||||||
print(f"Error: build date not found in {dist_app}")
|
if not build_date_pattern.match(g_build_date):
|
||||||
|
print(f"Error: build date {g_build_date} not found in {dist_app}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user