diff --git a/.github/workflows/other.bak b/.github/workflows/other.bak new file mode 100644 index 0000000..1d94a84 --- /dev/null +++ b/.github/workflows/other.bak @@ -0,0 +1,258 @@ +name: Build and Release CrossDesk + +on: + push: + branches: [release] + tags: + - "v*" + workflow_dispatch: + +permissions: + contents: write + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + # Linux Job with CUDA container + build-linux: + name: Build on (ubuntu + CUDA) + runs-on: ubuntu-22.04 + container: + image: nvidia/cuda:12.6.3-devel-ubuntu22.04 + options: --user root + defaults: + run: + working-directory: ${{ github.workspace }} + + steps: + - name: Install system dependencies + run: | + apt-get update + apt-get install -y \ + git \ + curl \ + unzip \ + software-properties-common \ + build-essential \ + libxcb-randr0-dev \ + libxcb-xtest0-dev \ + libxcb-xinerama0-dev \ + libxcb-shape0-dev \ + libxcb-xkb-dev \ + libxcb-xfixes0-dev \ + libxv-dev \ + libxtst-dev \ + libasound2-dev \ + libsndio-dev \ + libxcb-shm0-dev \ + libxrandr-dev \ + libpulse-dev + add-apt-repository ppa:xmake-io/xmake + apt-get update + apt-get install -y xmake + + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Cache xmake dependencies + uses: actions/cache@v4 + with: + path: ~/.xmake/packages + key: linux-xmake-deps-intel-${{ hashFiles('**/xmake.lua') }} + restore-keys: | + linux-xmake-deps-intel- + + - name: Build CrossDesk + run: xmake b -vy --root crossdesk + + # - name: Package + # run: | + # chmod +x ./scripts/linux/pkg_x86_64.sh + # ./scripts/linux/pkg_x86_64.sh + + # - name: Upload artifact + # uses: actions/upload-artifact@v4 + # with: + # name: crossdesk-linux-x86_64 + # path: ${{ github.workspace }}/build/linux/x86_64/release/crossdesk + + # Non-Linux platforms (macOS, Windows) + build-other: + name: Build on (${{ matrix.runner }} ${{ matrix.arch }}) + runs-on: ${{ matrix.runner }} + strategy: + matrix: + include: + - arch: x86_64 + platform: macos + runner: macos-13 + cache-key: intel + out-dir: ./build/macosx/x86_64/release/crossdesk + artifact-name: crossdesk-macos-x86_64 + package_script: ./scripts/macosx/pkg_x86_64.sh + - arch: arm64 + platform: macos + runner: macos-14 + cache-key: arm + out-dir: ./build/macosx/arm64/release/crossdesk + artifact-name: crossdesk-macos-arm64 + package_script: ./scripts/macosx/pkg_arm64.sh + - arch: x86_64 + platform: windows + runner: windows-2022 + cache-key: intel + out-dir: ./build/win/x86_64/release/crossdesk + artifact-name: crossdesk-win-x86_64 + package_script: ./scripts/windows/nsis_script.nsi + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Initialize submodules + run: git submodule update --init --recursive + + - name: Install xmake (macOS) + if: runner.os == 'macOS' + run: brew install xmake + + - name: Install xmake (Windows) + if: runner.os == 'Windows' + run: | + Invoke-Expression (Invoke-Webrequest 'https://raw.githubusercontent.com/tboox/xmake/master/scripts/get.ps1' -UseBasicParsing).Content + echo "C:\Users\runneradmin\xmake" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + + - name: Cache xmake dependencies (macOS) + if: runner.os == 'macOS' + uses: actions/cache@v4 + with: + path: ~/.xmake/packages + key: ${{ runner.os }}-xmake-deps-${{ matrix.cache-key }}-${{ hashFiles('**/xmake.lua') }} + restore-keys: | + ${{ runner.os }}-xmake-deps-${{ matrix.cache-key }}- + + - name: Get LOCALAPPDATA path (Windows) + if: runner.os == 'Windows' + id: localappdata + run: | + echo "localappdata=$env:LOCALAPPDATA" >> $env:GITHUB_OUTPUT + shell: pwsh + + - name: Cache xmake dependencies (Windows) + if: runner.os == 'Windows' + uses: actions/cache@v4 + with: + path: ${{ steps.localappdata.outputs.localappdata }}\.xmake\packages + key: ${{ runner.os }}-xmake-deps-${{ matrix.cache-key }}-${{ hashFiles('**/xmake.lua') }} + restore-keys: | + ${{ runner.os }}-xmake-deps-${{ matrix.cache-key }}- + + - name: Build CrossDesk + run: xmake b -vy crossdesk + + - name: Package + run: | + chmod +x ${{ matrix.package_script }} + ${{ matrix.package_script }} + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.artifact-name }} + path: ${{ matrix.out-dir }} + + # - name: Decode and save certificate + # shell: bash + # run: | + # mkdir -p certs + # echo "${{ secrets.CROSSDESK_CERT_BASE64 }}" | base64 --decode > certs/cert.crt + + # - name: Package CrossDesk app + # if: runner.os != 'Windows' + # run: | + # chmod +x ${{ matrix.package_script }} + # ${{ matrix.package_script }} + + # - name: Package CrossDesk app (Windows) + # if: runner.os == 'Windows' + # run: "& makensis.exe ${{ matrix.package_script }}" + # working-directory: ${{ github.workspace }} + + # - name: Upload build artifacts + # uses: actions/upload-artifact@v4 + # with: + # name: ${{ matrix.artifact-name }}-pkg + # path: crossdesk-${{ matrix.platform }}-${{ matrix.arch }}-v0.0.1.pkg + + # - name: Move files to release dir + # run: | + # mkdir -p release + # cp crossdesk-${{ matrix.platform }}-${{ matrix.arch }}-v0.0.1.pkg release/ + + # release: + # name: Publish Release + # if: startsWith(github.ref, 'refs/tags/v') + # needs: build + # runs-on: ubuntu-latest + + # steps: + # - name: Checkout repository + # uses: actions/checkout@v4 + + # - name: Download all artifacts + # uses: actions/download-artifact@v4 + # with: + # path: artifacts + + # - name: Extract version number + # id: version + # run: | + # VERSION="${GITHUB_REF##*/}" + # VERSION_NUM="${VERSION#v}" + # echo "VERSION_NUM=${VERSION_NUM}" >> $GITHUB_OUTPUT + + # - name: Rename artifacts + # run: | + # mkdir -p release + # cp artifacts/crossdesk-macos-x86_64-pkg/* release/crossdesk-macos-x86_64-v${{ steps.version.outputs.VERSION_NUM }}.pkg + # cp artifacts/crossdesk-macos-arm64-pkg/* release/crossdesk-macos-aarch64-v${{ steps.version.outputs.VERSION_NUM }}.pkg + + # - name: Upload to Versioned GitHub Release + # uses: softprops/action-gh-release@v2 + # with: + # tag_name: v${{ steps.version.outputs.VERSION_NUM }} + # name: Release v${{ steps.version.outputs.VERSION_NUM }} + # draft: false + # prerelease: false + # files: release/* + # generate_release_notes: false + # body: | + # Binary release only. Source code is not included. + + # - name: Upload to 'latest' Release + # run: | + # mkdir -p release/latest + # cp release/crossdesk-macos-x86_64-v${{ steps.version.outputs.VERSION_NUM }}.pkg release/latest/crossdesk-macos-x86_64-latest.pkg + # cp release/crossdesk-macos-aarch64-v${{ steps.version.outputs.VERSION_NUM }}.pkg release/latest/crossdesk-macos-aarch64-latest.pkg + + # - name: Create or update 'latest' tag + # run: | + # git config user.name "github-actions[bot]" + # git config user.email "github-actions[bot]@users.noreply.github.com" + # git tag -f latest + # git push origin latest --force + + # - name: Upload to GitHub Release (latest) + # uses: softprops/action-gh-release@v2 + # with: + # tag_name: latest + # name: Latest Release + # draft: false + # prerelease: false + # files: | + # release/latest/crossdesk-macos-*.pkg + # generate_release_notes: false + # \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..b77667a --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,132 @@ +name: Build and Release CrossDesk + +on: + push: + branches: [release] + tags: + - "v*" + workflow_dispatch: + +permissions: + contents: write + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + # Linux + build-linux: + name: Build on Ubuntu + runs-on: ubuntu-22.04 + container: + image: crossdesk/ubuntu22.04:latest + options: --user root + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Build CrossDesk + env: + CUDA_PATH: /usr/local/cuda + XMAKE_GLOBALDIR: /data + run: | + ls -la $XMAKE_GLOBALDIR + xmake b -vy --root crossdesk + + # macOS + build-macos: + name: Build on macOS + runs-on: ${{ matrix.runner }} + strategy: + matrix: + include: + - arch: x86_64 + runner: macos-13 + cache-key: intel + out-dir: ./build/macosx/x86_64/release/crossdesk + artifact-name: crossdesk-macos-x86_64 + package_script: ./scripts/macosx/pkg_x86_64.sh + - arch: arm64 + runner: macos-14 + cache-key: arm + out-dir: ./build/macosx/arm64/release/crossdesk + artifact-name: crossdesk-macos-arm64 + package_script: ./scripts/macosx/pkg_arm64.sh + steps: + - name: Cache xmake dependencies + uses: actions/cache@v4 + with: + path: ~/.xmake/packages + key: ${{ runner.os }}-xmake-deps-${{ matrix.cache-key }}-${{ hashFiles('**/xmake.lua') }} + restore-keys: | + ${{ runner.os }}-xmake-deps-${{ matrix.cache-key }}- + + - name: Install xmake + run: brew install xmake + + - name: Checkout code + uses: actions/checkout@v4 + + - name: Initialize submodules + run: git submodule update --init --recursive + + - name: Build CrossDesk + run: xmake b -vy crossdesk + + # Windows + build-windows: + name: Build on Windows + runs-on: windows-2022 + env: + XMAKE_GLOBALDIR: D:\xmake_global + steps: + - name: Cache xmake dependencies + uses: actions/cache@v4 + with: + path: D:\xmake_global\.xmake\packages + key: ${{ runner.os }}-xmake-deps-intel-${{ hashFiles('**/xmake.lua') }} + restore-keys: | + ${{ runner.os }}-xmake-deps-intel- + + - name: Install xmake + run: | + Invoke-Expression (Invoke-Webrequest 'https://raw.githubusercontent.com/tboox/xmake/master/scripts/get.ps1' -UseBasicParsing).Content + echo "C:\Users\runneradmin\xmake" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + xmake create cuda + Set-Location cuda + xmake g --theme=plain + $cudaPath = "" + $packagesPath = "D:\xmake_global\.xmake\packages" + + if (Test-Path $packagesPath) { + Write-Host "Packages directory exists: $packagesPath" + try { + $info = xmake require --info "cuda 12.6.3" 2>$null + if ($null -ne $info -and $info -ne "") { + $cudaPath = (($info | Select-String installdir).ToString() -replace '.*installdir:\s*','').Trim() + Write-Host "Resolved CUDA_PATH = $cudaPath" + } + } catch {} + } else { + Write-Host "Packages directory not found: $packagesPath" + Write-Host "Installing CUDA package..." + xmake require -vy "cuda 12.6.3" + $info = xmake require --info "cuda 12.6.3" + $cudaPath = (($info | Select-String installdir).ToString() -replace '.*installdir:\s*','').Trim() + Write-Host "Resolved CUDA_PATH = $cudaPath" + } + + echo "CUDA_PATH=$cudaPath" >> $env:GITHUB_ENV + Write-Host "Resolved CUDA_PATH = $cudaPath" + Pop-Location + + - name: Checkout code + uses: actions/checkout@v4 + + - name: Initialize submodules + run: git submodule update --init --recursive + + - name: Build CrossDesk + run: xmake b -vy crossdesk diff --git a/.github/workflows/release.yaml.bak b/.github/workflows/release.yaml.bak new file mode 100644 index 0000000..e189f4e --- /dev/null +++ b/.github/workflows/release.yaml.bak @@ -0,0 +1,213 @@ +name: Build and Release CrossDesk + +on: + push: + branches: [release] + tags: + - "v*" + workflow_dispatch: + +permissions: + contents: write + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + build: + name: Build on (${{ matrix.runner }} ${{ matrix.arch }}) + runs-on: ${{ matrix.runner }} + strategy: + matrix: + include: + - arch: x86_64 + platform: macos + runner: macos-13 + cache-key: intel + out-dir: ./build/macosx/x86_64/release/crossdesk + artifact-name: crossdesk-macos-x86_64 + package_script: ./scripts/macosx/pkg_x86_64.sh + - arch: arm64 + platform: macos + runner: macos-14 + cache-key: arm + out-dir: ./build/macosx/arm64/release/crossdesk + artifact-name: crossdesk-macos-arm64 + package_script: ./scripts/macosx/pkg_arm64.sh + - arch: x86_64 + platform: windows + runner: windows-2022 + cache-key: intel + out-dir: ./build/win/x86_64/release/crossdesk + artifact-name: crossdesk-win-x86_64 + package_script: ./scripts/windows/nsis_script.nsi + - arch: x86_64 + platform: linux + runner: ubuntu-22.04 + cache-key: intel + out-dir: ./build/linux/x86_64/release/crossdesk + artifact-name: crossdesk-linux-x86_64 + package_script: ./scripts/linux/pkg_x86_64.sh + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Initialize submodules + run: git submodule update --init --recursive + + - name: Install xmake + if: runner.os == 'macOS' + run: brew install xmake + + - name: Install xmake (Ubuntu) + if: runner.os == 'Linux' + run: | + curl -fsSL https://xmake.io/shget.text | bash + source ~/.xmake/profile + + - name: Install system dependencies (Ubuntu) + if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt-get -y install \ + libxcb-randr0-dev \ + libxcb-xtest0-dev \ + libxcb-xinerama0-dev \ + libxcb-shape0-dev \ + libxcb-xkb-dev \ + libxcb-xfixes0-dev \ + libxv-dev \ + libxtst-dev \ + libasound2-dev \ + libsndio-dev \ + libxcb-shm0-dev \ + libxrandr-dev \ + libpulse-dev + + - name: Install xmake (Windows) + if: runner.os == 'Windows' + run: | + Invoke-Expression (Invoke-Webrequest 'https://raw.githubusercontent.com/tboox/xmake/master/scripts/get.ps1' -UseBasicParsing).Content + echo "C:\Users\runneradmin\xmake" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + + - name: Build CrossDesk + run: xmake b -vy crossdesk + + - name: Cache xmake dependencies (Linux/macOS) + if: runner.os != 'Windows' + uses: actions/cache@v4 + with: + path: ~/.xmake/packages + key: ${{ runner.os }}-xmake-deps-${{ matrix.cache-key }}-${{ hashFiles('**/xmake.lua') }} + restore-keys: | + ${{ runner.os }}-xmake-deps-${{ matrix.cache-key }}- + + - name: Get LOCALAPPDATA path (Windows) + if: runner.os == 'Windows' + id: localappdata + run: | + echo "localappdata=$env:LOCALAPPDATA" >> $env:GITHUB_OUTPUT + shell: pwsh + + - name: Cache xmake dependencies (Windows) + if: runner.os == 'Windows' + uses: actions/cache@v4 + with: + path: ${{ steps.localappdata.outputs.localappdata }}\.xmake\packages + key: ${{ runner.os }}-xmake-deps-${{ matrix.cache-key }}-${{ hashFiles('**/xmake.lua') }} + restore-keys: | + ${{ runner.os }}-xmake-deps-${{ matrix.cache-key }}- + + + # - name: Decode and save certificate + # shell: bash + # run: | + # mkdir -p certs + # echo "${{ secrets.CROSSDESK_CERT_BASE64 }}" | base64 --decode > certs/cert.crt + + # - name: Package CrossDesk app + # if: runner.os != 'Windows' + # run: | + # chmod +x ${{ matrix.package_script }} + # ${{ matrix.package_script }} + + # - name: Package CrossDesk app (Windows) + # if: runner.os == 'Windows' + # run: "& makensis.exe ${{ matrix.package_script }}" + # working-directory: ${{ github.workspace }} + + # - name: Upload build artifacts + # uses: actions/upload-artifact@v4 + # with: + # name: ${{ matrix.artifact-name }}-pkg + # path: crossdesk-${{ matrix.platform }}-${{ matrix.arch }}-v0.0.1.pkg + + # - name: Move files to release dir + # run: | + # mkdir -p release + # cp crossdesk-${{ matrix.platform }}-${{ matrix.arch }}-v0.0.1.pkg release/ + + # release: + # name: Publish Release + # if: startsWith(github.ref, 'refs/tags/v') + # needs: build + # runs-on: ubuntu-latest + + # steps: + # - name: Checkout repository + # uses: actions/checkout@v4 + + # - name: Download all artifacts + # uses: actions/download-artifact@v4 + # with: + # path: artifacts + + # - name: Extract version number + # id: version + # run: | + # VERSION="${GITHUB_REF##*/}" + # VERSION_NUM="${VERSION#v}" + # echo "VERSION_NUM=${VERSION_NUM}" >> $GITHUB_OUTPUT + + # - name: Rename artifacts + # run: | + # mkdir -p release + # cp artifacts/crossdesk-macos-x86_64-pkg/* release/crossdesk-macos-x86_64-v${{ steps.version.outputs.VERSION_NUM }}.pkg + # cp artifacts/crossdesk-macos-arm64-pkg/* release/crossdesk-macos-aarch64-v${{ steps.version.outputs.VERSION_NUM }}.pkg + + # - name: Upload to Versioned GitHub Release + # uses: softprops/action-gh-release@v2 + # with: + # tag_name: v${{ steps.version.outputs.VERSION_NUM }} + # name: Release v${{ steps.version.outputs.VERSION_NUM }} + # draft: false + # prerelease: false + # files: release/* + # generate_release_notes: false + # body: | + # Binary release only. Source code is not included. + + # - name: Upload to 'latest' Release + # run: | + # mkdir -p release/latest + # cp release/crossdesk-macos-x86_64-v${{ steps.version.outputs.VERSION_NUM }}.pkg release/latest/crossdesk-macos-x86_64-latest.pkg + # cp release/crossdesk-macos-aarch64-v${{ steps.version.outputs.VERSION_NUM }}.pkg release/latest/crossdesk-macos-aarch64-latest.pkg + + # - name: Create or update 'latest' tag + # run: | + # git config user.name "github-actions[bot]" + # git config user.email "github-actions[bot]@users.noreply.github.com" + # git tag -f latest + # git push origin latest --force + + # - name: Upload to GitHub Release (latest) + # uses: softprops/action-gh-release@v2 + # with: + # tag_name: latest + # name: Latest Release + # draft: false + # prerelease: false + # files: | + # release/latest/crossdesk-macos-*.pkg + # generate_release_notes: false diff --git a/config/config.ini b/config/config.ini deleted file mode 100644 index 0dd66bc..0000000 --- a/config/config.ini +++ /dev/null @@ -1,19 +0,0 @@ -[signal server] -ip = 150.158.81.30 -port = 9099 - -[stun server] -ip = 150.158.81.30 -port = 3478 - -[turn server] -ip = 150.158.81.30 -port = 3478 -username = dijunkun -password = dijunkunpw - -[hardware acceleration] -turn_on = false - -[av1 encoding] -turn_on = true \ No newline at end of file diff --git a/icon/app.rc b/icons/app.rc similarity index 100% rename from icon/app.rc rename to icons/app.rc diff --git a/icon/app_icon.ico b/icons/app_icon.ico similarity index 100% rename from icon/app_icon.ico rename to icons/app_icon.ico diff --git a/icons/crossdesk.icns b/icons/crossdesk.icns new file mode 100644 index 0000000..99245bf Binary files /dev/null and b/icons/crossdesk.icns differ diff --git a/icons/crossdesk.ico b/icons/crossdesk.ico new file mode 100644 index 0000000..e51034c Binary files /dev/null and b/icons/crossdesk.ico differ diff --git a/icons/crossdesk.png b/icons/crossdesk.png new file mode 100644 index 0000000..982ac91 Binary files /dev/null and b/icons/crossdesk.png differ diff --git a/scripts/linux/pkg_x86_64.sh b/scripts/linux/pkg_x86_64.sh new file mode 100644 index 0000000..b71b424 --- /dev/null +++ b/scripts/linux/pkg_x86_64.sh @@ -0,0 +1,126 @@ +#!/bin/bash +set -e + +# 配置变量 +APP_NAME="CrossDesk" +APP_VERSION="0.0.1" +ARCHITECTURE="amd64" +MAINTAINER="Junkun Di " +DESCRIPTION="A simple cross-platform remote desktop client." + +# 目录结构 +DEB_DIR="$APP_NAME-$APP_VERSION" +DEBIAN_DIR="$DEB_DIR/DEBIAN" +BIN_DIR="$DEB_DIR/usr/local/bin" +CERT_SRC_DIR="$DEB_DIR/opt/$APP_NAME/certs" # 用于中转安装时分发 +ICON_DIR="$DEB_DIR/usr/share/icons/hicolor/256x256/apps" +DESKTOP_DIR="$DEB_DIR/usr/share/applications" + +# 清理已有的打包文件夹 +rm -rf "$DEB_DIR" + +# 创建目录结构 +mkdir -p "$DEBIAN_DIR" "$BIN_DIR" "$CERT_SRC_DIR" "$ICON_DIR" "$DESKTOP_DIR" + +# 复制二进制文件 +cp build/linux/x86_64/release/crossdesk "$BIN_DIR" + +# 复制证书文件(将来通过 postinst 拷贝到每个用户 XDG_CONFIG_HOME) +cp certs/crossdesk.cn_root.crt "$CERT_SRC_DIR/crossdesk.cn_root.crt" + +# 复制图标文件 +cp icons/crossdesk.png "$ICON_DIR/crossdesk.png" + +# 设置可执行权限 +chmod +x "$BIN_DIR/crossdesk" + +# 创建 control 文件 +cat > "$DEBIAN_DIR/control" << EOF +Package: $APP_NAME +Version: $APP_VERSION +Architecture: $ARCHITECTURE +Maintainer: $MAINTAINER +Description: $DESCRIPTION +Depends: libc6 (>= 2.29), libstdc++6 (>= 9), libx11-6, libxcb1, + libxcb-randr0, libxcb-xtest0, libxcb-xinerama0, libxcb-shape0, + libxcb-xkb1, libxcb-xfixes0, libxv1, libxtst6, libasound2, + libsndio7.0, libxcb-shm0, libpulse0, nvidia-cuda-toolkit +Priority: optional +Section: utils +EOF + +# 创建 desktop 文件 +cat > "$DESKTOP_DIR/$APP_NAME.desktop" << EOF +[Desktop Entry] +Version=$APP_VERSION +Name=$APP_NAME +Comment=$DESCRIPTION +Exec=/usr/local/bin/crossdesk +Icon=crossdesk +Terminal=false +Type=Application +Categories=Utility; +EOF + +# 创建卸载脚本 postrm +cat > "$DEBIAN_DIR/postrm" << EOF +#!/bin/bash +# post-removal script for $APP_NAME + +set -e + +if [ "\$1" = "remove" ] || [ "\$1" = "purge" ]; then + rm -f /usr/local/bin/crossdesk + rm -f /usr/share/icons/hicolor/256x256/apps/crossdesk.png + rm -f /usr/share/applications/$APP_NAME.desktop + rm -rf /opt/$APP_NAME +fi + +exit 0 +EOF + +chmod +x "$DEBIAN_DIR/postrm" + +# 创建安装后脚本 postinst(拷贝证书到每个用户 XDG_CONFIG_HOME) +cat > "$DEBIAN_DIR/postinst" << 'EOF' +#!/bin/bash +set -e + +CERT_SRC="/opt/CrossDesk/certs" +CERT_FILE="crossdesk.cn_root.crt" + +# 处理每个普通用户的配置目录 +for user_home in /home/*; do + [ -d "$user_home" ] || continue + username=$(basename "$user_home") + config_dir="$user_home/.config/CrossDesk/certs" + target="$config_dir/$CERT_FILE" + + if [ ! -f "$target" ]; then + mkdir -p "$config_dir" + cp "$CERT_SRC/$CERT_FILE" "$target" + chown -R "$username:$username" "$user_home/.config/CrossDesk" + echo "✔ Installed cert for $username at $target" + fi +done + +# 处理 root 用户(可选) +if [ -d "/root" ]; then + config_dir="/root/.config/CrossDesk/certs" + mkdir -p "$config_dir" + cp "$CERT_SRC/$CERT_FILE" "$config_dir/$CERT_FILE" + chown -R root:root /root/.config/CrossDesk +fi + +exit 0 +EOF + +chmod +x "$DEBIAN_DIR/postinst" + +# 构建 .deb 包 +dpkg-deb --build "$DEB_DIR" + +# 清理构建目录 +rm -rf "$DEB_DIR" + +echo "✅ Deb package for $APP_NAME created successfully." diff --git a/scripts/macosx/pkg_arm64.sh b/scripts/macosx/pkg_arm64.sh new file mode 100644 index 0000000..0f27cf0 --- /dev/null +++ b/scripts/macosx/pkg_arm64.sh @@ -0,0 +1,152 @@ +#!/bin/bash +set -e # 遇错退出 + +# === 配置变量 === +APP_NAME="crossdesk" +APP_NAME_UPPER="CrossDesk" # 这个变量用来指定大写的应用名 +EXECUTABLE_PATH="./build/macosx/arm64/release/crossdesk" # 可执行文件路径 +APP_VERSION="0.0.1" +PLATFORM="macos" +ARCH="arm64" +IDENTIFIER="cn.crossdesk.app" +ICON_PATH="./icons/crossdesk.icns" # .icns 图标路径 +MACOS_MIN_VERSION="10.12" + +CERTS_SOURCE="./certs" # 你的证书文件目录,里面放所有需要安装的文件 +CERT_NAME="crossdesk.cn_root.crt" + +APP_BUNDLE="${APP_NAME_UPPER}.app" # 使用大写的应用名称 +CONTENTS_DIR="${APP_BUNDLE}/Contents" +MACOS_DIR="${CONTENTS_DIR}/MacOS" +RESOURCES_DIR="${CONTENTS_DIR}/Resources" + +PKG_NAME="${APP_NAME}-${PLATFORM}-${ARCH}-v${APP_VERSION}.pkg" # 保持安装包名称小写 +DMG_NAME="${APP_NAME}-${PLATFORM}-${ARCH}-v${APP_VERSION}.dmg" +VOL_NAME="Install ${APP_NAME_UPPER}" + +# === 清理旧文件 === +echo "🧹 清理旧文件..." +rm -rf "${APP_BUNDLE}" "${PKG_NAME}" "${DMG_NAME}" build_pkg_temp CrossDesk_dmg_temp + +mkdir -p build_pkg_temp + +# === 创建 .app 结构 === +echo "📦 创建 ${APP_BUNDLE}..." +mkdir -p "${MACOS_DIR}" "${RESOURCES_DIR}" + +echo "🚚 拷贝可执行文件..." +cp "${EXECUTABLE_PATH}" "${MACOS_DIR}/${APP_NAME_UPPER}" # 拷贝时使用大写的应用名称 +chmod +x "${MACOS_DIR}/${APP_NAME_UPPER}" + +# === 图标 === +if [ -f "${ICON_PATH}" ]; then + cp "${ICON_PATH}" "${RESOURCES_DIR}/crossedesk.icns" + ICON_KEY="CFBundleIconFilecrossedesk.icns" + echo "🎨 图标添加完成" +else + ICON_KEY="" + echo "⚠️ 未找到图标文件,跳过图标设置" +fi + +# === 生成 Info.plist === +echo "📝 生成 Info.plist..." +cat > "${CONTENTS_DIR}/Info.plist" < + + + + CFBundleName + ${APP_NAME_UPPER} + CFBundleDisplayName + ${APP_NAME_UPPER} + CFBundleIdentifier + ${IDENTIFIER} + CFBundleVersion + ${APP_VERSION} + CFBundleShortVersionString + ${APP_VERSION} + CFBundleExecutable + ${APP_NAME_UPPER} + CFBundlePackageType + APPL + ${ICON_KEY} + LSMinimumSystemVersion + ${MACOS_MIN_VERSION} + NSHighResolutionCapable + + NSCameraUsageDescription + 应用需要访问摄像头 + NSMicrophoneUsageDescription + 应用需要访问麦克风 + NSAppleEventsUsageDescription + 应用需要发送 Apple 事件 + NSScreenCaptureUsageDescription + 应用需要录屏权限以捕获屏幕内容 + + +EOF + +echo "✅ .app 创建完成" + +# === 构建应用组件包 === +echo "📦 构建应用组件包..." +pkgbuild \ + --identifier "${IDENTIFIER}" \ + --version "${APP_VERSION}" \ + --install-location "/Applications" \ + --component "${APP_BUNDLE}" \ + build_pkg_temp/${APP_NAME}-component.pkg + +# === 构建 certs 组件包 === +# 先创建脚本目录和脚本文件 +mkdir -p scripts + +cat > scripts/postinstall <<'EOF' +#!/bin/bash +USER_HOME=$( /usr/bin/stat -f "%Su" /dev/console ) +HOME_DIR=$( /usr/bin/dscl . -read /Users/$USER_HOME NFSHomeDirectory | awk '{print $2}' ) + +DEST="$HOME_DIR/Library/Application Support/CrossDesk/certs" + +mkdir -p "$DEST" +cp -R "/Library/Application Support/CrossDesk/certs/"* "$DEST/" + +exit 0 +EOF + +chmod +x scripts/postinstall + +# 构建 certs 组件包,增加 --scripts 参数指定 postinstall +pkgbuild \ + --root "${CERTS_SOURCE}" \ + --identifier "${IDENTIFIER}.certs" \ + --version "${APP_VERSION}" \ + --install-location "/Library/Application Support/CrossDesk/certs" \ + --scripts scripts \ + build_pkg_temp/${APP_NAME}-certs.pkg + +# === 组合产品包 === +echo "🏗️ 组合最终安装包..." +productbuild \ + --package build_pkg_temp/${APP_NAME}-component.pkg \ + --package build_pkg_temp/${APP_NAME}-certs.pkg \ + "${PKG_NAME}" + +echo "✅ 生成安装包完成:${PKG_NAME}" + +# === 可选:打包成 DMG === +echo "📦 可选打包成 DMG..." +mkdir -p CrossDesk_dmg_temp +cp "${PKG_NAME}" CrossDesk_dmg_temp/ +ln -s /Applications CrossDesk_dmg_temp/Applications + +hdiutil create -volname "${VOL_NAME}" \ + -srcfolder CrossDesk_dmg_temp \ + -ov -format UDZO "${DMG_NAME}" + +rm -rf CrossDesk_dmg_temp build_pkg_temp scripts ${APP_BUNDLE} ${DMG_NAME} + +echo "🎉 所有打包完成:" +echo " ✔️ 应用:${APP_BUNDLE}" +echo " ✔️ 安装包:${PKG_NAME}" +echo " ✔️ 镜像包(可选):${DMG_NAME}" \ No newline at end of file diff --git a/scripts/macosx/pkg_x86_64.sh b/scripts/macosx/pkg_x86_64.sh new file mode 100644 index 0000000..d30fc23 --- /dev/null +++ b/scripts/macosx/pkg_x86_64.sh @@ -0,0 +1,152 @@ +#!/bin/bash +set -e # 遇错退出 + +# === 配置变量 === +APP_NAME="crossdesk" +APP_NAME_UPPER="CrossDesk" # 这个变量用来指定大写的应用名 +EXECUTABLE_PATH="build/macosx/x86_64/release/crossdesk" # 可执行文件路径 +APP_VERSION="0.0.1" +PLATFORM="macos" +ARCH="x86_64" +IDENTIFIER="cn.crossdesk.app" +ICON_PATH="icons/crossdesk.icns" # .icns 图标路径 +MACOS_MIN_VERSION="10.12" + +CERTS_SOURCE="certs" # 你的证书文件目录,里面放所有需要安装的文件 +CERT_NAME="crossdesk.cn_root.crt" + +APP_BUNDLE="${APP_NAME_UPPER}.app" # 使用大写的应用名称 +CONTENTS_DIR="${APP_BUNDLE}/Contents" +MACOS_DIR="${CONTENTS_DIR}/MacOS" +RESOURCES_DIR="${CONTENTS_DIR}/Resources" + +PKG_NAME="${APP_NAME}-${PLATFORM}-${ARCH}-v${APP_VERSION}.pkg" # 保持安装包名称小写 +DMG_NAME="${APP_NAME}-${PLATFORM}-${ARCH}-v${APP_VERSION}.dmg" +VOL_NAME="Install ${APP_NAME_UPPER}" + +# === 清理旧文件 === +echo "🧹 清理旧文件..." +rm -rf "${APP_BUNDLE}" "${PKG_NAME}" "${DMG_NAME}" build_pkg_temp CrossDesk_dmg_temp + +mkdir -p build_pkg_temp + +# === 创建 .app 结构 === +echo "📦 创建 ${APP_BUNDLE}..." +mkdir -p "${MACOS_DIR}" "${RESOURCES_DIR}" + +echo "🚚 拷贝可执行文件..." +cp "${EXECUTABLE_PATH}" "${MACOS_DIR}/${APP_NAME_UPPER}" # 拷贝时使用大写的应用名称 +chmod +x "${MACOS_DIR}/${APP_NAME_UPPER}" + +# === 图标 === +if [ -f "${ICON_PATH}" ]; then + cp "${ICON_PATH}" "${RESOURCES_DIR}/crossedesk.icns" + ICON_KEY="CFBundleIconFilecrossedesk.icns" + echo "🎨 图标添加完成" +else + ICON_KEY="" + echo "⚠️ 未找到图标文件,跳过图标设置" +fi + +# === 生成 Info.plist === +echo "📝 生成 Info.plist..." +cat > "${CONTENTS_DIR}/Info.plist" < + + + + CFBundleName + ${APP_NAME_UPPER} + CFBundleDisplayName + ${APP_NAME_UPPER} + CFBundleIdentifier + ${IDENTIFIER} + CFBundleVersion + ${APP_VERSION} + CFBundleShortVersionString + ${APP_VERSION} + CFBundleExecutable + ${APP_NAME_UPPER} + CFBundlePackageType + APPL + ${ICON_KEY} + LSMinimumSystemVersion + ${MACOS_MIN_VERSION} + NSHighResolutionCapable + + NSCameraUsageDescription + 应用需要访问摄像头 + NSMicrophoneUsageDescription + 应用需要访问麦克风 + NSAppleEventsUsageDescription + 应用需要发送 Apple 事件 + NSScreenCaptureUsageDescription + 应用需要录屏权限以捕获屏幕内容 + + +EOF + +echo "✅ .app 创建完成" + +# === 构建应用组件包 === +echo "📦 构建应用组件包..." +pkgbuild \ + --identifier "${IDENTIFIER}" \ + --version "${APP_VERSION}" \ + --install-location "/Applications" \ + --component "${APP_BUNDLE}" \ + build_pkg_temp/${APP_NAME}-component.pkg + +# === 构建 certs 组件包 === +# 先创建脚本目录和脚本文件 +mkdir -p scripts + +cat > scripts/postinstall <<'EOF' +#!/bin/bash +USER_HOME=$( /usr/bin/stat -f "%Su" /dev/console ) +HOME_DIR=$( /usr/bin/dscl . -read /Users/$USER_HOME NFSHomeDirectory | awk '{print $2}' ) + +DEST="$HOME_DIR/Library/Application Support/CrossDesk/certs" + +mkdir -p "$DEST" +cp -R "/Library/Application Support/CrossDesk/certs/"* "$DEST/" + +exit 0 +EOF + +chmod +x scripts/postinstall + +# 构建 certs 组件包,增加 --scripts 参数指定 postinstall +pkgbuild \ + --root "${CERTS_SOURCE}" \ + --identifier "${IDENTIFIER}.certs" \ + --version "${APP_VERSION}" \ + --install-location "/Library/Application Support/CrossDesk/certs" \ + --scripts scripts \ + build_pkg_temp/${APP_NAME}-certs.pkg + +# === 组合产品包 === +echo "🏗️ 组合最终安装包..." +productbuild \ + --package build_pkg_temp/${APP_NAME}-component.pkg \ + --package build_pkg_temp/${APP_NAME}-certs.pkg \ + "${PKG_NAME}" + +echo "✅ 生成安装包完成:${PKG_NAME}" + +# === 可选:打包成 DMG === +echo "📦 可选打包成 DMG..." +mkdir -p CrossDesk_dmg_temp +cp "${PKG_NAME}" CrossDesk_dmg_temp/ +ln -s /Applications CrossDesk_dmg_temp/Applications + +hdiutil create -volname "${VOL_NAME}" \ + -srcfolder CrossDesk_dmg_temp \ + -ov -format UDZO "${DMG_NAME}" + +rm -rf CrossDesk_dmg_temp build_pkg_temp scripts ${APP_BUNDLE} ${DMG_NAME} + +echo "🎉 所有打包完成:" +echo " ✔️ 应用:${APP_BUNDLE}" +echo " ✔️ 安装包:${PKG_NAME}" +echo " ✔️ 镜像包(可选):${DMG_NAME}" \ No newline at end of file diff --git a/scripts/windows/nsis_script.nsi b/scripts/windows/nsis_script.nsi new file mode 100644 index 0000000..3389454 --- /dev/null +++ b/scripts/windows/nsis_script.nsi @@ -0,0 +1,99 @@ +; ýűʹ HM VNISEdit ű༭򵼲 + +; װʼ峣 +!define PRODUCT_NAME "CrossDesk" +!define PRODUCT_VERSION "0.0.1" +!define PRODUCT_PUBLISHER "CrossDesk" +!define PRODUCT_WEB_SITE "https://www.crossdesk.cn/" +!define APP_NAME "CrossDesk" +!define UNINSTALL_REG_KEY "CrossDesk" + +;ﰲװͼ +Icon "icons\crossdesk.ico" +!define MUI_ICON "icons\crossdesk.ico" + +;ѹ +SetCompressor /FINAL lzma + +;ԱȨޣдHKLMҪ +RequestExecutionLevel admin + +; ------ MUI ִ涨 ------ +!include "MUI.nsh" +!define MUI_ABORTWARNING +!insertmacro MUI_PAGE_WELCOME +!insertmacro MUI_PAGE_DIRECTORY +!insertmacro MUI_PAGE_INSTFILES +!insertmacro MUI_PAGE_FINISH +!insertmacro MUI_LANGUAGE "SimpChinese" +!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS +; ------ MUI ------ + +Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" +OutFile "CrossDesk-${PRODUCT_VERSION}.exe" +InstallDir "$PROGRAMFILES\CrossDesk" +ShowInstDetails show + +Section "MainSection" + SetOutPath "$INSTDIR" + SetOverwrite ifnewer + + ;ļ + File /oname=crossdesk.exe "build\windows\x64\release\crossdesk\crossdesk.exe" + + ; ? ͼļװĿ¼ + File "icons\crossdesk.ico" + + ;джϢ + WriteUninstaller "$INSTDIR\uninstall.exe" + + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL_REG_KEY}" "DisplayName" "${PRODUCT_NAME}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL_REG_KEY}" "UninstallString" "$INSTDIR\uninstall.exe" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL_REG_KEY}" "DisplayVersion" "${PRODUCT_VERSION}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL_REG_KEY}" "Publisher" "${PRODUCT_PUBLISHER}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL_REG_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL_REG_KEY}" "DisplayIcon" "$INSTDIR\crossdesk.ico" + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL_REG_KEY}" "NoModify" 1 + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL_REG_KEY}" "NoRepair" 1 +SectionEnd + +Section "Cert" + SetOutPath "$APPDATA\CrossDesk\certs" + File /r "certs\crossdesk.cn_root.crt" +SectionEnd + +Section -AdditionalIcons + ;ݷʽ + CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\crossdesk.exe" "" "$INSTDIR\crossdesk.ico" + + ;↑ʼ˵ݷʽ + CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}.lnk" "$INSTDIR\crossdesk.exe" "" "$INSTDIR\crossdesk.ico" + + ;ҳݷʽ棩 + WriteIniStr "$DESKTOP\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}" +SectionEnd + +Section "Uninstall" + ; ɾжس + Delete "$INSTDIR\crossdesk.exe" + Delete "$INSTDIR\uninstall.exe" + + ; ݹɾװĿ¼ + RMDir /r "$INSTDIR" + + ; ɾͿʼ˵ݷʽ + Delete "$DESKTOP\${PRODUCT_NAME}.lnk" + Delete "$DESKTOP\${PRODUCT_NAME}.url" + Delete "$SMPROGRAMS\${PRODUCT_NAME}.lnk" + + ; ɾעж + DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL_REG_KEY}" + + ; ݹɾû AppData е CrossDesk ļ + RMDir /r "$APPDATA\CrossDesk" + RMDir /r "$LOCALAPPDATA\CrossDesk" +SectionEnd + + +Section -Post +SectionEnd \ No newline at end of file diff --git a/xmake.lua b/xmake.lua index 32191c3..cd280b8 100644 --- a/xmake.lua +++ b/xmake.lua @@ -30,11 +30,10 @@ if is_os("windows") then "Imm32", "iphlpapi") add_cxflags("/WX") elseif is_os("linux") then - add_requires("libpulse") add_links("pulse-simple", "pulse") add_requires("libyuv") add_syslinks("pthread", "dl") - add_links("SDL2", "cuda", "nvidia-encode", "nvcuvid", "asound", "X11", "Xtst", "Xrandr") + add_links("SDL2", "asound", "X11", "Xtst", "Xrandr") add_cxflags("-Wno-unused-variable") elseif is_os("macosx") then add_links("SDL2", "SDL2main") @@ -146,7 +145,7 @@ target("crossdesk") set_kind("binary") add_deps("rd_log", "common", "single_window") if is_os("windows") then - add_files("icon/app.rc") + add_files("icons/app.rc") elseif is_os("macosx") then -- add_rules("xcode.application") -- add_files("Info.plist")