build windows install

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages 2022-10-11 14:52:46 +08:00
parent 2ced73cdda
commit e2924f0d41
6 changed files with 74 additions and 26 deletions

View File

@ -189,7 +189,7 @@ def build_flutter_arch_manjaro():
os.chdir('..')
os.system('HBB=`pwd` FLUTTER=1 makepkg -f')
def build_flutter_windows_portable():
def build_flutter_windows(version):
os.system("cargo build --lib --features flutter --release")
os.chdir('flutter')
os.system("flutter build windows --release")
@ -203,6 +203,8 @@ def build_flutter_windows_portable():
else:
os.rename("./target/release/rustdesk-portable-packer.exe", "./rustdesk_portable.exe")
print(f"output location: {os.path.abspath(os.curdir)}/rustdesk_portable.exe")
os.system(f"cp -rf ./rustdesk_portable.exe ./rustdesk-{version}-install.exe")
print(f"output location: {os.path.abspath(os.curdir)}/rustdesk-{version}-install.exe")
def main():
parser = make_parser()
@ -227,8 +229,8 @@ def main():
os.system('python3 res/inline-sciter.py')
portable = args.portable
if windows:
if portable:
build_flutter_windows_portable()
if flutter:
build_flutter_windows(version)
return
os.system('cargo build --release --features ' + features)
# os.system('upx.exe target/release/rustdesk.exe')
@ -239,7 +241,7 @@ def main():
'target\\release\\rustdesk.exe')
else:
print('Not signed')
os.system(f'cp -rf target/release/RustDesk.exe rustdesk-{version}-setdown.exe')
os.system(f'cp -rf target/release/RustDesk.exe rustdesk-{version}-win7-install.exe')
elif os.path.isfile('/usr/bin/pacman'):
# pacman -S -needed base-devel
os.system("sed -i 's/pkgver=.*/pkgver=%s/g' PKGBUILD" % version)

View File

@ -181,9 +181,9 @@ class _InstallPageState extends State<InstallPage> with WindowListener {
void install() {
btnEnabled.value = false;
showProgress.value = true;
String args = '';
if (startmenu.value) args += 'startmenu ';
if (desktopicon.value) args += 'desktopicon ';
String args = '--flutter';
if (startmenu.value) args += ' startmenu';
if (desktopicon.value) args += ' desktopicon';
bind.installInstallMe(options: args, path: controller.text);
}

View File

@ -12,29 +12,37 @@ pub mod bin_reader;
const APP_PREFIX: &str = "rustdesk";
const APPNAME_RUNTIME_ENV_KEY: &str = "RUSTDESK_APPNAME";
fn setup(reader: BinaryReader) -> Option<PathBuf> {
// home dir
if let Some(dir) = dirs::data_local_dir() {
let dir = dir.join(APP_PREFIX);
for file in reader.files.iter() {
file.write_to_file(&dir);
}
#[cfg(unix)]
reader.configure_permission(&dir);
Some(dir.join(&reader.exe))
fn setup(reader: BinaryReader, dir: Option<PathBuf>, clear: bool) -> Option<PathBuf> {
let dir = if let Some(dir) = dir {
dir
} else {
eprintln!("not found data local dir");
None
// home dir
if let Some(dir) = dirs::data_local_dir() {
dir.join(APP_PREFIX)
} else {
eprintln!("not found data local dir");
return None;
}
};
if clear {
std::fs::remove_dir_all(&dir).ok();
}
for file in reader.files.iter() {
file.write_to_file(&dir);
}
#[cfg(unix)]
reader.configure_permission(&dir);
Some(dir.join(&reader.exe))
}
fn execute(path: PathBuf) {
fn execute(path: PathBuf, args: Vec<String>) {
println!("executing {}", path.display());
// setup env
let exe = std::env::current_exe().unwrap();
let exe_name = exe.file_name().unwrap();
// run executable
Command::new(path)
.args(args)
.env(APPNAME_RUNTIME_ENV_KEY, exe_name)
.stdin(Stdio::inherit())
.stdout(Stdio::inherit())
@ -43,9 +51,24 @@ fn execute(path: PathBuf) {
.expect(&format!("failed to execute {:?}", exe_name));
}
fn is_setup(name: &str) -> bool {
name.to_lowercase().ends_with("install.exe") || name.to_lowercase().ends_with("安装.exe")
}
fn main() {
let is_setup = is_setup(
&std::env::current_exe()
.unwrap()
.to_string_lossy()
.to_string(),
);
let reader = BinaryReader::default();
if let Some(exe) = setup(reader) {
execute(exe);
if let Some(exe) = setup(reader, None, is_setup) {
let args = if is_setup {
vec!["--install".to_owned()]
} else {
vec![]
};
execute(exe, args);
}
}

View File

@ -544,7 +544,7 @@ pub fn is_ip(id: &str) -> bool {
}
pub fn is_setup(name: &str) -> bool {
name.to_lowercase().ends_with("setdown.exe") || name.to_lowercase().ends_with("安装.exe")
name.to_lowercase().ends_with("install.exe") || name.to_lowercase().ends_with("安装.exe")
}
pub fn get_custom_rendezvous_server(custom: String) -> String {

View File

@ -6,6 +6,7 @@ pub fn core_main() -> Option<Vec<String>> {
// though async logger more efficient, but it also causes more problems, disable it for now
// let mut _async_logger_holder: Option<flexi_logger::LoggerHandle> = None;
let mut args = Vec::new();
let mut flutter_args = Vec::new();
let mut i = 0;
let mut is_setup = false;
let mut _is_elevate = false;
@ -25,13 +26,18 @@ pub fn core_main() -> Option<Vec<String>> {
}
i += 1;
}
if args.contains(&"--install".to_string()) {
is_setup = true;
}
if is_setup {
if args.is_empty() {
args.push("--install".to_owned());
} else if args[0] == "--noinstall" {
args.clear();
flutter_args.push("--install".to_string());
}
}
if args.contains(&"--noinstall".to_string()) {
args.clear();
}
if args.len() > 0 && args[0] == "--version" {
println!("{}", crate::VERSION);
return None;
@ -171,7 +177,10 @@ pub fn core_main() -> Option<Vec<String>> {
}
}
//_async_logger_holder.map(|x| x.flush());
Some(args)
#[cfg(feature = "flutter")]
return Some(flutter_args);
#[cfg(not(feature = "flutter"))]
return Some(args);
}
fn import_config(path: &str) {

View File

@ -1025,6 +1025,18 @@ copy /Y \"{tmp_path}\\Uninstall {app_name}.lnk\" \"{start_menu}\\\"
app_name = crate::get_app_name(),
);
}
let mut flutter_copy = Default::default();
if options.contains("--flutter") {
flutter_copy = format!(
"XCOPY \"{}\" \"{}\" /Y /E /H /C /I /K /R /Z",
std::env::current_exe()?
.parent()
.unwrap()
.to_string_lossy()
.to_string(),
path
);
}
let meta = std::fs::symlink_metadata(std::env::current_exe()?)?;
let size = meta.len() / 1024;
@ -1052,6 +1064,7 @@ if exist \"{tmp_path}\\{app_name} Tray.lnk\" del /f /q \"{tmp_path}\\{app_name}
{uninstall_str}
chcp 65001
md \"{path}\"
{flutter_copy}
copy /Y \"{src_exe}\" \"{exe}\"
copy /Y \"{ORIGIN_PROCESS_EXE}\" \"{path}\\{broker_exe}\"
\"{src_exe}\" --extract \"{path}\"
@ -1114,6 +1127,7 @@ sc delete {app_name}
} else {
&dels
},
flutter_copy = flutter_copy,
);
run_cmds(cmds, debug, "install")?;
std::thread::sleep(std::time::Duration::from_millis(2000));