refact: msi (#7774)

* refact: msi

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* Remove unused coment

Signed-off-by: fufesou <shuanglongchen@yeah.net>

---------

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2024-04-19 17:57:04 +08:00 committed by GitHub
parent 25eb8dc9b0
commit 819eea9456
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 32 deletions

View File

@ -180,7 +180,7 @@ jobs:
if: env.UPLOAD_ARTIFACT == 'true' if: env.UPLOAD_ARTIFACT == 'true'
run: | run: |
pushd ./res/msi pushd ./res/msi
python preprocess.py -arp -d ../../rustdesk python preprocess.py --arp -d ../../rustdesk
nuget restore msi.sln nuget restore msi.sln
msbuild msi.sln -p:Configuration=Release -p:Platform=x64 /p:TargetVersion=Windows10 msbuild msi.sln -p:Configuration=Release -p:Platform=x64 /p:TargetVersion=Windows10
mv ./Package/bin/x64/Release/en-us/Package.msi ../../SignOutput/rustdesk-${{ env.VERSION }}-${{ matrix.job.arch }}-beta.msi mv ./Package/bin/x64/Release/en-us/Package.msi ../../SignOutput/rustdesk-${{ env.VERSION }}-${{ matrix.job.arch }}-beta.msi

View File

@ -6,6 +6,7 @@ import sys
import uuid import uuid
import argparse import argparse
import datetime import datetime
import subprocess
import re import re
from pathlib import Path from pathlib import Path
@ -46,14 +47,12 @@ def make_parser():
help="The dist direcotry to install.", help="The dist direcotry to install.",
) )
parser.add_argument( parser.add_argument(
"-arp",
"--arp", "--arp",
action="store_true", action="store_true",
help="Is ARPSYSTEMCOMPONENT", help="Is ARPSYSTEMCOMPONENT",
default=False, default=False,
) )
parser.add_argument( parser.add_argument(
"-custom-arp",
"--custom-arp", "--custom-arp",
type=str, type=str,
default="{}", default="{}",
@ -63,7 +62,7 @@ def make_parser():
"-c", "--custom", action="store_true", help="Is custom client", default=False "-c", "--custom", action="store_true", help="Is custom client", default=False
) )
parser.add_argument( parser.add_argument(
"-an", "--app-name", type=str, default="RustDesk", help="The app name." "--app-name", type=str, default="RustDesk", help="The app name."
) )
parser.add_argument( parser.add_argument(
"-v", "--version", type=str, default="", help="The app version." "-v", "--version", type=str, default="", help="The app version."
@ -149,7 +148,7 @@ def gen_pre_vars(args, dist_dir):
f'{indent}<?define Description="{args.app_name} Installer" ?>\n', f'{indent}<?define Description="{args.app_name} Installer" ?>\n',
f'{indent}<?define ProductLower="{args.app_name.lower()}" ?>\n', f'{indent}<?define ProductLower="{args.app_name.lower()}" ?>\n',
f'{indent}<?define RegKeyRoot=".$(var.ProductLower)" ?>\n', f'{indent}<?define RegKeyRoot=".$(var.ProductLower)" ?>\n',
f'{indent}<?define RegKeyInstall="$(var.RegKeyRoot)\Install" ?>\n', f'{indent}<?define RegKeyInstall="$(var.RegKeyRoot)\\Install" ?>\n',
f'{indent}<?define BuildDir="{dist_dir}" ?>\n', f'{indent}<?define BuildDir="{dist_dir}" ?>\n',
f'{indent}<?define BuildDate="{g_build_date}" ?>\n', f'{indent}<?define BuildDate="{g_build_date}" ?>\n',
"\n", "\n",
@ -390,37 +389,26 @@ def gen_content_between_tags(filename, tag_start, tag_end, func):
return True return True
def init_global_vars(args): def init_global_vars(dist_dir, app_name, args):
var_file = "../../src/version.rs" dist_app = dist_dir.joinpath(app_name + ".exe")
if not Path(var_file).exists(): def read_process_output(args):
print(f"Error: {var_file} not found") process = subprocess.Popen(f'{dist_app} {args}', stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
return False output, _ = process.communicate()
return output.decode('utf-8').strip()
with open(var_file, "r") as f:
content = f.readlines()
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 == "":
# pub const VERSION: &str = "1.2.4"; g_version = read_process_output('--version')
version_pattern = re.compile(r'.*VERSION: &str = "(.*)";.*')
for line in content:
match = version_pattern.match(line)
if match:
g_version = match.group(1)
break
if g_version == "": if g_version == "":
print(f"Error: version not found in {var_file}") print(f"Error: version not found in {dist_app}")
return False return False
# pub const BUILD_DATE: &str = "2024-04-08 23:11"; g_build_date = read_process_output('--build-date')
build_date_pattern = re.compile(r'BUILD_DATE: &str = "(.*)";') if g_build_date == "":
for line in content: print(f"Error: build date not found in {dist_app}")
match = build_date_pattern.match(line) return False
if match:
g_build_date = match.group(1)
break
return True return True
@ -448,7 +436,7 @@ if __name__ == "__main__":
app_name = args.app_name app_name = args.app_name
dist_dir = Path(sys.argv[0]).parent.joinpath(args.dist_dir).resolve() dist_dir = Path(sys.argv[0]).parent.joinpath(args.dist_dir).resolve()
if not init_global_vars(args): if not init_global_vars(dist_dir, app_name, args):
sys.exit(-1) sys.exit(-1)
if not gen_pre_vars(args, dist_dir): if not gen_pre_vars(args, dist_dir):

View File

@ -114,9 +114,14 @@ pub fn core_main() -> Option<Vec<String>> {
if args.contains(&"--noinstall".to_string()) { if args.contains(&"--noinstall".to_string()) {
args.clear(); args.clear();
} }
if args.len() > 0 && args[0] == "--version" { if args.len() > 0 {
println!("{}", crate::VERSION); if args[0] == "--version" {
return None; println!("{}", crate::VERSION);
return None;
} else if args[0] == "--build-date" {
println!("{}", crate::BUILD_DATE);
return None;
}
} }
#[cfg(windows)] #[cfg(windows)]
{ {