Merge pull request #3856 from Kingtous/master

feat: add x86 windows sciter build
This commit is contained in:
RustDesk 2023-03-31 21:55:42 +08:00 committed by GitHub
commit e1e9c2bf2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 79 additions and 42 deletions

View File

@ -154,7 +154,7 @@ jobs:
name: ${{ matrix.job.target }} (${{ matrix.job.os }})
runs-on: ${{ matrix.job.os }}
# Temporarily disable this action due to additional test is needed.
if: false
# if: false
strategy:
fail-fast: false
matrix:
@ -175,14 +175,10 @@ jobs:
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable-${{ matrix.job.target }}
toolchain: nightly-${{ matrix.job.target }}
target: ${{ matrix.job.target }}
override: true
profile: minimal # minimal component installation (ie, no documentation)
- name: Set Rust toolchain to the target
run: |
rustup default stable-${{ matrix.job.target }}
- uses: Swatinem/rust-cache@v2
with:
@ -204,6 +200,8 @@ jobs:
shell: bash
run: |
python3 res/inline-sciter.py
# Patch sciter x86
sed -i 's/branch = "dyn"/branch = "dyn_x86"/g' ./Cargo.toml
# Replace the link for the ico.
rm res/icon.ico && cp flutter/windows/runner/resources/app_icon.ico res/icon.ico
cargo build --features inline --release --bins
@ -1003,7 +1001,7 @@ jobs:
done
- name: Publish debian package
if: ${{ matrix.job.extra-build-features == '' }} && env.UPLOAD_ARTIFACT == 'true'
if: matrix.job.extra-build-features == '' && env.UPLOAD_ARTIFACT == 'true'
uses: softprops/action-gh-release@v1
with:
prerelease: true
@ -1176,7 +1174,7 @@ jobs:
done
- name: Publish debian package
if: ${{ matrix.job.extra-build-features == '' }} && env.UPLOAD_ARTIFACT == 'true'
if: matrix.job.extra-build-features == '' && env.UPLOAD_ARTIFACT == 'true'
uses: softprops/action-gh-release@v1
with:
prerelease: true
@ -1199,7 +1197,7 @@ jobs:
sudo appimage-builder --skip-tests --recipe ./AppImageBuilder-${{ matrix.job.arch }}.yml
- name: Publish appimage package
if: ${{ matrix.job.extra-build-features == 'appimage' }} && env.UPLOAD_ARTIFACT == 'true'
if: matrix.job.extra-build-features == 'appimage' && env.UPLOAD_ARTIFACT == 'true'
uses: softprops/action-gh-release@v1
with:
prerelease: true
@ -1273,7 +1271,7 @@ jobs:
# res/rustdesk*.zst
- name: Publish fedora28/centos8 package
if: ${{ matrix.job.extra-build-features == '' }} && env.UPLOAD_ARTIFACT == 'true'
if: matrix.job.extra-build-features == '' && env.UPLOAD_ARTIFACT == 'true'
uses: softprops/action-gh-release@v1
with:
prerelease: true
@ -1396,7 +1394,7 @@ jobs:
done
- name: Publish debian package
if: ${{ matrix.job.extra-build-features == '' }} && env.UPLOAD_ARTIFACT == 'true'
if: matrix.job.extra-build-features == '' && env.UPLOAD_ARTIFACT == 'true'
uses: softprops/action-gh-release@v1
with:
prerelease: true
@ -1452,7 +1450,7 @@ jobs:
cd res && HBB=`pwd`/.. FLUTTER=1 makepkg -f
- name: Publish archlinux package
if: ${{ matrix.job.extra-build-features == '' }} && env.UPLOAD_ARTIFACT == 'true'
if: matrix.job.extra-build-features == '' && env.UPLOAD_ARTIFACT == 'true'
uses: softprops/action-gh-release@v1
with:
prerelease: true
@ -1461,7 +1459,7 @@ jobs:
res/rustdesk*.zst
- name: Build appimage package
if: ${{ matrix.job.extra-build-features == 'appimage' }}
if: matrix.job.extra-build-features == 'appimage' && env.UPLOAD_ARTIFACT == 'true'
shell: bash
run: |
# set-up appimage-builder
@ -1475,7 +1473,7 @@ jobs:
sudo appimage-builder --skip-tests --recipe ./AppImageBuilder-x86_64.yml
- name: Publish appimage package
if: ${{ matrix.job.extra-build-features == 'appimage' }} && env.UPLOAD_ARTIFACT == 'true'
if: matrix.job.extra-build-features == 'appimage' && env.UPLOAD_ARTIFACT == 'true'
uses: softprops/action-gh-release@v1
with:
prerelease: true
@ -1484,7 +1482,7 @@ jobs:
./appimage/rustdesk-${{ env.VERSION }}-*.AppImage
- name: Publish fedora28/centos8 package
if: ${{ matrix.job.extra-build-features == '' }} && env.UPLOAD_ARTIFACT == 'true'
if: matrix.job.extra-build-features == '' && env.UPLOAD_ARTIFACT == 'true'
uses: softprops/action-gh-release@v1
with:
prerelease: true

2
Cargo.lock generated
View File

@ -6343,7 +6343,7 @@ dependencies = [
[[package]]
name = "trayicon"
version = "0.1.3-1"
source = "git+https://github.com/open-trade/trayicon-rs#8d9c4489287752cc5be4a35c103198f7111112f9"
source = "git+https://github.com/open-trade/trayicon-rs#35bd01963271b45a0b6a0f65f1ce03a5f35bc691"
dependencies = [
"winapi 0.3.9",
"winit",

View File

@ -10,15 +10,16 @@ use hbb_common::{
sleep, timeout, tokio,
};
use std::io::prelude::*;
use std::path::Path;
use std::ptr::null_mut;
use std::{
collections::HashMap,
ffi::OsString,
fs, io, mem,
os::windows::process::CommandExt,
path::PathBuf,
sync::{Arc, Mutex},
time::{Duration, Instant},
collections::HashMap
};
use winapi::{
ctypes::c_void,
@ -717,7 +718,7 @@ pub fn is_share_rdp() -> bool {
}
pub fn set_share_rdp(enable: bool) {
let (subkey, _, _, _) = get_install_info();
let (subkey, _, _, _, _) = get_install_info();
let cmd = format!(
"reg add {} /f /v share_rdp /t REG_SZ /d \"{}\"",
subkey,
@ -810,11 +811,11 @@ fn get_valid_subkey() -> String {
return get_subkey(&app_name, false);
}
pub fn get_install_info() -> (String, String, String, String) {
pub fn get_install_info() -> (String, String, String, String, String) {
get_install_info_with_subkey(get_valid_subkey())
}
fn get_default_install_info() -> (String, String, String, String) {
fn get_default_install_info() -> (String, String, String, String, String) {
get_install_info_with_subkey(get_subkey(&crate::get_app_name(), false))
}
@ -883,7 +884,7 @@ pub fn check_update_broker_process() -> ResultType<()> {
Ok(())
}
fn get_install_info_with_subkey(subkey: String) -> (String, String, String, String) {
fn get_install_info_with_subkey(subkey: String) -> (String, String, String, String, String) {
let mut path = get_reg_of(&subkey, "InstallLocation");
if path.is_empty() {
path = get_default_install_path();
@ -894,26 +895,32 @@ fn get_install_info_with_subkey(subkey: String) -> (String, String, String, Stri
crate::get_app_name()
);
let exe = format!("{}\\{}.exe", path, crate::get_app_name());
(subkey, path, start_menu, exe)
let dll = format!("{}\\sciter.dll", path);
(subkey, path, start_menu, exe, dll)
}
pub fn copy_exe_cmd(src_exe: &str, _exe: &str, path: &str) -> String {
pub fn copy_raw_cmd(src_raw: &str, _raw: &str, _path: &str) -> String {
#[cfg(feature = "flutter")]
let main_exe = format!(
let main_raw = format!(
"XCOPY \"{}\" \"{}\" /Y /E /H /C /I /K /R /Z",
PathBuf::from(src_exe)
PathBuf::from(src_raw)
.parent()
.unwrap()
.to_string_lossy()
.to_string(),
path
_path
);
#[cfg(not(feature = "flutter"))]
let main_exe = format!(
"copy /Y \"{src_exe}\" \"{exe}\"",
src_exe = src_exe,
exe = _exe
let main_raw = format!(
"copy /Y \"{src_raw}\" \"{raw}\"",
src_raw = src_raw,
raw = _raw
);
return main_raw;
}
pub fn copy_exe_cmd(src_exe: &str, exe: &str, path: &str) -> String {
let main_exe = copy_raw_cmd(src_exe, exe, path);
return format!(
"
@ -929,8 +936,19 @@ pub fn copy_exe_cmd(src_exe: &str, _exe: &str, path: &str) -> String {
}
pub fn update_me() -> ResultType<()> {
let (_, path, _, exe) = get_install_info();
let (_, path, _, exe, dll) = get_install_info();
let src_exe = std::env::current_exe()?.to_str().unwrap_or("").to_owned();
let src_dll = std::env::current_exe()?
.parent()
.unwrap_or(&Path::new(&get_default_install_path()))
.join("sciter.dll")
.to_str()
.unwrap_or("")
.to_owned();
#[cfg(feature = "flutter")]
let copy_dll = "".to_string();
#[cfg(not(feature = "flutter"))]
let copy_dll = copy_raw_cmd(&src_dll, &dll, &path);
let cmds = format!(
"
chcp 65001
@ -938,10 +956,12 @@ pub fn update_me() -> ResultType<()> {
taskkill /F /IM {broker_exe}
taskkill /F /IM {app_name}.exe /FI \"PID ne {cur_pid}\"
{copy_exe}
{copy_dll}
sc start {app_name}
{lic}
",
copy_exe = copy_exe_cmd(&src_exe, &exe, &path),
copy_dll = copy_dll,
broker_exe = crate::win_privacy::INJECTED_PROCESS_EXE,
app_name = crate::get_app_name(),
lic = register_licence(),
@ -980,12 +1000,14 @@ fn get_after_install(exe: &str) -> String {
pub fn install_me(options: &str, path: String, silent: bool, debug: bool) -> ResultType<()> {
let uninstall_str = get_uninstall(false);
let mut path = path.trim_end_matches('\\').to_owned();
let (subkey, _path, start_menu, exe) = get_default_install_info();
let (subkey, _path, start_menu, exe, dll) = get_default_install_info();
let mut exe = exe;
let mut dll = dll;
if path.is_empty() {
path = _path;
} else {
exe = exe.replace(&_path, &path);
dll = dll.replace(&_path, &path);
}
let mut version_major = "0";
let mut version_minor = "0";
@ -1109,6 +1131,18 @@ if exist \"{tmp_path}\\{app_name} Tray.lnk\" del /f /q \"{tmp_path}\\{app_name}
app_name = crate::get_app_name(),
);
let src_exe = std::env::current_exe()?.to_str().unwrap_or("").to_string();
let src_dll = std::env::current_exe()?
.parent()
.unwrap_or(&Path::new(&get_default_install_path()))
.join("sciter.dll")
.to_str()
.unwrap_or("")
.to_owned();
#[cfg(feature = "flutter")]
let copy_dll = "".to_string();
#[cfg(not(feature = "flutter"))]
let copy_dll = copy_raw_cmd(&src_dll, &dll, &path);
let install_cert = if options.contains("driverCert") {
format!("\"{}\" --install-cert \"RustDeskIddDriver.cer\"", src_exe)
@ -1122,6 +1156,7 @@ if exist \"{tmp_path}\\{app_name} Tray.lnk\" del /f /q \"{tmp_path}\\{app_name}
chcp 65001
md \"{path}\"
{copy_exe}
{copy_dll}
reg add {subkey} /f
reg add {subkey} /f /v DisplayIcon /t REG_SZ /d \"{exe}\"
reg add {subkey} /f /v DisplayName /t REG_SZ /d \"{app_name}\"
@ -1181,6 +1216,7 @@ sc delete {app_name}
&dels
},
copy_exe = copy_exe_cmd(&src_exe, &exe, &path),
copy_dll = copy_dll
);
run_cmds(cmds, debug, "install")?;
std::thread::sleep(std::time::Duration::from_millis(2000));
@ -1193,7 +1229,7 @@ sc delete {app_name}
}
pub fn run_after_install() -> ResultType<()> {
let (_, _, _, exe) = get_install_info();
let (_, _, _, exe,_) = get_install_info();
run_cmds(get_after_install(&exe), true, "after_install")
}
@ -1227,7 +1263,7 @@ fn get_before_uninstall(kill_self: bool) -> String {
}
fn get_uninstall(kill_self: bool) -> String {
let (subkey, path, start_menu, _) = get_install_info();
let (subkey, path, start_menu, _, _) = get_install_info();
format!(
"
{before_uninstall}
@ -1331,7 +1367,7 @@ pub fn is_installed() -> bool {
service::ServiceAccess,
service_manager::{ServiceManager, ServiceManagerAccess},
};
let (_, _, _, exe) = get_install_info();
let (_, _, _, exe, _) = get_install_info();
if !std::fs::metadata(exe).is_ok() {
return false;
}
@ -1347,7 +1383,7 @@ pub fn is_installed() -> bool {
}
pub fn get_installed_version() -> String {
let (_, _, _, exe) = get_install_info();
let (_, _, _, exe, _) = get_install_info();
if let Ok(output) = std::process::Command::new(exe).arg("--version").output() {
for line in String::from_utf8_lossy(&output.stdout).lines() {
return line.to_owned();
@ -1357,7 +1393,7 @@ pub fn get_installed_version() -> String {
}
fn get_reg(name: &str) -> String {
let (subkey, _, _, _) = get_install_info();
let (subkey, _, _, _, _) = get_install_info();
get_reg_of(&subkey, name)
}
@ -1408,7 +1444,7 @@ pub fn bootstrap() {
}
fn register_licence() -> String {
let (subkey, _, _, _) = get_install_info();
let (subkey, _, _, _, _) = get_install_info();
if let Ok(lic) = get_license_from_exe_name() {
format!(
"
@ -1765,14 +1801,17 @@ pub fn send_message_to_hnwd(
pub fn create_process_with_logon(user: &str, pwd: &str, exe: &str, arg: &str) -> ResultType<()> {
let last_error_table = HashMap::from([
(ERROR_LOGON_FAILURE, "The user name or password is incorrect."),
(ERROR_ACCESS_DENIED, "Access is denied.")
(
ERROR_LOGON_FAILURE,
"The user name or password is incorrect.",
),
(ERROR_ACCESS_DENIED, "Access is denied."),
]);
unsafe {
let user_split = user.split("\\").collect::<Vec<&str>>();
let wuser = wide_string(user_split.get(1).unwrap_or(&user));
let wpc = wide_string(user_split.get(0).unwrap_or(&""));
let wpc = wide_string(user_split.get(0).unwrap_or(&""));
let wpwd = wide_string(pwd);
let cmd = if arg.is_empty() {
format!("\"{}\"", exe)
@ -1804,7 +1843,7 @@ pub fn create_process_with_logon(user: &str, pwd: &str, exe: &str, arg: &str) ->
{
let last_error = GetLastError();
bail!(
"CreateProcessWithLogonW failed : \"{}\", errno={}",
"CreateProcessWithLogonW failed : \"{}\", errno={}",
last_error_table
.get(&last_error)
.unwrap_or(&"Unknown error"),