diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index efaecb4..2b7ed2d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,11 @@ permissions: contents: read jobs: + conversion-engines: + if: github.event_name != 'schedule' + uses: ./.github/workflows/conversion-bundle.yml windows: + needs: conversion-engines if: github.event_name != 'schedule' runs-on: windows-latest timeout-minutes: 30 @@ -39,7 +43,15 @@ jobs: & ./tests/DailyToolkit.Desktop.Tests/bin/Release/net10.0-windows10.0.26100.0/DailyToolkit.Desktop.Tests.exe --clipboard-native-filepack-ipc-checks if ($LASTEXITCODE -ne 0) { throw 'Explorer IPC fixture failed; see its bounded protocol trace.' } } - - name: Prepare local conversion test engines + - uses: actions/download-artifact@v8 + with: + name: conversion-ffmpeg-win-x64 + path: .local/conversion-tools/tools/ffmpeg + - uses: actions/download-artifact@v8 + with: + name: conversion-office-win-x64 + path: .local/conversion-tools/tools/libreoffice + - name: Prepare bundled conversion test engines timeout-minutes: 12 shell: pwsh run: ./scripts/prepare-conversion-checks.ps1 @@ -55,20 +67,14 @@ jobs: - name: Retain direct and transitive dependency audit shell: pwsh run: ./scripts/audit-dependencies.ps1 - - name: Keep quality reports, logs and fixture images - if: always() - uses: actions/upload-artifact@v7 - with: - name: quality-check-diagnostics - path: | - .local/quality-checks/** - .local/dependency-audit/** - .local/conversion-test-engines/** - if-no-files-found: warn - retention-days: 14 - name: Package portable app shell: pwsh run: ./scripts/publish.ps1 + - name: Check actual portable engines offline + shell: pwsh + run: | + [xml]$properties = Get-Content -LiteralPath Directory.Build.props -Raw + ./scripts/test-conversion-bundle.ps1 -PayloadDirectory "artifacts/DailyToolkit-$($properties.Project.PropertyGroup.Version)-win-x64" - name: Package installer shell: pwsh run: ./scripts/package-installer.ps1 -Compiler (Join-Path ${env:ProgramFiles(x86)} 'Inno Setup 6\ISCC.exe') @@ -81,6 +87,19 @@ jobs: artifacts/SHA256SUMS.txt if-no-files-found: error retention-days: 14 + - name: Keep quality reports, logs and fixture images + if: always() + timeout-minutes: 2 + continue-on-error: true + uses: actions/upload-artifact@v7 + with: + name: quality-check-diagnostics + path: | + .local/quality-checks/** + .local/dependency-audit/** + .local/conversion-test-engines/** + if-no-files-found: warn + retention-days: 14 installer: needs: windows runs-on: windows-latest diff --git a/.github/workflows/conversion-bundle.yml b/.github/workflows/conversion-bundle.yml new file mode 100644 index 0000000..266bc26 --- /dev/null +++ b/.github/workflows/conversion-bundle.yml @@ -0,0 +1,74 @@ +name: Prepare offline conversion engines +on: + workflow_call: +permissions: + contents: read +jobs: + ffmpeg: + runs-on: ubuntu-latest + timeout-minutes: 35 + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + - uses: actions/cache@v5 + id: cache + with: + path: .local/conversion-tools/tools/ffmpeg + key: conversion-ffmpeg-x64-${{ runner.os }}-${{ hashFiles('scripts/build-conversion-ffmpeg.sh', 'scripts/conversion-sources.json', 'scripts/conversion-manifest.py') }} + - name: Prepare cross compiler + if: steps.cache.outputs.cache-hit != 'true' + run: | + sudo apt-get update -qq + sudo apt-get install -y --no-install-recommends gcc-mingw-w64-x86-64-posix g++-mingw-w64-x86-64-posix nasm cmake ninja-build meson pkg-config make + - name: Build only the conversion engine + if: steps.cache.outputs.cache-hit != 'true' + run: bash scripts/build-conversion-ffmpeg.sh + - name: Verify engine source and inventory + run: python3 scripts/conversion-manifest.py verify .local/conversion-tools/tools/ffmpeg ffmpeg scripts/build-conversion-ffmpeg.sh scripts/conversion-sources.json + - uses: actions/upload-artifact@v7 + with: + name: conversion-ffmpeg-win-x64 + path: .local/conversion-tools/tools/ffmpeg/** + retention-days: 14 + - uses: actions/upload-artifact@v7 + if: failure() + with: + name: conversion-ffmpeg-build-logs + path: | + .local/conversion-ffmpeg/**/*.log + .local/conversion-ffmpeg/**/config.log + retention-days: 7 + office: + runs-on: windows-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + - uses: actions/cache@v5 + id: cache + with: + path: .local/conversion-tools/tools/libreoffice + key: conversion-office-x64-${{ runner.os }}-${{ hashFiles('scripts/prepare-conversion-office.ps1', 'scripts/stage-conversion-office.py', 'scripts/conversion-manifest.py') }} + - shell: pwsh + if: steps.cache.outputs.cache-hit != 'true' + run: ./scripts/prepare-conversion-office.ps1 + - name: Verify office source and inventory + shell: pwsh + run: | + python scripts/conversion-manifest.py verify .local/conversion-tools/tools/libreoffice libreoffice scripts/prepare-conversion-office.ps1 scripts/stage-conversion-office.py + if ($LASTEXITCODE -ne 0) { throw 'Prepared office component verification failed.' } + - uses: actions/upload-artifact@v7 + with: + name: conversion-office-win-x64 + path: .local/conversion-tools/tools/libreoffice/** + retention-days: 14 + - uses: actions/upload-artifact@v7 + if: always() + with: + name: conversion-office-selection + path: | + .local/conversion-office/**/*.json + .local/conversion-office/**/*.log + retention-days: 7 diff --git a/AGENTS.md b/AGENTS.md index 734167e..138b77d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -6,7 +6,8 @@ - 当前项目接续指定 `gpt-6.1-sol`、`xhigh`,不自行切换模型或推理强度;不能确认云端所选配置时如实说明。没有本次任务的明确要求时,不创建子代理。 - `scripts/check-cloud.ps1` 仅构建和检查 Core;通过不代表 Windows 桌面功能、管理员拖放或安装已验证。完整 Windows 检查继续使用现有工作流。 - 未获当前任务授权,不发布版本、不安装更新、不操作实际用户数据、自启、网络或 VPN,不关闭用户程序,不执行实机键鼠或 UAC 测试。保留已有未跟踪文件和本地证据。 -- 版本号遵循 `docs/VERSIONING.md`:`a` 为大版本,`b=0` 为大版本首个优化阶段、`b=1–9` 为功能阶段,`c` 为无固定硬上限的补丁号。本轮格式转换按用户指定为 `0.9.1`。 +- 版本号遵循 `docs/VERSIONING.md`:`a` 为大版本,`b=0` 为大版本首个优化阶段、`b=1–9` 为功能阶段,`c` 为无固定硬上限的补丁号。格式转换首发按用户指定为 `0.9.1`;离线内置作为 `0.9.2` 补丁开发,源码、构建包与公开发布分别核对。 +- 格式转换必须随软件离线可用、可携带,不要求用户另装引擎、运行库或选择程序路径。依赖只保留转换所需部分及许可、源码材料;精简后实际检查全部已有转换类型和进程退出,不能用开发机已安装的程序掩盖缺失项。详见 `docs/CONVERSION_BUNDLE.md`。 ## UI 一致性 diff --git a/Directory.Build.props b/Directory.Build.props index b4546d0..e09b77d 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -4,7 +4,7 @@ enable true true - 0.9.1 + 0.9.2 YMXKNebula Windows 桌面工具集,提供放大镜、浮笺、剪贴回溯、文件集装箱、格式转换和电脑信息查看。 https://github.com/YMXKNebula/DailyToolkit diff --git a/README.md b/README.md index 309d603..fdf155d 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Windows 桌面工具集:放大镜、浮笺、剪贴回溯、文件集装箱、格式转换和电脑信息。 -[下载最新版](https://github.com/YMXKNebula/DailyToolkit/releases/latest) · [安装与更新](docs/INSTALLATION.md) · [更新说明](docs/RELEASE_091.md) +[下载最新版](https://github.com/YMXKNebula/DailyToolkit/releases/latest) · [安装与更新](docs/INSTALLATION.md) · [更新说明](docs/RELEASE_092.md) ## 下载 @@ -37,7 +37,7 @@ Windows 桌面工具集:放大镜、浮笺、剪贴回溯、文件集装箱、 剪贴回溯默认关闭,开启后持续记录剪贴板,仅在本机加密保存。复制敏感内容前请暂停记录或排除来源应用,无法自动识别所有密码。文件默认只记路径,开启缓存后可保存文件副本。 -格式转换不调用在线服务或 AI,原文件保留。文档转换需要本机 LibreOffice,WebP 和部分音视频格式需要 FFmpeg;引擎不随程序捆绑,也不会自动下载。 +格式转换组件已内置,无需另装程序,不调用在线服务或 AI。原文件保留,携带时保留完整软件目录。 > 放大镜用于带反作弊的游戏时可能导致封号,请谨慎使用。 diff --git a/THIRD_PARTY_NOTICES.txt b/THIRD_PARTY_NOTICES.txt index 21fceb7..fe7681c 100644 --- a/THIRD_PARTY_NOTICES.txt +++ b/THIRD_PARTY_NOTICES.txt @@ -10,6 +10,25 @@ https://www.7-zip.org/ https://github.com/ip7z/7zip/releases/tag/26.04 Corresponding source: https://github.com/ip7z/7zip/releases/download/26.04/7z2604-src.7z +FFmpeg 9.0.2 (custom Windows x64 conversion build, separate process) +Copyright (c) the FFmpeg developers and codec library contributors. +GPL-2.0-or-later; x264 GPL, LAME LGPL, and BSD/Zlib codec libraries. +Only the exposed conversion targets are included; no player, ffprobe, network +protocols, capture devices or neural/AI processing is built. +License: tools/ffmpeg/LICENSE.txt and tools/ffmpeg/licenses/. +Complete pinned source archives and build recipe: tools/ffmpeg/sources/. +https://ffmpeg.org/ +https://github.com/FFmpeg/FFmpeg/commit/946fcce07b6dcd0331c8cc609192aeff5e1924f8 + +LibreOffice 26.2.6.3 (selected unmodified local conversion runtime) +Copyright (c) The Document Foundation and contributors. +MPL-2.0 and third-party licenses; includes the app-local Microsoft Visual C++ CRT. +No LibreOffice installation, updater, shell integration, Java/Python runtime, +dictionaries, help package or independent office entry points are installed. +Original notices: tools/libreoffice/license.txt, LICENSE.html and NOTICE. +Exact upstream binary, source access and runtime terms: tools/libreoffice/SOURCE.txt. +https://www.libreoffice.org/licenses/ + The application packages include the following components under the MIT License: AMD FidelityFX Contrast Adaptive Sharpening (adapted CAS filter weights) diff --git a/docs/CONVERSION_BUNDLE.md b/docs/CONVERSION_BUNDLE.md new file mode 100644 index 0000000..6e1723e --- /dev/null +++ b/docs/CONVERSION_BUNDLE.md @@ -0,0 +1,36 @@ +# 格式转换内置组件 + +0.9.2 补丁将转换组件放入安装版和便携版。正式 0.9.1 的标签、附件和校验文件保持原样;本页描述源码和构建方案,不代表 0.9.2 已公开发布。 + +## 运行与携带 + +保留完整软件目录即可运行,不要求用户安装 FFmpeg、LibreOffice、.NET 或 Java,也不下载模型、插件和运行库。程序按自身目录寻找 `tools/ffmpeg/ffmpeg.exe` 和 `tools/libreoffice/program/soffice.com`,旧设置中的绝对路径不参与启动。 + +转换程序只在任务中启动。结束、取消或停用后,等待自有进程、文件和管道释放;关闭或收起主窗口继续已提交任务。主程序及其他已启用工具仍有正常运行成本。 + +沿用主窗口 `FeatureSwitch`、`Card`、`SectionTitle`、`MutedText`、`AccentButton` 和输入、选择、列表模板;本补丁没有新增样式。移除外部程序路径配置,将“保存设置”放回转换选项。 + +## 组件选择 + +| 组件 | 固定来源与许可 | 随包内容 | +| --- | --- | --- | +| FFmpeg 9.0.2 | 官方源码 `946fcce07b6dcd0331c8cc609192aeff5e1924f8`;本构建 GPL-2.0-or-later | 一个静态转换程序、当前格式所需编码器及常用解码器、完整源码包、构建脚本和许可 | +| LibreOffice 26.2.6.3 | 官方 Windows x64 包,SHA-256 `f9877032fd908beb9c0ddf06df4af5c2e85f419c42e14876c4cce5aae5fb2660`;MPL-2.0 与第三方许可 | 文字、表格、演示转换所需运行库、注册表数据、共享控件配置、初始配置和字体 | +| Noto Sans CJK SC 2.004 | 官方固定源码版本,字体 SHA-256 `2c76254f6fc379fddfce0a7e84fb5385bb135d3e399294f6eeb6680d0365b74b`;OFL-1.1 | 一份常规中文字体及原许可;由 LibreOffice 私有加载,不注册系统字体 | +| Microsoft Visual C++ CRT | 已许可构建环境的 `VC/Redist/MSVC/.../x64/Microsoft.VC*.CRT`;Microsoft 条款 | 依赖检查实际需要的、签名有效且未改动的 DLL,放在转换程序目录;不运行运行库安装器 | + +FFmpeg 禁用网络协议、设备采集、硬件加速和未使用的输出功能,不构建播放器、探测工具或 AI 过滤器;Opus 的神经网络选项关闭。精简解码器仍保留常见电影音轨、Windows 录屏和无损输入,避免只按容器扩展名削减兼容性。 + +LibreOffice 不带帮助包、词典、扩展、图库、模板、Java/Python 运行时、独立办公入口、更新程序或系统集成。公共 DLL 的静态与延迟导入逐项检查,缺失依赖直接失败。共享控件配置及首次启动配置属于转换所需数据:缺少前者会使文档无法加载,缺少后者会使独立用户配置初始化失败。 + +许可证、版权和源码取得方式随各组件提供。FFmpeg 保留全部静态链接库的固定源码和构建配方;LibreOffice 保留官方许可、版权与对应源码说明;Microsoft DLL 的再分发遵循构建环境的 Visual Studio Distributable Code 条款。 + +## 构建与检查 + +`.github/workflows/conversion-bundle.yml` 准备两套固定组件。FFmpeg 在 Linux 交叉编译,输入摘要见 `scripts/conversion-sources.json`;LibreOffice 在可丢弃 Windows 环境中仅提取官方归档,再按依赖筛选。两者生成包含逐文件摘要和配方摘要的 `bundle.json`,不接纳额外文件。构建缓存按配方变化更新。 + +`scripts/publish.ps1` 验证组件及精确载荷后打包;安装版与便携版必须使用相同组件字节。`.local`、开发工具、报告、测试素材和实际用户数据不进入载荷。 + +Windows 检查保留原有完整质量门禁,并用实际便携目录和隔离安装目录运行 `scripts/test-conversion-bundle.ps1`:仅阻止测试自有程序出站联网,清除 PATH 中的外部程序目录,检查空路径和旧路径设置、WebP 透明度、现有音视频输出、文档往返及 PDF、私有中文字体嵌入、文件独占重开和进程退出。失败不能改用电脑上另装的引擎。 + +深浅主题、宽窄页面和 100/150/200% DPI 检查属于 WPF 渲染验收。Core 通过不能代表 Windows 桌面;隔离 Windows CI 也不代表 Windows 10/11 实机、混合 DPI、管理员拖放、真实安装、自启或用户电脑内存场景已验收。 diff --git a/docs/FORMAT_CONVERSION.md b/docs/FORMAT_CONVERSION.md index 7f6429c..ddb22b2 100644 --- a/docs/FORMAT_CONVERSION.md +++ b/docs/FORMAT_CONVERSION.md @@ -6,26 +6,24 @@ 在左侧启用“格式转换”,选择类型和输出格式,添加或拖入文件,选择保存位置后开始。每批最多 100 个文件,依次转换;原文件只读,同名输出自动更名。失败或取消的项目可以再次点击“开始转换”重试,已经完成的项目不重复执行。 -文件清单保留在本次运行中,重启后不恢复转换历史;输出位置、格式和本地引擎设置可以保存。 +文件清单保留在本次运行中,重启后不恢复转换历史;输出位置、格式和画质可以保存。 关闭或收起主窗口不打断已经提交的转换。停用功能会取消本批剩余任务,等待本次转换释放文件、流、编解码对象和自有进程;已经完成的结果保留。退出软件沿用现有任务确认与保存保护流程。 -## 格式与本地依赖 +## 支持格式 | 类型 | 输入 | 输出与说明 | | --- | --- | --- | | 图片 | PNG、JPG/JPEG、BMP、TIFF、静态 GIF | PNG、JPG、BMP、TIFF、PDF;使用 Windows 图片组件 | -| WebP | 静态 WebP,以及上述图片 | WebP 与其他图片格式互转,需要本地 FFmpeg | +| WebP | 静态 WebP,以及上述图片 | WebP 与其他图片格式互转 | | PDF | PDF | 每页输出 PNG 或 JPG,可选 72–300 DPI;使用 Windows PDF 组件 | -| 音频 | MP3、M4A、AAC、WAV、FLAC、OGG、WMA、Opus 及受支持视频中的音轨 | MP3、M4A、WAV 可使用 Windows 编解码器;FLAC、OGG 需要 FFmpeg | -| 视频 | MP4、M4V、MKV、MOV、AVI、WebM、WMV、MPEG | MP4、WMV 可使用 Windows 编解码器;MKV、WebM 需要 FFmpeg。实际输入支持取决于系统或所选引擎的解码器 | -| 文字 | DOCX、ODT、TXT | PDF、DOCX、ODT、TXT,需要 LibreOffice | -| 表格 | XLSX、ODS、CSV | PDF、XLSX、ODS、CSV,需要 LibreOffice;CSV 是单表文本格式,不保留多表、公式和样式 | -| 演示文稿 | PPTX、ODP | PDF、PPTX、ODP,需要 LibreOffice | +| 音频 | MP3、M4A、AAC、WAV、FLAC、OGG、WMA、Opus 及受支持视频中的音轨 | MP3、M4A、WAV、FLAC、OGG | +| 视频 | MP4、M4V、MKV、MOV、AVI、WebM、WMV、MPEG | MP4、WMV、MKV、WebM;支持常见 H.264、HEVC、AV1、VP8/VP9 等编码 | +| 文字 | DOCX、ODT、TXT | PDF、DOCX、ODT、TXT | +| 表格 | XLSX、ODS、CSV | PDF、XLSX、ODS、CSV;CSV 是单表文本格式,不保留多表、公式和样式 | +| 演示文稿 | PPTX、ODP | PDF、PPTX、ODP | -Windows N 等缺少媒体组件的系统,以及系统无法解码的输入,可以选择本地 FFmpeg。FFmpeg 构建需要包含所选编码器,例如 MP4 使用 libx264、WebP 使用 libwebp、WebM 使用 libvpx-vp9/libopus。配置 FFmpeg 后,音视频统一使用该引擎。 - -“本地引擎”只选择本机已有的 `ffmpeg.exe`、LibreOffice `program/soffice.exe` 或 `soffice.com`,不下载、安装或自动更新引擎。当前程序没有捆绑这两项依赖;准备好本地引擎后,转换过程不需要互联网。参考 [FFmpeg 官方下载说明](https://ffmpeg.org/download.html)和 [LibreOffice 官方下载](https://www.libreoffice.org/download/download-libreoffice/)。 +转换组件随软件提供,无需另装 FFmpeg、LibreOffice、.NET 或 Java。保留完整软件目录即可携带,转换时不下载程序、模型或插件。内置组件的许可和源码说明位于 `tools/`。 ## 结果与限制 @@ -33,10 +31,10 @@ Windows N 等缺少媒体组件的系统,以及系统无法解码的输入, - 尊重常见 EXIF 方向。多页 TIFF 转图片会逐页输出,转 TIFF/PDF 保留页序;动态图明确拒绝,不静默丢帧。 - 图片 PDF 每个输入文件生成一个 PDF,多页 TIFF 生成多页 PDF;不是 OCR,不提取或重建文字。PDF 转图片也不等于 PDF 转 Word。 - 单张图片或 PDF 页面最多 4000 万像素,图片输入不超过 512 MB,最多 500 页;多页 TIFF 输出总计最多 8000 万像素。 -- 音视频保留一个主要视频轨和一个主要音轨,不保留字幕、附件及全部原始元数据。系统转换保持源视频尺寸和帧率;不同编码器、色彩空间和 HDR 的效果仍需按实际素材检查。 +- 音视频保留一个主要视频轨和一个主要音轨,不保留字幕、附件及全部原始元数据。转换保持源视频尺寸和帧率,奇数宽高补到偶数;不同编码器、色彩空间和 HDR 的效果仍需按实际素材检查。 - Office 转换使用 LibreOffice 的格式实现,字体、复杂排版、公式和动画可能变化,不能承诺与 Microsoft Office 完全一致。旧二进制 DOC/XLS/PPT、受密码保护文件及 PDF 转可编辑 Office 文档不在本次范围。 - Office 使用本任务独立的配置和输入副本,禁用宏与更新检查,不接入已有用户窗口。带宏、需读取外部内容或外部数据公式的文档明确拒绝;普通网页超链接可以保留。 -- 输入、输出和引擎路径必须是本机磁盘路径;不接受 URL、UNC 或映射网络盘。不是任意第三方程序的网络沙箱,应选择可信的本地引擎。 +- 输入、输出必须是本机磁盘路径;不接受 URL、UNC 或映射网络盘。 ## 实现与检查 @@ -44,7 +42,7 @@ Windows N 等缺少媒体组件的系统,以及系统无法解码的输入, 每个输入使用输出目录内的独立临时目录,完成并校验后提交,拒绝覆盖;同一输入的多页结果在发布前统一校验,失败回滚本次已提交结果。FFmpeg 结果在提交前完整解码验证。LibreOffice 的独立配置放在较短的系统临时目录,避免 Windows 下的深层缓存路径问题,用完后清理。 -系统音视频转换在本程序按任务启动的独立进程内执行,完成后退出,释放编解码对象持有的文件句柄。外部引擎和系统转换进程均使用独立 Windows Job,取消只终止本次进程树;没有全局轮询或常驻转换进程。不依赖强制回收整个应用的托管堆来解锁文件。 +正式软件的音视频由内置 FFmpeg 处理。保留的系统编解码回归夹具在本程序按任务启动的独立进程内执行,完成后退出,释放编解码对象持有的文件句柄。外部引擎和系统转换进程均使用独立 Windows Job,取消只终止本次进程树;没有全局轮询或常驻转换进程。不依赖强制回收整个应用的托管堆来解锁文件。 引擎标准输出和错误输出由本次任务的专用线程读取,避免同步管道等待占用共享线程池;进程结束、管道关闭后,读取线程随任务退出。 @@ -58,6 +56,6 @@ Windows 隔离验收入口: DailyToolkit.Desktop.Tests.exe --clipboard-native-conversion-checks <图片输出目录> ``` -已接入 `scripts/check-quality.ps1 -IsolatedCi`,覆盖图片透明度、TIFF 多页、图片/PDF 往返、动态图拒绝、原件保护、停用取消、失败保存,以及深浅主题、宽窄页面和 100/150/200% DPI 渲染。CI 准备经过摘要校验的本地测试引擎,实际检查文字、表格、演示文稿往返及 PDF 渲染;引擎不进入软件载荷。系统音视频检查包含 MP3/M4A/WAV、MP4/WMV、尺寸与帧率保留、进程取消和文件独占重开。渲染检查不代替实际屏幕与混合 DPI 验收。 +已接入 `scripts/check-quality.ps1 -IsolatedCi`,覆盖图片透明度、TIFF 多页、图片/PDF 往返、动态图拒绝、原件保护、停用取消、失败保存,以及深浅主题、宽窄页面和 100/150/200% DPI 渲染。CI 从固定版本源码构建 FFmpeg,从校验摘要的官方包提取 LibreOffice,实际检查文字、表格、演示文稿往返及 PDF 渲染。另用实际便携目录与安装目录检查内置组件,阻止测试程序出站联网并清除 PATH 中的外部程序目录。系统音视频检查包含 MP3/M4A/WAV、MP4/WMV、尺寸与帧率保留、进程取消和文件独占重开。渲染检查不代替实际屏幕与混合 DPI 验收。 Linux 可进行 Core 检查、配置引擎的实际转换与 Windows 交叉编译;这些结果不能表述为已完成 Windows 桌面、系统编解码、真实拖放、用户数据、安装或本机内存验收。每次实际执行结果以本次日志为准。 diff --git a/docs/INSTALLER_README.txt b/docs/INSTALLER_README.txt index 91b10c4..615c031 100644 --- a/docs/INSTALLER_README.txt +++ b/docs/INSTALLER_README.txt @@ -25,7 +25,7 @@ Windows x64,已在 Windows 11 测试,Windows 10 尚未完整验证。 关闭窗口不停止已提交任务;关闭功能会停止任务,保留记录供重新开始。 清理工作区会删除其中全部文件,请先移出要保留的内容。 格式转换支持图片、PDF、音视频和文档,本地处理,不使用在线服务或 AI。 -文档需要本机 LibreOffice;WebP 和部分音视频格式需要 FFmpeg,不自动下载引擎。 +转换组件已内置,无需另装程序,可离线使用。携带时保留完整软件目录。 原文件保留,同名输出自动更名;停用功能会取消本批剩余任务。 配色预设点击即保存,自定义颜色保存后应用。 diff --git a/docs/PORTABLE_README.txt b/docs/PORTABLE_README.txt index 6c7876f..382b617 100644 --- a/docs/PORTABLE_README.txt +++ b/docs/PORTABLE_README.txt @@ -25,7 +25,7 @@ DailyToolkit 外部工作区清理会删除其中全部文件,请先移出要保留的内容。 格式转换支持图片、PDF、音视频和文档,本地处理,不使用在线服务或 AI。 -文档需要本机 LibreOffice;WebP 和部分音视频格式需要 FFmpeg,不自动下载引擎。 +转换组件已内置,无需另装程序,可离线使用。携带时保留完整软件目录。 原文件保留,同名输出自动更名;停用功能会取消本批剩余任务。 配色预设点击即保存,自定义颜色保存后应用。 diff --git a/docs/RELEASE_092.md b/docs/RELEASE_092.md new file mode 100644 index 0000000..01f0f2f --- /dev/null +++ b/docs/RELEASE_092.md @@ -0,0 +1,10 @@ +# DailyToolkit 0.9.2 + +- 内置图片、音视频和文档转换组件,断网可用,无需另装 FFmpeg、LibreOffice、.NET 或 Java。 +- 移除转换程序路径设置,解压或安装后直接使用;携带时保留完整软件目录。 +- 精简无关组件,保留转换所需的运行库、字体及许可材料。 +- 沿用现有界面和转换格式;原文件保留,任务结束或取消后释放本次转换进程。 + +[安装版](https://github.com/YMXKNebula/DailyToolkit/releases/download/v0.9.2/DailyToolkit-0.9.2-win-x64-setup.exe) · [便携版](https://github.com/YMXKNebula/DailyToolkit/releases/download/v0.9.2/DailyToolkit-0.9.2-win-x64-portable.zip) · [格式转换说明](FORMAT_CONVERSION.md) + +已有版本可在“设置 → 关于”检查更新。个人数据保留,复杂文档转换后请检查排版。 diff --git a/docs/VERSIONING.md b/docs/VERSIONING.md index 79078bc..f7386e9 100644 --- a/docs/VERSIONING.md +++ b/docs/VERSIONING.md @@ -13,4 +13,4 @@ 例如,`1.0.0` 是大版本首版,`1.1.0` 是该大版本的首个功能发布,随后可有 `1.1.1`、`1.1.2`;下一项功能进入 `1.2.0`。大版本通常经过 `b=1–9` 的功能阶段,具体发布时间和内容仍由当前任务决定,不自动生成未来版本或新增其他发布规则。 -本轮格式转换版本按用户明确指定为 **0.9.1**,不自动改为 0.9.0。历史标签、已发布附件及其校验文件保留原样,不按新规则重新编号。 +格式转换首发按用户明确指定为 **0.9.1**。离线内置补丁按用户于 2026-11-12 确认的版本 **0.9.2** 发布。历史标签、已发布附件及其校验文件保留原样,不按新规则重新编号。 diff --git a/installer/DailyToolkit.iss b/installer/DailyToolkit.iss index 8327043..31bef50 100644 --- a/installer/DailyToolkit.iss +++ b/installer/DailyToolkit.iss @@ -62,6 +62,13 @@ Name: "english"; MessagesFile: "compiler:Default.isl" Name: "desktopicon"; Description: "{cm:DesktopIcon}"; Flags: unchecked Name: "migratestartup"; Description: "{cm:MigrateStartup}"; Check: HasOtherStartup +[Dirs] +; LibreOffice creates these empty shared-cache directories on first use. +; Register them so uninstall removes them only while empty, retaining added files. +Name: "{app}\tools\libreoffice\share\uno_packages"; Flags: uninsalwaysuninstall +Name: "{app}\tools\libreoffice\share\uno_packages\cache"; Flags: uninsalwaysuninstall +Name: "{app}\tools\libreoffice\share\uno_packages\cache\uno_packages"; Flags: uninsalwaysuninstall + [Files] Source: "{#PayloadDir}\DailyToolkit.exe"; DestDir: "{app}"; Flags: ignoreversion Source: "{#PayloadDir}\LICENSE-DailyToolkit.txt"; DestDir: "{app}"; Flags: ignoreversion @@ -75,6 +82,8 @@ Source: "{#PayloadDir}\tools\7zip\Readme.txt"; DestDir: "{app}\tools\7zip"; Flag Source: "{#PayloadDir}\tools\7zip\SOURCE.txt"; DestDir: "{app}\tools\7zip"; Flags: ignoreversion Source: "{#PayloadDir}\tools\7zip\COPYING.txt"; DestDir: "{app}\tools\7zip"; Flags: ignoreversion Source: "{#PayloadDir}\tools\7zip\7z2604-src.7z"; DestDir: "{app}\tools\7zip"; Flags: ignoreversion +Source: "{#PayloadDir}\tools\ffmpeg\*"; DestDir: "{app}\tools\ffmpeg"; Flags: ignoreversion recursesubdirs createallsubdirs +Source: "{#PayloadDir}\tools\libreoffice\*"; DestDir: "{app}\tools\libreoffice"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "..\docs\INSTALLER_README.txt"; DestDir: "{app}"; DestName: "README.txt"; Flags: ignoreversion [Icons] diff --git a/scripts/build-conversion-ffmpeg.sh b/scripts/build-conversion-ffmpeg.sh new file mode 100644 index 0000000..399f26c --- /dev/null +++ b/scripts/build-conversion-ffmpeg.sh @@ -0,0 +1,166 @@ +#!/usr/bin/env bash +# Cross-build the local converter, never a player, downloader or system install. +set -euo pipefail +root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd) +work="$root/.local/conversion-ffmpeg" +mkdir -p "$work" +build=$(mktemp -d "$work/build-XXXXXX") +export GIT_CEILING_DIRECTORIES="$build" +prefix="$build/prefix" +out="$build/output" +mkdir -p "$prefix" "$out/licenses" "$out/sources" +jobs=${CONVERSION_BUILD_JOBS:-2} +export CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ +export AR=x86_64-w64-mingw32-ar RANLIB=x86_64-w64-mingw32-ranlib STRIP=x86_64-w64-mingw32-strip +export PKG_CONFIG_LIBDIR="$prefix/lib/pkgconfig" PKG_CONFIG_PATH="$prefix/lib/pkgconfig" +export CFLAGS='-O2' CXXFLAGS='-O2' + +python3 - "$root/scripts/conversion-sources.json" "$build" <<'PY' +import hashlib,json,os,pathlib,shutil,subprocess,sys,tarfile +spec=pathlib.Path(sys.argv[1]); root=pathlib.Path(sys.argv[2]) +for item in json.loads(spec.read_text()): + name=item['name']; archive=root/'output'/'sources'/(name+'.tar.gz') + local=pathlib.Path(os.environ.get('CONVERSION_SOURCE_DIRECTORY',str(root)))/(name+'.tar.gz') + if local.is_file(): shutil.copyfile(local,archive) + else: subprocess.run(['curl','--fail','--silent','--show-error','--location','--connect-timeout','20','--max-time','180','--output',str(archive),item['url']],check=True) + if hashlib.sha256(archive.read_bytes()).hexdigest()!=item['sha256']: raise RuntimeError('Source checksum mismatch: '+name) + target=root/name; target.mkdir() + subprocess.run(['tar','-xzf',str(archive),'--strip-components=1','-C',str(target)],check=True) + notices=[p for p in target.iterdir() if p.is_file() and (p.name.upper().startswith(('COPYING','LICENSE','PATENT','NOTICE','AUTHORS')))] + destination=root/'output'/'licenses'/name; destination.mkdir() + for p in notices: (destination/p.name).write_bytes(p.read_bytes()) + if not notices: raise RuntimeError('No source license: '+name) +PY +cat > "$build/windows.cmake" < "$build/windows.meson" <"$build/$label.log" 2>&1; then + tail -n 100 "$build/$label.log" + if [[ "$label" == ffmpeg-configure ]]; then tail -n 100 "$build/ffmpeg/ffbuild/config.log"; fi + return 1 + fi +} +cmake_lib() { + local name=$1; shift + run "$name-configure" cmake -S "$build/$name" -B "$build/$name-build" -G Ninja \ + -DCMAKE_TOOLCHAIN_FILE="$build/windows.cmake" -DCMAKE_INSTALL_PREFIX="$prefix" \ + -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF "$@" + run "$name-build" cmake --build "$build/$name-build" --parallel "$jobs" + run "$name-install" cmake --install "$build/$name-build" +} +cmake_lib ogg -DINSTALL_DOCS=OFF +cmake_lib zlib -DZLIB_BUILD_EXAMPLES=OFF -DZLIB_BUILD_TESTING=OFF -DZLIB_BUILD_SHARED=OFF +# Upstream's Windows static archive has a suffix while its pkg-config file +# advertises -lz. Keep a link inside this private cross-build prefix only. +if [[ ! -f "$prefix/lib/libz.a" && -f "$prefix/lib/libzs.a" ]]; then ln -s libzs.a "$prefix/lib/libz.a"; fi +if [[ ! -f "$prefix/lib/libz.a" && -f "$prefix/lib/libzstatic.a" ]]; then ln -s libzstatic.a "$prefix/lib/libz.a"; fi +cmake_lib vorbis +cmake_lib opus -DOPUS_BUILD_TESTING=OFF -DOPUS_BUILD_PROGRAMS=OFF -DOPUS_DRED=OFF -DOPUS_DEEP_PLC=OFF -DOPUS_OSCE=OFF +cmake_lib webp -DWEBP_BUILD_ANIM_UTILS=OFF -DWEBP_BUILD_CWEBP=OFF -DWEBP_BUILD_DWEBP=OFF \ + -DWEBP_BUILD_GIF2WEBP=OFF -DWEBP_BUILD_IMG2WEBP=OFF -DWEBP_BUILD_VWEBP=OFF \ + -DWEBP_BUILD_WEBPINFO=OFF -DWEBP_BUILD_LIBWEBPMUX=OFF -DWEBP_BUILD_WEBPMUX=OFF -DWEBP_BUILD_EXTRAS=OFF +run dav1d-configure meson setup "$build/dav1d-build" "$build/dav1d" --cross-file "$build/windows.meson" \ + --prefix "$prefix" --libdir lib --buildtype release --default-library static -Denable_tools=false -Denable_tests=false +run dav1d-build ninja -C "$build/dav1d-build" -j "$jobs" +run dav1d-install meson install -C "$build/dav1d-build" +( + cd "$build/lame" + run lame-configure ./configure --host=x86_64-w64-mingw32 --prefix="$prefix" --disable-shared --enable-static --disable-frontend --disable-decoder --disable-nasm + run lame-build make -j "$jobs" + run lame-install make install +) +( + cd "$build/x264" + run x264-configure ./configure --host=x86_64-w64-mingw32 --cross-prefix=x86_64-w64-mingw32- --prefix="$prefix" \ + --enable-static --disable-cli --disable-opencl --disable-avs --disable-lavf --disable-swscale --disable-ffms + run x264-build make -j "$jobs" + run x264-install make install-lib-static install-lib-dev +) +( + cd "$build/vpx" + run vpx-configure ./configure --target=x86_64-win64-gcc --prefix="$prefix" --as=nasm \ + --enable-static --disable-shared --disable-examples --disable-tools --disable-docs --disable-unit-tests \ + --disable-vp8-encoder --disable-vp8-decoder --disable-vp9-decoder + run vpx-build make -j "$jobs" + run vpx-install make install +) +( + cd "$build/ffmpeg" + # This source archive sits below DailyToolkit's Git checkout. Use FFmpeg's + # release metadata so version.sh cannot pick up the parent repository hash. + printf '%s\n' '9.0.2' > VERSION + # Keep decoding broad within the advertised containers; only encode our + # exposed targets. There is no network protocol, capture device or AI filter. + decoders='aac,aac_fixed,ac3,eac3,alac,mp1,mp1float,mp2,mp2float,mp3,mp3float,flac,vorbis,opus,wmav1,wmav2,wmapro,wmalossless,pcm_s16le,pcm_s16be,pcm_s24le,pcm_s24be,pcm_s32le,pcm_s32be,pcm_f32le,pcm_f32be,pcm_f64le,pcm_f64be,pcm_u8,pcm_alaw,pcm_mulaw,adpcm_ms,adpcm_ima_wav,h264,hevc,mpeg1video,mpeg2video,mpeg4,msmpeg4v1,msmpeg4v2,msmpeg4v3,wmv1,wmv2,wmv3,vc1,vp8,vp9,libdav1d,prores,ffv1,dvvideo,mjpeg,png,bmp,tiff,gif,webp,rawvideo,qtrle' + decoders+=',aac_latm,dca,mlp,truehd,mss1,mss2,huffyuv,ffvhuff,adpcm_ima_qt' + run ffmpeg-configure ./configure --target-os=mingw32 --arch=x86_64 --enable-cross-compile \ + --cross-prefix=x86_64-w64-mingw32- --cc="$CC" --cxx="$CXX" --pkg-config=pkg-config --pkg-config-flags=--static \ + --extra-cflags="-I$prefix/include" --extra-ldflags="-L$prefix/lib -static" \ + --enable-static --disable-shared --enable-gpl --disable-autodetect --disable-debug --disable-doc \ + --disable-network --disable-devices --disable-hwaccels --disable-avdevice --disable-everything \ + --enable-ffmpeg --disable-ffplay --disable-ffprobe \ + --enable-zlib --enable-libx264 --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-libvpx --enable-libwebp --enable-libdav1d \ + --enable-protocol=file,pipe --enable-decoder="$decoders" \ + --enable-encoder=libmp3lame,aac,pcm_s16le,flac,libvorbis,libvpx_vp9,libopus,libx264,wmv2,wmav2,png,libwebp,ffv1,wrapped_avframe \ + --enable-demuxer=aac,loas,mov,matroska,avi,asf,mpegps,mpegts,mpegvideo,mp3,wav,flac,ogg,image2,image2pipe,png_pipe,webp_pipe,jpeg_pipe,bmp_pipe,tiff_pipe,gif,rawvideo \ + --enable-muxer=image2,image2pipe,webp,mp3,ipod,wav,flac,ogg,mp4,asf,matroska,webm,null \ + --enable-parser=aac,aac_latm,ac3,dca,mlp,flac,h264,hevc,mjpeg,mpeg4video,mpegaudio,mpegvideo,opus,vorbis,vp8,vp9,av1,png \ + --enable-bsf=aac_adtstoasc,h264_mp4toannexb,hevc_mp4toannexb,extract_extradata \ + --enable-filter=pad,format,scale,aresample,aformat,null,anull,trim,atrim,setpts,asetpts,fps + run ffmpeg-build make -j "$jobs" ffmpeg.exe + "$STRIP" ffmpeg.exe + cp ffmpeg.exe "$out/ffmpeg.exe" + cp VERSION config.h config_components.h ffbuild/config.mak "$out/sources/" + cp COPYING.GPLv2 "$out/LICENSE.txt" +) +# Full preferred source and exact build recipe travel with the executable. +cp "$root/scripts/build-conversion-ffmpeg.sh" "$root/scripts/conversion-sources.json" "$out/sources/" +mkdir -p "$out/licenses/toolchain" +for notice in /usr/share/doc/gcc-mingw-w64-base/copyright /usr/share/doc/mingw-w64-common/copyright; do + [[ -f "$notice" ]] || { echo "Missing toolchain notice: $notice"; exit 1; } + cp "$notice" "$out/licenses/toolchain/$(basename "$(dirname "$notice")").txt" +done +printf '%s\n' 'FFmpeg 9.0.2, GPL-2.0-or-later, with x264 and the codecs listed in sources/conversion-sources.json.' \ + 'Unmodified upstream source archives, notices and the cross-build recipe are included in sources/ and licenses/.' \ + 'No ffplay, ffprobe, network protocols, capture devices, neural audio options or AI filters are built.' \ + 'Build dependencies on Ubuntu: gcc-mingw-w64-x86-64-posix g++-mingw-w64-x86-64-posix nasm cmake ninja-build meson pkg-config make curl python3.' \ + 'Rebuild from the DailyToolkit repository with: bash scripts/build-conversion-ffmpeg.sh' \ + 'For source-only rebuilding, copy the two recipe files to an empty scripts/ directory and set CONVERSION_SOURCE_DIRECTORY to this sources/ directory.' > "$out/SOURCE.txt" +x86_64-w64-mingw32-objdump -p "$out/ffmpeg.exe" | sed -n 's/.*DLL Name: //p' > "$out/system-dependencies.txt" +if grep -Eiq 'libgcc|libstdc|libwinpthread|libav|\.dll[^[:space:]]' "$out/system-dependencies.txt"; then + echo 'Unexpected external runtime DLL'; cat "$out/system-dependencies.txt"; exit 1 +fi +mkdir -p "$root/.local/conversion-tools/tools" +if [[ -e "$root/.local/conversion-tools/tools/ffmpeg" ]]; then echo 'Refuse to replace an existing engine directory'; exit 1; fi +mv "$out" "$root/.local/conversion-tools/tools/ffmpeg" +python3 "$root/scripts/conversion-manifest.py" create "$root/.local/conversion-tools/tools/ffmpeg" ffmpeg \ + "$root/scripts/build-conversion-ffmpeg.sh" "$root/scripts/conversion-sources.json" +echo 'FFmpeg bundle ready:' +du -sh "$root/.local/conversion-tools/tools/ffmpeg" +cat "$root/.local/conversion-tools/tools/ffmpeg/system-dependencies.txt" diff --git a/scripts/conversion-manifest.py b/scripts/conversion-manifest.py new file mode 100644 index 0000000..a49306c --- /dev/null +++ b/scripts/conversion-manifest.py @@ -0,0 +1,43 @@ +"""Create/verify the exact prepared component inventory, excluding the manifest itself.""" +import hashlib +import json +import pathlib +import sys + + +def digest(path): + with path.open('rb') as stream: + return hashlib.file_digest(stream, 'sha256').hexdigest() + + +def inventory(root): + files = [] + # Path ordering follows the host OS (case-insensitive on Windows). Use the + # archive's exact relative strings on both builders and Windows verification. + for path in sorted(root.rglob('*'), key=lambda p: p.relative_to(root).as_posix()): + if path.is_symlink(): + raise ValueError('A bundle cannot include links: ' + str(path)) + if path.is_file() and path != root / 'bundle.json': + rel = path.relative_to(root).as_posix() + if any(part.startswith('.') for part in pathlib.PurePosixPath(rel).parts): + raise ValueError('A bundle cannot include hidden development files: ' + rel) + files.append(dict(path=rel, bytes=path.stat().st_size, sha256=digest(path))) + return files + + +if __name__ == '__main__': + mode, directory, component, *recipes = sys.argv[1:] + root = pathlib.Path(directory) + manifest = root / 'bundle.json' + recipe = {pathlib.Path(p).name: digest(pathlib.Path(p)) for p in recipes} + value = dict(schema=1, component=component, recipe=recipe, files=inventory(root)) + if mode == 'create': + if manifest.exists(): + raise ValueError('Refuse to replace a component manifest') + manifest.write_text(json.dumps(value, indent=2) + '\n', encoding='utf-8') + elif mode == 'verify': + expected = json.loads(manifest.read_text(encoding='utf-8')) + if value != expected: + raise ValueError('Prepared component differs from its pinned recipe or inventory: ' + component) + else: + raise ValueError('Expected create or verify') diff --git a/scripts/conversion-payload.ps1 b/scripts/conversion-payload.ps1 new file mode 100644 index 0000000..338d89b --- /dev/null +++ b/scripts/conversion-payload.ps1 @@ -0,0 +1,36 @@ +# Dot-source from publish/package/test scripts. No downloads or system changes. +function Get-ApplicationPayloadFiles([string]$Directory) { + @('DailyToolkit.exe','LICENSE-DailyToolkit.txt','README.txt','THIRD_PARTY_NOTICES.txt', + 'microsoft.netcore.app.runtime-LICENSE.TXT','microsoft.netcore.app.runtime-THIRD-PARTY-NOTICES.TXT', + 'microsoft.windowsdesktop.app.runtime-LICENSE','licenses\Windows-SDK-License.rtf', + 'tools\7zip\7za.exe','tools\7zip\License.txt','tools\7zip\Readme.txt','tools\7zip\SOURCE.txt', + 'tools\7zip\COPYING.txt','tools\7zip\7z2604-src.7z') + Get-ConversionPayloadFiles $Directory +} + +function Get-ConversionPayloadFiles([string]$Directory) { + $result = [Collections.Generic.List[string]]::new() + foreach ($engine in @('ffmpeg','libreoffice')) { + $prefix = "tools/$engine/" + $base = Join-Path $Directory $prefix + $manifest = Join-Path $base 'bundle.json' + if (-not (Test-Path -LiteralPath $manifest)) { throw "Missing prepared $engine inventory." } + $spec = Get-Content -LiteralPath $manifest -Raw | ConvertFrom-Json + if ($spec.schema -ne 1 -or $spec.component -ne $engine -or $spec.files.Count -lt 3) { throw "Invalid $engine inventory." } + foreach ($entry in $spec.files) { + if ($entry.path -notmatch '^[A-Za-z0-9_\-/ .+]+$' -or $entry.path.StartsWith('/') -or + @($entry.path.Split('/') | Where-Object { $_ -in @('','.', '..') }).Count -or + $entry.sha256 -notmatch '^[a-f0-9]{64}$') { throw 'Invalid component inventory entry.' } + $file = Join-Path $base $entry.path + $item = Get-Item -LiteralPath $file -Force + if ($item.PSIsContainer -or $item.Attributes.HasFlag([IO.FileAttributes]::ReparsePoint) -or + $item.Length -ne $entry.bytes -or (Get-FileHash -LiteralPath $file).Hash.ToLowerInvariant() -ne $entry.sha256) { + throw "Component inventory mismatch: $($entry.path)" + } + $result.Add(($prefix + $entry.path).Replace('/', '\')) + } + $result.Add(($prefix + 'bundle.json').Replace('/', '\')) + } + if (@($result | Sort-Object -Unique).Count -ne $result.Count) { throw 'Duplicate component inventory paths.' } + $result.ToArray() +} diff --git a/scripts/conversion-sources.json b/scripts/conversion-sources.json new file mode 100644 index 0000000..e38935b --- /dev/null +++ b/scripts/conversion-sources.json @@ -0,0 +1,72 @@ +[ + { + "name": "ffmpeg", + "version": "9.0.2", + "revision": "946fcce07b6dcd0331c8cc609192aeff5e1924f8", + "url": "https://codeload.github.com/FFmpeg/FFmpeg/tar.gz/946fcce07b6dcd0331c8cc609192aeff5e1924f8", + "sha256": "0aa2b1de2a5698b20a23e93d539a9a8e82ca0117496c5bdf05d198805f42bb3b" + }, + { + "name": "x264", + "version": "stable-2026", + "revision": "31e19f92f00c7003fa115047ce50978bc98c3a0d", + "url": "https://codeload.github.com/mirror/x264/tar.gz/31e19f92f00c7003fa115047ce50978bc98c3a0d", + "sha256": "d053c9d86988d6bc78237ca5205865c5ddf99c98ef4cd9927eec8f6d388f6dd9" + }, + { + "name": "vpx", + "version": "1.17.0", + "revision": "6df3ec34557879fff673706f4a1d9fbd0f3a6f0e", + "url": "https://codeload.github.com/webmproject/libvpx/tar.gz/6df3ec34557879fff673706f4a1d9fbd0f3a6f0e", + "sha256": "073bd6202e4c55c8cb759abbb123aecd4cc8d99f52ba27af790178cfb1108423" + }, + { + "name": "opus", + "version": "1.6.1", + "revision": "22244de5a79bd1d6d623c32e72bf1954b56235be", + "url": "https://codeload.github.com/xiph/opus/tar.gz/22244de5a79bd1d6d623c32e72bf1954b56235be", + "sha256": "3267aa969b2b26542417f57819a5bc25d5079355300307dd2dddc7c704aed418" + }, + { + "name": "ogg", + "version": "1.3.6", + "revision": "be05b13e98b048f0b5a0f5fa8ce514d56db5f822", + "url": "https://codeload.github.com/xiph/ogg/tar.gz/be05b13e98b048f0b5a0f5fa8ce514d56db5f822", + "sha256": "b2ff5c003e5697507169f7d614d64dc4e8bf030c85ad081bec75c164566f8246" + }, + { + "name": "vorbis", + "version": "1.3.7", + "revision": "0657aee69dec8508a0011f47f3b69d7538e9d262", + "url": "https://codeload.github.com/xiph/vorbis/tar.gz/0657aee69dec8508a0011f47f3b69d7538e9d262", + "sha256": "6ccc3fa4cfd3072f9a772025cc8fd712098d081c00171b09b6627ffced7faa88" + }, + { + "name": "webp", + "version": "1.6.0", + "revision": "4fa21912338357f89e4fd51cf2368325b59e9bd9", + "url": "https://codeload.github.com/webmproject/libwebp/tar.gz/4fa21912338357f89e4fd51cf2368325b59e9bd9", + "sha256": "923f3382a47a2af185c3240c954cf004428b237bd7317413a95146d01eb4b94b" + }, + { + "name": "dav1d", + "version": "1.5.2", + "revision": "c720f4d3556a01916324aea155555d3efba842e8", + "url": "https://codeload.github.com/videolan/dav1d/tar.gz/c720f4d3556a01916324aea155555d3efba842e8", + "sha256": "6b15b0df3c10a60ae912b12e64f731888346d39fdc35d58966f2f26cca95745d" + }, + { + "name": "lame", + "version": "3.100", + "revision": "", + "url": "https://deb.debian.org/debian/pool/main/l/lame/lame_3.100.orig.tar.gz", + "sha256": "ddfe36cab873794038ae2c1210557ad34857a4b6bdc515785d1da9e175b1da1e" + }, + { + "name": "zlib", + "version": "1.4", + "revision": "99623ef7097352da7993ba614161fd6a311e046e", + "url": "https://codeload.github.com/madler/zlib/tar.gz/99623ef7097352da7993ba614161fd6a311e046e", + "sha256": "f0d590dd90243a12f551ee13359bf6c634249c55b316fa2b7dbecabe7ae9a904" + } +] diff --git a/scripts/inspect-office-probe.ps1 b/scripts/inspect-office-probe.ps1 new file mode 100644 index 0000000..9c36375 --- /dev/null +++ b/scripts/inspect-office-probe.ps1 @@ -0,0 +1,35 @@ +param([Parameter(Mandatory)][string]$ProgramDirectory) +$ErrorActionPreference = 'Stop' +if ($env:CI -ne 'true' -or -not $IsWindows) { throw 'Read-only probe diagnostics require disposable Windows CI.' } +$owned = @(Get-Process | Where-Object { + try { $_.Path -and [IO.Path]::GetDirectoryName($_.Path).Equals($ProgramDirectory, [StringComparison]::OrdinalIgnoreCase) } + catch { $false } +}) +$owned | Select-Object Id, ProcessName, MainWindowTitle, Responding | Format-Table -AutoSize | Out-String | Write-Host +Add-Type -TypeDefinition @' +using System; +using System.Text; +using System.Collections.Generic; +using System.Runtime.InteropServices; +public static class DailyToolkitOfficeProbeWindows { + delegate bool EnumWindow(IntPtr window, IntPtr data); + [DllImport("user32.dll")] static extern bool EnumWindows(EnumWindow callback, IntPtr data); + [DllImport("user32.dll")] static extern bool EnumChildWindows(IntPtr window, EnumWindow callback, IntPtr data); + [DllImport("user32.dll")] static extern uint GetWindowThreadProcessId(IntPtr window, out uint pid); + [DllImport("user32.dll", CharSet=CharSet.Unicode)] static extern int GetWindowText(IntPtr window, StringBuilder text, int length); + static string Read(IntPtr window) { var text=new StringBuilder(4096); GetWindowText(window,text,text.Capacity); return text.ToString(); } + public static string[] Capture(int[] processes) { + var owned=new HashSet(processes); var text=new List(); + EnumWindows((window,data)=>{ + uint pid; GetWindowThreadProcessId(window,out pid); + if(owned.Contains((int)pid)) { + text.Add("Owned window: "+Read(window)); + EnumChildWindows(window,(child,unused)=>{ var value=Read(child); if(value.Length>0) text.Add(value); return true; },IntPtr.Zero); + } + return true; + },IntPtr.Zero); + return text.ToArray(); + } +} +'@ +if ($owned.Count) { [DailyToolkitOfficeProbeWindows]::Capture([int[]]$owned.Id) | Write-Host } diff --git a/scripts/package-installer.ps1 b/scripts/package-installer.ps1 index 47eb682..465be53 100644 --- a/scripts/package-installer.ps1 +++ b/scripts/package-installer.ps1 @@ -6,17 +6,14 @@ $version = [string]$properties.Project.PropertyGroup.Version if ($version -notmatch '^\d+\.\d+\.\d+$') { throw 'The Windows installer requires a three-part release version.' } if (-not $PayloadDirectory) { $PayloadDirectory = Join-Path $projectRoot "artifacts\DailyToolkit-$version-win-x64" } $PayloadDirectory = [IO.Path]::GetFullPath($PayloadDirectory) +. (Join-Path $PSScriptRoot 'conversion-payload.ps1') $executable = Join-Path $PayloadDirectory 'DailyToolkit.exe' if (-not (Test-Path -LiteralPath $executable)) { throw 'Run scripts/publish.ps1 before packaging the installer.' } if ((Get-Item -LiteralPath $executable).VersionInfo.ProductVersion -notmatch ('^' + [regex]::Escape($version) + '(?:\+|$)')) { throw 'The application and installer versions must match.' } -$expected = @('DailyToolkit.exe','LICENSE-DailyToolkit.txt','README.txt','THIRD_PARTY_NOTICES.txt', - 'microsoft.netcore.app.runtime-LICENSE.TXT','microsoft.netcore.app.runtime-THIRD-PARTY-NOTICES.TXT', - 'microsoft.windowsdesktop.app.runtime-LICENSE','licenses\Windows-SDK-License.rtf', - 'tools\7zip\7za.exe','tools\7zip\License.txt','tools\7zip\Readme.txt','tools\7zip\SOURCE.txt', - 'tools\7zip\COPYING.txt','tools\7zip\7z2604-src.7z') -$actual = @(Get-ChildItem -LiteralPath $PayloadDirectory -Recurse -File | ForEach-Object { +$expected = @(Get-ApplicationPayloadFiles $PayloadDirectory) +$actual = @(Get-ChildItem -LiteralPath $PayloadDirectory -Recurse -File -Force | ForEach-Object { [IO.Path]::GetRelativePath($PayloadDirectory, $_.FullName) }) if (@(Compare-Object $expected $actual).Count -ne 0) { throw 'The portable payload has unexpected or missing files; refuse to package user data or development output.' } @@ -32,6 +29,15 @@ try { try { $zipExeHash = [Convert]::ToHexString($sha.ComputeHash($stream)) } finally { $sha.Dispose(); $stream.Dispose() } if ($zipExeHash -ne (Get-FileHash -LiteralPath $executable).Hash) { throw 'The ZIP and installer payload must contain the exact same application.' } + foreach ($relative in $expected | Where-Object { $_.StartsWith('tools\ffmpeg\') -or $_.StartsWith('tools\libreoffice\') }) { + $entry = $archive.GetEntry($relative.Replace('\','/')) + if (-not $entry) { $entry = $archive.GetEntry($relative) } + if (-not $entry) { throw "Missing portable component: $relative" } + $input = $entry.Open(); $algorithm = [Security.Cryptography.SHA256]::Create() + try { $checksum = [Convert]::ToHexString($algorithm.ComputeHash($input)) } + finally { $algorithm.Dispose(); $input.Dispose() } + if ($checksum -ne (Get-FileHash -LiteralPath (Join-Path $PayloadDirectory $relative)).Hash) { throw "ZIP component differs from installer: $relative" } + } } finally { $archive.Dispose() } if (-not $Compiler) { $Compiler = Join-Path $projectRoot '.local\inno-setup\7.1.0\ISCC.exe' @@ -52,4 +58,8 @@ $sums = @($setup, $zip) | ForEach-Object { (Get-FileHash -LiteralPath $_ -Algorithm SHA256).Hash.ToLowerInvariant() + ' ' + [IO.Path]::GetFileName($_) } [IO.File]::WriteAllLines((Join-Path $output 'SHA256SUMS.txt'), $sums, [Text.UTF8Encoding]::new($false)) +foreach ($file in Get-Item -LiteralPath $setup, $zip) { + Write-Host ("Package {0}: {1} bytes" -f $file.Name, $file.Length) +} +$sums | ForEach-Object { Write-Host $_ } Write-Output $setup diff --git a/scripts/prepare-conversion-checks.ps1 b/scripts/prepare-conversion-checks.ps1 index 6ec8e38..db9731f 100644 --- a/scripts/prepare-conversion-checks.ps1 +++ b/scripts/prepare-conversion-checks.ps1 @@ -1,44 +1,18 @@ -# Disposable Windows CI only. These engines are test dependencies, not payload. +# Disposable Windows CI. Use precisely the prepared portable engines; no installs. $ErrorActionPreference = 'Stop' -$PSNativeCommandUseErrorActionPreference = $false -if ($env:CI -ne 'true' -or -not $IsWindows) { throw 'Conversion engine preparation requires disposable Windows CI.' } -$ffmpeg = Get-Command ffmpeg.exe -ErrorAction SilentlyContinue -if (-not $ffmpeg) { - choco install ffmpeg --version=9.0.2 --yes --no-progress --limit-output - if ($LASTEXITCODE -ne 0) { throw 'FFmpeg test dependency installation failed.' } - $ffmpeg = Get-Command ffmpeg.exe -ErrorAction Stop -} -$office = Join-Path $env:ProgramFiles 'LibreOffice/program/soffice.com' -if (-not (Test-Path -LiteralPath $office)) { - $version = '26.2.6' - $url = "https://download.documentfoundation.org/libreoffice/stable/$version/win/x86_64/LibreOffice_${version}_Win_x86-64.msi" - $evidence = Join-Path $PSScriptRoot '../.local/conversion-test-engines' - New-Item -ItemType Directory -Path $evidence -Force | Out-Null - [xml]$metalink = (Invoke-WebRequest -Uri ($url + '.meta4') -TimeoutSec 60).Content - $entry = $metalink.metalink.file - $hash = @($entry.hash | Where-Object type -eq 'sha-256')[0].InnerText.ToLowerInvariant() - if ($hash -notmatch '^[a-f0-9]{64}$') { throw 'Official LibreOffice SHA-256 metadata was not found.' } - $urls = @($entry.url | Where-Object { $_.InnerText.StartsWith('https://') } | Sort-Object { [int]$_.priority } | Select-Object -First 4) - if ($urls.Count -eq 0) { throw 'Official HTTPS mirrors were not found.' } - $msi = Join-Path $env:RUNNER_TEMP "LibreOffice-$version.msi" - $downloaded = $false - foreach ($mirror in $urls) { - Write-Host ('Trying official LibreOffice mirror: ' + ([uri]$mirror.InnerText).Host) - & curl.exe --silent --show-error --fail --location --connect-timeout 15 --max-time 90 --output $msi $mirror.InnerText - if ($LASTEXITCODE -eq 0 -and (Get-FileHash -LiteralPath $msi -Algorithm SHA256).Hash.ToLowerInvariant() -eq $hash) { - $downloaded = $true; break - } - } - if (-not $downloaded) { throw 'No official mirror supplied the checksum-verified LibreOffice installer within its time limit.' } - @{ version = $version; sha256 = $hash; mirror = $mirror.InnerText } | ConvertTo-Json | Set-Content -LiteralPath (Join-Path $evidence 'libreoffice-download.json') -Encoding utf8 - $log = Join-Path ([IO.Path]::GetFullPath($evidence)) 'libreoffice-install.log' - $install = Start-Process msiexec.exe -ArgumentList @('/i', $msi, '/qn', '/norestart', '/L*v', $log) -PassThru - if (-not $install.WaitForExit(240000)) { Stop-Process -Id $install.Id; throw 'The disposable CI LibreOffice install exceeded four minutes.' } - if ($install.ExitCode -notin @(0, 3010)) { throw "LibreOffice test dependency installation failed: $($install.ExitCode)." } -} -if (-not (Test-Path -LiteralPath $office)) { throw 'LibreOffice console entry was not found.' } -"DAILYTOOLKIT_TEST_FFMPEG=$($ffmpeg.Source)" | Out-File -LiteralPath $env:GITHUB_ENV -Append -Encoding utf8 +if ($env:CI -ne 'true' -or -not $IsWindows) { throw 'Conversion engine checks require disposable Windows CI.' } +$root = [IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..')) +$bundle = Join-Path $root '.local/conversion-tools' +. (Join-Path $PSScriptRoot 'conversion-payload.ps1') +$files = @(Get-ConversionPayloadFiles $bundle) +$ffmpeg = Join-Path $bundle 'tools/ffmpeg/ffmpeg.exe' +$office = Join-Path $bundle 'tools/libreoffice/program/soffice.com' +"DAILYTOOLKIT_TEST_FFMPEG=$ffmpeg" | Out-File -LiteralPath $env:GITHUB_ENV -Append -Encoding utf8 "DAILYTOOLKIT_TEST_LIBREOFFICE=$office" | Out-File -LiteralPath $env:GITHUB_ENV -Append -Encoding utf8 -& $ffmpeg.Source -version | Select-Object -First 1 -& $office --version -Get-FileHash -LiteralPath $ffmpeg.Source, $office -Algorithm SHA256 | Format-Table -AutoSize +$versionLines = @(& $ffmpeg -version 2>&1) +if ($LASTEXITCODE -ne 0) { throw 'Bundled FFmpeg could not start.' } +$versionLines | Select-Object -First 1 +$protocols = (& $ffmpeg -hide_banner -protocols 2>&1 | Out-String) +if ($LASTEXITCODE -ne 0 -or $protocols -match '(?m)^\s+(https?|ftp|tcp|udp|tls|crypto)\s*$') { throw 'The converter must not contain network protocols.' } +Write-Host $protocols +Write-Host "Verified $($files.Count) prepared conversion component files; no program was installed." diff --git a/scripts/prepare-conversion-office.ps1 b/scripts/prepare-conversion-office.ps1 new file mode 100644 index 0000000..4260e8a --- /dev/null +++ b/scripts/prepare-conversion-office.ps1 @@ -0,0 +1,134 @@ +param([string]$OutputDirectory) +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +if (-not $IsWindows) { throw 'LibreOffice staging requires Windows; it never installs LibreOffice.' } +$root = [IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..')) +if (-not $OutputDirectory) { $OutputDirectory = Join-Path $root '.local/conversion-tools/tools/libreoffice' } +$OutputDirectory = [IO.Path]::GetFullPath($OutputDirectory) +if (Test-Path -LiteralPath $OutputDirectory) { throw 'Refuse to replace an existing staged office engine.' } +$version = '26.2.6' +$hash = 'f9877032fd908beb9c0ddf06df4af5c2e85f419c42e14876c4cce5aae5fb2660' +$url = "https://download.documentfoundation.org/libreoffice/stable/$version/win/x86_64/LibreOffice_${version}_Win_x86-64.msi" +$work = Join-Path $root ('.local/conversion-office/' + [guid]::NewGuid().ToString('N')) +New-Item -ItemType Directory -Path $work -Force | Out-Null +$msi = Join-Path $work "LibreOffice-$version.msi" +[xml]$meta = (Invoke-WebRequest ($url + '.meta4') -TimeoutSec 60).Content +$officialHash = @($meta.metalink.file.hash | Where-Object type -eq 'sha-256')[0].InnerText.ToLowerInvariant() +if ($officialHash -ne $hash) { throw 'Official office metadata differs from the pinned source; review before updating.' } +$downloaded = $false +foreach ($mirror in @($meta.metalink.file.url | Where-Object { $_.InnerText.StartsWith('https://') } | Sort-Object { [int]$_.priority } | Select-Object -First 4)) { + & curl.exe --fail --silent --show-error --location --connect-timeout 15 --max-time 90 --output $msi $mirror.InnerText + if ($LASTEXITCODE -eq 0 -and (Get-FileHash -LiteralPath $msi).Hash.ToLowerInvariant() -eq $hash) { $downloaded = $true; break } +} +if (-not $downloaded) { throw 'No official mirror returned the checksum-verified archive in time.' } +$extract = Join-Path $work 'extracted' +$p = Start-Process msiexec.exe -ArgumentList @('/a', ('"' + $msi + '"'), '/qn', '/norestart', ('TARGETDIR="' + $extract + '"'), '/L*v', ('"' + (Join-Path $work 'extract.log') + '"')) -PassThru +if (-not $p.WaitForExit(240000)) { throw 'Administrative archive extraction timed out; no installed application was changed.' } +if ($p.ExitCode -notin @(0,3010)) { throw "Administrative archive extraction failed: $($p.ExitCode)" } +$entry = @(Get-ChildItem -LiteralPath $extract -Recurse -Filter soffice.com -File) +if ($entry.Count -ne 1) { throw 'Expected one upstream office console entry.' } +$source = $entry[0].Directory.Parent.FullName +$vswhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio/Installer/vswhere.exe' +$vs = & $vswhere -latest -products '*' -property installationPath +if ($LASTEXITCODE -ne 0 -or -not $vs) { throw 'A licensed Visual C++ app-local CRT is required when preparing the bundle.' } +$crt = Get-ChildItem -LiteralPath (Join-Path $vs 'VC/Redist/MSVC') -Recurse -Directory -Filter 'Microsoft.VC*.CRT' | + Where-Object { $_.Parent.Name -eq 'x64' } | Sort-Object FullName -Descending | Select-Object -First 1 +if (-not $crt) { throw 'The Microsoft x64 app-local CRT was not found.' } +$metrics = & python (Join-Path $PSScriptRoot 'stage-conversion-office.py') $source $OutputDirectory $crt.FullName +if ($LASTEXITCODE -ne 0) { throw 'Office dependency staging failed.' } +$metrics | Set-Content -LiteralPath (Join-Path $work 'selection.json') -Encoding utf8 +$summary = $metrics | ConvertFrom-Json +Write-Host ("Office: selected {0:N1} MiB / {1:N1} MiB; {2} files; {3} checked binaries" -f ($summary.selectedBytes/1MB),($summary.upstreamBytes/1MB),$summary.selectedFiles,$summary.checkedBinaries) +Write-Host ('App-local CRT: ' + ($summary.microsoftRuntime -join ', ')) +$fontRevision = '523d033d6cb47f4a80c58a35753646f5c3608a78' +$fontDirectory = Join-Path $OutputDirectory 'share/fonts/truetype' +New-Item -ItemType Directory -Path $fontDirectory -Force | Out-Null +$font = Join-Path $fontDirectory 'NotoSansCJKsc-Regular.otf' +& curl.exe --fail --silent --show-error --location --connect-timeout 15 --max-time 90 --output $font "https://raw.githubusercontent.com/notofonts/noto-cjk/$fontRevision/Sans/OTF/SimplifiedChinese/NotoSansCJKsc-Regular.otf" +if ($LASTEXITCODE -ne 0 -or (Get-FileHash -LiteralPath $font).Hash.ToLowerInvariant() -ne '2c76254f6fc379fddfce0a7e84fb5385bb135d3e399294f6eeb6680d0365b74b') { throw 'Bundled Chinese font checksum mismatch.' } +$fontLicense = Join-Path $OutputDirectory 'LICENSE-NotoSansCJK.txt' +& curl.exe --fail --silent --show-error --location --connect-timeout 15 --max-time 60 --output $fontLicense "https://raw.githubusercontent.com/notofonts/noto-cjk/$fontRevision/LICENSE" +if ($LASTEXITCODE -ne 0 -or (Get-FileHash -LiteralPath $fontLicense).Hash.ToLowerInvariant() -ne '6a73f9541c2de74158c0e7cf6b0a58ef774f5a780bf191f2d7ec9cc53efe2bf2') { throw 'Bundled Chinese font license checksum mismatch.' } +$runtimeLicense = Join-Path $OutputDirectory 'LICENSE-Microsoft-VC-Runtime.docx' +$runtimeLicenseUrl = 'https://visualstudio.microsoft.com/wp-content/uploads/2025/10/Visual-C-V14-License-Redistributable_and_Runtime_ENU.docx' +& curl.exe --fail --silent --show-error --location --connect-timeout 15 --max-time 60 --output $runtimeLicense $runtimeLicenseUrl +if ($LASTEXITCODE -ne 0 -or (Get-FileHash -LiteralPath $runtimeLicense).Hash.ToLowerInvariant() -ne '08651651a7602fc7c0e2763de0fde1ff9f868df2780597cd1775ee9d6441c783') { throw 'The pinned Microsoft runtime license could not be preserved.' } +$licenseArchive = [IO.Compression.ZipFile]::OpenRead($runtimeLicense) +try { + $document = $licenseArchive.GetEntry('word/document.xml') + if (-not $document) { throw 'The Microsoft runtime license is not a valid source document.' } + $reader = [IO.StreamReader]::new($document.Open()) + try { [xml]$licenseXml = $reader.ReadToEnd() } finally { $reader.Dispose() } + $paragraphs = @($licenseXml.SelectNodes('//*[local-name()="p"]') | ForEach-Object { ($_.SelectNodes('.//*[local-name()="t"]') | ForEach-Object InnerText) -join '' }) + Write-Host ('Microsoft runtime license SHA-256: ' + (Get-FileHash -LiteralPath $runtimeLicense).Hash.ToLowerInvariant()) + $paragraphs | Write-Host +} finally { $licenseArchive.Dispose() } +foreach ($relative in $summary.microsoftRuntime) { + $file = Join-Path $OutputDirectory $relative + $signature = Get-AuthenticodeSignature -LiteralPath $file + if ($signature.Status -ne 'Valid' -or $signature.SignerCertificate.Subject -notmatch 'Microsoft Corporation') { throw 'The selected CRT is not an unchanged, signed Microsoft redistributable.' } + Write-Host ("CRT {0}: {1}; SHA-256 {2}" -f $relative, (Get-Item -LiteralPath $file).VersionInfo.FileVersion, (Get-FileHash -LiteralPath $file).Hash.ToLowerInvariant()) +} +@" +LibreOffice 26.2.6.3, The Document Foundation and contributors. +Unmodified upstream runtime files selected for Writer, Calc and Impress conversion. +MPL-2.0 and third-party licenses: license.txt, LICENSE.html and NOTICE in this folder. +Official binary archive: $url +SHA-256: $hash +Corresponding source and external dependency manifests: +https://download.documentfoundation.org/libreoffice/src/26.2.6/libreoffice-26.2.6.3.tar.xz +https://github.com/LibreOffice/core/tree/libreoffice-26.2.6.3 +The source archive includes download.lst and external/ with versions, checksums and build recipes. +This selection does not change upstream binaries. Selection recipe: scripts/stage-conversion-office.py in DailyToolkit source. +Microsoft Visual C++ CRT files are included app-local; no runtime installer or system registration is used. +Copyright (C) Microsoft Corporation. All rights reserved. +Runtime terms: LICENSE-Microsoft-VC-Runtime.docx +https://visualstudio.microsoft.com/license-terms/vs2026-ga-visualcpp-v14-redist-runtime/ +Redistribution is governed by the Visual Studio 2026 Distributable Code terms for the licensed build environment: +https://visualstudio.microsoft.com/license-terms/vs2026-ga-pro-enterprise/ +Noto Sans CJK SC 2.004 is included as a private document font, with no system font registration. +Copyright 2014-2021 Adobe and Noto contributors; SIL Open Font License 1.1 in LICENSE-NotoSansCJK.txt. +Font source: https://github.com/notofonts/noto-cjk/tree/$fontRevision +"@ | Set-Content -LiteralPath (Join-Path $OutputDirectory 'SOURCE.txt') -Encoding utf8 +$probeProfile = Join-Path ([IO.Path]::GetTempPath()) ('dtk-lo-' + [guid]::NewGuid().ToString('N')) +$probeInput = Join-Path $work '离线检查.txt' +[IO.File]::WriteAllText($probeInput, '格式转换离线检查', [Text.UTF8Encoding]::new($false)) +try { + New-Item -ItemType Directory -Path (Join-Path $probeProfile 'user') -Force | Out-Null + @' + + +3 +false + +'@ | Set-Content -LiteralPath (Join-Path $probeProfile 'user/registrymodifications.xcu') -Encoding utf8 + $probeLog = Join-Path $work 'probe.log' + $probeError = Join-Path $work 'probe-error.log' + $arguments = @(('-env:UserInstallation=' + ([uri]($probeProfile + '\')).AbsoluteUri), '--headless', '--nologo', '--nodefault', '--nofirststartwizard', '--norestore', '--convert-to', 'pdf', '--outdir', ('"' + $work + '"'), ('"' + $probeInput + '"')) + $probe = Start-Process -FilePath (Join-Path $OutputDirectory 'program/soffice.com') -ArgumentList $arguments -RedirectStandardOutput $probeLog -RedirectStandardError $probeError -PassThru + if (-not $probe.WaitForExit(60000)) { + if ($env:CI -eq 'true') { & (Join-Path $PSScriptRoot 'inspect-office-probe.ps1') -ProgramDirectory (Join-Path $OutputDirectory 'program') } + $probe.Kill($true); $probe.WaitForExit() + Get-Content -LiteralPath $probeLog, $probeError -ErrorAction SilentlyContinue | Write-Host + throw 'The selected app-local office probe exceeded one minute.' + } + Get-Content -LiteralPath $probeLog, $probeError -ErrorAction SilentlyContinue | Write-Host + if ($probe.ExitCode -ne 0 -or -not (Test-Path -LiteralPath (Join-Path $work '离线检查.pdf'))) { + Write-Host "Probe source exists: $(Test-Path -LiteralPath $probeInput); bytes: $((Get-Item -LiteralPath $probeInput).Length)" + $arguments | ForEach-Object { Write-Host "Probe argument: [$_]" } + $controlOutput = Join-Path $work 'untrimmed-control' + New-Item -ItemType Directory -Path $controlOutput -Force | Out-Null + $controlProfile = Join-Path ([IO.Path]::GetTempPath()) ('dtk-lo-' + [guid]::NewGuid().ToString('N')) + try { + $controlArguments = @(('-env:UserInstallation=' + ([uri]($controlProfile + '\')).AbsoluteUri), '--headless', '--nologo', '--nodefault', '--nofirststartwizard', '--norestore', '--convert-to', 'pdf', '--outdir', ('"' + $controlOutput + '"'), ('"' + $probeInput + '"')) + $control = Start-Process -FilePath (Join-Path $source 'program/soffice.com') -ArgumentList $controlArguments -RedirectStandardOutput (Join-Path $work 'control.log') -RedirectStandardError (Join-Path $work 'control-error.log') -PassThru + if (-not $control.WaitForExit(60000)) { $control.Kill($true); $control.WaitForExit() } + Get-Content -LiteralPath (Join-Path $work 'control.log'), (Join-Path $work 'control-error.log') -ErrorAction SilentlyContinue | Write-Host + Write-Host "Untrimmed control produced PDF: $(Test-Path -LiteralPath (Join-Path $controlOutput '离线检查.pdf'))" + } finally { if (Test-Path -LiteralPath $controlProfile) { Remove-Item -LiteralPath $controlProfile -Recurse -Force } } + throw 'Selected app-local office runtime did not convert Unicode text to PDF.' + } +} finally { if (Test-Path -LiteralPath $probeProfile) { Remove-Item -LiteralPath $probeProfile -Recurse -Force } } +Write-Host 'PASS Selected app-local LibreOffice: Unicode TXT to PDF without installation.' +& python (Join-Path $PSScriptRoot 'conversion-manifest.py') create $OutputDirectory libreoffice $PSCommandPath (Join-Path $PSScriptRoot 'stage-conversion-office.py') +if ($LASTEXITCODE -ne 0) { throw 'Office component manifest creation failed.' } diff --git a/scripts/publish.ps1 b/scripts/publish.ps1 index 88e7bc9..ea5ebf8 100644 --- a/scripts/publish.ps1 +++ b/scripts/publish.ps1 @@ -4,6 +4,16 @@ $projectRoot = [IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..')) $dotnetCommand = Get-Command dotnet -ErrorAction SilentlyContinue $dotnetPath = if ($dotnetCommand) { $dotnetCommand.Source } else { Join-Path $env:ProgramFiles 'dotnet\dotnet.exe' } if (-not (Test-Path -LiteralPath $dotnetPath)) { throw 'Install the .NET 10 SDK before publishing.' } +if ($Runtime -ne 'win-x64') { throw 'The offline conversion payload is validated for Windows x64 only.' } +. (Join-Path $PSScriptRoot 'conversion-payload.ps1') +$conversionDirectory = Join-Path $projectRoot '.local/conversion-tools' +foreach ($engine in @('ffmpeg','libreoffice')) { + $recipes = if ($engine -eq 'ffmpeg') { @('build-conversion-ffmpeg.sh','conversion-sources.json') } else { @('prepare-conversion-office.ps1','stage-conversion-office.py') } + $recipePaths = @($recipes | ForEach-Object { Join-Path $PSScriptRoot $_ }) + & python (Join-Path $PSScriptRoot 'conversion-manifest.py') verify (Join-Path $conversionDirectory "tools/$engine") $engine @recipePaths + if ($LASTEXITCODE -ne 0) { throw "Prepare the matching $engine bundle before publishing." } +} +$conversionFiles = @(Get-ConversionPayloadFiles $conversionDirectory) $env:DOTNET_CLI_HOME = Join-Path $projectRoot '.local\dotnet' $env:NUGET_PACKAGES = Join-Path $projectRoot '.local\nuget' $env:DOTNET_CLI_TELEMETRY_OPTOUT = '1' @@ -20,6 +30,11 @@ Push-Location -LiteralPath $projectRoot try { & $dotnetPath publish src/DailyToolkit.Desktop/DailyToolkit.Desktop.csproj -c Release -r $Runtime --self-contained true --disable-build-servers -m:1 --nologo -o $outputDirectory -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:DebugType=None -p:DebugSymbols=false @versionArguments if ($LASTEXITCODE -ne 0) { throw 'Publish failed.' } + foreach ($relative in $conversionFiles) { + $destination = Join-Path $outputDirectory $relative + New-Item -ItemType Directory -Path ([IO.Path]::GetDirectoryName($destination)) -Force | Out-Null + Copy-Item -LiteralPath (Join-Path $conversionDirectory $relative) -Destination $destination + } Copy-Item -LiteralPath (Join-Path $projectRoot 'LICENSE') -Destination (Join-Path $outputDirectory 'LICENSE-DailyToolkit.txt') Copy-Item -LiteralPath (Join-Path $projectRoot 'docs\PORTABLE_README.txt') -Destination (Join-Path $outputDirectory 'README.txt') Copy-Item -LiteralPath (Join-Path $projectRoot 'THIRD_PARTY_NOTICES.txt') -Destination (Join-Path $outputDirectory 'THIRD_PARTY_NOTICES.txt') @@ -36,6 +51,9 @@ try { } } } + $expected = @(Get-ApplicationPayloadFiles $outputDirectory) + $actual = @(Get-ChildItem -LiteralPath $outputDirectory -Recurse -File -Force | ForEach-Object { [IO.Path]::GetRelativePath($outputDirectory, $_.FullName) }) + if (@(Compare-Object $expected $actual).Count) { throw 'Unexpected or missing payload files; refuse to archive user data or development output.' } $zipPath = Join-Path $projectRoot ('artifacts\' + $packageName + '-portable.zip') Compress-Archive -Path (Join-Path $outputDirectory '*') -DestinationPath $zipPath -Force & (Join-Path $PSScriptRoot 'refresh-explorer-icon.ps1') -Executable (Join-Path $outputDirectory 'DailyToolkit.exe') | Out-Null diff --git a/scripts/stage-conversion-office.py b/scripts/stage-conversion-office.py new file mode 100644 index 0000000..2195c34 --- /dev/null +++ b/scripts/stage-conversion-office.py @@ -0,0 +1,135 @@ +"""Stage only the local Writer/Calc/Impress conversion runtime; no installer runs here.""" +import fnmatch +import hashlib +import json +import pathlib +import shutil +import struct +import sys + + +def imports(path): + data = path.read_bytes() + if data[:2] != b'MZ': + return [] + pe = struct.unpack_from(' FFmpegArguments(ConversionRequest request, s private static async Task RunProcessAsync(string executable, IReadOnlyList arguments, CancellationToken cancellationToken) { - if (string.IsNullOrWhiteSpace(executable)) throw new InvalidOperationException("请先在本地引擎中选择对应的程序。"); + if (string.IsNullOrWhiteSpace(executable)) throw new InvalidOperationException("转换组件缺失,请重新安装或解压完整软件包。"); executable = ConversionRunner.LocalPath(executable); - if (!File.Exists(executable)) throw new FileNotFoundException("本地引擎程序不存在。", executable); + if (!File.Exists(executable)) throw new FileNotFoundException("转换组件缺失,请重新安装或解压完整软件包。", executable); using var timeout = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); timeout.CancelAfter(TimeSpan.FromHours(2)); var start = new ProcessStartInfo(executable) @@ -137,6 +137,12 @@ private static async Task RunProcessAsync(string executable, IReadOnlyLi RedirectStandardOutput = true, RedirectStandardError = true, WorkingDirectory = Path.GetDirectoryName(executable)! }; + if (Path.GetFileName(executable).Equals("soffice.com", StringComparison.OrdinalIgnoreCase) || + Path.GetFileName(executable).Equals("soffice.exe", StringComparison.OrdinalIgnoreCase)) + { + foreach (var name in new[] { "URE_BOOTSTRAP", "UNO_PATH", "UNO_SERVICES", "UNO_TYPES", "PYTHONHOME", "PYTHONPATH" }) + start.Environment.Remove(name); + } foreach (var arg in arguments) start.ArgumentList.Add(arg); using var process = new Process { StartInfo = start }; using var job = CreateProcessJob(); diff --git a/src/DailyToolkit.Desktop/Conversion/ConversionView.xaml b/src/DailyToolkit.Desktop/Conversion/ConversionView.xaml index 599ecf5..e582c76 100644 --- a/src/DailyToolkit.Desktop/Conversion/ConversionView.xaml +++ b/src/DailyToolkit.Desktop/Conversion/ConversionView.xaml @@ -30,6 +30,7 @@ +