diff --git a/Documentation/admin-guide/installation.rst b/Documentation/admin-guide/installation.rst index f78d7e4b..618c304e 100644 --- a/Documentation/admin-guide/installation.rst +++ b/Documentation/admin-guide/installation.rst @@ -216,8 +216,11 @@ ISO 优先从固件交接的实际介质加载菜单,Live 与 Installer 的后 空间时增加 BIOS 引导的请求应在写入前失败。先备份用户文件和引导分区, 检查已安装 APK 数据库、信任密钥及所选更新介质。正常关闭已安装系统后, 再从安装介质启动。 -在安装器中选择更新和目标磁盘后,独立的后台进程只读检查已安装系统、桌面 -类型、软件包数据库、安装介质和空间。检查完成后仍留在目标磁盘步骤, +在安装器中选择更新和目标磁盘后,后台协调进程依次只读检查已安装系统、桌面 +类型、软件包数据库、安装介质、引导布局和空间,再验证离线软件包方案。 +每个阶段在独立进程组中执行,界面持续显示当前阶段;慢速读盘期间也能响应 +取消检查。取消后先终止该阶段的所有进程并释放挂载,再返回目标磁盘步骤。 +检查完成后仍留在目标磁盘步骤, 显示检查结果和检测到的 BIOS/UEFI 引导选项;可以先修改选择,再继续到只读摘要。 摘要列出当前版本、介质版本、根分区、ESP、空间需求和引导方式。核对后点击更新。 同盘有多个安装时,可在目标磁盘页选择明确的根分区和 ESP;留空 ESP 时读取 @@ -231,12 +234,16 @@ CLI,需要明确的 ``--disk``、``--boot-directory`` 和根分区身份; TTY 入口使用相同的后端,并在显示摘要和引导选项后通过 ``y/N`` 确认。 检查过程使用私有 APK 数据库和已安装系统的信任密钥,验证签名索引、完整 -软件包归档以及离线依赖。私有数据库和归档临时存放在启动时挂载的 ``/run`` -tmpfs 中,结束后清理,避免占满安装介质的固定大小运行时根文件系统。 +软件包归档以及离线依赖。私有数据库和有大小上限的计划数据临时存放在 +``/run`` tmpfs 中,结束后清理;归档直接从只读安装介质验证和读取, +不把整个仓库复制到内存。检查不修改目标系统。 +空间预算包括介质归档缓存、所有包(含上游依赖)的逐包正增长、最大单包的 +替换空间及保留余量;不提前把尚未删除的包或缩小的文件折算成可用空间。 确认后的执行会再次核对磁盘、分区 UUID、索引和 已安装包数据库及 world 选择;目标已经变化时需要重新检查。已被其他路径挂载的分区、 无法唯一识别的根分区或 ESP,以及早于已安装系统的介质会在写入前被拒绝。 +确认执行后不再单独重复一次完整检查;包事务在自己的预检通过后执行一次。 根文件系统使用 APK 更新,保留外部包、world 选择和受保护配置;新默认配置 可能以 ``.apk-new`` 出现。根事务成功后才发布引导文件。 离线更新只从安装介质的签名仓库取得新软件包。``world`` 中已有的 @@ -245,6 +252,14 @@ tmpfs 中,结束后清理,避免占满安装介质的固定大小运行时 原有仓库配置和标签选择保持不变;介质和已安装软件包无法满足的版本约束 仍会在预检查时拒绝,不会强制忽略依赖。 更新保留现有 fstab 和 swap 设置,不会自动添加或更改交换文件。 +软件包写入和引导发布期间不能通过界面取消。各阶段使用单调时钟计时:系统 +识别和挂载准备最多 2 分钟,介质检查和现有引导布局检查最多 3 分钟, +引导源检查、恢复和根同步最多 5 分钟,依赖检查最多 15 分钟,包更新最多 +60 分钟,引导发布最多 10 分钟。超时先请求终止,再强制终止整个进程组。 +界面的周期性状态表示协调进程仍在工作,不代表已完成新的文件或软件包。 +如果内核中的 I/O 无法响应终止,协调进程继续持锁并报告等待,不能把仍存活 +的写入进程当作已经退出。 + 更新详情显示软件包和引导操作的实际输出,完整日志位于安装器运行环境的 ``/var/log/installer-update.log``。失败页面保留错误和日志位置,并返回目标磁盘步骤重新检查; 新安装失败后也先返回检查方案,不能把重新进入进度页当作已经获准再次擦盘。 @@ -256,10 +271,16 @@ tmpfs 中,结束后清理,避免占满安装介质的固定大小运行时 出错会终止本次更新,日志和失败页保留步骤、文件名及命令退出状态,供重试定位。 目标系统的 ``/var/lib/reliefos/installer-update/state`` 持久记录软件包、根同步、 -引导提交和完成阶段。同一介质的引导提交失败后,重新检查会核对已完成的根 -事务,再继续引导提交;软件包阶段失败则重新预检并执行包事务。旧内核模块 +引导提交和完成阶段,记录通过临时文件、文件同步、原子替换和目录同步发布。 +同一介质的引导提交失败后,重新检查会核对根分区、索引、包数据库和 world, +只有这些身份仍匹配时才跳过已完成的包事务,继续引导提交;软件包阶段失败 +则重新预检并执行包修复。这属于向前修复,不是整个根文件系统的原子回滚。 +旧内核模块 保留与 A/B 内核发布继续使用共同的原生引导接口。更新期间由独立进程持有 -安装器更新锁,释放目标挂载后才报告完成。APK 已记录为损坏的系统包会先通过 +安装器更新锁,释放目标挂载后才报告完成。阶段及其子命令继承同一把锁, +避免协调进程意外退出后并行启动另一次写入。清理失败会保留工作区并报告错误; +检测到上次遗留的更新挂载时拒绝开始新事务,应保存日志并重启安装环境后重试。 +APK 已记录为损坏的系统包会先通过 已验证的归档执行定向修复,再执行升级;已有的外部包错误保留并在日志中说明。 旧内核包清单中的 ``kerneldebug.sys`` 作为可选历史成员继续校验、保留和恢复, diff --git a/Documentation/locale/en/LC_MESSAGES/admin-guide/installation.po b/Documentation/locale/en/LC_MESSAGES/admin-guide/installation.po index 01ea9db9..6e68e1f5 100644 --- a/Documentation/locale/en/LC_MESSAGES/admin-guide/installation.po +++ b/Documentation/locale/en/LC_MESSAGES/admin-guide/installation.po @@ -413,95 +413,6 @@ msgstr "" msgid "更新已有系统" msgstr "Updating an Existing System" -msgid "" -"更新不自动重分区。旧两分区 UEFI 磁盘保持原有布局,缺少 BIOS Boot 空间时增加 BIOS " -"引导的请求应在写入前失败。先备份用户文件和引导分区, 检查已安装 APK 数据库、信任密钥及所选更新介质。正常关闭已安装系统后, " -"再从安装介质启动。 在安装器中选择更新和目标磁盘后,独立的后台进程只读检查已安装系统、桌面 " -"类型、软件包数据库、安装介质和空间。检查完成后仍留在目标磁盘步骤, 显示检查结果和检测到的 BIOS/UEFI " -"引导选项;可以先修改选择,再继续到只读摘要。 摘要列出当前版本、介质版本、根分区、ESP、空间需求和引导方式。核对后点击更新。 " -"同盘有多个安装时,可在目标磁盘页选择明确的根分区和 ESP;留空 ESP 时读取 所选根的 fstab,不能简单取磁盘上第一个 " -"ESP。显式选择与该根的 fstab 不一致时 拒绝更新,避免把引导文件写到其他系统的分区。旧的 ``/boot`` 直接挂载 FAT32 " -"布局继续兼容,更新不强制改变现有挂载布局。 旧布局中未能通过所有权验证的现有 EFI 可执行文件及相邻配置会保留, 不会因系统更新而覆盖。兼容命令" -" ``reliefos-grub-installer`` 现直接转交原生 CLI,需要明确的 ``--disk``、``--boot-" -"directory`` 和根分区身份; 不再接受无法绑定安装实例的旧式单个 ESP 路径复制操作。 TTY " -"入口使用相同的后端,并在显示摘要和引导选项后通过 ``y/N`` 确认。" -msgstr "" -"Updates do not repartition automatically. Old two-partition UEFI disks " -"retain their layout; a request to add BIOS boot without BIOS Boot space " -"must fail before writing. First back up user files and boot partitions, " -"and check the installed APK database, trusted keys, and selected update " -"medium. Shut down the installed system normally before booting " -"installation media. After Update and a target disk are selected in the " -"installer, a separate background process performs read-only checks of the" -" installed system, desktop type, package database, installation medium, " -"and space. After inspection, the target disk step remains open and shows " -"the results and detected BIOS/UEFI bootloader choices. Adjust these " -"before continuing to the read-only review. The review lists the current " -"and medium versions, root partition, ESP, space requirements, and " -"bootloaders. Verify these and click Update. If the same disk contains " -"multiple installations, choose an explicit root partition and ESP on the " -"target disk page. Leaving ESP blank reads the selected root's fstab, " -"rather than simply taking the disk's first ESP. An explicit selection " -"inconsistent with that root's fstab is rejected to avoid writing boot " -"files to another system's partition. Legacy layouts mounting FAT32 " -"directly at ``/boot`` remain compatible; updates do not force changes to " -"existing mounts. Existing EFI executables and adjacent configuration in " -"old layouts that cannot pass ownership verification are preserved, rather" -" than overwritten by the system update. The compatibility command " -"``reliefos-grub-installer`` now forwards directly to the native CLI, " -"requiring explicit ``--disk``, ``--boot-directory``, and root partition " -"identity. It no longer accepts the old operation of copying to a single " -"ESP path without binding an installation instance. The TTY entry uses the" -" same backend and requests ``y/N`` confirmation after showing the summary" -" and boot options." - -msgid "" -"检查过程使用私有 APK 数据库和已安装系统的信任密钥,验证签名索引、完整 软件包归档以及离线依赖。私有数据库和归档临时存放在启动时挂载的 ``/run`` " -"tmpfs 中,结束后清理,避免占满安装介质的固定大小运行时根文件系统。 确认后的执行会再次核对磁盘、分区 " -"UUID、索引和 已安装包数据库及 world 选择;目标已经变化时需要重新检查。已被其他路径挂载的分区、 无法唯一识别的根分区或 " -"ESP,以及早于已安装系统的介质会在写入前被拒绝。" -msgstr "" -"Checks use a private APK database and the installed system's trusted keys" -" to verify signed indexes, complete package archives, and offline " -"dependencies. The private database and archives are stored temporarily in " -"the ``/run`` tmpfs mounted at boot and removed when the operation finishes, " -"so they do not fill the installation medium's fixed-size runtime root " -"filesystem. Execution after confirmation rechecks disks, partition " -"UUIDs, indexes, the installed package database, and world selections; " -"changed targets require a fresh check. Partitions already mounted " -"elsewhere, roots or ESPs that cannot be uniquely identified, and media " -"older than the installed system are rejected before writing." - -msgid "" -"根文件系统使用 APK 更新,保留外部包、world 选择和受保护配置;新默认配置 可能以 ``.apk-new`` " -"出现。根事务成功后才发布引导文件。 离线更新只从安装介质的签名仓库取得新软件包。``world`` 中已有的 " -"``@testing``、``@alpine`` 等标签在本次事务的私有配置中注册到该仓库, " -"使已安装的外部软件包可以继续满足依赖,不要求原仓库在线或保留索引缓存。 原有仓库配置和标签选择保持不变;介质和已安装软件包无法满足的版本约束 " -"仍会在预检查时拒绝,不会强制忽略依赖。 更新保留现有 fstab 和 swap 设置,不会自动添加或更改交换文件。 " -"更新详情显示软件包和引导操作的实际输出,完整日志位于安装器运行环境的 ``/var/log/installer-" -"update.log``。失败页面保留错误和日志位置,并返回目标磁盘步骤重新检查; " -"新安装失败后也先返回检查方案,不能把重新进入进度页当作已经获准再次擦盘。" -msgstr "" -"The root filesystem is updated with APK, preserving external packages, " -"world selections, and protected configuration; new defaults may appear as" -" ``.apk-new``. Boot files are published only after the root transaction " -"succeeds. Offline updates obtain new packages only from the installation " -"medium's signed repository. Existing tags in ``world``, such as " -"``@testing`` and ``@alpine``, are registered against that repository in " -"the transaction's private configuration, allowing installed external " -"packages to continue satisfying dependencies without requiring their " -"original repositories online or cached indexes. Existing repository " -"configuration and tag selections remain unchanged. Version constraints " -"that cannot be satisfied by the medium and installed packages are still " -"rejected during preflight; dependencies are not forcibly ignored. Updates" -" preserve existing fstab and swap settings and do not automatically add " -"or change swap files. Update details show actual output from package and " -"boot operations; the full log is at ``/var/log/installer-update.log`` in " -"the installer runtime. The failure page retains the error and log " -"location and returns to target disk selection for inspection. Failed " -"fresh installations also return to plan review; entering progress again " -"does not authorize another destructive write." - msgid "" "更新进度会显示当前的软件包或缓存归档、已处理数量和缓存大小,以及已复用的 缓存大小。大小按完成比较或发布的整个文件累计,正在复制的文件完成后计入;" " 包事务中的数量只计入当前包之前已处理的包。缓存归档和签名索引逐字节相同 时直接复用,内容不同则先写入独立临时文件并校验,再替换原文件。比较或写入" @@ -518,24 +429,6 @@ msgstr "" " retain the step, filename, and command exit status for diagnosing " "retries." -msgid "" -"目标系统的 ``/var/lib/reliefos/installer-update/state`` 持久记录软件包、根同步、 " -"引导提交和完成阶段。同一介质的引导提交失败后,重新检查会核对已完成的根 事务,再继续引导提交;软件包阶段失败则重新预检并执行包事务。旧内核模块 " -"保留与 A/B 内核发布继续使用共同的原生引导接口。更新期间由独立进程持有 安装器更新锁,释放目标挂载后才报告完成。APK " -"已记录为损坏的系统包会先通过 已验证的归档执行定向修复,再执行升级;已有的外部包错误保留并在日志中说明。" -msgstr "" -"The target system's ``/var/lib/reliefos/installer-update/state`` " -"persistently records package, root sync, boot commit, and completion " -"phases. After a boot commit fails for the same medium, rechecking " -"verifies the completed root transaction and resumes the boot commit; a " -"package-phase failure triggers a fresh preflight and package transaction." -" Retention of old kernel modules and A/B kernel publishing continue to " -"share the native boot interface. A separate process holds the installer " -"update lock throughout the update, reporting completion only after " -"releasing target mounts. System packages marked broken by APK are first " -"repaired selectively using verified archives, then upgraded. Existing " -"external-package errors are retained and explained in the log." - msgid "" "旧内核包清单中的 ``kerneldebug.sys`` 作为可选历史成员继续校验、保留和恢复, 以支持升级旧安装;新内核包和 ESP " "发布不生成该文件。历史成员若损坏或是符号 链接,仍会拒绝更新,不会跳过内核包完整性检查。" @@ -614,3 +507,127 @@ msgstr "" "bootloader have been tested booting from it. VirtIO-Block is not yet " "supported as a swap backend. It is not VMware PVSCSI; VMware validation " "is incomplete." + +msgid "" +"更新不自动重分区。旧两分区 UEFI 磁盘保持原有布局,缺少 BIOS Boot 空间时增加 BIOS 引导的请求应在写入前失败。先备份用户文件和引导分区, 检查已安装 APK " +"数据库、信任密钥及所选更新介质。正常关闭已安装系统后, 再从安装介质启动。 在安装器中选择更新和目标磁盘后,后台协调进程依次只读检查已安装系统、桌面 " +"类型、软件包数据库、安装介质、引导布局和空间,再验证离线软件包方案。 每个阶段在独立进程组中执行,界面持续显示当前阶段;慢速读盘期间也能响应 " +"取消检查。取消后先终止该阶段的所有进程并释放挂载,再返回目标磁盘步骤。 检查完成后仍留在目标磁盘步骤, 显示检查结果和检测到的 BIOS/UEFI " +"引导选项;可以先修改选择,再继续到只读摘要。 摘要列出当前版本、介质版本、根分区、ESP、空间需求和引导方式。核对后点击更新。 同盘有多个安装时,可在目标磁盘页选择明确的根分区和 " +"ESP;留空 ESP 时读取 所选根的 fstab,不能简单取磁盘上第一个 ESP。显式选择与该根的 fstab 不一致时 拒绝更新,避免把引导文件写到其他系统的分区。旧的 " +"``/boot`` 直接挂载 FAT32 布局继续兼容,更新不强制改变现有挂载布局。 旧布局中未能通过所有权验证的现有 EFI 可执行文件及相邻配置会保留, " +"不会因系统更新而覆盖。兼容命令 ``reliefos-grub-installer`` 现直接转交原生 CLI,需要明确的 " +"``--disk``、``--boot-directory`` 和根分区身份; 不再接受无法绑定安装实例的旧式单个 ESP 路径复制操作。 TTY " +"入口使用相同的后端,并在显示摘要和引导选项后通过 ``y/N`` 确认。" +msgstr "" +"Updates do not repartition automatically. Old two-partition UEFI disks retain their " +"layout; a request to add BIOS boot without BIOS Boot space must fail before writing. First " +"back up user files and boot partitions, and check the installed APK database, trusted " +"keys, and selected update medium. Shut down the installed system normally before booting " +"the installation media. After selecting Update and a target disk, the installer uses a " +"background coordinator to check the installed system, desktop type, package database, " +"installation medium, boot layout, and available space, then verifies the offline package " +"plan. Each stage runs in its own process group, and the interface shows the current stage. " +"Checks can be canceled while a slow disk is being read. Cancellation first stops the " +"stage's processes and releases its mounts, then returns to target disk selection. After " +"inspection, the target disk step remains open and shows the results and detected BIOS/UEFI " +"bootloader choices. Adjust these before continuing to the read-only review. The review " +"lists the installed and medium versions, root partition, ESP, space requirements, and " +"bootloaders. Verify these and click Update. If the same disk contains multiple " +"installations, choose an explicit root partition and ESP on the target disk page. Leaving " +"ESP blank reads the selected root's fstab, rather than simply taking the disk's first ESP. " +"An explicit selection inconsistent with that root's fstab is rejected to avoid writing " +"boot files to another system's partition. Legacy layouts mounting FAT32 directly at " +"``/boot`` remain compatible; updates do not force changes to existing mounts. Existing EFI " +"executables and adjacent configuration in old layouts that cannot pass ownership " +"verification are preserved, rather than overwritten by the system update. The " +"compatibility command ``reliefos-grub-installer`` now forwards directly to the native CLI, " +"requiring explicit ``--disk``, ``--boot-directory``, and root partition identity. It no " +"longer accepts the old operation of copying to a single ESP path without binding an " +"installation instance. The TTY entry uses the same backend and requests ``y/N`` " +"confirmation after showing the summary and boot options." + +msgid "" +"检查过程使用私有 APK 数据库和已安装系统的信任密钥,验证签名索引、完整 软件包归档以及离线依赖。私有数据库和有大小上限的计划数据临时存放在 ``/run`` tmpfs " +"中,结束后清理;归档直接从只读安装介质验证和读取, 不把整个仓库复制到内存。检查不修改目标系统。 空间预算包括介质归档缓存、所有包(含上游依赖)的逐包正增长、最大单包的 " +"替换空间及保留余量;不提前把尚未删除的包或缩小的文件折算成可用空间。 确认后的执行会再次核对磁盘、分区 UUID、索引和 已安装包数据库及 world " +"选择;目标已经变化时需要重新检查。已被其他路径挂载的分区、 无法唯一识别的根分区或 ESP,以及早于已安装系统的介质会在写入前被拒绝。" +msgstr "" +"Checks use a private APK database and the installed system's trusted keys to verify signed " +"indexes, complete package archives, and offline dependencies. The private database and " +"bounded planning data are stored temporarily in the ``/run`` tmpfs and removed at the end. " +"Archives are verified and read directly from the read-only installation medium, without " +"copying the entire repository into memory. Checks do not modify the target system. The " +"space budget includes cached media archives, positive per-package growth for all packages " +"including upstream dependencies, room to replace the largest package, and a reserve. It " +"does not count packages that have not yet been removed or size reductions as available " +"space. Execution after confirmation rechecks disks, partition UUIDs, indexes, the " +"installed package database, and world selections; changed targets require a fresh check. " +"Partitions already mounted elsewhere, roots or ESPs that cannot be uniquely identified, " +"and media older than the installed system are rejected before writing." + +msgid "" +"确认执行后不再单独重复一次完整检查;包事务在自己的预检通过后执行一次。 根文件系统使用 APK 更新,保留外部包、world 选择和受保护配置;新默认配置 可能以 " +"``.apk-new`` 出现。根事务成功后才发布引导文件。 离线更新只从安装介质的签名仓库取得新软件包。``world`` 中已有的 " +"``@testing``、``@alpine`` 等标签在本次事务的私有配置中注册到该仓库, 使已安装的外部软件包可以继续满足依赖,不要求原仓库在线或保留索引缓存。 " +"原有仓库配置和标签选择保持不变;介质和已安装软件包无法满足的版本约束 仍会在预检查时拒绝,不会强制忽略依赖。 更新保留现有 fstab 和 swap " +"设置,不会自动添加或更改交换文件。 软件包写入和引导发布期间不能通过界面取消。各阶段使用单调时钟计时:系统 识别和挂载准备最多 2 分钟,介质检查和现有引导布局检查最多 3 分钟, " +"引导源检查、恢复和根同步最多 5 分钟,依赖检查最多 15 分钟,包更新最多 60 分钟,引导发布最多 10 分钟。超时先请求终止,再强制终止整个进程组。 " +"界面的周期性状态表示协调进程仍在工作,不代表已完成新的文件或软件包。 如果内核中的 I/O 无法响应终止,协调进程继续持锁并报告等待,不能把仍存活 的写入进程当作已经退出。" +msgstr "" +"After confirmation, the installer does not repeat the complete inspection as a separate " +"step; the package transaction performs its own preflight once. The root filesystem is " +"updated with APK, preserving external packages, world selections, and protected " +"configuration; new defaults may appear as ``.apk-new``. Boot files are published only " +"after the root transaction succeeds. Offline updates obtain new packages only from the " +"installation medium's signed repository. Existing tags in ``world``, such as ``@testing`` " +"and ``@alpine``, are registered against that repository in the transaction's private " +"configuration, allowing installed external packages to continue satisfying dependencies " +"without requiring their original repositories online or cached indexes. Existing " +"repository configuration and tag selections remain unchanged. Version constraints that " +"cannot be satisfied by the medium and installed packages are still rejected during " +"preflight; dependencies are not forcibly ignored. Updates preserve existing fstab and swap " +"settings and do not automatically add or change swap files. Package writes and boot " +"publication cannot be canceled through the interface. Stages use monotonic deadlines: " +"system identification and mount preparation take at most 2 minutes; media and installed " +"boot-layout checks, 3 minutes; boot-source checks, recovery, and root synchronization, 5 " +"minutes; dependency planning, 15 minutes; package updates, 60 minutes; and boot " +"publication, 10 minutes. On timeout, the stage first receives a termination request, " +"followed by a forceful stop of its process group. Periodic interface updates indicate that " +"the coordinator is alive; they do not mean a new file or package has completed. If kernel " +"I/O cannot respond to termination, the coordinator keeps the lock and waits rather than " +"releasing a transaction with a live writer." + +msgid "" +"更新详情显示软件包和引导操作的实际输出,完整日志位于安装器运行环境的 ``/var/log/installer-update.log``。失败页面保留错误和日志位置,并返回目标磁盘" +"步骤重新检查; 新安装失败后也先返回检查方案,不能把重新进入进度页当作已经获准再次擦盘。" +msgstr "" +"Update details show actual output from package and boot operations; the full log is at " +"``/var/log/installer-update.log`` in the installer runtime. The failure page retains the " +"error and log location and returns to target disk selection for inspection. Failed fresh " +"installations also return to plan review; entering progress again does not authorize " +"another destructive write." + +msgid "" +"目标系统的 ``/var/lib/reliefos/installer-update/state`` 持久记录软件包、根同步、 " +"引导提交和完成阶段,记录通过临时文件、文件同步、原子替换和目录同步发布。 同一介质的引导提交失败后,重新检查会核对根分区、索引、包数据库和 world, " +"只有这些身份仍匹配时才跳过已完成的包事务,继续引导提交;软件包阶段失败 则重新预检并执行包修复。这属于向前修复,不是整个根文件系统的原子回滚。 旧内核模块 保留与 A/B " +"内核发布继续使用共同的原生引导接口。更新期间由独立进程持有 安装器更新锁,释放目标挂载后才报告完成。阶段及其子命令继承同一把锁, " +"避免协调进程意外退出后并行启动另一次写入。清理失败会保留工作区并报告错误; 检测到上次遗留的更新挂载时拒绝开始新事务,应保存日志并重启安装环境后重试。 APK " +"已记录为损坏的系统包会先通过 已验证的归档执行定向修复,再执行升级;已有的外部包错误保留并在日志中说明。" +msgstr "" +"The target system's ``/var/lib/reliefos/installer-update/state`` persistently records " +"package, root-sync, boot-commit, and completion phases. Each record is published using a " +"temporary file, file synchronization, atomic replacement, and directory synchronization. " +"After a boot commit fails for the same medium, rechecking verifies the root partition, " +"index, package database, and world selection. The installer skips the completed package " +"transaction and resumes boot publication only when all identities still match. A " +"package-phase failure triggers a fresh preflight and package repair. This is forward " +"recovery, not an atomic rollback of the whole root filesystem. Retention of old kernel " +"modules and A/B kernel publishing continue to share the native boot interface. The update " +"lock is inherited by each stage and its commands, preventing another write from starting " +"if the coordinator exits unexpectedly. Cleanup failures preserve the workspace and report " +"an error; if an old update mount remains, a new transaction is refused. Save the log and " +"restart the installer environment before retrying. System packages marked broken by APK " +"are first repaired selectively using verified archives, then upgraded. Existing " +"external-package errors are retained and explained in the log." diff --git a/Documentation/locale/ja/LC_MESSAGES/admin-guide/installation.po b/Documentation/locale/ja/LC_MESSAGES/admin-guide/installation.po index 98f41b26..55895b31 100644 --- a/Documentation/locale/ja/LC_MESSAGES/admin-guide/installation.po +++ b/Documentation/locale/ja/LC_MESSAGES/admin-guide/installation.po @@ -331,87 +331,12 @@ msgstr "" msgid "更新已有系统" msgstr "既存システムの更新" -msgid "" -"更新不自动重分区。旧两分区 UEFI 磁盘保持原有布局,缺少 BIOS Boot 空间时增加 BIOS " -"引导的请求应在写入前失败。先备份用户文件和引导分区, 检查已安装 APK 数据库、信任密钥及所选更新介质。正常关闭已安装系统后, " -"再从安装介质启动。 在安装器中选择更新和目标磁盘后,独立的后台进程只读检查已安装系统、桌面 " -"类型、软件包数据库、安装介质和空间。检查完成后仍留在目标磁盘步骤, 显示检查结果和检测到的 BIOS/UEFI " -"引导选项;可以先修改选择,再继续到只读摘要。 摘要列出当前版本、介质版本、根分区、ESP、空间需求和引导方式。核对后点击更新。 " -"同盘有多个安装时,可在目标磁盘页选择明确的根分区和 ESP;留空 ESP 时读取 所选根的 fstab,不能简单取磁盘上第一个 " -"ESP。显式选择与该根的 fstab 不一致时 拒绝更新,避免把引导文件写到其他系统的分区。旧的 ``/boot`` 直接挂载 FAT32 " -"布局继续兼容,更新不强制改变现有挂载布局。 旧布局中未能通过所有权验证的现有 EFI 可执行文件及相邻配置会保留, 不会因系统更新而覆盖。兼容命令" -" ``reliefos-grub-installer`` 现直接转交原生 CLI,需要明确的 ``--disk``、``--boot-" -"directory`` 和根分区身份; 不再接受无法绑定安装实例的旧式单个 ESP 路径复制操作。 TTY " -"入口使用相同的后端,并在显示摘要和引导选项后通过 ``y/N`` 确认。" -msgstr "" -"更新は自動で再パーティションしません。旧来の 2 パーティション UEFI ディスクは元の構成を保持し、BIOS Boot 領域がない状態で " -"BIOS 起動の追加を求めると書き込み前に失敗しなければなりません。まずユーザーファイルと起動パーティションをバックアップし、インストール済み " -"APK " -"データベース、信頼鍵、選択した更新メディアを確認します。インストール済みシステムを正常終了してからメディアで起動してください。インストーラーで更新と対象ディスクを選ぶと、独立したバックグラウンドプロセスが既存システム、デスクトップ種別、パッケージデータベース、メディア、容量を読み取り専用で確認します。検査後も対象ディスクの手順に留まり、検査結果と検出された" -" BIOS/UEFI " -"起動方式を表示します。選択を調整してから読み取り専用の確認画面へ進めます。確認画面には現在とメディアのバージョン、ルート、ESP、必要容量、起動方式を表示します。確認して更新をクリックしてください。同一ディスクに複数のインストールがある場合は、対象ディスクページでルートと" -" ESP を明示できます。ESP を空欄にすると選択したルートの fstab を読み、ディスクの最初の ESP " -"を単純に使用しません。明示指定がそのルートの fstab " -"と異なる場合は、他システムのパーティションへの起動ファイル書き込みを避けるため更新を拒否します。FAT32 を ``/boot`` " -"に直接マウントする旧構成も引き続き互換で、既存のマウント構成を強制変更しません。旧構成で所有関係を検証できなかった既存 EFI " -"実行ファイルと隣接設定は保持し、システム更新で上書きしません。互換コマンド ``reliefos-grub-installer`` " -"は現在ネイティブ CLI に直接転送し、明示的な ``--disk``、``--boot-" -"directory``、ルート識別情報が必要です。インストールインスタンスと結び付けられない、旧式の単一 ESP " -"パスへのコピー操作は受け付けません。TTY 入口も同じバックエンドを使い、概要と起動オプションの表示後に ``y/N`` で確認します。" - -msgid "" -"检查过程使用私有 APK 数据库和已安装系统的信任密钥,验证签名索引、完整 软件包归档以及离线依赖。私有数据库和归档临时存放在启动时挂载的 ``/run`` " -"tmpfs 中,结束后清理,避免占满安装介质的固定大小运行时根文件系统。 确认后的执行会再次核对磁盘、分区 " -"UUID、索引和 已安装包数据库及 world 选择;目标已经变化时需要重新检查。已被其他路径挂载的分区、 无法唯一识别的根分区或 " -"ESP,以及早于已安装系统的介质会在写入前被拒绝。" -msgstr "" -"確認処理は専用の APK " -"データベースとインストール済みシステムの信頼鍵を使用し、署名済みインデックス、パッケージアーカイブ全体、オフライン依存関係を検証します。" -"専用データベースとアーカイブは、起動時にマウントされる ``/run`` の tmpfs に一時保存し、処理の終了後に削除します。" -"これにより、インストールメディアの固定サイズの実行用ルートファイルシステムを使い切ることを防ぎます。確定後の実行時にもディスク、パーティション" -" UUID、インデックス、既存パッケージデータベース、world " -"の選択を再確認し、対象が変化していれば再検査が必要です。他の場所にマウント済みのパーティション、一意に識別できないルートや " -"ESP、既存システムより古いメディアは書き込み前に拒否します。" - -msgid "" -"根文件系统使用 APK 更新,保留外部包、world 选择和受保护配置;新默认配置 可能以 ``.apk-new`` " -"出现。根事务成功后才发布引导文件。 离线更新只从安装介质的签名仓库取得新软件包。``world`` 中已有的 " -"``@testing``、``@alpine`` 等标签在本次事务的私有配置中注册到该仓库, " -"使已安装的外部软件包可以继续满足依赖,不要求原仓库在线或保留索引缓存。 原有仓库配置和标签选择保持不变;介质和已安装软件包无法满足的版本约束 " -"仍会在预检查时拒绝,不会强制忽略依赖。 更新保留现有 fstab 和 swap 设置,不会自动添加或更改交换文件。 " -"更新详情显示软件包和引导操作的实际输出,完整日志位于安装器运行环境的 ``/var/log/installer-" -"update.log``。失败页面保留错误和日志位置,并返回目标磁盘步骤重新检查; " -"新安装失败后也先返回检查方案,不能把重新进入进度页当作已经获准再次擦盘。" -msgstr "" -"ルートファイルシステムは APK で更新し、外部パッケージ、world の選択、保護された設定を保持します。新しい既定設定は ``.apk-" -"new`` " -"として現れる場合があります。ルートのトランザクション成功後にだけ起動ファイルを公開します。オフライン更新で新規パッケージを取得するのはメディアの署名済みリポジトリからだけです。``world``" -" にある ``@testing``、``@alpine`` " -"などのタグは今回のトランザクション専用設定内でそのリポジトリに登録し、既存の外部パッケージが依存関係を満たし続けられるようにします。元のリポジトリのオンライン状態やインデックスキャッシュは要求しません。元のリポジトリ設定とタグ選択は保持し、メディアと既存パッケージで満たせないバージョン制約は事前検査で引き続き拒否して、依存関係を強制的に無視しません。既存の" -" fstab と swap 設定も保持し、swap " -"ファイルを自動追加・変更しません。更新の詳細にはパッケージ操作と起動操作の実際の出力を示し、完全なログはインストーラー実行環境の " -"``/var/log/installer-update.log`` " -"にあります。失敗画面にはエラーとログの場所を残し、対象ディスクの手順へ戻って再検査します。新規インストールの失敗後も先に構成を再確認し、進行画面に戻っただけで再度のディスク消去を許可したとは扱いません。" - msgid "" "更新进度会显示当前的软件包或缓存归档、已处理数量和缓存大小,以及已复用的 缓存大小。大小按完成比较或发布的整个文件累计,正在复制的文件完成后计入;" " 包事务中的数量只计入当前包之前已处理的包。缓存归档和签名索引逐字节相同 时直接复用,内容不同则先写入独立临时文件并校验,再替换原文件。比较或写入" " 出错会终止本次更新,日志和失败页保留步骤、文件名及命令退出状态,供重试定位。" msgstr "更新進行状況には現在のパッケージまたはキャッシュアーカイブ、処理済み件数、キャッシュ容量、再利用済み容量を表示します。容量は比較または公開を完了したファイル全体を累計し、コピー中のファイルは完了後に加算します。パッケージ処理の件数には現在のパッケージより前に処理済みのものだけを含めます。キャッシュアーカイブと署名済みインデックスがバイト単位で同じなら直接再利用し、内容が異なれば別の一時ファイルに書いて検証してから元を置換します。比較や書き込みのエラーは今回の更新を中止し、ログと失敗ページに手順、ファイル名、コマンド終了状態を残して再試行時の調査に使えるようにします。" -msgid "" -"目标系统的 ``/var/lib/reliefos/installer-update/state`` 持久记录软件包、根同步、 " -"引导提交和完成阶段。同一介质的引导提交失败后,重新检查会核对已完成的根 事务,再继续引导提交;软件包阶段失败则重新预检并执行包事务。旧内核模块 " -"保留与 A/B 内核发布继续使用共同的原生引导接口。更新期间由独立进程持有 安装器更新锁,释放目标挂载后才报告完成。APK " -"已记录为损坏的系统包会先通过 已验证的归档执行定向修复,再执行升级;已有的外部包错误保留并在日志中说明。" -msgstr "" -"対象システムの ``/var/lib/reliefos/installer-update/state`` " -"は、パッケージ、ルート同期、起動コミット、完了の各段階を永続記録します。同じメディアで起動コミットに失敗した後は、再検査で完了済みルートトランザクションを確認して起動コミットを再開します。パッケージ段階の失敗では事前検査とパッケージ処理を再実行します。旧カーネルモジュールの保持と" -" A/B " -"カーネル公開は、共通のネイティブ起動インターフェースを引き続き使います。更新中は独立したプロセスがインストーラー更新ロックを保持し、対象のマウント解放後にだけ完了を報告します。APK" -" " -"が破損済みと記録したシステムパッケージは、検証済みアーカイブで個別修復してから更新します。既存の外部パッケージのエラーは保持し、ログで説明します。" - msgid "" "旧内核包清单中的 ``kerneldebug.sys`` 作为可选历史成员继续校验、保留和恢复, 以支持升级旧安装;新内核包和 ESP " "发布不生成该文件。历史成员若损坏或是符号 链接,仍会拒绝更新,不会跳过内核包完整性检查。" @@ -474,3 +399,86 @@ msgstr "" "ディスクでは既存の GPT パーティションとファイルシステムを調べることができ、準備済みの ext4 パーティションをマウントできます。4Kn " "ディスクへの新規インストールや、そのディスクからのファームウェア・ブートローダー起動を確認したわけではありません。VirtIO-Block " "は現時点でスワップのバックエンドに使えません。VMware PVSCSI とは別のドライバーであり、VMware での検証は未完了です。" + +msgid "" +"更新不自动重分区。旧两分区 UEFI 磁盘保持原有布局,缺少 BIOS Boot 空间时增加 BIOS 引导的请求应在写入前失败。先备份用户文件和引导分区, 检查已安装 APK " +"数据库、信任密钥及所选更新介质。正常关闭已安装系统后, 再从安装介质启动。 在安装器中选择更新和目标磁盘后,后台协调进程依次只读检查已安装系统、桌面 " +"类型、软件包数据库、安装介质、引导布局和空间,再验证离线软件包方案。 每个阶段在独立进程组中执行,界面持续显示当前阶段;慢速读盘期间也能响应 " +"取消检查。取消后先终止该阶段的所有进程并释放挂载,再返回目标磁盘步骤。 检查完成后仍留在目标磁盘步骤, 显示检查结果和检测到的 BIOS/UEFI " +"引导选项;可以先修改选择,再继续到只读摘要。 摘要列出当前版本、介质版本、根分区、ESP、空间需求和引导方式。核对后点击更新。 同盘有多个安装时,可在目标磁盘页选择明确的根分区和 " +"ESP;留空 ESP 时读取 所选根的 fstab,不能简单取磁盘上第一个 ESP。显式选择与该根的 fstab 不一致时 拒绝更新,避免把引导文件写到其他系统的分区。旧的 " +"``/boot`` 直接挂载 FAT32 布局继续兼容,更新不强制改变现有挂载布局。 旧布局中未能通过所有权验证的现有 EFI 可执行文件及相邻配置会保留, " +"不会因系统更新而覆盖。兼容命令 ``reliefos-grub-installer`` 现直接转交原生 CLI,需要明确的 " +"``--disk``、``--boot-directory`` 和根分区身份; 不再接受无法绑定安装实例的旧式单个 ESP 路径复制操作。 TTY " +"入口使用相同的后端,并在显示摘要和引导选项后通过 ``y/N`` 确认。" +msgstr "" +"更新時に自動で再パーティションしません。旧来の 2 パーティション UEFI ディスクは元の構成を保持します。BIOS Boot 領域がない状態で BIOS " +"起動の追加を求めた場合は、書き込み前に失敗しなければなりません。まずユーザーファイルと起動パーティションをバックアップし、インストール済み APK " +"データベース、信頼鍵、選択した更新メディアを確認します。インストール済みシステムを正常終了してからメディアで起動してください。インストーラーで更新と対象ディスクを選ぶと、バックグラ" +"ウンドの調整プロセスが既存システム、デスクトップ種別、パッケージデータベース、メディア、起動レイアウト、空き容量を確認し、オフラインのパッケージ計画を検証します。各段階は独立したプ" +"ロセスグループで実行され、画面には現在の段階が表示されます。低速ディスクの読み取り中も検査をキャンセルできます。キャンセル時は、まず段階の全プロセスを停止してマウントを解放し、その" +"後対象ディスクの手順に戻ります。検査後も対象ディスクの手順に留まり、結果と検出された BIOS/UEFI " +"起動方式を表示します。選択を調整してから読み取り専用の確認画面へ進めます。確認画面にはインストール済みとメディアのバージョン、ルート、ESP、必要容量、起動方式を表示します。確認し" +"て更新をクリックしてください。同一ディスクに複数のインストールがある場合は、対象ディスクページでルートと ESP を明示できます。ESP を空欄にすると選択したルートの fstab " +"を読み、ディスクの最初の ESP を単純に使用しません。明示指定がそのルートの fstab と異なる場合は、他システムのパーティションへの起動ファイル書き込みを避けるため更新を拒否" +"します。FAT32 を ``/boot`` に直接マウントする旧構成も引き続き互換で、既存のマウント構成を強制変更しません。旧構成で所有関係を検証できなかった既存 EFI " +"実行ファイルと隣接設定は保持し、システム更新で上書きしません。互換コマンド ``reliefos-grub-installer`` は現在ネイティブ CLI に直接転送し、明示的な " +"``--disk``、``--boot-directory``、ルート識別情報が必要です。インストールインスタンスと結び付けられない旧式の単一 ESP " +"パスへのコピー操作は受け付けません。TTY 入口も同じバックエンドを使い、概要と起動オプションの表示後に ``y/N`` で確認します。" + +msgid "" +"检查过程使用私有 APK 数据库和已安装系统的信任密钥,验证签名索引、完整 软件包归档以及离线依赖。私有数据库和有大小上限的计划数据临时存放在 ``/run`` tmpfs " +"中,结束后清理;归档直接从只读安装介质验证和读取, 不把整个仓库复制到内存。检查不修改目标系统。 空间预算包括介质归档缓存、所有包(含上游依赖)的逐包正增长、最大单包的 " +"替换空间及保留余量;不提前把尚未删除的包或缩小的文件折算成可用空间。 确认后的执行会再次核对磁盘、分区 UUID、索引和 已安装包数据库及 world " +"选择;目标已经变化时需要重新检查。已被其他路径挂载的分区、 无法唯一识别的根分区或 ESP,以及早于已安装系统的介质会在写入前被拒绝。" +msgstr "" +"検査では専用の APK データベースとインストール済みシステムの信頼鍵を使用し、署名済みインデックス、パッケージアーカイブ全体、オフライン依存関係を検証します。専用データベースと上" +"限付きの計画データは ``/run`` の tmpfs に一時保存し、終了後に削除します。アーカイブは読み取り専用のインストールメディアから直接検証・読み取り、リポジトリ全体をメモ" +"リへコピーしません。検査によって対象システムは変更されません。容量の見積もりには、メディアアーカイブのキャッシュ、上流依存関係を含む全パッケージの正味増加分、最大パッケージ置換分、" +"予備領域を含めます。まだ削除されていないパッケージや縮小分を空き容量として先取りしません。確定後の実行時にもディスク、パーティション " +"UUID、インデックス、既存パッケージデータベース、world の選択を再確認し、対象が変化していれば再検査が必要です。他の場所にマウント済みのパーティション、一意に識別できないル" +"ートや ESP、既存システムより古いメディアは書き込み前に拒否します。" + +msgid "" +"确认执行后不再单独重复一次完整检查;包事务在自己的预检通过后执行一次。 根文件系统使用 APK 更新,保留外部包、world 选择和受保护配置;新默认配置 可能以 " +"``.apk-new`` 出现。根事务成功后才发布引导文件。 离线更新只从安装介质的签名仓库取得新软件包。``world`` 中已有的 " +"``@testing``、``@alpine`` 等标签在本次事务的私有配置中注册到该仓库, 使已安装的外部软件包可以继续满足依赖,不要求原仓库在线或保留索引缓存。 " +"原有仓库配置和标签选择保持不变;介质和已安装软件包无法满足的版本约束 仍会在预检查时拒绝,不会强制忽略依赖。 更新保留现有 fstab 和 swap " +"设置,不会自动添加或更改交换文件。 软件包写入和引导发布期间不能通过界面取消。各阶段使用单调时钟计时:系统 识别和挂载准备最多 2 分钟,介质检查和现有引导布局检查最多 3 分钟, " +"引导源检查、恢复和根同步最多 5 分钟,依赖检查最多 15 分钟,包更新最多 60 分钟,引导发布最多 10 分钟。超时先请求终止,再强制终止整个进程组。 " +"界面的周期性状态表示协调进程仍在工作,不代表已完成新的文件或软件包。 如果内核中的 I/O 无法响应终止,协调进程继续持锁并报告等待,不能把仍存活 的写入进程当作已经退出。" +msgstr "" +"確定後、完全な検査を別工程として重複実行しません。パッケージトランザクション自身の事前検査を一度実行します。ルートファイルシステムは APK で更新し、外部パッケージ、world " +"の選択、保護された設定を保持します。新しい既定設定は ``.apk-new`` として現れる場合があります。ルートのトランザクション成功後にだけ起動ファイルを公開します。オフライン" +"更新で新規パッケージを取得するのはメディアの署名済みリポジトリからだけです。``world`` にある ``@testing``、``@alpine`` " +"などのタグは今回のトランザクション専用設定内でそのリポジトリに登録し、既存の外部パッケージが依存関係を満たし続けられるようにします。元のリポジトリのオンライン状態やインデックスキャ" +"ッシュは要求しません。元のリポジトリ設定とタグ選択は保持し、メディアと既存パッケージで満たせないバージョン制約は事前検査で引き続き拒否して、依存関係を強制的に無視しません。既存の " +"fstab と swap 設定も保持し、swap ファイルを自動追加・変更しません。パッケージの書き込みと起動公開は画面からキャンセルできません。各段階は単調時計で期限を管理します" +"。システム識別とマウント準備は最大 2 分、メディアと既存起動レイアウトの検査は 3 分、起動元検査・復旧・ルート同期は 5 分、依存関係計画は 15 分、パッケージ更新は 60 " +"分、起動公開は 10 分です。期限超過時はまず終了要求を送り、その後プロセスグループを強制停止します。画面の定期更新は調整プロセスの稼働を示すもので、新しいファイルやパッケージの完" +"了を示すものではありません。カーネル I/O が終了要求に応答しない場合、書き込みプロセスが残ったままロックを解放せず、調整プロセスは保持したまま待機します。" + +msgid "" +"更新详情显示软件包和引导操作的实际输出,完整日志位于安装器运行环境的 ``/var/log/installer-update.log``。失败页面保留错误和日志位置,并返回目标磁盘" +"步骤重新检查; 新安装失败后也先返回检查方案,不能把重新进入进度页当作已经获准再次擦盘。" +msgstr "" +"更新の詳細にはパッケージ操作と起動操作の実際の出力を表示します。完全なログはインストーラー実行環境の ``/var/log/installer-update.log`` " +"にあります。失敗画面にはエラーとログの場所を残し、対象ディスクの手順へ戻って再検査します。新規インストールの失敗後も先に構成を再確認し、進行画面に戻っただけで再度のディスク消去を許" +"可したとは扱いません。" + +msgid "" +"目标系统的 ``/var/lib/reliefos/installer-update/state`` 持久记录软件包、根同步、 " +"引导提交和完成阶段,记录通过临时文件、文件同步、原子替换和目录同步发布。 同一介质的引导提交失败后,重新检查会核对根分区、索引、包数据库和 world, " +"只有这些身份仍匹配时才跳过已完成的包事务,继续引导提交;软件包阶段失败 则重新预检并执行包修复。这属于向前修复,不是整个根文件系统的原子回滚。 旧内核模块 保留与 A/B " +"内核发布继续使用共同的原生引导接口。更新期间由独立进程持有 安装器更新锁,释放目标挂载后才报告完成。阶段及其子命令继承同一把锁, " +"避免协调进程意外退出后并行启动另一次写入。清理失败会保留工作区并报告错误; 检测到上次遗留的更新挂载时拒绝开始新事务,应保存日志并重启安装环境后重试。 APK " +"已记录为损坏的系统包会先通过 已验证的归档执行定向修复,再执行升级;已有的外部包错误保留并在日志中说明。" +msgstr "" +"対象システムの ``/var/lib/reliefos/installer-update/state`` " +"は、パッケージ、ルート同期、起動コミット、完了の各段階を永続記録します。各記録は一時ファイル、ファイル同期、原子的置換、ディレクトリ同期を経て公開します。同じメディアで起動コミット" +"に失敗した後は、再検査でルートパーティション、インデックス、パッケージデータベース、world " +"の選択を確認します。すべての識別情報が一致する場合に限り、完了済みのパッケージ処理を省略して起動公開を再開します。パッケージ段階の失敗では事前検査とパッケージ修復を再実行します。こ" +"れは前進復旧であり、ルートファイルシステム全体の原子的なロールバックではありません。旧カーネルモジュールの保持と A/B " +"カーネル公開は、共通のネイティブ起動インターフェースを引き続き使います。段階とそのコマンドは更新ロックを継承し、調整プロセスが予期せず終了しても別の書き込みを開始できないようにしま" +"す。クリーンアップに失敗した場合は作業領域を保持してエラーを報告します。前回の更新マウントが残っていると新しい処理を拒否するため、ログを保存し、インストーラー環境を再起動してから再" +"試行してください。APK が破損済みと記録したシステムパッケージは、検証済みアーカイブで個別修復してから更新します。既存の外部パッケージのエラーは保持し、ログで説明します。" diff --git a/configs/nls/po/installer/installer.pot b/configs/nls/po/installer/installer.pot index 28476c3d..96b8d490 100644 --- a/configs/nls/po/installer/installer.pot +++ b/configs/nls/po/installer/installer.pot @@ -22,7 +22,7 @@ msgstr "" msgid "Account setup failed" msgstr "" -#: userland/apps/installer/main.cpp:175 +#: userland/apps/installer/main.cpp:212 msgid "Accounts" msgstr "" @@ -34,15 +34,15 @@ msgstr "" msgid "Add to Favorites" msgstr "" -#: userland/apps/installer/main.cpp:1025 +#: userland/apps/installer/main.cpp:1084 msgid "Add to plan" msgstr "" -#: userland/apps/installer/installer_update_engine.c:352 +#: userland/apps/installer/installer_update_engine.c:563 msgid "Administrator privileges are required" msgstr "" -#: userland/apps/installer/main.cpp:1210 +#: userland/apps/installer/main.cpp:1266 msgid "Administrator: root" msgstr "" @@ -54,7 +54,7 @@ msgstr "" msgid "Apply" msgstr "" -#: userland/apps/installer/installer_update_engine.c:418 +#: userland/apps/installer/installer_update_engine.c:623 msgid "Applying signed system packages" msgstr "" @@ -74,19 +74,19 @@ msgstr "" msgid "Automatic mode replaces its partition table; manual mode can preserve other partitions." msgstr "" -#: userland/apps/installer/main.cpp:1277 +#: userland/apps/installer/main.cpp:1333 msgid "Automatic partitioning creates a FAT32 ESP and an ext4 root. No BIOS Boot partition is needed." msgstr "" -#: userland/apps/installer/main.cpp:1278 +#: userland/apps/installer/main.cpp:1334 msgid "Automatic partitioning creates an unformatted BIOS Boot partition, a FAT32 ESP and an ext4 root. BIOS also uses the FAT32 partition for boot files." msgstr "" -#: userland/apps/installer/main.cpp:883 +#: userland/apps/installer/main.cpp:942 msgid "Automatic plan: BIOS Boot 1 MiB; ESP 128 MiB FAT32; root %llu MiB ext4.\nThis replaces all existing partitions only after confirmation." msgstr "" -#: userland/apps/installer/main.cpp:882 +#: userland/apps/installer/main.cpp:941 msgid "Automatic plan: ESP 128 MiB FAT32; root %llu MiB ext4.\nThis replaces all existing partitions only after confirmation." msgstr "" @@ -98,7 +98,7 @@ msgstr "" msgid "B BIOS E ESP R / D Data . Free" msgstr "" -#: userland/apps/installer/main.cpp:1128 +#: userland/apps/installer/main.cpp:1184 msgid "BIOS Boot" msgstr "" @@ -114,7 +114,7 @@ msgstr "" msgid "Boot partition" msgstr "" -#: userland/apps/installer/main.cpp:172 +#: configs/nls/messages/installer.c:16 msgid "Bootloaders" msgstr "" @@ -126,16 +126,24 @@ msgstr "" msgid "Cancel" msgstr "" +#: userland/apps/installer/main.cpp:299 +msgid "Cancel check" +msgstr "" + #: userland/apps/installer/installer_tty.c:397 msgid "Cancel installation" msgstr "" -#: userland/apps/installer/installer_tty.c:152 -msgid "Cannot display this partition layout." +#: userland/apps/installer/main.cpp:569 +msgid "Canceling the update check" msgstr "" -#: userland/apps/installer/main.cpp:480 -msgid "Cannot identify the selected partitions" +#: userland/apps/installer/installer_tui_job.c:229 +msgid "Canceling the update check. Waiting for cleanup." +msgstr "" + +#: userland/apps/installer/installer_tty.c:152 +msgid "Cannot display this partition layout." msgstr "" #: userland/apps/installer/installer_tty.c:233 @@ -150,11 +158,11 @@ msgstr "" msgid "Cannot read partition identity" msgstr "" -#: userland/apps/installer/main.cpp:912 +#: userland/apps/installer/main.cpp:971 msgid "Cannot read the partition layout" msgstr "" -#: userland/apps/installer/main.cpp:760 +#: userland/apps/installer/main.cpp:818 msgid "Cannot read the selected disk" msgstr "" @@ -162,19 +170,19 @@ msgstr "" msgid "Cannot select the requested locale." msgstr "" -#: userland/apps/installer/main.cpp:357 +#: userland/apps/installer/main.cpp:395 msgid "Cannot start the installation worker" msgstr "" -#: userland/apps/installer/main.cpp:467 +#: userland/apps/installer/main.cpp:525 msgid "Cannot start the update worker" msgstr "" -#: userland/apps/installer/main.cpp:949 +#: userland/apps/installer/main.cpp:1008 msgid "Cannot update the partition plan" msgstr "" -#: userland/apps/installer/main.cpp:1054 +#: userland/apps/installer/main.cpp:1113 msgid "Change added to the installation plan." msgstr "" @@ -190,11 +198,11 @@ msgstr "" msgid "Changes remain pending until you confirm the installation. Going back keeps your choices." msgstr "" -#: userland/apps/installer/main.cpp:192 +#: userland/apps/installer/main.cpp:229 msgid "Check Again" msgstr "" -#: userland/apps/installer/main.cpp:197 +#: userland/apps/installer/main.cpp:234 msgid "Check Update" msgstr "" @@ -202,23 +210,23 @@ msgstr "" msgid "Check system" msgstr "" -#: userland/apps/installer/main.cpp:1364 +#: userland/apps/installer/main.cpp:1420 msgid "Check the target and planned changes. Use Back or the sidebar to change your choices." msgstr "" -#: userland/apps/installer/installer_tty.c:489 +#: userland/apps/installer/installer_tty.c:493 msgid "Check username and matching passwords (1-32 characters, no spaces)." msgstr "" -#: userland/apps/installer/installer_update_engine.c:393 -msgid "Checking bootloader compatibility" +#: userland/apps/installer/installer_update_engine.c:611 +msgid "Checking bootloader files on the installation media" msgstr "" -#: userland/apps/installer/installer_update_engine.c:369 +#: userland/apps/installer/installer_update_engine.c:610 msgid "Checking installation media and free space" msgstr "" -#: userland/apps/installer/installer_tui_job.c:101 +#: userland/apps/installer/installer_tui_job.c:215 msgid "Checking installed system" msgstr "" @@ -226,27 +234,27 @@ msgstr "" msgid "Checking signed repository and package archives" msgstr "" -#: userland/apps/installer/main.cpp:1443 +#: userland/apps/installer/main.cpp:1499 msgid "Checking system update" msgstr "" -#: userland/apps/installer/main.cpp:502 -msgid "Checking the selected system" +#: userland/apps/installer/installer_update_engine.c:612 +msgid "Checking the installed bootloader layout" msgstr "" -#: userland/apps/installer/installer_update_engine.c:348 -msgid "Checking update target" +#: userland/apps/installer/main.cpp:550 +msgid "Checking the selected system" msgstr "" #: userland/apps/installer/installer_tty.c:264 msgid "Choose a language, then configure your installation. You can return to earlier steps before installing." msgstr "" -#: userland/apps/installer/main.cpp:696 +#: userland/apps/installer/main.cpp:754 msgid "Choose a new installation or update an existing ReliefOS system." msgstr "" -#: userland/apps/installer/main.cpp:1294 +#: userland/apps/installer/main.cpp:1350 msgid "Choose bootloaders" msgstr "" @@ -254,7 +262,7 @@ msgstr "" msgid "Choose how this disk will start. Selecting BIOS and UEFI supports both firmware types; the partition plan follows this choice." msgstr "" -#: userland/apps/installer/main.cpp:1320 +#: userland/apps/installer/main.cpp:1376 msgid "Choose the desktop and additional disk space for virtual memory." msgstr "" @@ -270,7 +278,7 @@ msgstr "" msgid "Choose the installed desktop and optional swapfile. These choices are included in the final review." msgstr "" -#: userland/apps/installer/main.cpp:640 +#: userland/apps/installer/main.cpp:698 msgid "Choose the language for Setup and the installed system." msgstr "" @@ -282,6 +290,10 @@ msgstr "" msgid "Close" msgstr "" +#: userland/apps/installer/installer_update_engine.c:637 +msgid "Closing the update target" +msgstr "" + #: userland/apps/installer/installer_update_progress.c:138 msgid "Comparing contents" msgstr "" @@ -290,7 +302,7 @@ msgstr "" msgid "Completed" msgstr "" -#: userland/apps/installer/installer_tty.c:62 +#: configs/nls/messages/installer.c:17 msgid "Configure partitions" msgstr "" @@ -298,11 +310,11 @@ msgstr "" msgid "Configuring installed system" msgstr "" -#: userland/apps/installer/main.cpp:176 +#: userland/apps/installer/main.cpp:213 msgid "Confirm" msgstr "" -#: userland/apps/installer/installer_tty.c:320 +#: configs/nls/messages/installer.c:22 msgid "Confirm password" msgstr "" @@ -314,7 +326,7 @@ msgstr "" msgid "Console only" msgstr "" -#: userland/apps/installer/main.cpp:1330 +#: userland/apps/installer/main.cpp:1386 msgid "Console only installs without a graphical login. XFCE is an experimental desktop option." msgstr "" @@ -386,7 +398,7 @@ msgstr "" msgid "Data partition" msgstr "" -#: userland/apps/installer/installer_tty.c:156 +#: configs/nls/messages/installer.c:23 msgid "Delete" msgstr "" @@ -410,7 +422,7 @@ msgstr "" msgid "Discard changes" msgstr "" -#: userland/apps/installer/main.cpp:1143 +#: userland/apps/installer/main.cpp:1200 msgid "Discard edits" msgstr "" @@ -418,7 +430,7 @@ msgstr "" msgid "Discard partition changes" msgstr "" -#: userland/apps/installer/main.cpp:1068 +#: userland/apps/installer/main.cpp:1127 msgid "Discard pending partition edits and reload the disk?" msgstr "" @@ -426,7 +438,7 @@ msgstr "" msgid "Discard the pending partition changes and read the current disk layout again?" msgstr "" -#: userland/apps/installer/main.cpp:171 +#: userland/apps/installer/main.cpp:208 msgid "Disk" msgstr "" @@ -434,23 +446,23 @@ msgstr "" msgid "Disk " msgstr "" -#: userland/apps/installer/main.cpp:1403 +#: userland/apps/installer/main.cpp:1459 msgid "Disk changes to apply" msgstr "" -#: userland/apps/installer/main.cpp:1099 +#: userland/apps/installer/main.cpp:1158 msgid "Disk layout" msgstr "" -#: userland/apps/installer/installer_tui_job.c:111 +#: userland/apps/installer/installer_tui_job.c:225 msgid "Disk operations are running. Please wait for completion." msgstr "" -#: userland/apps/installer/main.cpp:1444 +#: userland/apps/installer/main.cpp:1500 msgid "Do not turn off this machine." msgstr "" -#: userland/apps/installer/main.cpp:815 +#: userland/apps/installer/main.cpp:874 msgid "EFI system partition" msgstr "" @@ -462,7 +474,7 @@ msgstr "" msgid "Enter a positive whole number of MiB." msgstr "" -#: userland/apps/installer/installer_tty.c:494 +#: userland/apps/installer/installer_tty.c:498 msgid "Enter a valid swap size in MiB." msgstr "" @@ -474,7 +486,7 @@ msgstr "" msgid "Erase all partitions on %s.\nCreate ESP: 128 MiB, format FAT32.\nCreate system root: %llu MiB, format ext4." msgstr "" -#: userland/apps/installer/main.cpp:1100 +#: userland/apps/installer/main.cpp:1159 msgid "Erase disk and install automatically" msgstr "" @@ -490,7 +502,7 @@ msgstr "" msgid "Exit" msgstr "" -#: userland/apps/installer/main.cpp:520 +#: userland/apps/installer/main.cpp:578 msgid "Exit installer" msgstr "" @@ -498,7 +510,7 @@ msgstr "" msgid "Exit the installer?" msgstr "" -#: userland/apps/installer/main.cpp:521 +#: userland/apps/installer/main.cpp:579 msgid "Exit the installer? Unapplied disk changes and setup choices will be discarded." msgstr "" @@ -526,15 +538,15 @@ msgstr "" msgid "Filesystem label" msgstr "" -#: userland/apps/installer/main.cpp:179 +#: userland/apps/installer/main.cpp:216 msgid "Finish" msgstr "" -#: userland/apps/installer/installer_update_engine.c:437 +#: userland/apps/installer/installer_update_engine.c:627 msgid "Finishing the system update" msgstr "" -#: userland/apps/installer/installer_tty.c:156 +#: configs/nls/messages/installer.c:24 msgid "Format" msgstr "" @@ -550,7 +562,7 @@ msgstr "" msgid "Free / required space" msgstr "" -#: userland/apps/installer/main.cpp:699 +#: userland/apps/installer/main.cpp:757 msgid "Fresh Install" msgstr "" @@ -558,7 +570,7 @@ msgstr "" msgid "Go back to edit any option. Nothing is written until you choose Install." msgstr "" -#: userland/apps/installer/main.cpp:671 +#: userland/apps/installer/main.cpp:729 msgid "I accept the license terms" msgstr "" @@ -566,7 +578,7 @@ msgstr "" msgid "IceWM (default)" msgstr "" -#: userland/apps/installer/installer_update_engine.c:363 +#: userland/apps/installer/installer_update_engine.c:609 msgid "Identifying the installed system" msgstr "" @@ -582,7 +594,7 @@ msgstr "" msgid "Install" msgstr "" -#: userland/apps/installer/main.cpp:631 +#: userland/apps/installer/main.cpp:689 msgid "Install ReliefOS" msgstr "" @@ -610,11 +622,11 @@ msgstr "" msgid "Installation" msgstr "" -#: userland/apps/installer/main.cpp:1471 +#: userland/apps/installer/main.cpp:1527 msgid "Installation Complete" msgstr "" -#: userland/apps/installer/main.cpp:1497 +#: userland/apps/installer/main.cpp:1553 msgid "Installation Failed" msgstr "" @@ -646,11 +658,11 @@ msgstr "" msgid "Installation media is incomplete" msgstr "" -#: userland/apps/installer/installer_update_engine.c:257 +#: userland/apps/installer/installer_update_engine.c:300 msgid "Installation media is older than the installed system" msgstr "" -#: userland/apps/installer/model.c:167 +#: configs/nls/messages/installer.c:14 msgid "Installation mode" msgstr "" @@ -662,11 +674,11 @@ msgstr "" msgid "Installation result" msgstr "" -#: userland/apps/installer/main.cpp:695 +#: userland/apps/installer/main.cpp:753 msgid "Installation type" msgstr "" -#: userland/apps/installer/main.cpp:328 +#: userland/apps/installer/main.cpp:366 msgid "Installation worker failed" msgstr "" @@ -702,23 +714,23 @@ msgstr "" msgid "Invalid swap size" msgstr "" -#: userland/apps/installer/main.cpp:1067 +#: userland/apps/installer/main.cpp:1126 msgid "Keep changes" msgstr "" -#: userland/apps/installer/main.cpp:520 +#: userland/apps/installer/main.cpp:578 msgid "Keep configuring" msgstr "" -#: userland/apps/installer/installer_tty.c:374 +#: configs/nls/messages/installer.c:11 msgid "Language" msgstr "" -#: userland/apps/installer/main.cpp:169 +#: configs/nls/messages/installer.c:12 msgid "License" msgstr "" -#: userland/apps/installer/main.cpp:660 +#: userland/apps/installer/main.cpp:718 msgid "License agreement" msgstr "" @@ -726,11 +738,11 @@ msgstr "" msgid "Manage Favorites" msgstr "" -#: userland/apps/installer/main.cpp:891 +#: userland/apps/installer/main.cpp:950 msgid "Manual layout: assign BIOS Boot, ESP and root roles. BIOS Boot stays unformatted." msgstr "" -#: userland/apps/installer/main.cpp:890 +#: userland/apps/installer/main.cpp:949 msgid "Manual layout: assign a FAT32 ESP and an ext4 or ext3 root. BIOS Boot is not required for the selected bootloaders." msgstr "" @@ -738,11 +750,11 @@ msgstr "" msgid "Manual partitioning" msgstr "" -#: userland/apps/installer/main.cpp:1101 +#: userland/apps/installer/main.cpp:1160 msgid "Manual partitioning / keep other systems" msgstr "" -#: userland/apps/installer/main.cpp:170 +#: userland/apps/installer/main.cpp:207 msgid "Mode" msgstr "" @@ -750,7 +762,7 @@ msgstr "" msgid "Mount failed" msgstr "" -#: userland/apps/installer/install_ops.c:836 +#: configs/nls/messages/installer.c:5 msgid "Mounting target filesystems" msgstr "" @@ -762,11 +774,11 @@ msgstr "" msgid "New Directory?" msgstr "" -#: userland/apps/installer/main.cpp:1118 +#: configs/nls/messages/installer.c:31 msgid "New GPT" msgstr "" -#: userland/apps/installer/main.cpp:966 +#: userland/apps/installer/main.cpp:1025 msgid "New partition table added to the plan." msgstr "" @@ -786,7 +798,7 @@ msgstr "" msgid "No disks were found" msgstr "" -#: userland/apps/installer/main.cpp:1500 +#: userland/apps/installer/main.cpp:1556 msgid "No writes will continue after this error." msgstr "" @@ -814,7 +826,7 @@ msgstr "" msgid "Partition %u %s %llu MiB %s %s%s" msgstr "" -#: userland/apps/installer/main.cpp:973 +#: userland/apps/installer/main.cpp:1032 msgid "Partition deletion added to the plan." msgstr "" @@ -830,7 +842,7 @@ msgstr "" msgid "Partition operation failed" msgstr "" -#: userland/apps/installer/main.cpp:951 +#: userland/apps/installer/main.cpp:1010 msgid "Partition plan updated" msgstr "" @@ -838,11 +850,11 @@ msgstr "" msgid "Partition role" msgstr "" -#: userland/apps/installer/main.cpp:1088 +#: userland/apps/installer/main.cpp:1147 msgid "Partition role updated." msgstr "" -#: userland/apps/installer/main.cpp:173 +#: userland/apps/installer/main.cpp:210 msgid "Partitions" msgstr "" @@ -866,11 +878,11 @@ msgstr "" msgid "Pending layout - written only after INSTALL confirmation." msgstr "" -#: userland/apps/installer/main.cpp:971 +#: userland/apps/installer/main.cpp:1030 msgid "Plan deletion" msgstr "" -#: userland/apps/installer/main.cpp:964 +#: userland/apps/installer/main.cpp:1023 msgid "Plan new table" msgstr "" @@ -882,11 +894,11 @@ msgstr "" msgid "Power operation failed" msgstr "" -#: userland/apps/installer/main.cpp:710 +#: userland/apps/installer/main.cpp:768 msgid "Prepare a clean ReliefOS system with automatic or manual disk partitioning." msgstr "" -#: userland/apps/installer/installer_tui_job.c:109 +#: userland/apps/installer/installer_tui_job.c:223 msgid "Preparing operation" msgstr "" @@ -894,14 +906,18 @@ msgstr "" msgid "Preparing target disk" msgstr "" -#: userland/apps/installer/installer_update_engine.c:410 +#: userland/apps/installer/installer_update_engine.c:620 msgid "Preparing the installed system for update" msgstr "" -#: userland/apps/installer/main.cpp:502 +#: userland/apps/installer/main.cpp:550 msgid "Preparing the system update" msgstr "" +#: userland/apps/installer/installer_update_engine.c:568 +msgid "Preparing update session" +msgstr "" + #: userland/apps/installer/installer_update_progress.c:15 msgid "Preparing verified package archives" msgstr "" @@ -918,11 +934,11 @@ msgstr "" msgid "Preview" msgstr "" -#: userland/apps/installer/main.cpp:632 +#: userland/apps/installer/main.cpp:690 msgid "Previous Step" msgstr "" -#: userland/apps/installer/installer_update_engine.c:429 +#: userland/apps/installer/installer_update_engine.c:626 msgid "Publishing kernel and bootloader files" msgstr "" @@ -934,11 +950,11 @@ msgstr "" msgid "Ready" msgstr "" -#: userland/apps/installer/main.cpp:429 +#: userland/apps/installer/main.cpp:485 msgid "Ready to update" msgstr "" -#: userland/apps/installer/installer_update_engine.c:313 +#: userland/apps/installer/installer_update_engine.c:346 msgid "Recovering the previous update attempt" msgstr "" @@ -946,15 +962,15 @@ msgstr "" msgid "Refresh" msgstr "" -#: userland/apps/installer/main.cpp:813 +#: userland/apps/installer/main.cpp:872 msgid "ReliefOS system partition" msgstr "" -#: userland/apps/installer/main.cpp:1474 +#: userland/apps/installer/main.cpp:1530 msgid "ReliefOS was installed to the selected disk." msgstr "" -#: userland/apps/installer/main.cpp:1473 +#: userland/apps/installer/main.cpp:1529 msgid "ReliefOS was updated on the selected disk." msgstr "" @@ -966,11 +982,11 @@ msgstr "" msgid "Remove the installation media before rebooting." msgstr "" -#: userland/apps/installer/main.cpp:434 +#: userland/apps/installer/main.cpp:490 msgid "Remove the installation media, then restart." msgstr "" -#: userland/apps/installer/main.cpp:972 +#: userland/apps/installer/main.cpp:1031 msgid "Remove the selected partition when the installation is confirmed?" msgstr "" @@ -978,7 +994,7 @@ msgstr "" msgid "Removing retired package archives" msgstr "" -#: userland/apps/installer/installer_tty.c:156 +#: configs/nls/messages/installer.c:27 msgid "Rename" msgstr "" @@ -994,7 +1010,7 @@ msgstr "" msgid "Replace partition table" msgstr "" -#: userland/apps/installer/main.cpp:965 +#: userland/apps/installer/main.cpp:1024 msgid "Replace this disk's partition table in the installation plan? All existing partitions will be removed when you install." msgstr "" @@ -1010,7 +1026,7 @@ msgstr "" msgid "Resize the terminal to at least 60 columns and 20 rows." msgstr "" -#: userland/apps/installer/main.cpp:984 +#: userland/apps/installer/main.cpp:1043 msgid "Resizing changes the partition boundary. Existing filesystems cannot be shrunk here." msgstr "" @@ -1018,7 +1034,7 @@ msgstr "" msgid "Restart" msgstr "" -#: userland/apps/installer/main.cpp:1490 +#: userland/apps/installer/main.cpp:1546 msgid "Restart failed" msgstr "" @@ -1026,15 +1042,11 @@ msgstr "" msgid "Restoring retained kernel files" msgstr "" -#: userland/apps/installer/installer_update_engine.c:429 -msgid "Resuming bootloader publication" -msgstr "" - #: userland/apps/installer/installer_update_progress.c:140 msgid "Reused" msgstr "" -#: userland/apps/installer/main.cpp:1363 +#: configs/nls/messages/installer.c:19 msgid "Review installation" msgstr "" @@ -1042,7 +1054,7 @@ msgstr "" msgid "Review settings" msgstr "" -#: userland/apps/installer/main.cpp:1363 +#: userland/apps/installer/main.cpp:1419 msgid "Review system update" msgstr "" @@ -1050,15 +1062,15 @@ msgstr "" msgid "Review the configuration before trying again. Changes already written to disk may remain." msgstr "" -#: userland/apps/installer/main.cpp:1499 +#: userland/apps/installer/main.cpp:1555 msgid "Review the details, then check the update again to retry." msgstr "" -#: userland/apps/installer/main.cpp:429 +#: userland/apps/installer/main.cpp:485 msgid "Review the detected system and boot options, then continue to the summary." msgstr "" -#: userland/apps/installer/installer_tty.c:510 +#: userland/apps/installer/installer_tty.c:514 msgid "Review the disk layout and account settings before installing." msgstr "" @@ -1066,11 +1078,11 @@ msgstr "" msgid "Review the disk model, size and partitions before applying changes." msgstr "" -#: userland/apps/installer/installer_tty.c:485 +#: userland/apps/installer/installer_tty.c:489 msgid "Review the required BIOS Boot, ESP and root partitions." msgstr "" -#: userland/apps/installer/main.cpp:197 +#: userland/apps/installer/main.cpp:234 msgid "Review update" msgstr "" @@ -1090,19 +1102,19 @@ msgstr "" msgid "Scanning installation payload" msgstr "" -#: userland/apps/installer/main.cpp:800 +#: userland/apps/installer/main.cpp:858 msgid "Select Disk to Update" msgstr "" -#: userland/apps/installer/main.cpp:800 +#: userland/apps/installer/main.cpp:858 msgid "Select Installation Disk" msgstr "" -#: userland/apps/installer/main.cpp:639 +#: userland/apps/installer/main.cpp:697 msgid "Select Language" msgstr "" -#: userland/apps/installer/main.cpp:802 +#: userland/apps/installer/main.cpp:860 msgid "Select a disk and check its existing installation before continuing." msgstr "" @@ -1110,6 +1122,10 @@ msgstr "" msgid "Select a disk first." msgstr "" +#: userland/apps/installer/main.cpp:477 +msgid "Select a disk or run the checks again." +msgstr "" + #: userland/apps/installer/installer_tty.c:62 msgid "Select a partition first." msgstr "" @@ -1122,10 +1138,6 @@ msgstr "" msgid "Select boot partition" msgstr "" -#: userland/apps/installer/main.cpp:1109 -msgid "Select partitions for ReliefOS and keep other systems or data." -msgstr "" - #: userland/apps/installer/installer_tty.c:296 msgid "Select system partition" msgstr "" @@ -1134,7 +1146,7 @@ msgstr "" msgid "Select the disk to update" msgstr "" -#: userland/apps/installer/main.cpp:1295 +#: userland/apps/installer/main.cpp:1351 msgid "Select the firmware used to start this disk. You can select both BIOS and UEFI." msgstr "" @@ -1142,7 +1154,7 @@ msgstr "" msgid "Select the target disk" msgstr "" -#: userland/apps/installer/main.cpp:803 +#: userland/apps/installer/main.cpp:861 msgid "Select the target. The disk layout is configured in the following steps." msgstr "" @@ -1150,7 +1162,7 @@ msgstr "" msgid "Selected system does not support swap" msgstr "" -#: userland/apps/installer/main.cpp:232 +#: userland/apps/installer/main.cpp:269 msgid "Setup" msgstr "" @@ -1158,7 +1170,7 @@ msgstr "" msgid "Setup will check for an existing ReliefOS system." msgstr "" -#: userland/apps/installer/installer_tui_job.c:113 +#: userland/apps/installer/installer_tui_job.c:227 msgid "Show / hide log (F4)" msgstr "" @@ -1174,7 +1186,7 @@ msgstr "" msgid "Shut down" msgstr "" -#: userland/apps/installer/main.cpp:1384 +#: userland/apps/installer/main.cpp:1440 msgid "Signed packages are checked before changes. Boot files are published after the package transaction succeeds." msgstr "" @@ -1182,7 +1194,7 @@ msgstr "" msgid "Size" msgstr "" -#: userland/apps/installer/main.cpp:993 +#: userland/apps/installer/main.cpp:1052 msgid "Size (MiB)" msgstr "" @@ -1190,7 +1202,7 @@ msgstr "" msgid "Size in MiB" msgstr "" -#: userland/apps/installer/main.cpp:1373 +#: userland/apps/installer/main.cpp:1429 msgid "Skip" msgstr "" @@ -1206,7 +1218,11 @@ msgstr "" msgid "Step %d of %d" msgstr "" -#: userland/apps/installer/main.cpp:1402 +#: userland/apps/installer/installer_update_engine.c:521 +msgid "Stopping update check and cleaning up" +msgstr "" + +#: userland/apps/installer/main.cpp:1458 msgid "Swap" msgstr "" @@ -1214,7 +1230,7 @@ msgstr "" msgid "Swap requires an AHCI disk" msgstr "" -#: userland/apps/installer/main.cpp:1341 +#: userland/apps/installer/main.cpp:1397 msgid "Swap size (MiB)" msgstr "" @@ -1222,7 +1238,7 @@ msgstr "" msgid "Swap size in MiB" msgstr "" -#: userland/apps/installer/main.cpp:1349 +#: userland/apps/installer/main.cpp:1405 msgid "Swap uses space on the system partition and currently requires an AHCI disk. Enter a valid whole number of MiB." msgstr "" @@ -1234,15 +1250,15 @@ msgstr "" msgid "Synchronizing the offline package cache" msgstr "" -#: userland/apps/installer/installer_update_engine.c:424 +#: userland/apps/installer/installer_update_engine.c:624 msgid "Synchronizing the updated root filesystem" msgstr "" -#: userland/apps/installer/main.cpp:174 +#: userland/apps/installer/main.cpp:211 msgid "System" msgstr "" -#: userland/apps/installer/main.cpp:1319 +#: userland/apps/installer/main.cpp:1375 msgid "System options" msgstr "" @@ -1258,7 +1274,7 @@ msgstr "" msgid "System root: %s; format %s.\nESP: %s; %s.\nOther partitions are preserved except for the changes listed above." msgstr "" -#: userland/apps/installer/installer_update_engine.c:453 +#: userland/apps/installer/installer_update_engine.c:647 msgid "System update completed successfully" msgstr "" @@ -1270,7 +1286,7 @@ msgstr "" msgid "Tab / arrows: select Space: toggle PgUp/PgDn: scroll" msgstr "" -#: userland/apps/installer/installer_tty.c:415 +#: configs/nls/messages/installer.c:15 msgid "Target disk" msgstr "" @@ -1282,15 +1298,11 @@ msgstr "" msgid "Target disk is ready." msgstr "" -#: userland/apps/installer/installer_update_engine.c:382 -msgid "Target or media changed. Check the update again." -msgstr "" - #: userland/apps/installer/installer_tty.c:151 msgid "The automatic layout does not fit this disk. Select another disk or configure partitions manually." msgstr "" -#: userland/apps/installer/installer_tty.c:504 +#: userland/apps/installer/installer_tty.c:508 msgid "The confirmation word does not match." msgstr "" @@ -1298,10 +1310,6 @@ msgstr "" msgid "The disk plan could not be read. Return to Disk layout and review the target." msgstr "" -#: userland/apps/installer/main.cpp:1107 -msgid "The entire disk will be replaced. To preserve another system or data partition, choose manual partitioning." -msgstr "" - #: userland/apps/installer/installer_tty.c:203 msgid "The selected ESP will also be formatted." msgstr "" @@ -1314,15 +1322,15 @@ msgstr "" msgid "The system partition will be formatted. Review every pending change below." msgstr "" -#: userland/apps/installer/installer_tui_job.c:116 +#: userland/apps/installer/installer_tui_job.c:230 msgid "The terminal requested exit. Waiting for the disk operation to finish." msgstr "" -#: userland/apps/installer/main.cpp:1416 +#: userland/apps/installer/main.cpp:1472 msgid "These disk changes cannot be undone. Type INSTALL to confirm." msgstr "" -#: userland/apps/installer/main.cpp:985 +#: userland/apps/installer/main.cpp:1044 msgid "This change is added to the plan. Nothing is written until installation is confirmed." msgstr "" @@ -1334,7 +1342,7 @@ msgstr "" msgid "Type the confirmation word" msgstr "" -#: userland/apps/installer/main.cpp:1484 +#: userland/apps/installer/main.cpp:1540 msgid "UEFI boot file (add it in firmware if no automatic entry appears):" msgstr "" @@ -1342,7 +1350,7 @@ msgstr "" msgid "Unallocated" msgstr "" -#: userland/apps/installer/main.cpp:920 +#: userland/apps/installer/main.cpp:979 msgid "Unformatted" msgstr "" @@ -1358,15 +1366,15 @@ msgstr "" msgid "Update" msgstr "" -#: userland/apps/installer/main.cpp:1471 +#: userland/apps/installer/main.cpp:1527 msgid "Update Complete" msgstr "" -#: userland/apps/installer/main.cpp:701 +#: userland/apps/installer/main.cpp:759 msgid "Update Existing System" msgstr "" -#: userland/apps/installer/main.cpp:1497 +#: userland/apps/installer/main.cpp:1553 msgid "Update Failed" msgstr "" @@ -1374,11 +1382,23 @@ msgstr "" msgid "Update an existing system" msgstr "" -#: userland/apps/installer/main.cpp:825 +#: userland/apps/installer/main.cpp:884 msgid "Update bootloader software" msgstr "" -#: userland/apps/installer/installer_update_engine.c:402 +#: userland/apps/installer/main.cpp:477 +msgid "Update check canceled" +msgstr "" + +#: userland/apps/installer/installer_tty.c:474 +msgid "Update check canceled. Run the checks again when ready." +msgstr "" + +#: userland/apps/installer/installer_update_engine.c:644 +msgid "Update check cancelled" +msgstr "" + +#: userland/apps/installer/installer_update_engine.c:647 msgid "Update checks completed" msgstr "" @@ -1386,15 +1406,23 @@ msgstr "" msgid "Update completed successfully" msgstr "" -#: userland/apps/installer/main.cpp:1428 +#: userland/apps/installer/main.cpp:1484 msgid "Update details" msgstr "" -#: userland/apps/installer/main.cpp:712 +#: userland/apps/installer/main.cpp:770 msgid "Update preserves users, personal files, installed software and local configuration." msgstr "" -#: userland/apps/installer/installer_update_engine.c:536 +#: userland/apps/installer/installer_update_engine.c:782 +msgid "Update session completed" +msgstr "" + +#: userland/apps/installer/installer_update_engine.c:522 +msgid "Update stage timed out; stopping its processes" +msgstr "" + +#: userland/apps/installer/installer_update_engine.c:780 msgid "Update worker failed" msgstr "" @@ -1418,11 +1446,11 @@ msgstr "" msgid "Use Tab and the arrow keys to select controls. F3 continues and F2 returns to the previous step." msgstr "" -#: userland/apps/installer/main.cpp:1128 +#: configs/nls/messages/installer.c:29 msgid "Use as ESP" msgstr "" -#: userland/apps/installer/main.cpp:1128 +#: configs/nls/messages/installer.c:30 msgid "Use as root" msgstr "" @@ -1434,7 +1462,7 @@ msgstr "" msgid "Use the selected installation's fstab" msgstr "" -#: userland/apps/installer/main.cpp:1209 +#: userland/apps/installer/main.cpp:1265 msgid "User" msgstr "" @@ -1450,11 +1478,11 @@ msgstr "" msgid "Verifying package signatures" msgstr "" -#: userland/apps/installer/installer_update_engine.c:398 +#: userland/apps/installer/installer_update_engine.c:614 msgid "Verifying signed packages and dependencies" msgstr "" -#: userland/apps/installer/main.cpp:822 +#: userland/apps/installer/main.cpp:881 msgid "Version" msgstr "" @@ -1462,10 +1490,14 @@ msgstr "" msgid "View log" msgstr "" -#: userland/apps/installer/main.cpp:1016 +#: userland/apps/installer/main.cpp:1075 msgid "Volume label" msgstr "" +#: userland/apps/installer/main.cpp:570 +msgid "Waiting for the check to release its resources." +msgstr "" + #: configs/nls/messages/installer.c:13 msgid "Welcome" msgstr "" @@ -1478,7 +1510,7 @@ msgstr "" msgid "Writing system files to disk" msgstr "" -#: userland/apps/installer/installer_update_engine.c:360 +#: userland/apps/installer/installer_update_engine.c:596 msgid "Writing the update log" msgstr "" diff --git a/configs/nls/po/installer/ja_JP.po b/configs/nls/po/installer/ja_JP.po index c111c206..114a2055 100644 --- a/configs/nls/po/installer/ja_JP.po +++ b/configs/nls/po/installer/ja_JP.po @@ -35,7 +35,7 @@ msgstr "アカウントとシステム設定" msgid "Account setup failed" msgstr "アカウントの設定に失敗しました" -#: userland/apps/installer/main.cpp:175 +#: userland/apps/installer/main.cpp:212 msgid "Accounts" msgstr "アカウント" @@ -47,15 +47,15 @@ msgstr "アカウント、個人ファイル、インストール済みソフト msgid "Add to Favorites" msgstr "お気に入りに追加" -#: userland/apps/installer/main.cpp:1025 +#: userland/apps/installer/main.cpp:1084 msgid "Add to plan" msgstr "計画に追加" -#: userland/apps/installer/installer_update_engine.c:352 +#: userland/apps/installer/installer_update_engine.c:563 msgid "Administrator privileges are required" msgstr "管理者権限が必要です" -#: userland/apps/installer/main.cpp:1210 +#: userland/apps/installer/main.cpp:1266 msgid "Administrator: root" msgstr "管理者: root" @@ -67,7 +67,7 @@ msgstr "すべてのファイル (*)" msgid "Apply" msgstr "適用" -#: userland/apps/installer/installer_update_engine.c:418 +#: userland/apps/installer/installer_update_engine.c:623 msgid "Applying signed system packages" msgstr "署名済みシステムパッケージを適用しています" @@ -87,21 +87,21 @@ msgstr "自動構成" msgid "Automatic mode replaces its partition table; manual mode can preserve other partitions." msgstr "自動設定は分割表を置換します。他の領域を残す場合は手動設定を選択してください。" -#: userland/apps/installer/main.cpp:1277 +#: userland/apps/installer/main.cpp:1333 msgid "Automatic partitioning creates a FAT32 ESP and an ext4 root. No BIOS Boot partition is needed." msgstr "自動パーティション設定では FAT32 の ESP と ext4 のルートを作成します。BIOS Boot パーティションは不要です。" -#: userland/apps/installer/main.cpp:1278 +#: userland/apps/installer/main.cpp:1334 msgid "" "Automatic partitioning creates an unformatted BIOS Boot partition, a FAT32 ESP and an ext4 root. " "BIOS also uses the FAT32 partition for boot files." msgstr "自動パーティション設定では未フォーマットの BIOS Boot パーティション、FAT32 の ESP、ext4 のルートを作成します。BIOS も起動ファイルに FAT32 パーティションを使用します。" -#: userland/apps/installer/main.cpp:883 +#: userland/apps/installer/main.cpp:942 msgid "Automatic plan: BIOS Boot 1 MiB; ESP 128 MiB FAT32; root %llu MiB ext4.\nThis replaces all existing partitions only after confirmation." msgstr "自動分割の計画:BIOS Boot 1 MiB、ESP 128 MiB(FAT32)、ルート %llu MiB(ext4)。\nインストールを確定すると、既存のすべてのパーティションを置き換えます。" -#: userland/apps/installer/main.cpp:882 +#: userland/apps/installer/main.cpp:941 msgid "Automatic plan: ESP 128 MiB FAT32; root %llu MiB ext4.\nThis replaces all existing partitions only after confirmation." msgstr "自動分割の計画:ESP 128 MiB(FAT32)、ルート %llu MiB(ext4)。\nインストールを確定すると、既存のすべてのパーティションを置き換えます。" @@ -113,7 +113,7 @@ msgstr "単一の ReliefOS インストールを自動識別" msgid "B BIOS E ESP R / D Data . Free" msgstr "B BIOS E ESP R / D データ . 空き" -#: userland/apps/installer/main.cpp:1128 +#: userland/apps/installer/main.cpp:1184 msgid "BIOS Boot" msgstr "BIOS Boot" @@ -129,7 +129,7 @@ msgstr "ブートローダーのインストール確認に失敗しました" msgid "Boot partition" msgstr "ブートパーティション" -#: userland/apps/installer/main.cpp:172 +#: configs/nls/messages/installer.c:16 msgid "Bootloaders" msgstr "ブートローダー" @@ -141,18 +141,26 @@ msgstr "オフラインのパッケージ処理を計算しています" msgid "Cancel" msgstr "キャンセル" +#: userland/apps/installer/main.cpp:299 +msgid "Cancel check" +msgstr "確認をキャンセル" + #: userland/apps/installer/installer_tty.c:397 msgid "Cancel installation" msgstr "インストールを中止" +#: userland/apps/installer/main.cpp:569 +msgid "Canceling the update check" +msgstr "更新の確認をキャンセルしています" + +#: userland/apps/installer/installer_tui_job.c:229 +msgid "Canceling the update check. Waiting for cleanup." +msgstr "更新の確認をキャンセルしています。後処理の完了を待っています。" + #: userland/apps/installer/installer_tty.c:152 msgid "Cannot display this partition layout." msgstr "パーティション構成を表示できません。" -#: userland/apps/installer/main.cpp:480 -msgid "Cannot identify the selected partitions" -msgstr "選択したパーティションを識別できません" - #: userland/apps/installer/installer_tty.c:233 msgid "Cannot initialize the terminal or installer log" msgstr "端末またはインストールログを初期化できません" @@ -165,11 +173,11 @@ msgstr "インストールログを読み取れません" msgid "Cannot read partition identity" msgstr "パーティション識別情報を読み取れません" -#: userland/apps/installer/main.cpp:912 +#: userland/apps/installer/main.cpp:971 msgid "Cannot read the partition layout" msgstr "パーティション構成を読み取れません" -#: userland/apps/installer/main.cpp:760 +#: userland/apps/installer/main.cpp:818 msgid "Cannot read the selected disk" msgstr "選択したディスクを読み取れません" @@ -177,19 +185,19 @@ msgstr "選択したディスクを読み取れません" msgid "Cannot select the requested locale." msgstr "選択したロケールに切り替えられません。" -#: userland/apps/installer/main.cpp:357 +#: userland/apps/installer/main.cpp:395 msgid "Cannot start the installation worker" msgstr "インストール用バックグラウンドプロセスを起動できません" -#: userland/apps/installer/main.cpp:467 +#: userland/apps/installer/main.cpp:525 msgid "Cannot start the update worker" msgstr "更新ワーカーを起動できません" -#: userland/apps/installer/main.cpp:949 +#: userland/apps/installer/main.cpp:1008 msgid "Cannot update the partition plan" msgstr "パーティションの計画を変更できません" -#: userland/apps/installer/main.cpp:1054 +#: userland/apps/installer/main.cpp:1113 msgid "Change added to the installation plan." msgstr "変更をインストール計画に追加しました。" @@ -205,11 +213,11 @@ msgstr "変更はインストールを確定するまで適用されません。 msgid "Changes remain pending until you confirm the installation. Going back keeps your choices." msgstr "変更はインストールを確定するまで適用されません。前の手順に戻っても設定は保持されます。" -#: userland/apps/installer/main.cpp:192 +#: userland/apps/installer/main.cpp:229 msgid "Check Again" msgstr "再確認" -#: userland/apps/installer/main.cpp:197 +#: userland/apps/installer/main.cpp:234 msgid "Check Update" msgstr "更新を確認" @@ -217,23 +225,23 @@ msgstr "更新を確認" msgid "Check system" msgstr "システムを確認" -#: userland/apps/installer/main.cpp:1364 +#: userland/apps/installer/main.cpp:1420 msgid "Check the target and planned changes. Use Back or the sidebar to change your choices." msgstr "対象と変更内容を確認してください。「前へ」またはサイドバーから設定を変更できます。" -#: userland/apps/installer/installer_tty.c:489 +#: userland/apps/installer/installer_tty.c:493 msgid "Check username and matching passwords (1-32 characters, no spaces)." msgstr "ユーザー名とパスワードの一致を確認してください (1~32 文字、スペース不可)。" -#: userland/apps/installer/installer_update_engine.c:393 -msgid "Checking bootloader compatibility" -msgstr "ブートローダーの互換性を確認しています" +#: userland/apps/installer/installer_update_engine.c:611 +msgid "Checking bootloader files on the installation media" +msgstr "インストールメディアのブートローダーファイルを確認しています" -#: userland/apps/installer/installer_update_engine.c:369 +#: userland/apps/installer/installer_update_engine.c:610 msgid "Checking installation media and free space" msgstr "インストールメディアと空き容量を確認しています" -#: userland/apps/installer/installer_tui_job.c:101 +#: userland/apps/installer/installer_tui_job.c:215 msgid "Checking installed system" msgstr "インストール済みシステムを確認中" @@ -241,27 +249,27 @@ msgstr "インストール済みシステムを確認中" msgid "Checking signed repository and package archives" msgstr "署名付きリポジトリとパッケージを確認しています" -#: userland/apps/installer/main.cpp:1443 +#: userland/apps/installer/main.cpp:1499 msgid "Checking system update" msgstr "システム更新を確認しています" -#: userland/apps/installer/main.cpp:502 +#: userland/apps/installer/installer_update_engine.c:612 +msgid "Checking the installed bootloader layout" +msgstr "インストール済みブートローダーの配置を確認しています" + +#: userland/apps/installer/main.cpp:550 msgid "Checking the selected system" msgstr "選択したシステムを確認しています" -#: userland/apps/installer/installer_update_engine.c:348 -msgid "Checking update target" -msgstr "更新対象を確認しています" - #: userland/apps/installer/installer_tty.c:264 msgid "Choose a language, then configure your installation. You can return to earlier steps before installing." msgstr "言語を選び、インストールを設定してください。インストールを開始するまでは前の手順に戻れます。" -#: userland/apps/installer/main.cpp:696 +#: userland/apps/installer/main.cpp:754 msgid "Choose a new installation or update an existing ReliefOS system." msgstr "新規インストール、または既存の ReliefOS システムの更新を選んでください。" -#: userland/apps/installer/main.cpp:1294 +#: userland/apps/installer/main.cpp:1350 msgid "Choose bootloaders" msgstr "ブートローダーを選択" @@ -269,7 +277,7 @@ msgstr "ブートローダーを選択" msgid "Choose how this disk will start. Selecting BIOS and UEFI supports both firmware types; the partition plan follows this choice." msgstr "このディスクの起動方法を選んでください。BIOS と UEFI の両方を選ぶと、どちらのファームウェアでも起動できます。パーティションの計画もこの選択に従います。" -#: userland/apps/installer/main.cpp:1320 +#: userland/apps/installer/main.cpp:1376 msgid "Choose the desktop and additional disk space for virtual memory." msgstr "デスクトップ環境と仮想メモリ用の追加ディスク領域を設定してください。" @@ -285,7 +293,7 @@ msgstr "インストール先のディスクを選んでください。次の手 msgid "Choose the installed desktop and optional swapfile. These choices are included in the final review." msgstr "インストールするデスクトップ環境と必要に応じたスワップファイルを選んでください。設定は最終確認に表示されます。" -#: userland/apps/installer/main.cpp:640 +#: userland/apps/installer/main.cpp:698 msgid "Choose the language for Setup and the installed system." msgstr "セットアップとインストール後のシステムで使用する言語を選択してください。" @@ -297,6 +305,10 @@ msgstr "BIOS Boot パーティション %u の全内容(%llu バイト)を msgid "Close" msgstr "閉じる" +#: userland/apps/installer/installer_update_engine.c:637 +msgid "Closing the update target" +msgstr "更新対象の後処理を行っています" + #: userland/apps/installer/installer_update_progress.c:138 msgid "Comparing contents" msgstr "内容を比較中" @@ -305,7 +317,7 @@ msgstr "内容を比較中" msgid "Completed" msgstr "完了" -#: userland/apps/installer/installer_tty.c:62 +#: configs/nls/messages/installer.c:17 msgid "Configure partitions" msgstr "パーティションを設定" @@ -313,11 +325,11 @@ msgstr "パーティションを設定" msgid "Configuring installed system" msgstr "インストール済みシステムを設定しています" -#: userland/apps/installer/main.cpp:176 +#: userland/apps/installer/main.cpp:213 msgid "Confirm" msgstr "確認" -#: userland/apps/installer/installer_tty.c:320 +#: configs/nls/messages/installer.c:22 msgid "Confirm password" msgstr "パスワードの確認" @@ -329,7 +341,7 @@ msgstr "root パスワードの確認" msgid "Console only" msgstr "コンソールのみ" -#: userland/apps/installer/main.cpp:1330 +#: userland/apps/installer/main.cpp:1386 msgid "Console only installs without a graphical login. XFCE is an experimental desktop option." msgstr "「コンソールのみ」ではグラフィカルログインをインストールしません。XFCE は実験的なデスクトップです。" @@ -401,7 +413,7 @@ msgstr "カスタムフィルター" msgid "Data partition" msgstr "データパーティション" -#: userland/apps/installer/installer_tty.c:156 +#: configs/nls/messages/installer.c:23 msgid "Delete" msgstr "削除" @@ -425,7 +437,7 @@ msgstr "無効" msgid "Discard changes" msgstr "変更を破棄" -#: userland/apps/installer/main.cpp:1143 +#: userland/apps/installer/main.cpp:1200 msgid "Discard edits" msgstr "編集内容を破棄" @@ -433,7 +445,7 @@ msgstr "編集内容を破棄" msgid "Discard partition changes" msgstr "パーティションの変更を破棄" -#: userland/apps/installer/main.cpp:1068 +#: userland/apps/installer/main.cpp:1127 msgid "Discard pending partition edits and reload the disk?" msgstr "未適用のパーティション編集を破棄し、ディスクを読み直しますか?" @@ -441,7 +453,7 @@ msgstr "未適用のパーティション編集を破棄し、ディスクを読 msgid "Discard the pending partition changes and read the current disk layout again?" msgstr "未適用のパーティション変更を破棄し、現在のディスク構成を読み直しますか?" -#: userland/apps/installer/main.cpp:171 +#: userland/apps/installer/main.cpp:208 msgid "Disk" msgstr "ディスク" @@ -449,23 +461,23 @@ msgstr "ディスク" msgid "Disk " msgstr "ディスク " -#: userland/apps/installer/main.cpp:1403 +#: userland/apps/installer/main.cpp:1459 msgid "Disk changes to apply" msgstr "適用するディスクの変更" -#: userland/apps/installer/main.cpp:1099 +#: userland/apps/installer/main.cpp:1158 msgid "Disk layout" msgstr "ディスク構成" -#: userland/apps/installer/installer_tui_job.c:111 +#: userland/apps/installer/installer_tui_job.c:225 msgid "Disk operations are running. Please wait for completion." msgstr "ディスク操作を実行しています。完了までお待ちください。" -#: userland/apps/installer/main.cpp:1444 +#: userland/apps/installer/main.cpp:1500 msgid "Do not turn off this machine." msgstr "このコンピューターの電源を切らないでください。" -#: userland/apps/installer/main.cpp:815 +#: userland/apps/installer/main.cpp:874 msgid "EFI system partition" msgstr "EFI システムパーティション" @@ -478,7 +490,7 @@ msgstr "経過時間:%lu 秒" msgid "Enter a positive whole number of MiB." msgstr "MiB 単位の正の整数を入力してください。" -#: userland/apps/installer/installer_tty.c:494 +#: userland/apps/installer/installer_tty.c:498 msgid "Enter a valid swap size in MiB." msgstr "有効なスワップサイズを MiB 単位で入力してください。" @@ -490,7 +502,7 @@ msgstr "%s のすべてのパーティションを消去します。\nBIOS Boot msgid "Erase all partitions on %s.\nCreate ESP: 128 MiB, format FAT32.\nCreate system root: %llu MiB, format ext4." msgstr "%s のすべてのパーティションを消去します。\nESP を作成:128 MiB、FAT32 でフォーマット。\nシステムのルートを作成:%llu MiB、ext4 でフォーマット。" -#: userland/apps/installer/main.cpp:1100 +#: userland/apps/installer/main.cpp:1159 msgid "Erase disk and install automatically" msgstr "ディスクを消去して自動インストール" @@ -506,7 +518,7 @@ msgstr "下にフォーマットが明記されていなければ、ESP の既 msgid "Exit" msgstr "終了" -#: userland/apps/installer/main.cpp:520 +#: userland/apps/installer/main.cpp:578 msgid "Exit installer" msgstr "インストーラーを終了" @@ -514,7 +526,7 @@ msgstr "インストーラーを終了" msgid "Exit the installer?" msgstr "インストーラーを終了しますか?" -#: userland/apps/installer/main.cpp:521 +#: userland/apps/installer/main.cpp:579 msgid "Exit the installer? Unapplied disk changes and setup choices will be discarded." msgstr "インストーラーを終了しますか?未適用のディスク変更とインストール設定は破棄されます。" @@ -542,15 +554,15 @@ msgstr "ファイルシステム" msgid "Filesystem label" msgstr "ファイルシステムラベル" -#: userland/apps/installer/main.cpp:179 +#: userland/apps/installer/main.cpp:216 msgid "Finish" msgstr "完了" -#: userland/apps/installer/installer_update_engine.c:437 +#: userland/apps/installer/installer_update_engine.c:627 msgid "Finishing the system update" msgstr "システム更新を完了しています" -#: userland/apps/installer/installer_tty.c:156 +#: configs/nls/messages/installer.c:24 msgid "Format" msgstr "フォーマット" @@ -566,7 +578,7 @@ msgstr "選択した ESP をフォーマット (その上のすべての EFI 起 msgid "Free / required space" msgstr "空き容量 / 必要容量" -#: userland/apps/installer/main.cpp:699 +#: userland/apps/installer/main.cpp:757 msgid "Fresh Install" msgstr "新規インストール" @@ -574,7 +586,7 @@ msgstr "新規インストール" msgid "Go back to edit any option. Nothing is written until you choose Install." msgstr "前の手順に戻って設定を変更できます。「インストール」を選ぶまでディスクには書き込みません。" -#: userland/apps/installer/main.cpp:671 +#: userland/apps/installer/main.cpp:729 msgid "I accept the license terms" msgstr "ライセンス条項に同意する" @@ -582,7 +594,7 @@ msgstr "ライセンス条項に同意する" msgid "IceWM (default)" msgstr "IceWM(既定)" -#: userland/apps/installer/installer_update_engine.c:363 +#: userland/apps/installer/installer_update_engine.c:609 msgid "Identifying the installed system" msgstr "インストール済みシステムを識別しています" @@ -598,7 +610,7 @@ msgstr "入力が長すぎます" msgid "Install" msgstr "インストール" -#: userland/apps/installer/main.cpp:631 +#: userland/apps/installer/main.cpp:689 msgid "Install ReliefOS" msgstr "ReliefOS をインストール" @@ -626,11 +638,11 @@ msgstr "UEFI ブートローダーをインストールまたは更新" msgid "Installation" msgstr "インストール" -#: userland/apps/installer/main.cpp:1471 +#: userland/apps/installer/main.cpp:1527 msgid "Installation Complete" msgstr "インストール完了" -#: userland/apps/installer/main.cpp:1497 +#: userland/apps/installer/main.cpp:1553 msgid "Installation Failed" msgstr "インストール失敗" @@ -662,11 +674,11 @@ msgstr "インストール構成 — 変更は未適用" msgid "Installation media is incomplete" msgstr "インストールメディアが不完全です" -#: userland/apps/installer/installer_update_engine.c:257 +#: userland/apps/installer/installer_update_engine.c:300 msgid "Installation media is older than the installed system" msgstr "インストールメディアはインストール済みシステムより古いバージョンです" -#: userland/apps/installer/model.c:167 +#: configs/nls/messages/installer.c:14 msgid "Installation mode" msgstr "インストールモード" @@ -678,11 +690,11 @@ msgstr "インストールの進行状況" msgid "Installation result" msgstr "インストール結果" -#: userland/apps/installer/main.cpp:695 +#: userland/apps/installer/main.cpp:753 msgid "Installation type" msgstr "インストール方法" -#: userland/apps/installer/main.cpp:328 +#: userland/apps/installer/main.cpp:366 msgid "Installation worker failed" msgstr "インストール用バックグラウンドプロセスでエラーが発生しました" @@ -718,23 +730,23 @@ msgstr "無効なサイズ" msgid "Invalid swap size" msgstr "スワップサイズが無効です" -#: userland/apps/installer/main.cpp:1067 +#: userland/apps/installer/main.cpp:1126 msgid "Keep changes" msgstr "変更を保持" -#: userland/apps/installer/main.cpp:520 +#: userland/apps/installer/main.cpp:578 msgid "Keep configuring" msgstr "設定を続ける" -#: userland/apps/installer/installer_tty.c:374 +#: configs/nls/messages/installer.c:11 msgid "Language" msgstr "言語" -#: userland/apps/installer/main.cpp:169 +#: configs/nls/messages/installer.c:12 msgid "License" msgstr "ライセンス" -#: userland/apps/installer/main.cpp:660 +#: userland/apps/installer/main.cpp:718 msgid "License agreement" msgstr "ライセンス契約" @@ -742,11 +754,11 @@ msgstr "ライセンス契約" msgid "Manage Favorites" msgstr "お気に入りの管理" -#: userland/apps/installer/main.cpp:891 +#: userland/apps/installer/main.cpp:950 msgid "Manual layout: assign BIOS Boot, ESP and root roles. BIOS Boot stays unformatted." msgstr "手動構成: BIOS Boot、ESP、ルートの役割を割り当てます。BIOS Boot はフォーマットされません。" -#: userland/apps/installer/main.cpp:890 +#: userland/apps/installer/main.cpp:949 msgid "Manual layout: assign a FAT32 ESP and an ext4 or ext3 root. BIOS Boot is not required for the selected bootloaders." msgstr "手動構成: FAT32 の ESP と ext4 または ext3 のルートを割り当てます。選択したブートローダーでは BIOS Boot は不要です。" @@ -754,11 +766,11 @@ msgstr "手動構成: FAT32 の ESP と ext4 または ext3 のルートを割 msgid "Manual partitioning" msgstr "手動構成" -#: userland/apps/installer/main.cpp:1101 +#: userland/apps/installer/main.cpp:1160 msgid "Manual partitioning / keep other systems" msgstr "手動で分割 / 他のシステムを保持" -#: userland/apps/installer/main.cpp:170 +#: userland/apps/installer/main.cpp:207 msgid "Mode" msgstr "モード" @@ -766,7 +778,7 @@ msgstr "モード" msgid "Mount failed" msgstr "マウントに失敗しました" -#: userland/apps/installer/install_ops.c:836 +#: configs/nls/messages/installer.c:5 msgid "Mounting target filesystems" msgstr "対象ファイルシステムをマウントしています" @@ -778,11 +790,11 @@ msgstr "名前" msgid "New Directory?" msgstr "新しいフォルダーを作成しますか?" -#: userland/apps/installer/main.cpp:1118 +#: configs/nls/messages/installer.c:31 msgid "New GPT" msgstr "新しい GPT" -#: userland/apps/installer/main.cpp:966 +#: userland/apps/installer/main.cpp:1025 msgid "New partition table added to the plan." msgstr "新しいパーティションテーブルを計画に追加しました。" @@ -802,7 +814,7 @@ msgstr "ブートローダーが選択されていません。新規インスト msgid "No disks were found" msgstr "ディスクが見つかりませんでした" -#: userland/apps/installer/main.cpp:1500 +#: userland/apps/installer/main.cpp:1556 msgid "No writes will continue after this error." msgstr "このエラーの後、書き込みは続行されません。" @@ -831,7 +843,7 @@ msgstr "パーティション" msgid "Partition %u %s %llu MiB %s %s%s" msgstr "パーティション %u %s %llu MiB %s %s%s" -#: userland/apps/installer/main.cpp:973 +#: userland/apps/installer/main.cpp:1032 msgid "Partition deletion added to the plan." msgstr "パーティションの削除を計画に追加しました。" @@ -847,7 +859,7 @@ msgstr "パーティション名" msgid "Partition operation failed" msgstr "パーティション操作に失敗しました" -#: userland/apps/installer/main.cpp:951 +#: userland/apps/installer/main.cpp:1010 msgid "Partition plan updated" msgstr "パーティションの計画を更新しました" @@ -855,11 +867,11 @@ msgstr "パーティションの計画を更新しました" msgid "Partition role" msgstr "パーティションの用途" -#: userland/apps/installer/main.cpp:1088 +#: userland/apps/installer/main.cpp:1147 msgid "Partition role updated." msgstr "パーティションの役割を更新しました。" -#: userland/apps/installer/main.cpp:173 +#: userland/apps/installer/main.cpp:210 msgid "Partitions" msgstr "パーティション" @@ -883,11 +895,11 @@ msgstr "ペイロードのスキャンに失敗しました" msgid "Pending layout - written only after INSTALL confirmation." msgstr "適用予定の構成です。INSTALL の最終確認後に書き込みます。" -#: userland/apps/installer/main.cpp:971 +#: userland/apps/installer/main.cpp:1030 msgid "Plan deletion" msgstr "削除を計画" -#: userland/apps/installer/main.cpp:964 +#: userland/apps/installer/main.cpp:1023 msgid "Plan new table" msgstr "新しいテーブルを計画" @@ -899,11 +911,11 @@ msgstr "既存のファイルを選択してください。" msgid "Power operation failed" msgstr "電源操作に失敗しました" -#: userland/apps/installer/main.cpp:710 +#: userland/apps/installer/main.cpp:768 msgid "Prepare a clean ReliefOS system with automatic or manual disk partitioning." msgstr "自動または手動のパーティション設定で、新しい ReliefOS システムを準備します。" -#: userland/apps/installer/installer_tui_job.c:109 +#: userland/apps/installer/installer_tui_job.c:223 msgid "Preparing operation" msgstr "操作を準備しています" @@ -911,14 +923,18 @@ msgstr "操作を準備しています" msgid "Preparing target disk" msgstr "対象ディスクを準備しています" -#: userland/apps/installer/installer_update_engine.c:410 +#: userland/apps/installer/installer_update_engine.c:620 msgid "Preparing the installed system for update" msgstr "インストール済みシステムの更新を準備しています" -#: userland/apps/installer/main.cpp:502 +#: userland/apps/installer/main.cpp:550 msgid "Preparing the system update" msgstr "システム更新を準備しています" +#: userland/apps/installer/installer_update_engine.c:568 +msgid "Preparing update session" +msgstr "更新の準備をしています" + #: userland/apps/installer/installer_update_progress.c:15 msgid "Preparing verified package archives" msgstr "検証済みパッケージを準備しています" @@ -935,11 +951,11 @@ msgstr "「再起動」を押すと、インストールしたディスクから msgid "Preview" msgstr "プレビュー" -#: userland/apps/installer/main.cpp:632 +#: userland/apps/installer/main.cpp:690 msgid "Previous Step" msgstr "前の手順" -#: userland/apps/installer/installer_update_engine.c:429 +#: userland/apps/installer/installer_update_engine.c:626 msgid "Publishing kernel and bootloader files" msgstr "カーネルとブートローダーのファイルを配置しています" @@ -951,11 +967,11 @@ msgstr "オフラインパッケージのキャッシュを反映しています msgid "Ready" msgstr "準備完了" -#: userland/apps/installer/main.cpp:429 +#: userland/apps/installer/main.cpp:485 msgid "Ready to update" msgstr "更新の準備完了" -#: userland/apps/installer/installer_update_engine.c:313 +#: userland/apps/installer/installer_update_engine.c:346 msgid "Recovering the previous update attempt" msgstr "前回の更新処理を復旧しています" @@ -963,15 +979,15 @@ msgstr "前回の更新処理を復旧しています" msgid "Refresh" msgstr "更新" -#: userland/apps/installer/main.cpp:813 +#: userland/apps/installer/main.cpp:872 msgid "ReliefOS system partition" msgstr "ReliefOS システムパーティション" -#: userland/apps/installer/main.cpp:1474 +#: userland/apps/installer/main.cpp:1530 msgid "ReliefOS was installed to the selected disk." msgstr "選択したディスクに ReliefOS をインストールしました。" -#: userland/apps/installer/main.cpp:1473 +#: userland/apps/installer/main.cpp:1529 msgid "ReliefOS was updated on the selected disk." msgstr "選択したディスクの ReliefOS を更新しました。" @@ -983,11 +999,11 @@ msgstr "続行する前にインストールメディアを取り外してくだ msgid "Remove the installation media before rebooting." msgstr "再起動する前にインストールメディアを取り外してください。" -#: userland/apps/installer/main.cpp:434 +#: userland/apps/installer/main.cpp:490 msgid "Remove the installation media, then restart." msgstr "インストールメディアを取り外してから再起動してください。" -#: userland/apps/installer/main.cpp:972 +#: userland/apps/installer/main.cpp:1031 msgid "Remove the selected partition when the installation is confirmed?" msgstr "インストールを確定したときに、選択したパーティションを削除しますか?" @@ -995,7 +1011,7 @@ msgstr "インストールを確定したときに、選択したパーティシ msgid "Removing retired package archives" msgstr "廃止されたパッケージを削除しています" -#: userland/apps/installer/installer_tty.c:156 +#: configs/nls/messages/installer.c:27 msgid "Rename" msgstr "名前の変更" @@ -1011,7 +1027,7 @@ msgstr "署名付きシステムパッケージを修復しています" msgid "Replace partition table" msgstr "パーティションテーブルを置換" -#: userland/apps/installer/main.cpp:965 +#: userland/apps/installer/main.cpp:1024 msgid "Replace this disk's partition table in the installation plan? All existing partitions will be removed when you install." msgstr "このディスクのパーティションテーブルの置換を計画しますか?インストール時に既存のすべてのパーティションが削除されます。" @@ -1027,7 +1043,7 @@ msgstr "パーティションのサイズを変更" msgid "Resize the terminal to at least 60 columns and 20 rows." msgstr "端末のサイズを 60 列、20 行以上にしてください。" -#: userland/apps/installer/main.cpp:984 +#: userland/apps/installer/main.cpp:1043 msgid "Resizing changes the partition boundary. Existing filesystems cannot be shrunk here." msgstr "サイズ変更はパーティションの境界を変更します。既存のファイルシステムはここでは縮小できません。" @@ -1035,7 +1051,7 @@ msgstr "サイズ変更はパーティションの境界を変更します。既 msgid "Restart" msgstr "再起動" -#: userland/apps/installer/main.cpp:1490 +#: userland/apps/installer/main.cpp:1546 msgid "Restart failed" msgstr "再起動に失敗しました" @@ -1043,15 +1059,11 @@ msgstr "再起動に失敗しました" msgid "Restoring retained kernel files" msgstr "保存したカーネルファイルを復元しています" -#: userland/apps/installer/installer_update_engine.c:429 -msgid "Resuming bootloader publication" -msgstr "ブートローダーの配置を再開しています" - #: userland/apps/installer/installer_update_progress.c:140 msgid "Reused" msgstr "再利用済み" -#: userland/apps/installer/main.cpp:1363 +#: configs/nls/messages/installer.c:19 msgid "Review installation" msgstr "インストール設定の確認" @@ -1059,7 +1071,7 @@ msgstr "インストール設定の確認" msgid "Review settings" msgstr "設定を見直す" -#: userland/apps/installer/main.cpp:1363 +#: userland/apps/installer/main.cpp:1419 msgid "Review system update" msgstr "システム更新を確認" @@ -1067,15 +1079,15 @@ msgstr "システム更新を確認" msgid "Review the configuration before trying again. Changes already written to disk may remain." msgstr "再試行する前に設定を見直してください。すでにディスクに書き込まれた変更は残っている場合があります。" -#: userland/apps/installer/main.cpp:1499 +#: userland/apps/installer/main.cpp:1555 msgid "Review the details, then check the update again to retry." msgstr "詳細を確認し、再試行するには更新をもう一度確認してください。" -#: userland/apps/installer/main.cpp:429 +#: userland/apps/installer/main.cpp:485 msgid "Review the detected system and boot options, then continue to the summary." msgstr "検出されたシステムと起動オプションを確認してから、最終確認に進んでください。" -#: userland/apps/installer/installer_tty.c:510 +#: userland/apps/installer/installer_tty.c:514 msgid "Review the disk layout and account settings before installing." msgstr "インストール前にディスク構成とアカウント設定を確認してください。" @@ -1083,11 +1095,11 @@ msgstr "インストール前にディスク構成とアカウント設定を確 msgid "Review the disk model, size and partitions before applying changes." msgstr "変更を適用する前にディスクのモデル、容量、既存のパーティションを確認してください。" -#: userland/apps/installer/installer_tty.c:485 +#: userland/apps/installer/installer_tty.c:489 msgid "Review the required BIOS Boot, ESP and root partitions." msgstr "必要な BIOS Boot、ESP、ルートパーティションを確認してください。" -#: userland/apps/installer/main.cpp:197 +#: userland/apps/installer/main.cpp:234 msgid "Review update" msgstr "更新内容を確認" @@ -1107,19 +1119,19 @@ msgstr "システム設定を保存しています" msgid "Scanning installation payload" msgstr "インストールペイロードをスキャンしています" -#: userland/apps/installer/main.cpp:800 +#: userland/apps/installer/main.cpp:858 msgid "Select Disk to Update" msgstr "更新するディスクを選択" -#: userland/apps/installer/main.cpp:800 +#: userland/apps/installer/main.cpp:858 msgid "Select Installation Disk" msgstr "インストール先のディスクを選択" -#: userland/apps/installer/main.cpp:639 +#: userland/apps/installer/main.cpp:697 msgid "Select Language" msgstr "言語を選択" -#: userland/apps/installer/main.cpp:802 +#: userland/apps/installer/main.cpp:860 msgid "Select a disk and check its existing installation before continuing." msgstr "ディスクを選び、既存のシステムを確認してから進んでください。" @@ -1127,6 +1139,10 @@ msgstr "ディスクを選び、既存のシステムを確認してから進ん msgid "Select a disk first." msgstr "先にディスクを選択してください。" +#: userland/apps/installer/main.cpp:477 +msgid "Select a disk or run the checks again." +msgstr "ディスクを選択するか、もう一度確認を実行してください。" + #: userland/apps/installer/installer_tty.c:62 msgid "Select a partition first." msgstr "先にパーティションを選択してください。" @@ -1139,10 +1155,6 @@ msgstr "対象のディスクを選び、構成をもう一度確認してくだ msgid "Select boot partition" msgstr "ブートパーティションを選択" -#: userland/apps/installer/main.cpp:1109 -msgid "Select partitions for ReliefOS and keep other systems or data." -msgstr "ReliefOS 用のパーティションを選び、ほかのシステムやデータを保持します。" - #: userland/apps/installer/installer_tty.c:296 msgid "Select system partition" msgstr "システムパーティションを選択" @@ -1151,7 +1163,7 @@ msgstr "システムパーティションを選択" msgid "Select the disk to update" msgstr "更新するディスクを選択" -#: userland/apps/installer/main.cpp:1295 +#: userland/apps/installer/main.cpp:1351 msgid "Select the firmware used to start this disk. You can select both BIOS and UEFI." msgstr "このディスクの起動に使用するファームウェアを選択してください。BIOS と UEFI の両方を選択できます。" @@ -1159,7 +1171,7 @@ msgstr "このディスクの起動に使用するファームウェアを選択 msgid "Select the target disk" msgstr "対象ディスクを選択" -#: userland/apps/installer/main.cpp:803 +#: userland/apps/installer/main.cpp:861 msgid "Select the target. The disk layout is configured in the following steps." msgstr "対象のディスクを選んでください。ディスク構成は次の手順で設定します。" @@ -1167,7 +1179,7 @@ msgstr "対象のディスクを選んでください。ディスク構成は次 msgid "Selected system does not support swap" msgstr "選択したシステムはスワップに対応していません" -#: userland/apps/installer/main.cpp:232 +#: userland/apps/installer/main.cpp:269 msgid "Setup" msgstr "セットアップ" @@ -1175,7 +1187,7 @@ msgstr "セットアップ" msgid "Setup will check for an existing ReliefOS system." msgstr "セットアップは既存の ReliefOS システムを確認します。" -#: userland/apps/installer/installer_tui_job.c:113 +#: userland/apps/installer/installer_tui_job.c:227 msgid "Show / hide log (F4)" msgstr "ログを表示/非表示(F4)" @@ -1191,7 +1203,7 @@ msgstr "表示:" msgid "Shut down" msgstr "シャットダウン" -#: userland/apps/installer/main.cpp:1384 +#: userland/apps/installer/main.cpp:1440 msgid "" "Signed packages are checked before changes. Boot files are published after the package " "transaction succeeds." @@ -1201,7 +1213,7 @@ msgstr "変更前に署名済みパッケージを確認します。パッケー msgid "Size" msgstr "容量" -#: userland/apps/installer/main.cpp:993 +#: userland/apps/installer/main.cpp:1052 msgid "Size (MiB)" msgstr "サイズ(MiB)" @@ -1209,7 +1221,7 @@ msgstr "サイズ(MiB)" msgid "Size in MiB" msgstr "サイズ(MiB)" -#: userland/apps/installer/main.cpp:1373 +#: userland/apps/installer/main.cpp:1429 msgid "Skip" msgstr "スキップ" @@ -1225,7 +1237,11 @@ msgstr "一般ユーザーのパスワード" msgid "Step %d of %d" msgstr "手順 %d / %d" -#: userland/apps/installer/main.cpp:1402 +#: userland/apps/installer/installer_update_engine.c:521 +msgid "Stopping update check and cleaning up" +msgstr "更新の確認を停止し、後処理を行っています" + +#: userland/apps/installer/main.cpp:1458 msgid "Swap" msgstr "スワップ" @@ -1233,7 +1249,7 @@ msgstr "スワップ" msgid "Swap requires an AHCI disk" msgstr "スワップには AHCI ディスクが必要です" -#: userland/apps/installer/main.cpp:1341 +#: userland/apps/installer/main.cpp:1397 msgid "Swap size (MiB)" msgstr "スワップサイズ(MiB)" @@ -1241,7 +1257,7 @@ msgstr "スワップサイズ(MiB)" msgid "Swap size in MiB" msgstr "スワップサイズ(MiB)" -#: userland/apps/installer/main.cpp:1349 +#: userland/apps/installer/main.cpp:1405 msgid "Swap uses space on the system partition and currently requires an AHCI disk. Enter a valid whole number of MiB." msgstr "スワップはシステムパーティションの領域を使用し、現在は AHCI ディスクが必要です。MiB 単位で有効な整数を入力してください。" @@ -1253,15 +1269,15 @@ msgstr "インストール先のファイルシステムを同期しています msgid "Synchronizing the offline package cache" msgstr "オフラインパッケージのキャッシュを同期しています" -#: userland/apps/installer/installer_update_engine.c:424 +#: userland/apps/installer/installer_update_engine.c:624 msgid "Synchronizing the updated root filesystem" msgstr "更新したルートファイルシステムを同期しています" -#: userland/apps/installer/main.cpp:174 +#: userland/apps/installer/main.cpp:211 msgid "System" msgstr "システム" -#: userland/apps/installer/main.cpp:1319 +#: userland/apps/installer/main.cpp:1375 msgid "System options" msgstr "システム設定" @@ -1277,7 +1293,7 @@ msgstr "システムルート" msgid "System root: %s; format %s.\nESP: %s; %s.\nOther partitions are preserved except for the changes listed above." msgstr "システムのルート:%s、%s でフォーマット。\nESP:%s、%s。\n上記の変更を除き、他のパーティションは保持されます。" -#: userland/apps/installer/installer_update_engine.c:453 +#: userland/apps/installer/installer_update_engine.c:647 msgid "System update completed successfully" msgstr "システム更新が正常に完了しました" @@ -1289,7 +1305,7 @@ msgstr "システムバージョン" msgid "Tab / arrows: select Space: toggle PgUp/PgDn: scroll" msgstr "Tab/矢印キーで選択 Space で切替 PgUp/PgDn でスクロール" -#: userland/apps/installer/installer_tty.c:415 +#: configs/nls/messages/installer.c:15 msgid "Target disk" msgstr "対象ディスク" @@ -1301,15 +1317,11 @@ msgstr "対象のディスクが変更されました。インストール計画 msgid "Target disk is ready." msgstr "対象ディスクの準備ができました。" -#: userland/apps/installer/installer_update_engine.c:382 -msgid "Target or media changed. Check the update again." -msgstr "対象またはメディアが変更されました。更新をもう一度確認してください。" - #: userland/apps/installer/installer_tty.c:151 msgid "The automatic layout does not fit this disk. Select another disk or configure partitions manually." msgstr "自動構成はこのディスクに収まりません。別のディスクを選択するか、パーティションを手動で設定してください。" -#: userland/apps/installer/installer_tty.c:504 +#: userland/apps/installer/installer_tty.c:508 msgid "The confirmation word does not match." msgstr "確認の文字列が一致しません。" @@ -1317,10 +1329,6 @@ msgstr "確認の文字列が一致しません。" msgid "The disk plan could not be read. Return to Disk layout and review the target." msgstr "ディスクの計画を読み取れませんでした。「ディスク構成」に戻り、対象を確認してください。" -#: userland/apps/installer/main.cpp:1107 -msgid "The entire disk will be replaced. To preserve another system or data partition, choose manual partitioning." -msgstr "ディスク全体の構成を置き換えます。他のシステムやデータパーティションを保持する場合は、手動での分割を選んでください。" - #: userland/apps/installer/installer_tty.c:203 msgid "The selected ESP will also be formatted." msgstr "選択した ESP もフォーマットします。" @@ -1333,15 +1341,15 @@ msgstr "選択したディスクは利用できなくなりました" msgid "The system partition will be formatted. Review every pending change below." msgstr "システムパーティションをフォーマットします。以下の未適用の変更をすべて確認してください。" -#: userland/apps/installer/installer_tui_job.c:116 +#: userland/apps/installer/installer_tui_job.c:230 msgid "The terminal requested exit. Waiting for the disk operation to finish." msgstr "端末から終了が要求されました。ディスク操作の完了を待っています。" -#: userland/apps/installer/main.cpp:1416 +#: userland/apps/installer/main.cpp:1472 msgid "These disk changes cannot be undone. Type INSTALL to confirm." msgstr "これらのディスク変更は元に戻せません。確定するには INSTALL と入力してください。" -#: userland/apps/installer/main.cpp:985 +#: userland/apps/installer/main.cpp:1044 msgid "This change is added to the plan. Nothing is written until installation is confirmed." msgstr "この変更を計画に追加します。インストールを確定するまでディスクには書き込みません。" @@ -1353,7 +1361,7 @@ msgstr "INSTALL と入力してインストールを確認" msgid "Type the confirmation word" msgstr "確認の文字列を入力" -#: userland/apps/installer/main.cpp:1484 +#: userland/apps/installer/main.cpp:1540 msgid "UEFI boot file (add it in firmware if no automatic entry appears):" msgstr "UEFI 起動ファイル (自動エントリが表示されない場合はファームウェアに追加):" @@ -1361,7 +1369,7 @@ msgstr "UEFI 起動ファイル (自動エントリが表示されない場合 msgid "Unallocated" msgstr "未割り当て" -#: userland/apps/installer/main.cpp:920 +#: userland/apps/installer/main.cpp:979 msgid "Unformatted" msgstr "フォーマットしない" @@ -1377,15 +1385,15 @@ msgstr "上下で選択 PgUp/PgDn でページ切替 Home/End で先頭/末尾 msgid "Update" msgstr "更新" -#: userland/apps/installer/main.cpp:1471 +#: userland/apps/installer/main.cpp:1527 msgid "Update Complete" msgstr "更新完了" -#: userland/apps/installer/main.cpp:701 +#: userland/apps/installer/main.cpp:759 msgid "Update Existing System" msgstr "既存システムを更新" -#: userland/apps/installer/main.cpp:1497 +#: userland/apps/installer/main.cpp:1553 msgid "Update Failed" msgstr "更新失敗" @@ -1393,11 +1401,23 @@ msgstr "更新失敗" msgid "Update an existing system" msgstr "既存のシステムを更新" -#: userland/apps/installer/main.cpp:825 +#: userland/apps/installer/main.cpp:884 msgid "Update bootloader software" msgstr "ブートローダーソフトウェアを更新" -#: userland/apps/installer/installer_update_engine.c:402 +#: userland/apps/installer/main.cpp:477 +msgid "Update check canceled" +msgstr "更新の確認をキャンセルしました" + +#: userland/apps/installer/installer_tty.c:474 +msgid "Update check canceled. Run the checks again when ready." +msgstr "更新の確認をキャンセルしました。準備ができたら、もう一度確認を実行してください。" + +#: userland/apps/installer/installer_update_engine.c:644 +msgid "Update check cancelled" +msgstr "更新の確認をキャンセルしました" + +#: userland/apps/installer/installer_update_engine.c:647 msgid "Update checks completed" msgstr "更新の確認が完了しました" @@ -1405,15 +1425,23 @@ msgstr "更新の確認が完了しました" msgid "Update completed successfully" msgstr "更新が正常に完了しました" -#: userland/apps/installer/main.cpp:1428 +#: userland/apps/installer/main.cpp:1484 msgid "Update details" msgstr "更新の詳細" -#: userland/apps/installer/main.cpp:712 +#: userland/apps/installer/main.cpp:770 msgid "Update preserves users, personal files, installed software and local configuration." msgstr "更新ではユーザー、個人ファイル、インストール済みソフトウェア、ローカル設定を保持します。" -#: userland/apps/installer/installer_update_engine.c:536 +#: userland/apps/installer/installer_update_engine.c:782 +msgid "Update session completed" +msgstr "今回の更新処理が完了しました" + +#: userland/apps/installer/installer_update_engine.c:522 +msgid "Update stage timed out; stopping its processes" +msgstr "更新の処理がタイムアウトしたため、関連プロセスを停止しています" + +#: userland/apps/installer/installer_update_engine.c:780 msgid "Update worker failed" msgstr "更新ワーカーが失敗しました" @@ -1437,11 +1465,11 @@ msgstr "用途" msgid "Use Tab and the arrow keys to select controls. F3 continues and F2 returns to the previous step." msgstr "Tab と矢印キーで項目を選択します。F3 で次へ進み、F2 で前の手順に戻ります。" -#: userland/apps/installer/main.cpp:1128 +#: configs/nls/messages/installer.c:29 msgid "Use as ESP" msgstr "ESP として使用" -#: userland/apps/installer/main.cpp:1128 +#: configs/nls/messages/installer.c:30 msgid "Use as root" msgstr "ルートとして使用" @@ -1453,7 +1481,7 @@ msgstr "fstab を使用" msgid "Use the selected installation's fstab" msgstr "選択したインストールの fstab を使用" -#: userland/apps/installer/main.cpp:1209 +#: userland/apps/installer/main.cpp:1265 msgid "User" msgstr "ユーザー" @@ -1469,11 +1497,11 @@ msgstr "ユーザー名" msgid "Verifying package signatures" msgstr "パッケージの署名を検証しています" -#: userland/apps/installer/installer_update_engine.c:398 +#: userland/apps/installer/installer_update_engine.c:614 msgid "Verifying signed packages and dependencies" msgstr "署名済みパッケージと依存関係を検証しています" -#: userland/apps/installer/main.cpp:822 +#: userland/apps/installer/main.cpp:881 msgid "Version" msgstr "バージョン" @@ -1481,10 +1509,14 @@ msgstr "バージョン" msgid "View log" msgstr "ログを表示" -#: userland/apps/installer/main.cpp:1016 +#: userland/apps/installer/main.cpp:1075 msgid "Volume label" msgstr "ボリュームラベル" +#: userland/apps/installer/main.cpp:570 +msgid "Waiting for the check to release its resources." +msgstr "確認処理がリソースを解放するまで待っています。" + #: configs/nls/messages/installer.c:13 msgid "Welcome" msgstr "ようこそ" @@ -1497,7 +1529,7 @@ msgstr "割り当てた領域を書き込んでいます" msgid "Writing system files to disk" msgstr "システムファイルをディスクに書き込んでいます" -#: userland/apps/installer/installer_update_engine.c:360 +#: userland/apps/installer/installer_update_engine.c:596 msgid "Writing the update log" msgstr "更新ログを書き込んでいます" @@ -1563,6 +1595,27 @@ msgstr "root パスワード" msgid "unformatted" msgstr "未フォーマット" +#~ msgid "Cannot identify the selected partitions" +#~ msgstr "選択したパーティションを識別できません" + +#~ msgid "Checking bootloader compatibility" +#~ msgstr "ブートローダーの互換性を確認しています" + +#~ msgid "Checking update target" +#~ msgstr "更新対象を確認しています" + +#~ msgid "Resuming bootloader publication" +#~ msgstr "ブートローダーの配置を再開しています" + +#~ msgid "Select partitions for ReliefOS and keep other systems or data." +#~ msgstr "ReliefOS 用のパーティションを選び、ほかのシステムやデータを保持します。" + +#~ msgid "Target or media changed. Check the update again." +#~ msgstr "対象またはメディアが変更されました。更新をもう一度確認してください。" + +#~ msgid "The entire disk will be replaced. To preserve another system or data partition, choose manual partitioning." +#~ msgstr "ディスク全体の構成を置き換えます。他のシステムやデータパーティションを保持する場合は、手動での分割を選んでください。" + #~ msgid "Choose automatic installation or prepare a manual layout for this disk." #~ msgstr "自動インストールを選ぶか、このディスクのパーティションを手動で設定してください。" diff --git a/configs/nls/po/installer/zh_CN.po b/configs/nls/po/installer/zh_CN.po index 3805ecf3..890c61f1 100644 --- a/configs/nls/po/installer/zh_CN.po +++ b/configs/nls/po/installer/zh_CN.po @@ -35,7 +35,7 @@ msgstr "账户和系统选项" msgid "Account setup failed" msgstr "账户创建失败" -#: userland/apps/installer/main.cpp:175 +#: userland/apps/installer/main.cpp:212 msgid "Accounts" msgstr "账户" @@ -47,15 +47,15 @@ msgstr "保留账户、个人文件、已安装软件和本地配置。" msgid "Add to Favorites" msgstr "添加到收藏夹" -#: userland/apps/installer/main.cpp:1025 +#: userland/apps/installer/main.cpp:1084 msgid "Add to plan" msgstr "添加到安装计划" -#: userland/apps/installer/installer_update_engine.c:352 +#: userland/apps/installer/installer_update_engine.c:563 msgid "Administrator privileges are required" msgstr "需要管理员权限" -#: userland/apps/installer/main.cpp:1210 +#: userland/apps/installer/main.cpp:1266 msgid "Administrator: root" msgstr "管理员:root" @@ -67,7 +67,7 @@ msgstr "所有文件 (*)" msgid "Apply" msgstr "应用" -#: userland/apps/installer/installer_update_engine.c:418 +#: userland/apps/installer/installer_update_engine.c:623 msgid "Applying signed system packages" msgstr "正在更新已签名的系统软件包" @@ -87,21 +87,21 @@ msgstr "自动分区" msgid "Automatic mode replaces its partition table; manual mode can preserve other partitions." msgstr "自动模式会替换分区表;手动模式可以保留其他分区。" -#: userland/apps/installer/main.cpp:1277 +#: userland/apps/installer/main.cpp:1333 msgid "Automatic partitioning creates a FAT32 ESP and an ext4 root. No BIOS Boot partition is needed." msgstr "自动分区将创建 FAT32 ESP 和 ext4 根分区,无需 BIOS Boot 分区。" -#: userland/apps/installer/main.cpp:1278 +#: userland/apps/installer/main.cpp:1334 msgid "" "Automatic partitioning creates an unformatted BIOS Boot partition, a FAT32 ESP and an ext4 root. " "BIOS also uses the FAT32 partition for boot files." msgstr "自动分区将创建未格式化的 BIOS Boot 分区、FAT32 ESP 和 ext4 根分区。BIOS 也使用 FAT32 分区存放启动文件。" -#: userland/apps/installer/main.cpp:883 +#: userland/apps/installer/main.cpp:942 msgid "Automatic plan: BIOS Boot 1 MiB; ESP 128 MiB FAT32; root %llu MiB ext4.\nThis replaces all existing partitions only after confirmation." msgstr "自动分区计划:BIOS Boot 1 MiB;ESP 128 MiB,FAT32;根分区 %llu MiB,ext4。\n确认安装后才会替换所有现有分区。" -#: userland/apps/installer/main.cpp:882 +#: userland/apps/installer/main.cpp:941 msgid "Automatic plan: ESP 128 MiB FAT32; root %llu MiB ext4.\nThis replaces all existing partitions only after confirmation." msgstr "自动分区计划:ESP 128 MiB,FAT32;根分区 %llu MiB,ext4。\n确认安装后才会替换所有现有分区。" @@ -113,7 +113,7 @@ msgstr "自动识别唯一的 ReliefOS 安装" msgid "B BIOS E ESP R / D Data . Free" msgstr "B BIOS E ESP R / D 数据 . 空闲" -#: userland/apps/installer/main.cpp:1128 +#: userland/apps/installer/main.cpp:1184 msgid "BIOS Boot" msgstr "BIOS Boot" @@ -129,7 +129,7 @@ msgstr "引导安装预检查失败" msgid "Boot partition" msgstr "引导分区" -#: userland/apps/installer/main.cpp:172 +#: configs/nls/messages/installer.c:16 msgid "Bootloaders" msgstr "引导方式" @@ -141,18 +141,26 @@ msgstr "正在计算离线软件包事务" msgid "Cancel" msgstr "取消" +#: userland/apps/installer/main.cpp:299 +msgid "Cancel check" +msgstr "取消检查" + #: userland/apps/installer/installer_tty.c:397 msgid "Cancel installation" msgstr "取消安装" +#: userland/apps/installer/main.cpp:569 +msgid "Canceling the update check" +msgstr "正在取消更新检查" + +#: userland/apps/installer/installer_tui_job.c:229 +msgid "Canceling the update check. Waiting for cleanup." +msgstr "正在取消更新检查,等待清理完成。" + #: userland/apps/installer/installer_tty.c:152 msgid "Cannot display this partition layout." msgstr "无法显示此磁盘分区布局。" -#: userland/apps/installer/main.cpp:480 -msgid "Cannot identify the selected partitions" -msgstr "无法识别所选分区" - #: userland/apps/installer/installer_tty.c:233 msgid "Cannot initialize the terminal or installer log" msgstr "无法初始化终端或安装日志" @@ -165,11 +173,11 @@ msgstr "无法读取安装日志" msgid "Cannot read partition identity" msgstr "无法读取分区标识" -#: userland/apps/installer/main.cpp:912 +#: userland/apps/installer/main.cpp:971 msgid "Cannot read the partition layout" msgstr "无法读取分区布局" -#: userland/apps/installer/main.cpp:760 +#: userland/apps/installer/main.cpp:818 msgid "Cannot read the selected disk" msgstr "无法读取选定的磁盘" @@ -177,19 +185,19 @@ msgstr "无法读取选定的磁盘" msgid "Cannot select the requested locale." msgstr "无法切换到所选语言。" -#: userland/apps/installer/main.cpp:357 +#: userland/apps/installer/main.cpp:395 msgid "Cannot start the installation worker" msgstr "无法启动安装后台进程" -#: userland/apps/installer/main.cpp:467 +#: userland/apps/installer/main.cpp:525 msgid "Cannot start the update worker" msgstr "无法启动后台更新进程" -#: userland/apps/installer/main.cpp:949 +#: userland/apps/installer/main.cpp:1008 msgid "Cannot update the partition plan" msgstr "无法修改分区计划" -#: userland/apps/installer/main.cpp:1054 +#: userland/apps/installer/main.cpp:1113 msgid "Change added to the installation plan." msgstr "更改已添加到安装计划。" @@ -205,11 +213,11 @@ msgstr "更改将在确认安装后写入磁盘。" msgid "Changes remain pending until you confirm the installation. Going back keeps your choices." msgstr "更改将在确认安装后写入磁盘。返回上一步会保留当前选择。" -#: userland/apps/installer/main.cpp:192 +#: userland/apps/installer/main.cpp:229 msgid "Check Again" msgstr "重新检查" -#: userland/apps/installer/main.cpp:197 +#: userland/apps/installer/main.cpp:234 msgid "Check Update" msgstr "检查更新" @@ -217,23 +225,23 @@ msgstr "检查更新" msgid "Check system" msgstr "检查系统" -#: userland/apps/installer/main.cpp:1364 +#: userland/apps/installer/main.cpp:1420 msgid "Check the target and planned changes. Use Back or the sidebar to change your choices." msgstr "请检查目标磁盘和计划中的更改。可使用“上一步”或侧栏返回修改。" -#: userland/apps/installer/installer_tty.c:489 +#: userland/apps/installer/installer_tty.c:493 msgid "Check username and matching passwords (1-32 characters, no spaces)." msgstr "请检查用户名和两次密码(1–32 个字符,不含空格)。" -#: userland/apps/installer/installer_update_engine.c:393 -msgid "Checking bootloader compatibility" -msgstr "正在检查引导器兼容性" +#: userland/apps/installer/installer_update_engine.c:611 +msgid "Checking bootloader files on the installation media" +msgstr "正在检查安装介质上的引导器文件" -#: userland/apps/installer/installer_update_engine.c:369 +#: userland/apps/installer/installer_update_engine.c:610 msgid "Checking installation media and free space" msgstr "正在检查安装介质与可用空间" -#: userland/apps/installer/installer_tui_job.c:101 +#: userland/apps/installer/installer_tui_job.c:215 msgid "Checking installed system" msgstr "正在检查已安装的系统" @@ -241,27 +249,27 @@ msgstr "正在检查已安装的系统" msgid "Checking signed repository and package archives" msgstr "正在检查签名仓库和软件包归档" -#: userland/apps/installer/main.cpp:1443 +#: userland/apps/installer/main.cpp:1499 msgid "Checking system update" msgstr "正在检查系统更新" -#: userland/apps/installer/main.cpp:502 +#: userland/apps/installer/installer_update_engine.c:612 +msgid "Checking the installed bootloader layout" +msgstr "正在检查已安装系统的引导布局" + +#: userland/apps/installer/main.cpp:550 msgid "Checking the selected system" msgstr "正在检查所选系统" -#: userland/apps/installer/installer_update_engine.c:348 -msgid "Checking update target" -msgstr "正在检查更新目标" - #: userland/apps/installer/installer_tty.c:264 msgid "Choose a language, then configure your installation. You can return to earlier steps before installing." msgstr "请选择语言,然后配置安装选项。开始安装前可随时返回前面的步骤。" -#: userland/apps/installer/main.cpp:696 +#: userland/apps/installer/main.cpp:754 msgid "Choose a new installation or update an existing ReliefOS system." msgstr "请选择全新安装或更新现有的 ReliefOS 系统。" -#: userland/apps/installer/main.cpp:1294 +#: userland/apps/installer/main.cpp:1350 msgid "Choose bootloaders" msgstr "选择引导方式" @@ -269,7 +277,7 @@ msgstr "选择引导方式" msgid "Choose how this disk will start. Selecting BIOS and UEFI supports both firmware types; the partition plan follows this choice." msgstr "请选择此磁盘的引导方式。同时选择 BIOS 和 UEFI 可兼容两种固件;分区计划会相应调整。" -#: userland/apps/installer/main.cpp:1320 +#: userland/apps/installer/main.cpp:1376 msgid "Choose the desktop and additional disk space for virtual memory." msgstr "请选择桌面环境,以及用于虚拟内存的额外磁盘空间。" @@ -285,7 +293,7 @@ msgstr "请选择安装磁盘。后续步骤可选择擦除整盘,或手动分 msgid "Choose the installed desktop and optional swapfile. These choices are included in the final review." msgstr "请选择要安装的桌面环境,并按需启用交换文件。这些选项会列入最终安装摘要。" -#: userland/apps/installer/main.cpp:640 +#: userland/apps/installer/main.cpp:698 msgid "Choose the language for Setup and the installed system." msgstr "选择安装程序和安装后系统使用的语言。" @@ -297,6 +305,10 @@ msgstr "清除 BIOS Boot 分区 %u 的全部内容(%llu 字节)。\n" msgid "Close" msgstr "关闭" +#: userland/apps/installer/installer_update_engine.c:637 +msgid "Closing the update target" +msgstr "正在释放更新目标" + #: userland/apps/installer/installer_update_progress.c:138 msgid "Comparing contents" msgstr "正在比较内容" @@ -305,7 +317,7 @@ msgstr "正在比较内容" msgid "Completed" msgstr "已完成" -#: userland/apps/installer/installer_tty.c:62 +#: configs/nls/messages/installer.c:17 msgid "Configure partitions" msgstr "配置分区" @@ -313,11 +325,11 @@ msgstr "配置分区" msgid "Configuring installed system" msgstr "正在配置已安装的系统" -#: userland/apps/installer/main.cpp:176 +#: userland/apps/installer/main.cpp:213 msgid "Confirm" msgstr "确认" -#: userland/apps/installer/installer_tty.c:320 +#: configs/nls/messages/installer.c:22 msgid "Confirm password" msgstr "确认密码" @@ -329,7 +341,7 @@ msgstr "确认 root 密码" msgid "Console only" msgstr "仅控制台" -#: userland/apps/installer/main.cpp:1330 +#: userland/apps/installer/main.cpp:1386 msgid "Console only installs without a graphical login. XFCE is an experimental desktop option." msgstr "“纯控制台”不安装图形登录环境。XFCE 为实验性桌面选项。" @@ -401,7 +413,7 @@ msgstr "自定义筛选器" msgid "Data partition" msgstr "数据分区" -#: userland/apps/installer/installer_tty.c:156 +#: configs/nls/messages/installer.c:23 msgid "Delete" msgstr "删除" @@ -425,7 +437,7 @@ msgstr "已禁用" msgid "Discard changes" msgstr "放弃更改" -#: userland/apps/installer/main.cpp:1143 +#: userland/apps/installer/main.cpp:1200 msgid "Discard edits" msgstr "放弃编辑" @@ -433,7 +445,7 @@ msgstr "放弃编辑" msgid "Discard partition changes" msgstr "放弃分区更改" -#: userland/apps/installer/main.cpp:1068 +#: userland/apps/installer/main.cpp:1127 msgid "Discard pending partition edits and reload the disk?" msgstr "放弃尚未应用的分区编辑,并重新读取磁盘?" @@ -441,7 +453,7 @@ msgstr "放弃尚未应用的分区编辑,并重新读取磁盘?" msgid "Discard the pending partition changes and read the current disk layout again?" msgstr "放弃尚未应用的分区更改,并重新读取磁盘当前的分区布局?" -#: userland/apps/installer/main.cpp:171 +#: userland/apps/installer/main.cpp:208 msgid "Disk" msgstr "硬盘" @@ -449,23 +461,23 @@ msgstr "硬盘" msgid "Disk " msgstr "磁盘 " -#: userland/apps/installer/main.cpp:1403 +#: userland/apps/installer/main.cpp:1459 msgid "Disk changes to apply" msgstr "将要应用的磁盘更改" -#: userland/apps/installer/main.cpp:1099 +#: userland/apps/installer/main.cpp:1158 msgid "Disk layout" msgstr "磁盘布局" -#: userland/apps/installer/installer_tui_job.c:111 +#: userland/apps/installer/installer_tui_job.c:225 msgid "Disk operations are running. Please wait for completion." msgstr "正在执行磁盘操作,请等待完成。" -#: userland/apps/installer/main.cpp:1444 +#: userland/apps/installer/main.cpp:1500 msgid "Do not turn off this machine." msgstr "请勿关闭此计算机。" -#: userland/apps/installer/main.cpp:815 +#: userland/apps/installer/main.cpp:874 msgid "EFI system partition" msgstr "EFI 系统分区" @@ -478,7 +490,7 @@ msgstr "已用时间:%lu 秒" msgid "Enter a positive whole number of MiB." msgstr "请输入大于零的整数 MiB。" -#: userland/apps/installer/installer_tty.c:494 +#: userland/apps/installer/installer_tty.c:498 msgid "Enter a valid swap size in MiB." msgstr "请输入有效的交换文件大小(MiB)。" @@ -490,7 +502,7 @@ msgstr "擦除 %s 上的所有分区。\n创建 BIOS Boot:1 MiB,不格式化 msgid "Erase all partitions on %s.\nCreate ESP: 128 MiB, format FAT32.\nCreate system root: %llu MiB, format ext4." msgstr "擦除 %s 上的所有分区。\n创建 ESP:128 MiB,格式化为 FAT32。\n创建系统根分区:%llu MiB,格式化为 ext4。" -#: userland/apps/installer/main.cpp:1100 +#: userland/apps/installer/main.cpp:1159 msgid "Erase disk and install automatically" msgstr "擦除整盘并自动安装" @@ -506,7 +518,7 @@ msgstr "除非下方列出了格式化操作,否则会保留 ESP 中的现有 msgid "Exit" msgstr "退出" -#: userland/apps/installer/main.cpp:520 +#: userland/apps/installer/main.cpp:578 msgid "Exit installer" msgstr "退出安装器" @@ -514,7 +526,7 @@ msgstr "退出安装器" msgid "Exit the installer?" msgstr "退出安装器?" -#: userland/apps/installer/main.cpp:521 +#: userland/apps/installer/main.cpp:579 msgid "Exit the installer? Unapplied disk changes and setup choices will be discarded." msgstr "退出安装器?尚未应用的磁盘更改和安装设置将被放弃。" @@ -542,15 +554,15 @@ msgstr "文件系统" msgid "Filesystem label" msgstr "文件系统卷标" -#: userland/apps/installer/main.cpp:179 +#: userland/apps/installer/main.cpp:216 msgid "Finish" msgstr "完成" -#: userland/apps/installer/installer_update_engine.c:437 +#: userland/apps/installer/installer_update_engine.c:627 msgid "Finishing the system update" msgstr "正在完成系统更新" -#: userland/apps/installer/installer_tty.c:156 +#: configs/nls/messages/installer.c:24 msgid "Format" msgstr "格式" @@ -566,7 +578,7 @@ msgstr "格式化所选 ESP(擦除其中所有 EFI 引导文件)" msgid "Free / required space" msgstr "可用/所需空间" -#: userland/apps/installer/main.cpp:699 +#: userland/apps/installer/main.cpp:757 msgid "Fresh Install" msgstr "全新安装" @@ -574,7 +586,7 @@ msgstr "全新安装" msgid "Go back to edit any option. Nothing is written until you choose Install." msgstr "可返回修改任何选项。点击“安装”前不会写入磁盘。" -#: userland/apps/installer/main.cpp:671 +#: userland/apps/installer/main.cpp:729 msgid "I accept the license terms" msgstr "我接受许可协议条款" @@ -582,7 +594,7 @@ msgstr "我接受许可协议条款" msgid "IceWM (default)" msgstr "IceWM(默认)" -#: userland/apps/installer/installer_update_engine.c:363 +#: userland/apps/installer/installer_update_engine.c:609 msgid "Identifying the installed system" msgstr "正在识别已安装的系统" @@ -598,7 +610,7 @@ msgstr "输入内容过长" msgid "Install" msgstr "安装" -#: userland/apps/installer/main.cpp:631 +#: userland/apps/installer/main.cpp:689 msgid "Install ReliefOS" msgstr "安装 ReliefOS" @@ -626,11 +638,11 @@ msgstr "安装或更新 UEFI 引导程序" msgid "Installation" msgstr "安装" -#: userland/apps/installer/main.cpp:1471 +#: userland/apps/installer/main.cpp:1527 msgid "Installation Complete" msgstr "安装完成" -#: userland/apps/installer/main.cpp:1497 +#: userland/apps/installer/main.cpp:1553 msgid "Installation Failed" msgstr "安装失败" @@ -662,11 +674,11 @@ msgstr "安装布局 — 更改尚未应用" msgid "Installation media is incomplete" msgstr "安装介质不完整" -#: userland/apps/installer/installer_update_engine.c:257 +#: userland/apps/installer/installer_update_engine.c:300 msgid "Installation media is older than the installed system" msgstr "安装介质的版本早于已安装系统" -#: userland/apps/installer/model.c:167 +#: configs/nls/messages/installer.c:14 msgid "Installation mode" msgstr "安装模式" @@ -678,11 +690,11 @@ msgstr "安装进度" msgid "Installation result" msgstr "安装结果" -#: userland/apps/installer/main.cpp:695 +#: userland/apps/installer/main.cpp:753 msgid "Installation type" msgstr "安装方式" -#: userland/apps/installer/main.cpp:328 +#: userland/apps/installer/main.cpp:366 msgid "Installation worker failed" msgstr "安装后台进程失败" @@ -718,23 +730,23 @@ msgstr "大小无效" msgid "Invalid swap size" msgstr "交换文件大小无效" -#: userland/apps/installer/main.cpp:1067 +#: userland/apps/installer/main.cpp:1126 msgid "Keep changes" msgstr "保留更改" -#: userland/apps/installer/main.cpp:520 +#: userland/apps/installer/main.cpp:578 msgid "Keep configuring" msgstr "继续配置" -#: userland/apps/installer/installer_tty.c:374 +#: configs/nls/messages/installer.c:11 msgid "Language" msgstr "语言" -#: userland/apps/installer/main.cpp:169 +#: configs/nls/messages/installer.c:12 msgid "License" msgstr "许可证" -#: userland/apps/installer/main.cpp:660 +#: userland/apps/installer/main.cpp:718 msgid "License agreement" msgstr "许可协议" @@ -742,11 +754,11 @@ msgstr "许可协议" msgid "Manage Favorites" msgstr "管理收藏夹" -#: userland/apps/installer/main.cpp:891 +#: userland/apps/installer/main.cpp:950 msgid "Manual layout: assign BIOS Boot, ESP and root roles. BIOS Boot stays unformatted." msgstr "手动布局:指定 BIOS 引导分区、ESP 和根分区。BIOS 引导分区不格式化。" -#: userland/apps/installer/main.cpp:890 +#: userland/apps/installer/main.cpp:949 msgid "Manual layout: assign a FAT32 ESP and an ext4 or ext3 root. BIOS Boot is not required for the selected bootloaders." msgstr "手动布局:指定 FAT32 ESP 和 ext4 或 ext3 根分区。当前引导选择不需要 BIOS Boot 分区。" @@ -754,11 +766,11 @@ msgstr "手动布局:指定 FAT32 ESP 和 ext4 或 ext3 根分区。当前引 msgid "Manual partitioning" msgstr "手动分区" -#: userland/apps/installer/main.cpp:1101 +#: userland/apps/installer/main.cpp:1160 msgid "Manual partitioning / keep other systems" msgstr "手动分区 / 保留其他系统" -#: userland/apps/installer/main.cpp:170 +#: userland/apps/installer/main.cpp:207 msgid "Mode" msgstr "模式" @@ -766,7 +778,7 @@ msgstr "模式" msgid "Mount failed" msgstr "挂载失败" -#: userland/apps/installer/install_ops.c:836 +#: configs/nls/messages/installer.c:5 msgid "Mounting target filesystems" msgstr "正在挂载目标文件系统" @@ -778,11 +790,11 @@ msgstr "名称" msgid "New Directory?" msgstr "新建目录?" -#: userland/apps/installer/main.cpp:1118 +#: configs/nls/messages/installer.c:31 msgid "New GPT" msgstr "新建 GPT" -#: userland/apps/installer/main.cpp:966 +#: userland/apps/installer/main.cpp:1025 msgid "New partition table added to the plan." msgstr "新的分区表已添加到安装计划。" @@ -802,7 +814,7 @@ msgstr "未选择引导程序。新安装的系统需要另行配置引导程序 msgid "No disks were found" msgstr "未找到硬盘" -#: userland/apps/installer/main.cpp:1500 +#: userland/apps/installer/main.cpp:1556 msgid "No writes will continue after this error." msgstr "出现此错误后不会继续写入。" @@ -831,7 +843,7 @@ msgstr "分区" msgid "Partition %u %s %llu MiB %s %s%s" msgstr "分区 %u %s %llu MiB %s %s%s" -#: userland/apps/installer/main.cpp:973 +#: userland/apps/installer/main.cpp:1032 msgid "Partition deletion added to the plan." msgstr "分区删除操作已添加到安装计划。" @@ -847,7 +859,7 @@ msgstr "分区名称" msgid "Partition operation failed" msgstr "分区操作失败" -#: userland/apps/installer/main.cpp:951 +#: userland/apps/installer/main.cpp:1010 msgid "Partition plan updated" msgstr "分区计划已更新" @@ -855,11 +867,11 @@ msgstr "分区计划已更新" msgid "Partition role" msgstr "分区用途" -#: userland/apps/installer/main.cpp:1088 +#: userland/apps/installer/main.cpp:1147 msgid "Partition role updated." msgstr "已更新分区用途。" -#: userland/apps/installer/main.cpp:173 +#: userland/apps/installer/main.cpp:210 msgid "Partitions" msgstr "分区" @@ -883,11 +895,11 @@ msgstr "扫描安装负载失败" msgid "Pending layout - written only after INSTALL confirmation." msgstr "待应用方案,最终确认安装后才会写入磁盘。" -#: userland/apps/installer/main.cpp:971 +#: userland/apps/installer/main.cpp:1030 msgid "Plan deletion" msgstr "计划删除" -#: userland/apps/installer/main.cpp:964 +#: userland/apps/installer/main.cpp:1023 msgid "Plan new table" msgstr "计划新建分区表" @@ -899,11 +911,11 @@ msgstr "请选择已存在的文件!" msgid "Power operation failed" msgstr "电源操作失败" -#: userland/apps/installer/main.cpp:710 +#: userland/apps/installer/main.cpp:768 msgid "Prepare a clean ReliefOS system with automatic or manual disk partitioning." msgstr "通过自动或手动分区安装全新的 ReliefOS 系统。" -#: userland/apps/installer/installer_tui_job.c:109 +#: userland/apps/installer/installer_tui_job.c:223 msgid "Preparing operation" msgstr "正在准备操作" @@ -911,14 +923,18 @@ msgstr "正在准备操作" msgid "Preparing target disk" msgstr "正在准备目标磁盘" -#: userland/apps/installer/installer_update_engine.c:410 +#: userland/apps/installer/installer_update_engine.c:620 msgid "Preparing the installed system for update" msgstr "正在准备更新已安装的系统" -#: userland/apps/installer/main.cpp:502 +#: userland/apps/installer/main.cpp:550 msgid "Preparing the system update" msgstr "正在准备系统更新" +#: userland/apps/installer/installer_update_engine.c:568 +msgid "Preparing update session" +msgstr "正在准备更新" + #: userland/apps/installer/installer_update_progress.c:15 msgid "Preparing verified package archives" msgstr "正在准备已验证的软件包归档" @@ -935,11 +951,11 @@ msgstr "点击重启从已安装硬盘启动。" msgid "Preview" msgstr "预览" -#: userland/apps/installer/main.cpp:632 +#: userland/apps/installer/main.cpp:690 msgid "Previous Step" msgstr "上一步" -#: userland/apps/installer/installer_update_engine.c:429 +#: userland/apps/installer/installer_update_engine.c:626 msgid "Publishing kernel and bootloader files" msgstr "正在提交内核与引导文件" @@ -951,11 +967,11 @@ msgstr "正在发布离线软件包缓存" msgid "Ready" msgstr "就绪" -#: userland/apps/installer/main.cpp:429 +#: userland/apps/installer/main.cpp:485 msgid "Ready to update" msgstr "可以开始更新" -#: userland/apps/installer/installer_update_engine.c:313 +#: userland/apps/installer/installer_update_engine.c:346 msgid "Recovering the previous update attempt" msgstr "正在恢复上一次未完成的更新" @@ -963,15 +979,15 @@ msgstr "正在恢复上一次未完成的更新" msgid "Refresh" msgstr "刷新" -#: userland/apps/installer/main.cpp:813 +#: userland/apps/installer/main.cpp:872 msgid "ReliefOS system partition" msgstr "ReliefOS 系统分区" -#: userland/apps/installer/main.cpp:1474 +#: userland/apps/installer/main.cpp:1530 msgid "ReliefOS was installed to the selected disk." msgstr "ReliefOS 已安装到所选硬盘。" -#: userland/apps/installer/main.cpp:1473 +#: userland/apps/installer/main.cpp:1529 msgid "ReliefOS was updated on the selected disk." msgstr "所选硬盘上的 ReliefOS 已更新。" @@ -983,11 +999,11 @@ msgstr "继续前请移除安装介质。" msgid "Remove the installation media before rebooting." msgstr "重启前请移除安装介质。" -#: userland/apps/installer/main.cpp:434 +#: userland/apps/installer/main.cpp:490 msgid "Remove the installation media, then restart." msgstr "移除安装介质,然后重启。" -#: userland/apps/installer/main.cpp:972 +#: userland/apps/installer/main.cpp:1031 msgid "Remove the selected partition when the installation is confirmed?" msgstr "确认安装时删除选定的分区?" @@ -995,7 +1011,7 @@ msgstr "确认安装时删除选定的分区?" msgid "Removing retired package archives" msgstr "正在移除已停用的软件包归档" -#: userland/apps/installer/installer_tty.c:156 +#: configs/nls/messages/installer.c:27 msgid "Rename" msgstr "重命名" @@ -1011,7 +1027,7 @@ msgstr "正在修复已签名的系统软件包" msgid "Replace partition table" msgstr "替换分区表" -#: userland/apps/installer/main.cpp:965 +#: userland/apps/installer/main.cpp:1024 msgid "Replace this disk's partition table in the installation plan? All existing partitions will be removed when you install." msgstr "将替换此磁盘的分区表加入安装计划?开始安装时会删除所有现有分区。" @@ -1027,7 +1043,7 @@ msgstr "调整分区大小" msgid "Resize the terminal to at least 60 columns and 20 rows." msgstr "请将终端调整到至少 60 列、20 行。" -#: userland/apps/installer/main.cpp:984 +#: userland/apps/installer/main.cpp:1043 msgid "Resizing changes the partition boundary. Existing filesystems cannot be shrunk here." msgstr "调整大小会更改分区边界。此处无法缩小现有文件系统。" @@ -1035,7 +1051,7 @@ msgstr "调整大小会更改分区边界。此处无法缩小现有文件系统 msgid "Restart" msgstr "重启" -#: userland/apps/installer/main.cpp:1490 +#: userland/apps/installer/main.cpp:1546 msgid "Restart failed" msgstr "重启失败" @@ -1043,15 +1059,11 @@ msgstr "重启失败" msgid "Restoring retained kernel files" msgstr "正在恢复已保留的内核文件" -#: userland/apps/installer/installer_update_engine.c:429 -msgid "Resuming bootloader publication" -msgstr "正在继续提交引导文件" - #: userland/apps/installer/installer_update_progress.c:140 msgid "Reused" msgstr "已复用" -#: userland/apps/installer/main.cpp:1363 +#: configs/nls/messages/installer.c:19 msgid "Review installation" msgstr "核对安装设置" @@ -1059,7 +1071,7 @@ msgstr "核对安装设置" msgid "Review settings" msgstr "重新检查设置" -#: userland/apps/installer/main.cpp:1363 +#: userland/apps/installer/main.cpp:1419 msgid "Review system update" msgstr "确认系统更新" @@ -1067,15 +1079,15 @@ msgstr "确认系统更新" msgid "Review the configuration before trying again. Changes already written to disk may remain." msgstr "重试前请重新检查设置。已经写入磁盘的更改可能仍然存在。" -#: userland/apps/installer/main.cpp:1499 +#: userland/apps/installer/main.cpp:1555 msgid "Review the details, then check the update again to retry." msgstr "请查看详细日志,然后重新检查更新以重试。" -#: userland/apps/installer/main.cpp:429 +#: userland/apps/installer/main.cpp:485 msgid "Review the detected system and boot options, then continue to the summary." msgstr "请核对检测到的系统和引导选项,然后查看摘要。" -#: userland/apps/installer/installer_tty.c:510 +#: userland/apps/installer/installer_tty.c:514 msgid "Review the disk layout and account settings before installing." msgstr "安装前请检查磁盘布局和账户设置。" @@ -1083,11 +1095,11 @@ msgstr "安装前请检查磁盘布局和账户设置。" msgid "Review the disk model, size and partitions before applying changes." msgstr "应用更改前,请核对磁盘型号、容量和现有分区。" -#: userland/apps/installer/installer_tty.c:485 +#: userland/apps/installer/installer_tty.c:489 msgid "Review the required BIOS Boot, ESP and root partitions." msgstr "请核对所需的 BIOS Boot、ESP 和根分区。" -#: userland/apps/installer/main.cpp:197 +#: userland/apps/installer/main.cpp:234 msgid "Review update" msgstr "核对更新摘要" @@ -1107,19 +1119,19 @@ msgstr "正在保存系统设置" msgid "Scanning installation payload" msgstr "正在扫描安装载荷" -#: userland/apps/installer/main.cpp:800 +#: userland/apps/installer/main.cpp:858 msgid "Select Disk to Update" msgstr "选择要更新的硬盘" -#: userland/apps/installer/main.cpp:800 +#: userland/apps/installer/main.cpp:858 msgid "Select Installation Disk" msgstr "选择安装硬盘" -#: userland/apps/installer/main.cpp:639 +#: userland/apps/installer/main.cpp:697 msgid "Select Language" msgstr "选择语言" -#: userland/apps/installer/main.cpp:802 +#: userland/apps/installer/main.cpp:860 msgid "Select a disk and check its existing installation before continuing." msgstr "请选择磁盘并检查其中的现有安装,然后继续。" @@ -1127,6 +1139,10 @@ msgstr "请选择磁盘并检查其中的现有安装,然后继续。" msgid "Select a disk first." msgstr "请先选择磁盘。" +#: userland/apps/installer/main.cpp:477 +msgid "Select a disk or run the checks again." +msgstr "请选择磁盘或重新运行检查。" + #: userland/apps/installer/installer_tty.c:62 msgid "Select a partition first." msgstr "请先选择分区。" @@ -1139,10 +1155,6 @@ msgstr "请选择目标磁盘,并重新检查分区布局。" msgid "Select boot partition" msgstr "选择引导分区" -#: userland/apps/installer/main.cpp:1109 -msgid "Select partitions for ReliefOS and keep other systems or data." -msgstr "选择 ReliefOS 使用的分区,并保留其他系统或数据。" - #: userland/apps/installer/installer_tty.c:296 msgid "Select system partition" msgstr "选择系统分区" @@ -1151,7 +1163,7 @@ msgstr "选择系统分区" msgid "Select the disk to update" msgstr "请选择要更新的硬盘" -#: userland/apps/installer/main.cpp:1295 +#: userland/apps/installer/main.cpp:1351 msgid "Select the firmware used to start this disk. You can select both BIOS and UEFI." msgstr "选择用于启动此磁盘的固件类型。可以同时选择 BIOS 和 UEFI。" @@ -1159,7 +1171,7 @@ msgstr "选择用于启动此磁盘的固件类型。可以同时选择 BIOS 和 msgid "Select the target disk" msgstr "请选择目标硬盘" -#: userland/apps/installer/main.cpp:803 +#: userland/apps/installer/main.cpp:861 msgid "Select the target. The disk layout is configured in the following steps." msgstr "请选择目标磁盘。后续步骤将配置分区布局。" @@ -1167,7 +1179,7 @@ msgstr "请选择目标磁盘。后续步骤将配置分区布局。" msgid "Selected system does not support swap" msgstr "所选系统不支持交换空间" -#: userland/apps/installer/main.cpp:232 +#: userland/apps/installer/main.cpp:269 msgid "Setup" msgstr "安装" @@ -1175,7 +1187,7 @@ msgstr "安装" msgid "Setup will check for an existing ReliefOS system." msgstr "安装程序会检测现有 ReliefOS 系统。" -#: userland/apps/installer/installer_tui_job.c:113 +#: userland/apps/installer/installer_tui_job.c:227 msgid "Show / hide log (F4)" msgstr "显示/隐藏日志(F4)" @@ -1191,7 +1203,7 @@ msgstr "显示:" msgid "Shut down" msgstr "关机" -#: userland/apps/installer/main.cpp:1384 +#: userland/apps/installer/main.cpp:1440 msgid "" "Signed packages are checked before changes. Boot files are published after the package " "transaction succeeds." @@ -1201,7 +1213,7 @@ msgstr "写入前校验软件包签名,软件包事务成功后再提交引导 msgid "Size" msgstr "容量" -#: userland/apps/installer/main.cpp:993 +#: userland/apps/installer/main.cpp:1052 msgid "Size (MiB)" msgstr "大小(MiB)" @@ -1209,7 +1221,7 @@ msgstr "大小(MiB)" msgid "Size in MiB" msgstr "大小(MiB)" -#: userland/apps/installer/main.cpp:1373 +#: userland/apps/installer/main.cpp:1429 msgid "Skip" msgstr "跳过" @@ -1225,7 +1237,11 @@ msgstr "普通用户密码" msgid "Step %d of %d" msgstr "第 %d 步,共 %d 步" -#: userland/apps/installer/main.cpp:1402 +#: userland/apps/installer/installer_update_engine.c:521 +msgid "Stopping update check and cleaning up" +msgstr "正在停止更新检查并清理" + +#: userland/apps/installer/main.cpp:1458 msgid "Swap" msgstr "交换空间" @@ -1233,7 +1249,7 @@ msgstr "交换空间" msgid "Swap requires an AHCI disk" msgstr "交换文件需要 AHCI 磁盘" -#: userland/apps/installer/main.cpp:1341 +#: userland/apps/installer/main.cpp:1397 msgid "Swap size (MiB)" msgstr "交换空间大小(MiB)" @@ -1241,7 +1257,7 @@ msgstr "交换空间大小(MiB)" msgid "Swap size in MiB" msgstr "交换文件大小(MiB)" -#: userland/apps/installer/main.cpp:1349 +#: userland/apps/installer/main.cpp:1405 msgid "Swap uses space on the system partition and currently requires an AHCI disk. Enter a valid whole number of MiB." msgstr "交换文件占用系统分区的空间,目前需要 AHCI 磁盘。请输入有效的整数大小,单位为 MiB。" @@ -1253,15 +1269,15 @@ msgstr "正在同步目标文件系统" msgid "Synchronizing the offline package cache" msgstr "正在同步离线软件包缓存" -#: userland/apps/installer/installer_update_engine.c:424 +#: userland/apps/installer/installer_update_engine.c:624 msgid "Synchronizing the updated root filesystem" msgstr "正在同步更新后的根文件系统" -#: userland/apps/installer/main.cpp:174 +#: userland/apps/installer/main.cpp:211 msgid "System" msgstr "系统" -#: userland/apps/installer/main.cpp:1319 +#: userland/apps/installer/main.cpp:1375 msgid "System options" msgstr "系统选项" @@ -1277,7 +1293,7 @@ msgstr "系统根分区" msgid "System root: %s; format %s.\nESP: %s; %s.\nOther partitions are preserved except for the changes listed above." msgstr "系统根分区:%s;格式化为 %s。\nESP:%s;%s。\n除上方列出的更改外,其他分区保持不变。" -#: userland/apps/installer/installer_update_engine.c:453 +#: userland/apps/installer/installer_update_engine.c:647 msgid "System update completed successfully" msgstr "系统更新成功" @@ -1289,7 +1305,7 @@ msgstr "系统版本" msgid "Tab / arrows: select Space: toggle PgUp/PgDn: scroll" msgstr "Tab/方向键选择 空格切换 PgUp/PgDn 翻页" -#: userland/apps/installer/installer_tty.c:415 +#: configs/nls/messages/installer.c:15 msgid "Target disk" msgstr "目标磁盘" @@ -1301,15 +1317,11 @@ msgstr "目标磁盘已变化;请重新检查安装计划" msgid "Target disk is ready." msgstr "目标硬盘已准备就绪。" -#: userland/apps/installer/installer_update_engine.c:382 -msgid "Target or media changed. Check the update again." -msgstr "目标系统或安装介质已变化,请重新检查更新。" - #: userland/apps/installer/installer_tty.c:151 msgid "The automatic layout does not fit this disk. Select another disk or configure partitions manually." msgstr "此磁盘无法容纳自动方案。请选择其他磁盘或手动配置分区。" -#: userland/apps/installer/installer_tty.c:504 +#: userland/apps/installer/installer_tty.c:508 msgid "The confirmation word does not match." msgstr "确认文字不匹配。" @@ -1317,10 +1329,6 @@ msgstr "确认文字不匹配。" msgid "The disk plan could not be read. Return to Disk layout and review the target." msgstr "无法读取磁盘计划。请返回“磁盘布局”检查目标磁盘。" -#: userland/apps/installer/main.cpp:1107 -msgid "The entire disk will be replaced. To preserve another system or data partition, choose manual partitioning." -msgstr "整个磁盘的分区将被替换。若要保留其他系统或数据分区,请选择手动分区。" - #: userland/apps/installer/installer_tty.c:203 msgid "The selected ESP will also be formatted." msgstr "选定的 ESP 也将被格式化。" @@ -1333,15 +1341,15 @@ msgstr "选定的磁盘已不可用" msgid "The system partition will be formatted. Review every pending change below." msgstr "系统分区将被格式化。请核对下方所有待应用的更改。" -#: userland/apps/installer/installer_tui_job.c:116 +#: userland/apps/installer/installer_tui_job.c:230 msgid "The terminal requested exit. Waiting for the disk operation to finish." msgstr "终端已请求退出,正在等待磁盘操作完成。" -#: userland/apps/installer/main.cpp:1416 +#: userland/apps/installer/main.cpp:1472 msgid "These disk changes cannot be undone. Type INSTALL to confirm." msgstr "这些磁盘更改无法撤销。请输入 INSTALL 确认。" -#: userland/apps/installer/main.cpp:985 +#: userland/apps/installer/main.cpp:1044 msgid "This change is added to the plan. Nothing is written until installation is confirmed." msgstr "此更改将添加到安装计划。确认安装前不会写入磁盘。" @@ -1353,7 +1361,7 @@ msgstr "输入 INSTALL 确认安装" msgid "Type the confirmation word" msgstr "输入确认文字" -#: userland/apps/installer/main.cpp:1484 +#: userland/apps/installer/main.cpp:1540 msgid "UEFI boot file (add it in firmware if no automatic entry appears):" msgstr "UEFI 引导文件(若未自动出现入口,请在固件中添加):" @@ -1361,7 +1369,7 @@ msgstr "UEFI 引导文件(若未自动出现入口,请在固件中添加) msgid "Unallocated" msgstr "未分配空间" -#: userland/apps/installer/main.cpp:920 +#: userland/apps/installer/main.cpp:979 msgid "Unformatted" msgstr "不格式化" @@ -1377,15 +1385,15 @@ msgstr "上下键选择分区 PgUp/PgDn 翻页 Home/End 首尾 Tab 操作栏" msgid "Update" msgstr "更新" -#: userland/apps/installer/main.cpp:1471 +#: userland/apps/installer/main.cpp:1527 msgid "Update Complete" msgstr "更新完成" -#: userland/apps/installer/main.cpp:701 +#: userland/apps/installer/main.cpp:759 msgid "Update Existing System" msgstr "更新现有系统" -#: userland/apps/installer/main.cpp:1497 +#: userland/apps/installer/main.cpp:1553 msgid "Update Failed" msgstr "更新失败" @@ -1393,11 +1401,23 @@ msgstr "更新失败" msgid "Update an existing system" msgstr "更新已有系统" -#: userland/apps/installer/main.cpp:825 +#: userland/apps/installer/main.cpp:884 msgid "Update bootloader software" msgstr "更新引导器程序" -#: userland/apps/installer/installer_update_engine.c:402 +#: userland/apps/installer/main.cpp:477 +msgid "Update check canceled" +msgstr "已取消更新检查" + +#: userland/apps/installer/installer_tty.c:474 +msgid "Update check canceled. Run the checks again when ready." +msgstr "已取消更新检查。准备好后可重新运行检查。" + +#: userland/apps/installer/installer_update_engine.c:644 +msgid "Update check cancelled" +msgstr "已取消更新检查" + +#: userland/apps/installer/installer_update_engine.c:647 msgid "Update checks completed" msgstr "更新检查完成" @@ -1405,15 +1425,23 @@ msgstr "更新检查完成" msgid "Update completed successfully" msgstr "更新成功完成" -#: userland/apps/installer/main.cpp:1428 +#: userland/apps/installer/main.cpp:1484 msgid "Update details" msgstr "更新详情" -#: userland/apps/installer/main.cpp:712 +#: userland/apps/installer/main.cpp:770 msgid "Update preserves users, personal files, installed software and local configuration." msgstr "更新会保留用户、个人文件、已安装软件和本地配置。" -#: userland/apps/installer/installer_update_engine.c:536 +#: userland/apps/installer/installer_update_engine.c:782 +msgid "Update session completed" +msgstr "本次更新操作已完成" + +#: userland/apps/installer/installer_update_engine.c:522 +msgid "Update stage timed out; stopping its processes" +msgstr "更新步骤超时,正在停止相关进程" + +#: userland/apps/installer/installer_update_engine.c:780 msgid "Update worker failed" msgstr "后台更新进程执行失败" @@ -1437,11 +1465,11 @@ msgstr "用途" msgid "Use Tab and the arrow keys to select controls. F3 continues and F2 returns to the previous step." msgstr "使用 Tab 和方向键选择控件,F3 继续,F2 返回上一步。" -#: userland/apps/installer/main.cpp:1128 +#: configs/nls/messages/installer.c:29 msgid "Use as ESP" msgstr "用作 ESP" -#: userland/apps/installer/main.cpp:1128 +#: configs/nls/messages/installer.c:30 msgid "Use as root" msgstr "用作根分区" @@ -1453,7 +1481,7 @@ msgstr "使用 fstab" msgid "Use the selected installation's fstab" msgstr "使用所选安装的 fstab" -#: userland/apps/installer/main.cpp:1209 +#: userland/apps/installer/main.cpp:1265 msgid "User" msgstr "用户" @@ -1469,11 +1497,11 @@ msgstr "用户名" msgid "Verifying package signatures" msgstr "正在验证软件包签名" -#: userland/apps/installer/installer_update_engine.c:398 +#: userland/apps/installer/installer_update_engine.c:614 msgid "Verifying signed packages and dependencies" msgstr "正在校验软件包签名与依赖" -#: userland/apps/installer/main.cpp:822 +#: userland/apps/installer/main.cpp:881 msgid "Version" msgstr "版本" @@ -1481,10 +1509,14 @@ msgstr "版本" msgid "View log" msgstr "查看日志" -#: userland/apps/installer/main.cpp:1016 +#: userland/apps/installer/main.cpp:1075 msgid "Volume label" msgstr "卷标" +#: userland/apps/installer/main.cpp:570 +msgid "Waiting for the check to release its resources." +msgstr "正在等待检查进程释放资源。" + #: configs/nls/messages/installer.c:13 msgid "Welcome" msgstr "欢迎" @@ -1497,7 +1529,7 @@ msgstr "正在写入分配的空间" msgid "Writing system files to disk" msgstr "正在向磁盘写入系统文件" -#: userland/apps/installer/installer_update_engine.c:360 +#: userland/apps/installer/installer_update_engine.c:596 msgid "Writing the update log" msgstr "正在写入更新日志" @@ -1563,6 +1595,27 @@ msgstr "root 密码" msgid "unformatted" msgstr "未格式化" +#~ msgid "Cannot identify the selected partitions" +#~ msgstr "无法识别所选分区" + +#~ msgid "Checking bootloader compatibility" +#~ msgstr "正在检查引导器兼容性" + +#~ msgid "Checking update target" +#~ msgstr "正在检查更新目标" + +#~ msgid "Resuming bootloader publication" +#~ msgstr "正在继续提交引导文件" + +#~ msgid "Select partitions for ReliefOS and keep other systems or data." +#~ msgstr "选择 ReliefOS 使用的分区,并保留其他系统或数据。" + +#~ msgid "Target or media changed. Check the update again." +#~ msgstr "目标系统或安装介质已变化,请重新检查更新。" + +#~ msgid "The entire disk will be replaced. To preserve another system or data partition, choose manual partitioning." +#~ msgstr "整个磁盘的分区将被替换。若要保留其他系统或数据分区,请选择手动分区。" + #~ msgid "Choose automatic installation or prepare a manual layout for this disk." #~ msgstr "请选择自动安装,或为此磁盘手动配置分区。" diff --git a/scripts/reliefos/Makefile.tests b/scripts/reliefos/Makefile.tests index 65eb739e..279a72ee 100644 --- a/scripts/reliefos/Makefile.tests +++ b/scripts/reliefos/Makefile.tests @@ -119,6 +119,11 @@ test-build: sdk rootfs-raw $(HOST_RUNTIME_DEVELOPMENT_PRODUCTS) test-tools $(REL +@$(call RELIEFOS_RUN_CONTRACT_TESTS,$(RELIEFOS_SELECTED_BUILD_TESTS)) @$(RELIEFOS_TEST_PYTHON) $(RELIEFOS_SRC)/tools/test_xorg_qemu.py --source-only +# The signed Installer update fixtures use the real APK producer and installed +# Bash. Require the managed tree explicitly so a clean `make test-build` has +# the same inputs as CI after its image build. +test-build: $(UPSTREAM_APK) $(APK_MANAGED_ROOT)/.apk-complete + .PHONY: test-ci-validate test-ci-kernel test-ci-auth test-ci-pages test-ci-validate: @$(RELIEFOS_TEST_PYTHON) '$(RELIEFOS_CI_SELECTOR)' --root '$(RELIEFOS_SRC)' --check diff --git a/tests/build/brand-allowlist.tsv b/tests/build/brand-allowlist.tsv index 5bb5bd4e..52ef2377 100644 --- a/tests/build/brand-allowlist.tsv +++ b/tests/build/brand-allowlist.tsv @@ -341,3 +341,4 @@ main compatibility userland/apps/systemupdate/apk.c 原生更新器验证已发 main compatibility tools/test_system_update.py 原生更新器验证既有 RPR health.txt 响应的兼容夹具,不作为用户界面品牌。 main compatibility tools/tests/test_system_update_packaging.py 真实签名 APK 回归验证旧 leonos-apps 文件所有权及已发布 leonos-* 命令别名迁移。 main compatibility tests/build/test-desktop-backend.sh 桌面载荷回归验证已发布 leonos-* 更新命令别名统一指向原生更新核心,不保留旧脚本实现。 +main compatibility tools/tests/installer_update_model_test.c Fixture verifies legacy os-release ID compatibility during update inspection. diff --git a/tests/build/test-installer-update-engine.sh b/tests/build/test-installer-update-engine.sh new file mode 100755 index 00000000..b8b718a8 --- /dev/null +++ b/tests/build/test-installer-update-engine.sh @@ -0,0 +1,16 @@ +#!/bin/sh +set -eu +ulimit -c 0 +src=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd -P) +work=$(mktemp -d "${TMPDIR:-$src/out/tmp}/installer-update-engine.XXXXXX") +trap 'rm -rf "$work"' EXIT HUP INT TERM +mkdir -p "$work/target" "$work/media/usr/share/reliefos/apk/repository" +printf 'fixture package archive\n' > "$work/media/usr/share/reliefos/apk/repository/fixture.apk" +${HOSTCC:-cc} -std=c11 -D_GNU_SOURCE -O1 -Wall -Wextra -Werror \ + -fsanitize=address,undefined -fno-sanitize-recover=all -g \ + -ffunction-sections -fdata-sections -Wl,--gc-sections \ + -I"$src/userland/runtime/include" -I"$src/include" -idirafter "$src/kernel/reliefnt/include/uapi" \ + "$src/tools/tests/installer_update_engine_test.c" \ + "$src/userland/apps/installer/installer_update_supervisor.c" \ + "$src/userland/apps/installer/installer_update_progress.c" -o "$work/test" +ASAN_OPTIONS=detect_leaks=1 UBSAN_OPTIONS=halt_on_error=1 "$work/test" "$work" diff --git a/tests/build/test-installer-update-packages.sh b/tests/build/test-installer-update-packages.sh new file mode 100755 index 00000000..d6b35b80 --- /dev/null +++ b/tests/build/test-installer-update-packages.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Real signed APK transactions, including bounded read-only Installer preflight. +set -eu +src=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd -P) +RELIEFOS_TEST_OUTPUT=${RELIEFOS_TEST_OUTPUT:-${RELIEFOS_TEST_BUILD_ROOT:-$src/out/x86_64/release}} +export RELIEFOS_TEST_OUTPUT +exec "${RELIEFOS_TEST_PYTHON:-python3}" "$src/tools/test_installer_update_packages.py" -v diff --git a/tests/build/test-installer-update-supervisor.sh b/tests/build/test-installer-update-supervisor.sh new file mode 100755 index 00000000..44c1403a --- /dev/null +++ b/tests/build/test-installer-update-supervisor.sh @@ -0,0 +1,11 @@ +#!/bin/sh +set -eu +ulimit -c 0 +src=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd -P) +work=$(mktemp -d "${TMPDIR:-$src/out/tmp}/installer-update-supervisor.XXXXXX") +trap 'rm -rf "$work"' EXIT HUP INT TERM +${HOSTCC:-cc} -std=gnu11 -O1 -Wall -Wextra -Werror \ + -fsanitize=address,undefined -fno-sanitize-recover=all -g \ + "$src/tools/tests/installer_update_supervisor_test.c" \ + "$src/userland/apps/installer/installer_update_supervisor.c" -o "$work/test" +ASAN_OPTIONS=detect_leaks=1:handle_sigbus=0 UBSAN_OPTIONS=halt_on_error=1 "$work/test" diff --git a/tests/build/test-installer-update-target.sh b/tests/build/test-installer-update-target.sh new file mode 100755 index 00000000..e7e7e1d4 --- /dev/null +++ b/tests/build/test-installer-update-target.sh @@ -0,0 +1,12 @@ +#!/bin/sh +set -eu +ulimit -c 0 +src=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd -P) +work=$(mktemp -d "${TMPDIR:-$src/out/tmp}/installer-update-target.XXXXXX") +trap 'rm -rf "$work"' EXIT HUP INT TERM +${HOSTCC:-cc} -std=c11 -D_GNU_SOURCE -O1 -Wall -Wextra -Werror \ + -fsanitize=address,undefined -fno-sanitize-recover=all -g \ + -ffunction-sections -fdata-sections -Wl,--gc-sections \ + -I"$src/userland/runtime/include" \ + "$src/tools/tests/installer_update_target_test.c" -o "$work/test" +ASAN_OPTIONS=detect_leaks=1 UBSAN_OPTIONS=halt_on_error=1 "$work/test" diff --git a/tools/test_installer_input.py b/tools/test_installer_input.py index eb62a985..588b94e0 100644 --- a/tools/test_installer_input.py +++ b/tools/test_installer_input.py @@ -48,11 +48,25 @@ def test_worker_progress_does_not_block_copying(self): executable = str(Path(tmp) / "worker") subprocess.run([ "cc", "-std=gnu11", "-O1", "-g", "-Wall", "-Wextra", "-Werror", + "-DINSTALLER_JOB_FINISH_TIMEOUT_MS=100", "-fsanitize=address,undefined", "tools/tests/installer_job_test.c", "userland/apps/installer/installer_job.c", "-o", executable, ], cwd=ROOT, check=True) subprocess.run([executable], check=True, timeout=10) + def test_update_sessions_require_complete_metadata_and_terminal_result(self): + with tempfile.TemporaryDirectory(prefix="installer-update-session-") as tmp: + executable = str(Path(tmp) / "protocol") + subprocess.run([ + "cc", "-std=gnu11", "-O1", "-g", "-Wall", "-Wextra", "-Werror", + "-fsanitize=address,undefined", "-ffunction-sections", "-fdata-sections", + "-Wl,--gc-sections", "tools/tests/installer_update_protocol_test.c", + "userland/apps/installer/installer_update_protocol.c", + "userland/apps/installer/installer_update_model.c", + "userland/apps/installer/installer_update_progress.c", "-o", executable, + ], cwd=ROOT, check=True) + subprocess.run([executable], check=True, timeout=10) + def test_fresh_copy_metadata_and_failure_safety(self): """Exercise real copy metadata and publication on an owned host tree.""" with tempfile.TemporaryDirectory(prefix="installer-fresh-copy-") as tmp: diff --git a/tools/test_installer_update_packages.py b/tools/test_installer_update_packages.py index 5227bb29..59934c1b 100644 --- a/tools/test_installer_update_packages.py +++ b/tools/test_installer_update_packages.py @@ -35,6 +35,7 @@ def setUpClass(cls): "target/home/test", "target/usr/share/external", "target/bin", "target/usr/lib/reliefos", "target/var/lib/reliefos"): (cls.base / name).mkdir(parents=True, exist_ok=True) + (cls.base / "dev/null").touch() shutil.copy2(BUSYBOX, cls.base / "bin/busybox") for name in subprocess.check_output([BUSYBOX, "--list"], text=True).splitlines(): if name != "busybox": @@ -124,9 +125,16 @@ def target_snapshot(self): return {str(path.relative_to(target)): hashlib.sha256(path.read_bytes()).hexdigest() for path in target.rglob("*") if path.is_file() and not path.is_symlink()} - def transaction(self, mode="--check", expected=None, cache_readonly=False, readonly_tmp=False): - readonly = ('mount --bind "$1/target" "$1/target"; ' - 'mount -o remount,bind,ro "$1/target"; ') if mode == "--check" else "" + def transaction(self, mode="--check", expected=None, cache_readonly=False, readonly_tmp=False, + runtime_limit=None, owned_workspace=False): + # Give /target its own mount before making the live root read-only. + # Only apply may write it; /run is the sole writable live filesystem. + readonly = 'mount --bind "$1/target" "$1/target"; ' + if mode == "--check": + readonly += 'mount -o remount,bind,ro "$1/target"; ' + # The installation medium is immutable in every helper mode. + readonly += ('mount --bind "$1/newrepo" "$1/newrepo"; ' + 'mount -o remount,bind,ro "$1/newrepo"; ') if cache_readonly: readonly += ('mount --bind "$1/target/usr/share/reliefos/apk/repository" ' '"$1/target/usr/share/reliefos/apk/repository"; ' @@ -134,18 +142,33 @@ def transaction(self, mode="--check", expected=None, cache_readonly=False, reado if readonly_tmp: readonly += ('mount --bind "$1/tmp" "$1/tmp"; ' 'mount -o remount,bind,ro "$1/tmp"; ') + readonly += ('mount -t tmpfs -o size=' + str(runtime_limit or 16 * 1024**2) + + ' tmpfs "$1/run"; ') + if owned_workspace: + # Apply read-only to the parent mount itself before adding its + # writable child, without changing the tmpfs superblock flags. + readonly += ('mkdir -p "$1/run/owned-update"; ' + 'mount --bind "$1/run" "$1/run"; ' + 'mount -o remount,bind,ro "$1/run"; ' + 'mount -t tmpfs -o size=' + str(runtime_limit or 16 * 1024**2) + + ' tmpfs "$1/run/owned-update"; ') + readonly += 'mount -o remount,bind,ro "$1"; ' result = subprocess.run([ "unshare", "-Urmp", "--fork", "sh", "-eu", "-c", 'mount --make-rprivate /; mount --bind "$1" "$1"; ' # musl falls back to /proc/self/fd for fchmodat(AT_SYMLINK_NOFOLLOW) # on hosts without fchmodat2. Match the live guest's proc mount so # APK can restore setuid modes inside this private namespace. - 'mount -t proc proc "$1/proc"; ' + 'mount -t proc proc "$1/proc"; mount --bind /dev/null "$1/dev/null"; ' + 'mkdir -p "$1/.oldroot"; ' + readonly + - 'cd "$1"; mkdir -p .oldroot; pivot_root . .oldroot; ' - 'shift; exec /bin/sh /sbin/update "$@"', + 'cd "$1"; pivot_root . .oldroot; ' + 'shift; TMPDIR=' + ('/run/owned-update' if owned_workspace else '/run') + + ' exec /bin/sh /sbin/update "$@"', "sh", self.runner, mode, "/target", "/newrepo", *([expected] if expected else [])], text=True, capture_output=True, timeout=60) + self.assertFalse(list(self.runner.glob("*.apk")), + "preflight downloaded package archives into the live root") return result def check(self): @@ -166,6 +189,155 @@ def test_preflight_does_not_require_writable_runtime_tmp(self): self.assertEqual(self.target_snapshot(), before) self.assertFalse(list((self.runner / "run").glob("reliefos-update.*"))) + def test_preflight_uses_the_supervisors_owned_planner_workspace(self): + # /run itself is read-only; only the supplied TMPDIR is writable. + before = self.target_snapshot() + result = self.transaction(runtime_limit=1024**2, owned_workspace=True) + self.assertEqual(result.returncode, 0, result.stdout + result.stderr) + self.assertEqual(self.target_snapshot(), before) + + def large_media_package(self): + # High entropy keeps the signed archive larger than the complete /run + # allowance. A fetch-to-tmpfs implementation cannot pass these cases. + self.package("reliefos-fixture", "2.0-r0", self.runner / "newrepo", + payload={"usr/share/reliefos-fixture/data": os.urandom(2 * 1024**2).hex()}) + self.index(self.runner / "newrepo") + archive = self.runner / "newrepo/reliefos-fixture-2.0-r0.apk" + self.assertGreater(archive.stat().st_size, 1024**2) + return archive + + def test_preflight_streams_signed_archives_larger_than_runtime_tmpfs(self): + self.select_external_tag() + archive = self.large_media_package() + before = self.target_snapshot() + result = self.transaction(runtime_limit=1024**2) + self.assertEqual(result.returncode, 0, result.stdout + result.stderr) + self.assertEqual(self.target_snapshot(), before) + self.assertIn("reliefos-fixture", result.stdout) + self.assertGreater(archive.stat().st_size, 1024**2) + + def test_apply_streams_packages_and_caches_from_readonly_media(self): + archive = self.large_media_package() + result = self.transaction("--apply", runtime_limit=1024**2) + self.assertEqual(result.returncode, 0, result.stdout + result.stderr) + cached = self.runner / "target/usr/share/reliefos/apk/repository" / archive.name + self.assertEqual(cached.read_bytes(), archive.read_bytes()) + self.assertEqual((self.runner / "target/usr/share/reliefos-fixture/data").stat().st_size, + 4 * 1024**2) + + def test_nonregular_archive_objects_are_rejected_without_blocking(self): + archive = self.runner / "newrepo/reliefos-fixture-2.0-r0.apk" + original = archive.read_bytes() + before = self.target_snapshot() + for kind in ("fifo", "symlink", "directory"): + with self.subTest(kind=kind): + archive.unlink() + if kind == "fifo": + os.mkfifo(archive) + elif kind == "symlink": + archive.symlink_to("../oldrepo/reliefos-fixture-1.0-r0.apk") + else: + archive.mkdir() + result = self.transaction() + self.assertNotEqual(result.returncode, 0, result.stdout + result.stderr) + self.assertIn("unsafe package file", result.stdout + result.stderr) + self.assertEqual(self.target_snapshot(), before) + if kind == "directory": + archive.rmdir() + else: + archive.unlink() + archive.write_bytes(original) + + def test_oversized_archive_is_rejected_before_any_package_read(self): + archive = self.runner / "newrepo/reliefos-fixture-2.0-r0.apk" + with archive.open("wb") as stream: + stream.truncate(4 * 1024**3 + 1) + before = self.target_snapshot() + result = self.transaction() + self.assertNotEqual(result.returncode, 0, result.stdout + result.stderr) + self.assertIn("size limit", result.stdout + result.stderr) + self.assertEqual(self.target_snapshot(), before) + + def test_metadata_and_trust_key_fifos_are_rejected_without_blocking(self): + for relative in ("target/etc/apk/world", "target/lib/apk/db/installed", "target/etc/apk/arch", + "newrepo/packages.adb", "target/etc/apk/keys/test.rsa.pub"): + with self.subTest(path=relative): + path = self.runner / relative + original = path.read_bytes() + path.unlink() + os.mkfifo(path) + result = self.transaction() + self.assertNotEqual(result.returncode, 0, result.stdout + result.stderr) + self.assertIn("unsafe package file", result.stdout + result.stderr) + path.unlink() + path.write_bytes(original) + + def test_oversized_planning_metadata_is_rejected_before_copy(self): + for relative, limit in (("target/etc/apk/world", 1024**2), + ("target/lib/apk/db/installed", 64 * 1024**2), + ("newrepo/packages.adb", 16 * 1024**2)): + with self.subTest(path=relative): + path = self.runner / relative + original = path.read_bytes() + with path.open("wb") as stream: + stream.truncate(limit + 1) + result = self.transaction(runtime_limit=1024**2) + self.assertNotEqual(result.returncode, 0, result.stdout + result.stderr) + self.assertIn("size limit", result.stdout + result.stderr) + path.write_bytes(original) + + def test_signed_archive_not_matching_index_is_rejected_before_changes(self): + # A second valid signature does not make these bytes the archive + # selected by the signed index. + self.package("reliefos-fixture", "2.0-r0", self.runner / "oldrepo", + payload={"usr/share/reliefos-fixture/version": "different signed content"}) + shutil.copy2(self.runner / "oldrepo/reliefos-fixture-2.0-r0.apk", + self.runner / "newrepo/reliefos-fixture-2.0-r0.apk") + before = self.target_snapshot() + for mode in ("--check", "--apply"): + with self.subTest(mode=mode): + result = self.transaction(mode) + self.assertNotEqual(result.returncode, 0, result.stdout + result.stderr) + self.assertIn("ADB integrity error", result.stdout + result.stderr) + self.assertEqual(self.target_snapshot(), before) + + def test_unselected_and_older_archive_identities_are_checked_before_caching(self): + # Neither version belongs to the target's world. Both are nevertheless + # part of the complete offline repository that apply will publish. + for version in ("1.0-r0", "2.0-r0"): + self.package("unused-extra", version, self.runner / "newrepo") + self.index(self.runner / "newrepo") + self.package("unused-extra", "1.0-r0", self.runner / "oldrepo", + payload={"usr/share/unused-extra/version": "different signed content"}) + shutil.copy2(self.runner / "oldrepo/unused-extra-1.0-r0.apk", + self.runner / "newrepo/unused-extra-1.0-r0.apk") + before = self.target_snapshot() + for mode in ("--check", "--apply"): + with self.subTest(mode=mode): + result = self.transaction(mode) + self.assertNotEqual(result.returncode, 0, result.stdout + result.stderr) + self.assertIn("unused-extra-1.0-r0", result.stdout + result.stderr) + self.assertIn("ADB integrity error", result.stdout + result.stderr) + self.assertEqual(self.target_snapshot(), before) + + def test_unindexed_signed_archive_is_not_published_to_offline_cache(self): + self.package("unused-extra", "1.0-r0", self.runner / "newrepo") + result = self.transaction("--apply") + self.assertEqual(result.returncode, 0, result.stdout + result.stderr) + cache = self.runner / "target/usr/share/reliefos/apk/repository" + self.assertTrue((cache / "reliefos-fixture-2.0-r0.apk").is_file()) + self.assertFalse((cache / "unused-extra-1.0-r0.apk").exists()) + + def test_missing_unselected_media_archive_is_rejected_before_changes(self): + self.package("unused-extra", "1.0-r0", self.runner / "newrepo") + self.index(self.runner / "newrepo") + (self.runner / "newrepo/unused-extra-1.0-r0.apk").unlink() + before = self.target_snapshot() + result = self.transaction("--apply") + self.assertNotEqual(result.returncode, 0, result.stdout + result.stderr) + self.assertIn("unused-extra-1.0-r0", result.stdout + result.stderr) + self.assertEqual(self.target_snapshot(), before) + def test_unsigned_index_is_rejected_before_target_changes(self): self.index(self.runner / "newrepo", signed=False) result = self.check() @@ -631,8 +803,8 @@ def test_retry_after_committed_apk_failure_preserves_tagged_world(self): if [ "${1:-}" = --root ] && [ "${2:-}" = /target ]; then case " $* " in *' upgrade '*) - if [ ! -e /tmp/failed-after-commit ]; then - touch /tmp/failed-after-commit + if [ ! -e /target/var/lib/reliefos/failed-after-commit ]; then + touch /target/var/lib/reliefos/failed-after-commit echo 'ERROR: injected failure after APK committed' >&2 exit 42 fi ;; diff --git a/tools/tests/installer_job_test.c b/tools/tests/installer_job_test.c index 5796bdfc..632ecde5 100644 --- a/tools/tests/installer_job_test.c +++ b/tools/tests/installer_job_test.c @@ -6,6 +6,8 @@ #include #include #include +#include +#include #include static int busy_worker(void *context, struct installer_job_packet *final) @@ -31,6 +33,41 @@ static int failed_worker(void *context, struct installer_job_packet *final) _exit(7); } +static volatile sig_atomic_t stop_requested; +static void request_stop(int signal_number) { (void)signal_number; stop_requested = 1; } + +static int cancelable_worker(void *context, struct installer_job_packet *final) +{ + int ready = *(int *)context; + struct sigaction action = {.sa_handler = request_stop}; + sigemptyset(&action.sa_mask); + assert(!sigaction(SIGTERM, &action, NULL)); + assert(write(ready, "x", 1) == 1); + close(ready); + while (!stop_requested) usleep(1000); + strcpy(final->message, "cleanup complete"); + return -ECANCELED; +} + +static uint64_t now_ms(void) +{ + struct timespec now; + assert(!clock_gettime(CLOCK_MONOTONIC, &now)); + return (uint64_t)now.tv_sec * 1000u + (uint64_t)now.tv_nsec / 1000000u; +} + +static int finish(struct installer_job *job) +{ + int result; + uint64_t started = now_ms(); + do { + result = installer_job_step(job); + if (result > 0) usleep(1000); + assert(now_ms() - started < 3000); + } while (result > 0); + return result; +} + int main(void) { int notify[2]; @@ -56,5 +93,32 @@ int main(void) if (result > 0) usleep(1000); } while (result > 0); assert(result < 0 && !state.complete); - puts("PASS nonblocking progress, final result delivery, and abnormal worker exit"); + + assert(!pipe(notify)); + assert(!installer_job_start(&state, cancelable_worker, ¬ify[1], NULL)); + close(notify[1]); + ready = (struct pollfd){.fd = notify[0], .events = POLLIN}; + assert(poll(&ready, 1, 2000) == 1); + close(notify[0]); + assert(!installer_job_request_stop(&state)); + assert(!finish(&state)); + assert(state.final.result == -ECANCELED && !strcmp(state.final.message, "cleanup complete")); + + /* Final result delivery must terminate if a live UI stops consuming. */ + assert(!pipe(notify)); + assert(!installer_job_start(&state, busy_worker, ¬ify[1], NULL)); + close(notify[1]); + ready = (struct pollfd){.fd = notify[0], .events = POLLIN}; + assert(poll(&ready, 1, 2000) == 1); + close(notify[0]); + uint64_t started = now_ms(); + siginfo_t observed; + do { + memset(&observed, 0, sizeof(observed)); + assert(!waitid(P_PID, (id_t)state.pid, &observed, WEXITED | WNOHANG | WNOWAIT)); + if (!observed.si_pid) usleep(1000); + assert(now_ms() - started < 3000); + } while (!observed.si_pid); + assert(finish(&state) < 0); + puts("PASS nonblocking progress, bounded final delivery, cancellation cleanup and abnormal worker exit"); } diff --git a/tools/tests/installer_update_engine_test.c b/tools/tests/installer_update_engine_test.c new file mode 100644 index 00000000..4978c131 --- /dev/null +++ b/tools/tests/installer_update_engine_test.c @@ -0,0 +1,489 @@ +/* Run the real coordinator, stage supervisor, shared-memory publication and + * command pipes against deterministic offline storage adapters. No host disk, + * mount operation, installed APK executable or root privilege is needed. */ +#define _GNU_SOURCE 1 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static char fixture_target[PATH_MAX], fixture_media[PATH_MAX], fixture_log[PATH_MAX]; +static int fixture_spawn(pid_t *, const char *, const posix_spawn_file_actions_t *, + const posix_spawnattr_t *, char *const [], char *const []); +static int fixture_syncfs(int); +static int fixture_statvfs(const char *, struct statvfs *); +static int fixture_fstat(int, struct stat *); +static uid_t fixture_geteuid(void); + +#define UPDATE_MEDIA_CONSOLE fixture_media +#define UPDATE_MEDIA_XFCE fixture_media +#define UPDATE_MEDIA_XORG fixture_media +#define UPDATE_ESP fixture_media +#define UPDATE_LOG fixture_log +#define UPDATE_HELPER "/fixture/reliefos-apk-update" +#define posix_spawn fixture_spawn +#define syncfs fixture_syncfs +#define statvfs(...) fixture_statvfs(__VA_ARGS__) +#define fstat fixture_fstat +#define geteuid fixture_geteuid +#include "../../userland/apps/installer/installer_update_engine.c" +#undef posix_spawn +#undef syncfs +#undef statvfs +#undef fstat +#undef geteuid + +enum fixture_call { + CALL_LOCK, CALL_OPEN, CALL_LEGACY, CALL_PACKAGES_READ, CALL_MEDIA_READ, + CALL_COMPARE, CALL_HASH, CALL_JOURNAL_READ, CALL_PAYLOAD, CALL_LAYOUT, + CALL_PLAN, CALL_WRITABLE, CALL_RESTORE, CALL_JOURNAL_WRITE, CALL_APPLY, + CALL_SYNC, CALL_BOOT, CALL_CLEANUP, CALL_UNLOCK, +}; +struct fixture_event { enum fixture_call call; char phase[32]; }; +struct fixture_state { + struct fixture_event events[256]; + unsigned event_count, successes, sync_calls; + int packages_committed, packages_error, boot_error, cleanup_error; + int sync_fail_at, fault_payload, no_free_space; + uint64_t growth, largest; + struct installer_update_checkpoint journal; +}; +static struct fixture_state *fixture; +static const char root_uuid[] = "11111111-2222-3333-4444-555555555555"; +static const char esp_uuid[] = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"; + +static void record_phase(enum fixture_call call, const char *phase) +{ + unsigned index = fixture->event_count++; + assert(index < sizeof(fixture->events) / sizeof(fixture->events[0])); + fixture->events[index].call = call; + snprintf(fixture->events[index].phase, sizeof(fixture->events[index].phase), "%s", phase ? phase : ""); +} + +static void record(enum fixture_call call) { record_phase(call, NULL); } + +static unsigned count(enum fixture_call call) +{ + unsigned result = 0; + for (unsigned i = 0; i < fixture->event_count; ++i) result += fixture->events[i].call == call; + return result; +} + +static unsigned position(enum fixture_call call, const char *phase) +{ + for (unsigned i = 0; i < fixture->event_count; ++i) + if (fixture->events[i].call == call && (!phase || !strcmp(phase, fixture->events[i].phase))) return i; + assert(!"required transaction operation was skipped"); + return 0; +} + +static void digest(char output[65], char value) { memset(output, value, 64); output[64] = 0; } + +static uid_t fixture_geteuid(void) { return 0; } + +static int fixture_fstat(int fd, struct stat *status) +{ + int result = fstat(fd, status); + if (!result) status->st_uid = 0; + return result; +} + +static int fixture_statvfs(const char *path, struct statvfs *space) +{ + assert(!strcmp(path, fixture_target)); + memset(space, 0, sizeof(*space)); + space->f_frsize = 4096; + space->f_bavail = fixture->no_free_space ? 0 : 1024 * 1024; + return 0; +} + +static int fixture_syncfs(int fd) +{ + assert(fcntl(fd, F_GETFD) >= 0); + record(CALL_SYNC); + if (++fixture->sync_calls == (unsigned)fixture->sync_fail_at) { errno = EIO; return -1; } + return 0; +} + +/* Preserve the actual spawn file actions, pipe lifetime, wait status and + * inherited process group. Only the external programs' behavior is replaced. */ +static int fixture_spawn(pid_t *pid, const char *path, const posix_spawn_file_actions_t *actions, + const posix_spawnattr_t *attributes, char *const arguments[], char *const environment[]) +{ + char script[256] = "exit 0"; + if (!strcmp(path, "/sbin/apk")) { + assert(!strcmp(arguments[1], "version") && !strcmp(arguments[2], "-t")); + record(CALL_COMPARE); + strcpy(script, "printf '<\\n'"); + } else if (!strcmp(path, "/bin/busybox")) { + assert(!strcmp(arguments[1], "sha256sum")); + record(CALL_HASH); + char hash[65]; + char value = strstr(arguments[2], "/packages.adb") ? 'a' : + strstr(arguments[2], "/lib/apk/db/installed") ? (fixture->packages_committed ? 'd' : 'b') : + strstr(arguments[2], "/etc/apk/world") ? (fixture->packages_committed ? 'e' : 'c') : 0; + assert(value); + digest(hash, value); + snprintf(script, sizeof(script), "printf '%s fixture\\n'", hash); + } else if (!strcmp(path, "/bin/sh")) { + assert(!strcmp(arguments[1], UPDATE_HELPER)); + if (!strcmp(arguments[2], "--check")) record(CALL_PLAN); + else { + assert(!strcmp(arguments[2], "--apply")); + record(CALL_APPLY); + assert(!strcmp(fixture->journal.phase, "packages")); + if (fixture->packages_error) strcpy(script, "exit 23"); + else fixture->packages_committed = 1; + } + } else { + assert(!strcmp(path, "/usr/libexec/reliefos/kernel-bundle") && !strcmp(arguments[1], "--restore-all")); + record(CALL_RESTORE); + } + char *const shell[] = {"sh", "-c", script, NULL}; + return posix_spawn(pid, "/bin/sh", actions, attributes, shell, environment); +} + +int installer_update_target_lock(struct installer_update_target *target) +{ + record(CALL_LOCK); + memset(target, 0, sizeof(*target)); + target->lock_fd = open("/dev/null", O_RDONLY | O_CLOEXEC); + assert(target->lock_fd >= 0); + return 0; +} + +int installer_update_target_open(struct installer_update_target *target, const char *disk, + const char *expected_root, const char *expected_esp) +{ + record(CALL_OPEN); + assert(!strcmp(disk, "/dev/fixture")); + assert(!expected_root || !*expected_root || !strcmp(expected_root, root_uuid)); + assert(!expected_esp || !*expected_esp || !strcmp(expected_esp, esp_uuid)); + assert(strlen(fixture_target) < sizeof(target->root)); + strcpy(target->root, fixture_target); + strcpy(target->boot, fixture_target); + strcpy(target->esp, fixture_target); + strcpy(target->info.disk, disk); + strcpy(target->info.root_uuid, root_uuid); + strcpy(target->info.esp_uuid, esp_uuid); + strcpy(target->info.profile, "console"); + strcpy(target->info.installed_version, "1.0"); + target->info.boot_modes = RELIEFOS_BOOT_BIOS | RELIEFOS_BOOT_UEFI; + return 0; +} + +int installer_update_target_writable(struct installer_update_target *target) +{ + (void)target; + record(CALL_WRITABLE); + return 0; +} + +int installer_update_target_unmount(struct installer_update_target *target) +{ + (void)target; + record(CALL_CLEANUP); + return fixture->cleanup_error; +} + +int installer_update_target_unlock(struct installer_update_target *target) +{ + record(CALL_UNLOCK); + assert(target->lock_fd >= 0 && !close(target->lock_fd)); + target->lock_fd = -1; + return 0; +} + +int reliefos_block_partition_uuid(const char *disk, uint32_t index, char uuid[37]) +{ + assert(!strcmp(disk, "/dev/fixture") && index < 2); + strcpy(uuid, index ? esp_uuid : root_uuid); + return 0; +} + +int reliefos_account_legacy_check(const char *target) +{ + assert(!strcmp(target, fixture_target)); + record(CALL_LEGACY); + return 0; +} + +int installer_update_read_media(const char *root, const char *profile, struct installer_update_info *info) +{ + assert(!strcmp(root, fixture_media) && !strcmp(profile, "console")); + record(CALL_MEDIA_READ); + memset(info, 0, sizeof(*info)); + strcpy(info->installed_version, "2.0"); + return 0; +} + +int installer_update_read_packages(const char *root, struct installer_update_packages *packages) +{ + assert(!strcmp(root, fixture_target) || !strcmp(root, fixture_media)); + record(CALL_PACKAGES_READ); + memset(packages, 0, sizeof(*packages)); + strcpy(packages->kernel_version, !strcmp(root, fixture_media) || fixture->packages_committed ? "2.0" : "1.0"); + packages->installed_bytes = !strcmp(root, fixture_media) ? 2048 : 1024; + packages->largest_package = 512; + return 0; +} + +int installer_update_measure_growth(const char *installed_root, const char *media_root, + uint64_t *growth, uint64_t *largest) +{ + assert(!strcmp(installed_root, fixture_target) && !strcmp(media_root, fixture_media)); + *growth = fixture->growth; + *largest = fixture->largest; + return 0; +} + +int installer_update_read_checkpoint(const char *root, struct installer_update_checkpoint *checkpoint) +{ + assert(!strcmp(root, fixture_target)); + record(CALL_JOURNAL_READ); + *checkpoint = fixture->journal; + return 0; +} + +int installer_update_write_checkpoint(const char *root, const struct installer_update_checkpoint *checkpoint) +{ + assert(!strcmp(root, fixture_target)); + record_phase(CALL_JOURNAL_WRITE, checkpoint->phase); + fixture->journal = *checkpoint; + return 0; +} + +int reliefos_boot_validate_payload(const struct reliefos_boot_install_options *options) +{ + assert(options->source == fixture_media); + record(CALL_PAYLOAD); + if (fixture->fault_payload) { signal(SIGBUS, SIG_DFL); raise(SIGBUS); _exit(125); } + return 0; +} + +int reliefos_boot_validate_target(const struct reliefos_boot_install_options *options) +{ + assert(!strcmp(options->boot_dir, fixture_target)); + record(CALL_LAYOUT); + return 0; +} + +int reliefos_boot_validate_instance(const struct reliefos_boot_install_options *options, const char *esp) +{ + (void)options; (void)esp; + assert(!"fixture uses a conventional ESP layout"); + return -EINVAL; +} + +int reliefos_boot_install_at_root(const struct reliefos_boot_install_options *options, const char *root) +{ + assert(!strcmp(root, fixture_target) && !strcmp(options->root_partuuid, root_uuid)); + assert(!strcmp(fixture->journal.phase, "boot")); + record(CALL_BOOT); + return fixture->boot_error; +} + +int reliefos_boot_install_instance_at_root(const struct reliefos_boot_install_options *options, + const char *root, const char *esp) +{ + (void)options; (void)root; (void)esp; + assert(!"fixture uses a conventional ESP layout"); + return -EINVAL; +} + +static void observe(void *context, unsigned progress, const char *message) +{ + (void)context; + assert(message && *message && progress <= 100); + if (progress == 100) ++fixture->successes; +} + +static void clear_observations(void) +{ + fixture->event_count = fixture->successes = fixture->sync_calls = 0; + memset(fixture->events, 0, sizeof(fixture->events)); +} + +static void fresh(void) +{ + memset(fixture, 0, sizeof(*fixture)); + fixture->growth = 1024; + fixture->largest = 512; +} + +static struct installer_update_info checked(void) +{ + struct installer_update_info info; + assert(!installer_update_check("/dev/fixture", &info, observe, NULL)); + assert(!count(CALL_WRITABLE) && !count(CALL_JOURNAL_WRITE) && !count(CALL_APPLY) && !count(CALL_BOOT) && !count(CALL_SYNC)); + assert(count(CALL_CLEANUP) == 1 && count(CALL_UNLOCK) == 1 && fixture->successes == 1); + return info; +} + +static void assert_closed(void) +{ + assert(count(CALL_CLEANUP) == 1 && count(CALL_UNLOCK) == 1); + assert(position(CALL_CLEANUP, NULL) < position(CALL_UNLOCK, NULL)); +} + +static void test_success(void) +{ + fresh(); + struct installer_update_info expected = checked(), result; + assert(count(CALL_PLAN) == 1); + clear_observations(); + assert(!installer_update_apply(&expected, 3, &result, observe, NULL)); + assert(!count(CALL_PLAN) && count(CALL_APPLY) == 1 && count(CALL_BOOT) == 1 && count(CALL_SYNC) == 2); + assert(fixture->successes == 1 && !result.pending[0] && !strcmp(fixture->journal.phase, "done")); + assert(position(CALL_WRITABLE, NULL) < position(CALL_JOURNAL_WRITE, "packages")); + assert(position(CALL_JOURNAL_WRITE, "packages") < position(CALL_APPLY, NULL)); + assert(position(CALL_APPLY, NULL) < position(CALL_SYNC, NULL)); + assert(position(CALL_SYNC, NULL) < position(CALL_JOURNAL_WRITE, "root-ready")); + assert(position(CALL_JOURNAL_WRITE, "root-ready") < position(CALL_JOURNAL_WRITE, "boot")); + assert(position(CALL_JOURNAL_WRITE, "boot") < position(CALL_BOOT, NULL)); + assert(position(CALL_BOOT, NULL) < position(CALL_JOURNAL_WRITE, "done")); + assert(position(CALL_JOURNAL_WRITE, "done") < position(CALL_CLEANUP, NULL)); + assert_closed(); +} + +static void test_stale(void) +{ + fresh(); + struct installer_update_info expected = checked(), result; + clear_observations(); + expected.database_sha256[0] = 'f'; + assert(installer_update_apply(&expected, 3, &result, observe, NULL) == -ESTALE); + assert(!count(CALL_WRITABLE) && !count(CALL_APPLY) && !count(CALL_BOOT) && !count(CALL_JOURNAL_WRITE)); + assert(!fixture->successes && result.error_number == ESTALE); + assert_closed(); +} + +static void test_insufficient_space(void) +{ + fresh(); + struct installer_update_info expected = checked(), result; + clear_observations(); fixture->no_free_space = 1; + assert(installer_update_apply(&expected, 3, &result, observe, NULL) == -ENOSPC); + assert(!count(CALL_WRITABLE) && !count(CALL_APPLY) && !count(CALL_BOOT) && !count(CALL_JOURNAL_WRITE)); + assert(!fixture->successes && result.error_number == ENOSPC); + assert_closed(); + clear_observations(); + assert(installer_update_check("/dev/fixture", &result, observe, NULL) == -ENOSPC); + assert(!count(CALL_PLAN) && !count(CALL_PAYLOAD) && !count(CALL_WRITABLE)); + assert(!fixture->successes); + assert_closed(); +} + +static void test_sync_failure(void) +{ + fresh(); + struct installer_update_info expected = checked(), result; + clear_observations(); fixture->sync_fail_at = 1; + assert(installer_update_apply(&expected, 3, &result, observe, NULL) == -EIO); + assert(count(CALL_APPLY) == 1 && count(CALL_SYNC) == 1 && !count(CALL_BOOT)); + assert(!strcmp(fixture->journal.phase, "packages") && !fixture->successes); + assert_closed(); +} + +static void test_package_failure(void) +{ + fresh(); + struct installer_update_info expected = checked(), result; + clear_observations(); fixture->packages_error = 1; + assert(installer_update_apply(&expected, 3, &result, observe, NULL) == -EPROTO); + assert(count(CALL_APPLY) == 1 && !count(CALL_BOOT) && !count(CALL_SYNC)); + assert(!strcmp(fixture->journal.phase, "packages-failed") && !fixture->successes); + assert_closed(); +} + +static void test_boot_failure_and_resume(void) +{ + fresh(); + struct installer_update_info expected = checked(), result; + clear_observations(); fixture->boot_error = -EIO; + assert(installer_update_apply(&expected, 3, &result, observe, NULL) == -EIO); + assert(count(CALL_APPLY) == 1 && count(CALL_BOOT) == 1 && fixture->packages_committed); + assert(!strcmp(fixture->journal.phase, "boot-failed") && !fixture->successes); + assert_closed(); + clear_observations(); fixture->boot_error = 0; + expected = checked(); + assert(!strcmp(expected.pending, "boot-failed") && !count(CALL_PLAN)); + clear_observations(); + assert(!installer_update_apply(&expected, 3, &result, observe, NULL)); + assert(!count(CALL_APPLY) && !count(CALL_PLAN) && count(CALL_BOOT) == 1 && count(CALL_RESTORE) == 1); + assert(!strcmp(fixture->journal.phase, "done") && fixture->successes == 1); + assert_closed(); +} + +static void test_root_ready_resume(void) +{ + fresh(); + fixture->packages_committed = 1; + strcpy(fixture->journal.phase, "root-ready"); + strcpy(fixture->journal.root_uuid, root_uuid); + digest(fixture->journal.index_sha256, 'a'); + digest(fixture->journal.database_sha256, 'd'); + digest(fixture->journal.world_sha256, 'e'); + fixture->no_free_space = 1; + struct installer_update_info expected = checked(), result; + assert(!strcmp(expected.pending, "root-ready") && !count(CALL_PLAN)); + assert(expected.free_bytes < expected.required_bytes); + clear_observations(); + assert(!installer_update_apply(&expected, 3, &result, observe, NULL)); + assert(!count(CALL_APPLY) && !count(CALL_PLAN) && count(CALL_BOOT) == 1 && count(CALL_RESTORE) == 1); + assert(!strcmp(fixture->journal.phase, "done")); + assert_closed(); +} + +static void test_cleanup_failure(void) +{ + fresh(); + struct installer_update_info expected = checked(), result; + clear_observations(); fixture->cleanup_error = -EBUSY; + assert(installer_update_apply(&expected, 3, &result, observe, NULL) == -EBUSY); + assert(count(CALL_BOOT) == 1 && !strcmp(fixture->journal.phase, "done")); + assert(!fixture->successes && result.error_number == EBUSY); + assert_closed(); +} + +static void test_stage_fault(void) +{ + fresh(); fixture->fault_payload = 1; + struct installer_update_info result; + assert(installer_update_check("/dev/fixture", &result, observe, NULL) == -EIO); + assert(count(CALL_PAYLOAD) == 1 && !count(CALL_LAYOUT) && !count(CALL_PLAN)); + assert(!count(CALL_WRITABLE) && !count(CALL_JOURNAL_WRITE) && !fixture->successes); + assert(result.error_number == EIO); + assert_closed(); +} + +int main(int argc, char **argv) +{ + assert(argc == 2 && strlen(argv[1]) < 180); + snprintf(fixture_target, sizeof(fixture_target), "%s/target", argv[1]); + snprintf(fixture_media, sizeof(fixture_media), "%s/media", argv[1]); + snprintf(fixture_log, sizeof(fixture_log), "%s/update.log", argv[1]); + fixture = mmap(NULL, sizeof(*fixture), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0); + assert(fixture != MAP_FAILED); + test_success(); + test_stale(); + test_insufficient_space(); + test_sync_failure(); + test_package_failure(); + test_boot_failure_and_resume(); + test_root_ready_resume(); + test_cleanup_failure(); + test_stage_fault(); + assert(!munmap(fixture, sizeof(*fixture))); + puts("PASS real update engine ordering, stale snapshots, durable retry phases, failures and SIGBUS cleanup"); + return 0; +} diff --git a/tools/tests/installer_update_model_test.c b/tools/tests/installer_update_model_test.c index ab78d7a8..5a648b53 100644 --- a/tools/tests/installer_update_model_test.c +++ b/tools/tests/installer_update_model_test.c @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -19,9 +20,100 @@ static void write_file(const char *root, const char *relative, const char *text) assert(!fclose(stream)); } +static void test_package_growth(const char *root) +{ + char media[PATH_MAX], path[PATH_MAX]; + assert(snprintf(media, sizeof(media), "%s/growth-media", root) < (int)sizeof(media)); + assert(!mkdir(media, 0755)); + const char *const directories[] = {"lib", "lib/apk", "lib/apk/db"}; + for (unsigned i = 0; i < sizeof(directories) / sizeof(directories[0]); ++i) { + assert(snprintf(path, sizeof(path), "%s/%s", media, directories[i]) < (int)sizeof(path)); + assert(!mkdir(path, 0755)); + } + /* Unchanged and shrinking packages, removed legacy wrappers and retained + * user packages cannot cancel the space needed by a new upstream library. + * Input order differs deliberately so matching requires package names. */ + write_file(root, "lib/apk/db/installed", + "P:external-retained\nV:1\nI:4000000000\n\n" + "P:reliefos-sqlite\nV:1\nI:1000000\n\n" + "P:same-version\nV:2-r0\nI:500\n\n" + "P:shrinking\nV:1\nI:50000000\n\n" + "P:growing\nV:1\nI:100\n\n"); + write_file(media, "lib/apk/db/installed", + "P:llvm22-libs\nV:22-r0\nI:190973792\n\n" + "P:shrinking\nV:2\nI:10\n\n" + "P:same-version\nV:2-r0\nI:500\n\n" + "P:sqlite-libs\nV:3\nI:1640464\n\n" + "P:growing\nV:2\nI:150\n"); + uint64_t growth = 0, largest = 0; + assert(!installer_update_measure_growth(root, media, &growth, &largest)); + assert(growth == UINT64_C(190973792) + UINT64_C(1640464) + 50); + assert(largest == UINT64_C(190973792)); + /* Already committed packages remain affordable on a repair/retry rather + * than charging the entire installed system's bytes once again. */ + assert(!installer_update_measure_growth(media, media, &growth, &largest)); + assert(!growth && largest == UINT64_C(190973792)); + + write_file(root, "lib/apk/db/installed", ""); + const char *const invalid[] = { + "P:missing-size\nV:1\n\n", + "P:duplicate-size\nV:1\nI:1\nI:2\n\n", + "P:../invalid-name\nV:1\nI:1\n\n", + "P:negative-size\nV:1\nI:-1\n\n", + "P:overflow-size\nV:1\nI:18446744073709551616\n\n", + "P:duplicate-name\nV:1\nI:1\n\nP:duplicate-name\nV:2\nI:2\n\n", + }; + for (unsigned i = 0; i < sizeof(invalid) / sizeof(invalid[0]); ++i) { + write_file(media, "lib/apk/db/installed", invalid[i]); + growth = largest = 42; + assert(installer_update_measure_growth(root, media, &growth, &largest) == -EINVAL); + assert(!growth && !largest); + } + /* Duplicate names on the installed side are equally ambiguous. */ + write_file(root, "lib/apk/db/installed", invalid[5]); + write_file(media, "lib/apk/db/installed", "P:new\nV:1\nI:1\n\n"); + assert(installer_update_measure_growth(root, media, &growth, &largest) == -EINVAL); + assert(!growth && !largest); + write_file(root, "lib/apk/db/installed", ""); + write_file(media, "lib/apk/db/installed", + "P:first\nV:1\nI:18446744073709551615\n\nP:second\nV:1\nI:1\n\n"); + assert(installer_update_measure_growth(root, media, &growth, &largest) == -EOVERFLOW); + assert(!growth && !largest); + + assert(snprintf(path, sizeof(path), "%s/lib/apk/db/installed", media) < (int)sizeof(path)); + assert(!unlink(path)); + assert(!mkfifo(path, 0600)); + assert(installer_update_measure_growth(root, media, &growth, &largest) == -EINVAL); + assert(!growth && !largest); + assert(!unlink(path)); + assert(!symlink("/etc/passwd", path)); + assert(installer_update_measure_growth(root, media, &growth, &largest) == -ELOOP); + assert(!growth && !largest); + assert(!unlink(path)); + FILE *stream = fopen(path, "w"); + assert(stream); + assert(fwrite("P:hidden\0name\nV:1\nI:1\n", 1, 22, stream) == 22); + assert(!fclose(stream)); + assert(installer_update_measure_growth(root, media, &growth, &largest) == -EINVAL); + assert(!growth && !largest); + + stream = fopen(path, "w"); + assert(stream); + for (unsigned i = 0; i < 8192; ++i) assert(fprintf(stream, "P:package-%u\nV:1\nI:1\n\n", i) > 0); + assert(!fclose(stream)); + assert(!installer_update_measure_growth(root, media, &growth, &largest)); + assert(growth == 8192 && largest == 1); + stream = fopen(path, "a"); + assert(stream && fputs("P:one-too-many\nV:1\nI:1\n\n", stream) >= 0 && !fclose(stream)); + assert(installer_update_measure_growth(root, media, &growth, &largest) == -EOVERFLOW); + assert(!growth && !largest); +} + int main(int argc, char **argv) { assert(argc == 2); + /* A FIFO regression must fail promptly rather than hanging the test job. */ + alarm(10); const char *root = argv[1]; const char *const directories[] = { "etc", "etc/apk", "etc/reliefos", "lib", "lib/apk", "lib/apk/db", @@ -52,6 +144,19 @@ int main(int argc, char **argv) assert(!unlink(path)); assert(!symlink("/etc/os-release", path)); assert(installer_update_read_system(root, &info) == -EINVAL); + assert(!unlink(path)); + assert(!mkfifo(path, 0600)); + assert(installer_update_read_system(root, &info) == -EINVAL); + assert(!unlink(path)); + write_file(root, "etc/os-release", "ID=reliefos\nVERSION_ID=5.3.1\nID=leonos\n"); + assert(installer_update_read_system(root, &info) == -EINVAL); + write_file(root, "etc/os-release", "ID=reliefos\nVERSION_ID=5.3.1\n"); + snprintf(path, sizeof(path), "%s/etc/reliefos/desktop-backend", root); + assert(!unlink(path)); + assert(!mkfifo(path, 0600)); + assert(installer_update_read_system(root, &info) == -EINVAL); + assert(!unlink(path)); + write_file(root, "etc/reliefos/desktop-backend", "console\n"); write_file(root, "lib/apk/db/installed", "P:external-fixture\nV:1.0-r0\nI:999999\n\n" @@ -64,6 +169,17 @@ int main(int argc, char **argv) assert(!packages.has_xfce_session); write_file(root, "lib/apk/db/installed", "P:xfce4-session\nV:4.20.2-r0\nI:44032\n"); assert(!installer_update_read_packages(root, &packages) && packages.has_xfce_session); + snprintf(path, sizeof(path), "%s/lib/apk/db/installed", root); + assert(!unlink(path)); + assert(!mkfifo(path, 0600)); + assert(installer_update_read_packages(root, &packages) == -EINVAL); + assert(!unlink(path)); + int oversized = open(path, O_WRONLY | O_CREAT | O_EXCL, 0600); + assert(oversized >= 0 && !ftruncate(oversized, 64u * 1024u * 1024u + 1u)); + assert(!close(oversized)); + assert(installer_update_read_packages(root, &packages) == -EOVERFLOW); + assert(!unlink(path)); + write_file(root, "lib/apk/db/installed", "P:reliefos-kernel\nV:5.3.1-r2\nI:200\n\n"); unsigned progress = 0; char message[128] = ""; @@ -135,6 +251,52 @@ int main(int argc, char **argv) assert(!installer_update_write_checkpoint(root, &state)); assert(!installer_update_read_checkpoint(root, &restored)); assert(!strcmp(restored.phase, "boot")); - puts("PASS installer update metadata, protocol and durable retry state"); + strcpy(state.phase, "unknown"); + assert(installer_update_write_checkpoint(root, &state) == -EINVAL); + assert(!installer_update_read_checkpoint(root, &restored)); + assert(!strcmp(restored.phase, "boot")); + strcpy(state.phase, "boot"); + state.index_sha256[0] = 'z'; + assert(installer_update_write_checkpoint(root, &state) == -EINVAL); + state.index_sha256[0] = 'a'; + strcpy(state.root_uuid, "00000000-0000-0000-0000-000000000000"); + assert(installer_update_write_checkpoint(root, &state) == -EINVAL); + strcpy(state.root_uuid, "8ab5d176-6479-4ec8-b382-531fca6ea662"); + snprintf(path, sizeof(path), "%s/var/lib/reliefos/installer-update/state", root); + assert(!unlink(path)); + assert(!mkfifo(path, 0600)); + assert(installer_update_read_checkpoint(root, &restored) == -EINVAL); + assert(!restored.phase[0]); + assert(!unlink(path)); + assert(!symlink("/etc/passwd", path)); + assert(installer_update_read_checkpoint(root, &restored) == -ELOOP); + assert(!unlink(path)); + oversized = open(path, O_WRONLY | O_CREAT | O_EXCL, 0600); + assert(oversized >= 0 && !ftruncate(oversized, 1025)); + assert(!close(oversized)); + assert(installer_update_read_checkpoint(root, &restored) == -EOVERFLOW); + assert(!unlink(path)); + char invalid[1024]; + snprintf(invalid, sizeof(invalid), + "format=1\nphase=unknown\nroot_uuid=%s\nindex_sha256=%s\ndatabase_sha256=%s\nworld_sha256=%s\n", + state.root_uuid, state.index_sha256, state.database_sha256, state.world_sha256); + write_file(root, "var/lib/reliefos/installer-update/state", invalid); + assert(installer_update_read_checkpoint(root, &restored) == -EINVAL); + assert(!restored.phase[0]); + assert(!installer_update_write_checkpoint(root, &state)); + FILE *duplicate = fopen(path, "a"); + assert(duplicate && fputs("phase=done\n", duplicate) >= 0 && !fclose(duplicate)); + assert(installer_update_read_checkpoint(root, &restored) == -EINVAL); + assert(!restored.phase[0]); + assert(!installer_update_write_checkpoint(root, &state)); + assert(!installer_update_read_checkpoint(root, &restored)); + assert(!strcmp(state.phase, restored.phase)); + assert(!strcmp(state.root_uuid, restored.root_uuid)); + assert(!strcmp(state.index_sha256, restored.index_sha256)); + assert(!strcmp(state.database_sha256, restored.database_sha256)); + assert(!strcmp(state.world_sha256, restored.world_sha256)); + test_package_growth(root); + alarm(0); + puts("PASS installer update metadata, conservative per-package space, protocol and durable retry state"); return 0; } diff --git a/tools/tests/installer_update_protocol_test.c b/tools/tests/installer_update_protocol_test.c new file mode 100644 index 00000000..f834d54f --- /dev/null +++ b/tools/tests/installer_update_protocol_test.c @@ -0,0 +1,86 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +#include "../../userland/apps/installer/installer_update.h" +#include +#include +#include +#include + +static struct installer_update_session session; +static struct installer_update_info info; +static unsigned progress; +static char message[256]; + +static int line(const char *text) +{ + return installer_update_session_line(&session, &info, &progress, message, sizeof(message), text); +} + +static void reset(void) +{ + memset(&session, 0, sizeof(session)); + memset(&info, 0, sizeof(info)); + progress = 0; + message[0] = 0; +} + +static void snapshot(void) +{ + static const char *const records[] = { + "info\tdisk\t/dev/sda", "info\troot_device\t/dev/sda3", "info\tesp_device\t/dev/sda2", + "info\troot_uuid\t11111111-2222-3333-4444-555555555555", + "info\tesp_uuid\taaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "info\tboot_file\t", + "info\tinstalled_version\t5.3.3", "info\tmedia_version\t5.3.4", "info\tprofile\txorg", + "info\tinstalled_kernel\t5.3.3-r0", "info\tmedia_kernel\t5.3.4-r0", + "info\tindex_sha256\t0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", + "info\tdatabase_sha256\t0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", + "info\tworld_sha256\t0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", + "info\tpending\t", "info\tfree_bytes\t1000000000", "info\trequired_bytes\t1000000", + "info\tboot_modes\t3", + }; + for (unsigned i = 0; i < sizeof(records) / sizeof(records[0]); ++i) assert(line(records[i]) == 1); +} + +int main(void) +{ + reset(); snapshot(); + assert(line("progress\t100\tUpdate checks completed") == 2 && progress == 100); + assert(installer_update_session_finish(&session, &info) == -EPROTO); + assert(line("result\t0\tUpdate checks completed") == 5); + assert(!installer_update_session_finish(&session, &info)); + assert(line("result\t0\tDuplicate completion") < 0); + assert(installer_update_session_finish(&session, &info) == -EPROTO); + + reset(); + assert(line("result\t0\tMissing metadata") < 0); + reset(); snapshot(); + assert(line("info\tdisk\t/dev/sdb") < 0); + assert(line("result\t0\tCannot recover a protocol error") < 0); + reset(); snapshot(); strcpy(info.root_uuid, "not-a-uuid"); + assert(line("result\t0\tInvalid metadata") < 0); + reset(); snapshot(); strcpy(info.index_sha256, "unsigned-index"); + assert(line("result\t0\tInvalid digest") < 0); + + reset(); + assert(line("error\t125\tCheck canceled") == 3); + assert(line("result\t125\tCheck canceled") == 5); + assert(installer_update_session_finish(&session, &info) == -ECANCELED); + reset(); + assert(line("error\t5\tRead failed") == 3); + assert(line("result\t0\tCannot report success after failure") < 0); + reset(); + assert(line("error\t5\tRead failed") == 3); + assert(line("result\t110\tMismatched error") < 0); + reset(); + assert(line("result\t110\tRead timed out") == 5); + assert(installer_update_session_finish(&session, &info) == -ETIMEDOUT); + assert(!strcmp(info.failure, "Read timed out")); + reset(); + assert(line("ordinary output on the control stream") < 0); + reset(); + assert(line("result\t0\tBad\tmessage") < 0); + reset(); + char oversized[600]; memset(oversized, 'x', sizeof(oversized)); oversized[599] = 0; + assert(line(oversized) < 0); + puts("PASS complete update sessions, cancellation, truncation, invalid and duplicate records"); + return 0; +} diff --git a/tools/tests/installer_update_supervisor_test.c b/tools/tests/installer_update_supervisor_test.c new file mode 100644 index 00000000..b063f0cf --- /dev/null +++ b/tools/tests/installer_update_supervisor_test.c @@ -0,0 +1,99 @@ +#define _GNU_SOURCE 1 +#include "../../userland/apps/installer/installer_update_supervisor.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct fixture { int mode; pid_t descendant; unsigned pulses; volatile sig_atomic_t cancel; }; +static int operation(void *context) +{ + struct fixture *test = context; + if (test->mode == 0) return -ENOSPC; + if (test->mode == 1) { raise(SIGBUS); return 0; } + if (test->mode == 5) __atomic_store_n(&test->descendant, getpid(), __ATOMIC_RELEASE); + if (test->mode == 2 || test->mode == 3) { + pid_t child = fork(); + assert(child >= 0); + if (!child) { + signal(SIGTERM, SIG_IGN); + for (;;) pause(); + } + test->descendant = child; + if (test->mode == 2) return 0; /* Even success must retire descendants. */ + } + if (test->mode == 3) signal(SIGTERM, SIG_IGN); + for (;;) (void)poll(NULL, 0, 10); +} +static void pulse(void *context, int stopping) +{ + struct fixture *test = context; + (void)stopping; + if (++test->pulses == 1 && test->mode == 4) test->cancel = 1; +} +static unsigned long elapsed(struct timespec start) +{ + struct timespec now; + assert(!clock_gettime(CLOCK_MONOTONIC, &now)); + return (unsigned long)((now.tv_sec - start.tv_sec) * 1000 + (now.tv_nsec - start.tv_nsec) / 1000000); +} +static void test_coordinator_death(struct fixture *test) +{ + test->mode = 5; + test->descendant = 0; + pid_t coordinator = fork(); + assert(coordinator >= 0); + if (!coordinator) { + (void)installer_update_supervise(operation, test, 10000, NULL, NULL, NULL); + _exit(1); + } + struct timespec start; + assert(!clock_gettime(CLOCK_MONOTONIC, &start)); + pid_t stage; + while (!(stage = __atomic_load_n(&test->descendant, __ATOMIC_ACQUIRE)) && elapsed(start) < 2000) + (void)poll(NULL, 0, 10); + assert(stage > 1); + assert(!kill(coordinator, SIGKILL)); + int status; + assert(waitpid(coordinator, &status, 0) == coordinator); + assert(WIFSIGNALED(status) && WTERMSIG(status) == SIGKILL); + /* The test is the nearest Linux subreaper. PDEATHSIG must retire the stage + * even though nobody remains inside supervise() to send its group a signal. */ + assert(!clock_gettime(CLOCK_MONOTONIC, &start)); + pid_t result; + while (!(result = waitpid(stage, &status, WNOHANG)) && elapsed(start) < 2000) + (void)poll(NULL, 0, 10); + assert(result == stage && WIFSIGNALED(status) && WTERMSIG(status) == SIGKILL); +} +int main(void) +{ + struct fixture *test = mmap(NULL, sizeof(*test), PROT_READ | PROT_WRITE, + MAP_SHARED | MAP_ANONYMOUS, -1, 0); + assert(test != MAP_FAILED); + assert(installer_update_supervise(operation, test, 1000, NULL, NULL, NULL) == -ENOSPC); + test->mode = 1; + assert(installer_update_supervise(operation, test, 1000, NULL, NULL, NULL) == -EIO); + test->mode = 2; + assert(!installer_update_supervise(operation, test, 1000, NULL, NULL, NULL)); + assert(test->descendant > 1 && kill(test->descendant, 0) < 0 && errno == ESRCH); + test->mode = 3; + struct timespec started; + assert(!clock_gettime(CLOCK_MONOTONIC, &started)); + assert(installer_update_supervise(operation, test, 80, NULL, pulse, test) == -ETIMEDOUT); + assert(elapsed(started) < 3000); + assert(test->descendant > 1 && kill(test->descendant, 0) < 0 && errno == ESRCH); + test->mode = 4; test->pulses = 0; + assert(installer_update_supervise(operation, test, 3000, &test->cancel, pulse, test) == -ECANCELED); + assert(test->pulses); + assert(installer_update_supervise(operation, test, 1000, &test->cancel, NULL, NULL) == -ECANCELED); + test_coordinator_death(test); + int status; + assert(waitpid(-1, &status, WNOHANG) < 0 && errno == ECHILD); + assert(!munmap(test, sizeof(*test))); + puts("PASS supervised errno, SIGBUS, deadline, TERM escalation, descendant retirement, cancellation and coordinator death"); +} diff --git a/tools/tests/installer_update_target_test.c b/tools/tests/installer_update_target_test.c new file mode 100644 index 00000000..93a13b46 --- /dev/null +++ b/tools/tests/installer_update_target_test.c @@ -0,0 +1,322 @@ +/* Exercise cleanup after an interrupted mount stage without requiring root or + * mounting any host filesystem. The mount table, not publication flags, is the + * independent observation of what the kernel accepted before a child died. */ +#define _GNU_SOURCE 1 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static FILE *fixture_setmntent(const char *, const char *); +static struct mntent *fixture_getmntent(FILE *); +static int fixture_endmntent(FILE *); +static int fixture_umount2(const char *, int); +static int fixture_rmdir(const char *); +static int fixture_mkdir(const char *, mode_t); +static int fixture_lstat(const char *, struct stat *); +static int fixture_fstat(int, struct stat *); +static int fixture_open(const char *, int, ...); +#define setmntent fixture_setmntent +#define getmntent fixture_getmntent +#define endmntent fixture_endmntent +#define umount2 fixture_umount2 +#define rmdir fixture_rmdir +#define mkdir fixture_mkdir +#define lstat fixture_lstat +#define fstat fixture_fstat +#define open fixture_open +#include "../../userland/apps/installer/installer_update_target.c" +#undef setmntent +#undef getmntent +#undef endmntent +#undef umount2 +#undef rmdir +#undef mkdir +#undef lstat +#undef fstat +#undef open + +static const char *const points[] = { + "/run/reliefos/update-a1B2c3/root/boot", "/run/reliefos/update-a1B2c3/root/efi", + "/run/reliefos/update-a1B2c3/root", "/run/reliefos/update-other1/root", + "/run/reliefos/update-not-a-workspace/root", "/run/reliefos/update-a1B2c3-other/root", + "/mnt/unrelated/root", "/run/reliefos/update-a1B2c3/root/proc", + "/run/reliefos/update-a1B2c3", + "/run/reliefos/update-a1B2c3/reliefos-update.aB3dE5/root/lib", +}; +enum { POINTS = sizeof(points) / sizeof(points[0]) }; +static int active[POINTS], cursor, fail_at = -1, table_error, calls, removes; +static char called[4][256]; +static char lock_file[] = "/tmp/installer-update-lock.XXXXXX"; +static char fixture_workspace[] = "/tmp/installer-update-workspace.XXXXXX"; + +/* Redirect only the runtime directory and lock pathname. Lock acquisition, + * inheritance, contention and close all use real host kernel operations. */ +static int fixture_mkdir(const char *path, mode_t mode) +{ + assert(!strcmp(path, "/run/reliefos") && mode == 0755); + errno = EEXIST; + return -1; +} + +static int fixture_lstat(const char *path, struct stat *status) +{ + assert(!strcmp(path, "/run/reliefos")); + memset(status, 0, sizeof(*status)); + status->st_mode = S_IFDIR | 0755; + return 0; +} + +static int fixture_fstat(int fd, struct stat *status) +{ + int result = fstat(fd, status); + if (!result) status->st_uid = 0; /* Keep the test usable by an unprivileged builder. */ + return result; +} + +static int fixture_open(const char *path, int flags, ...) +{ + mode_t mode = 0; + if (flags & O_CREAT) { + va_list arguments; + va_start(arguments, flags); + mode = va_arg(arguments, int); + va_end(arguments); + } + if (!strcmp(path, "/run/reliefos/installer-update.lock")) path = lock_file; + else if (!strcmp(path, "/run/reliefos/update-a1B2c3")) path = fixture_workspace; + return open(path, flags, mode); +} + +static FILE *fixture_setmntent(const char *path, const char *mode) +{ + assert(!strcmp(path, "/proc/self/mounts") && !strcmp(mode, "r")); + if (table_error) { errno = EIO; return NULL; } + cursor = 0; + FILE *stream = tmpfile(); + assert(stream); + return stream; +} + +static struct mntent *fixture_getmntent(FILE *stream) +{ + (void)stream; + static struct mntent entry; + while (cursor < POINTS) { + int index = cursor++; + if (!active[index]) continue; + entry.mnt_dir = (char *)points[index]; + return &entry; + } + return NULL; +} + +static int fixture_endmntent(FILE *stream) { assert(!fclose(stream)); return 1; } + +static int fixture_umount2(const char *path, int flags) +{ + assert(!flags && calls < 4); + snprintf(called[calls++], sizeof(called[0]), "%s", path); + for (unsigned i = 0; i < POINTS; ++i) { + if (strcmp(path, points[i])) continue; + assert(active[i]); + if ((int)i == fail_at) { errno = EBUSY; return -1; } + active[i] = 0; + return 0; + } + assert(!"unmounting an unobserved path"); + return -1; +} + +static int fixture_rmdir(const char *path) +{ + assert(!active[0] && !active[1] && !active[2]); + assert(!strcmp(path, "/run/reliefos/update-a1B2c3/root") || + !strcmp(path, "/run/reliefos/update-a1B2c3")); + ++removes; + return 0; +} + +static struct installer_update_target target(void) +{ + struct installer_update_target result = {.lock_fd = -1}; + strcpy(result.workspace, "/run/reliefos/update-a1B2c3"); + return result; +} + +static void test_lock_inheritance(void) +{ + int fixture = mkstemp(lock_file); + assert(fixture >= 0 && !close(fixture)); + memset(active, 0, sizeof(active)); + active[4] = active[5] = active[6] = 1; + struct installer_update_target state, other; + assert(!installer_update_target_lock(&state)); + assert(fcntl(state.lock_fd, F_GETFD) & FD_CLOEXEC); + assert(installer_update_target_lock(&other) == -EBUSY && other.lock_fd == -1); + + int control[2], ready[2]; + assert(!pipe(control) && !pipe(ready)); + pid_t child = fork(); + assert(child >= 0); + if (!child) { + assert(!close(control[1]) && !close(ready[0])); + assert(dup2(control[0], STDIN_FILENO) == STDIN_FILENO); + assert(dup2(ready[1], STDOUT_FILENO) == STDOUT_FILENO); + assert(!close(control[0]) && !close(ready[1])); + /* The stage clears CLOEXEC before launching its command, exactly as + * the coordinator does for real update descendants. */ + assert(!fcntl(state.lock_fd, F_SETFD, 0)); + execl("/bin/sh", "sh", "-c", "printf r; read line", (char *)NULL); + _exit(127); + } + assert(!close(control[0]) && !close(ready[1])); + char byte; + assert(read(ready[0], &byte, 1) == 1 && byte == 'r'); + assert(!close(ready[0])); + assert(!installer_update_target_unlock(&state)); + assert(installer_update_target_lock(&other) == -EBUSY && other.lock_fd == -1); + assert(write(control[1], "\n", 1) == 1 && !close(control[1])); + int status; + assert(waitpid(child, &status, 0) == child && WIFEXITED(status) && !WEXITSTATUS(status)); + assert(!installer_update_target_lock(&state)); + assert(!installer_update_target_unlock(&state)); + + /* An idle advisory lock does not prove that a crashed coordinator's + * global mounts are gone. Refusal must release its newly acquired fd. */ + active[7] = 1; + assert(installer_update_target_lock(&state) == -EBUSY && state.lock_fd == -1); + active[7] = 0; active[8] = 1; + assert(installer_update_target_lock(&state) == -EBUSY && state.lock_fd == -1); + active[8] = 0; + table_error = 1; + assert(installer_update_target_lock(&state) == -EIO && state.lock_fd == -1); + table_error = 0; + assert(!installer_update_target_lock(&state)); + assert(!installer_update_target_unlock(&state)); + assert(!unlink(lock_file)); +} + +static void test_owned_planner_cleanup(void) +{ + memset(active, 0, sizeof(active)); + char plan[256], metadata[320], link[320]; + snprintf(plan, sizeof(plan), "%s/reliefos-update.aB3dE5", fixture_workspace); + snprintf(metadata, sizeof(metadata), "%s/root/lib/apk/db/installed", plan); + /* An uncatchable helper fault leaves metadata behind. Its coordinator + * still knows the workspace and must release these tmpfs allocations. */ + pid_t child = fork(); + assert(child >= 0); + if (!child) { + execl("/bin/sh", "sh", "-c", + "umask 077; mkdir -p \"$1/reliefos-update.aB3dE5/root/lib/apk/db\"; " + "printf metadata > \"$1/reliefos-update.aB3dE5/root/lib/apk/db/installed\"; kill -KILL $$", + "sh", fixture_workspace, (char *)NULL); + _exit(127); + } + int status; + assert(waitpid(child, &status, 0) == child && WIFSIGNALED(status) && WTERMSIG(status) == SIGKILL); + assert(!access(metadata, F_OK)); + char outside[] = "/tmp/installer-update-outside.XXXXXX", outside_file[256]; + assert(mkdtemp(outside)); + snprintf(outside_file, sizeof(outside_file), "%s/keep", outside); + int fd = open(outside_file, O_WRONLY | O_CREAT | O_EXCL, 0600); + assert(fd >= 0 && write(fd, "untouched", 9) == 9 && !close(fd)); + snprintf(link, sizeof(link), "%s/root/foreign-directory", plan); + assert(!symlink(outside, link)); + struct installer_update_target state = target(); + calls = removes = 0; + assert(!installer_update_target_unmount(&state)); + assert(!access(outside_file, F_OK) && access(plan, F_OK) < 0 && errno == ENOENT); + assert(!state.workspace[0] && !calls && removes == 2); + + /* Reject unknown workspace contents before deleting any owned plan. */ + assert(!mkdir(plan, 0700)); + snprintf(metadata, sizeof(metadata), "%s/installed-before", plan); + fd = open(metadata, O_WRONLY | O_CREAT | O_EXCL, 0600); + assert(fd >= 0 && !close(fd)); + char unknown[256]; + snprintf(unknown, sizeof(unknown), "%s/administrator-notes", fixture_workspace); + fd = open(unknown, O_WRONLY | O_CREAT | O_EXCL, 0600); + assert(fd >= 0 && !close(fd)); + assert(cleanup_plans("/run/reliefos/update-a1B2c3") == -ENOTEMPTY); + assert(!access(metadata, F_OK) && !access(unknown, F_OK)); + assert(!unlink(unknown)); + + /* A same-filesystem bind mount must block cleanup even when st_dev would + * let a naive recursive remover cross it. No real mount is needed. */ + active[9] = 1; + assert(cleanup_plans("/run/reliefos/update-a1B2c3") == -EBUSY); + assert(!access(metadata, F_OK)); + active[9] = 0; + table_error = 1; + assert(cleanup_plans("/run/reliefos/update-a1B2c3") == -EIO); + assert(!access(metadata, F_OK)); + table_error = 0; + assert(!cleanup_plans("/run/reliefos/update-a1B2c3")); + assert(access(plan, F_OK) < 0 && errno == ENOENT); + + /* An entry with the expected planner name still cannot redirect cleanup + * outside its workspace. The directory link itself is retained on error. */ + assert(!symlink(outside, plan)); + assert(cleanup_plans("/run/reliefos/update-a1B2c3") == -EPERM); + struct stat preserved; + assert(!lstat(plan, &preserved) && S_ISLNK(preserved.st_mode)); + assert(!unlink(plan)); + fd = open(outside_file, O_RDONLY); + char content[10] = {0}; + assert(fd >= 0 && read(fd, content, 9) == 9 && !strcmp(content, "untouched") && !close(fd)); + assert(!unlink(outside_file) && !rmdir(outside)); +} + +int main(void) +{ + assert(mkdtemp(fixture_workspace)); + struct installer_update_target state = target(); + active[0] = active[1] = active[2] = active[3] = 1; + assert(!installer_update_target_unmount(&state)); + assert(calls == 3 && removes == 2 && active[3]); + for (unsigned i = 0; i < 3; ++i) assert(!strcmp(called[i], points[i])); + assert(!state.workspace[0] && !state.root_mounted && !state.boot_mounted && !state.esp_mounted); + + state = target(); calls = removes = 0; + state.root_mounted = state.boot_mounted = state.esp_mounted = 1; + assert(!installer_update_target_unmount(&state)); + assert(!calls && removes == 2); + assert(!state.root_mounted && !state.boot_mounted && !state.esp_mounted); + + state = target(); calls = removes = 0; + active[0] = active[1] = active[2] = 1; fail_at = 0; + assert(installer_update_target_unmount(&state) == -EBUSY); + assert(calls == 1 && !removes && state.boot_mounted && active[0] && active[1] && active[2]); + fail_at = -1; calls = 0; + assert(!installer_update_target_unmount(&state)); + assert(calls == 3 && removes == 2 && active[3]); + + state = target(); calls = removes = 0; table_error = 1; + assert(installer_update_target_unmount(&state) == -EIO); + assert(!calls && !removes && state.workspace[0]); + table_error = 0; + strcpy(state.workspace, "/run/reliefos/update-a1B2c3/../other"); + assert(installer_update_target_unmount(&state) == -EINVAL); + assert(!calls && !removes); + + state.lock_fd = open("/dev/null", O_RDONLY); + assert(state.lock_fd >= 0); + int previous = state.lock_fd; + assert(!installer_update_target_unlock(&state) && state.lock_fd == -1); + assert(fcntl(previous, F_GETFD) < 0 && errno == EBADF); + assert(!installer_update_target_unlock(&state)); + test_lock_inheritance(); + test_owned_planner_cleanup(); + assert(!rmdir(fixture_workspace)); + puts("PASS interrupted update cleanup, inherited locks and owned planner recovery"); + return 0; +} diff --git a/tools/tests/reliefapk_process_test.cpp b/tools/tests/reliefapk_process_test.cpp index ae7e8506..3437f158 100644 --- a/tools/tests/reliefapk_process_test.cpp +++ b/tools/tests/reliefapk_process_test.cpp @@ -22,6 +22,7 @@ const char *self_path = nullptr; int checks = 0; int failures = 0; volatile sig_atomic_t pty_helper_saw_hup = 0; +volatile sig_atomic_t cooperative_stop = 0; constexpr size_t DualStreamPrebuffer = 4096; void pty_helper_sighup(int) @@ -29,6 +30,8 @@ void pty_helper_sighup(int) pty_helper_saw_hup = 1; } +void cooperative_sigterm(int) { cooperative_stop = 1; } + void check(bool condition, const char *message) { ++checks; @@ -124,6 +127,24 @@ int child_main(int argc, char **argv) if (strcmp(argv[1], "--child-wait") == 0) { for (;;) pause(); } + if (strcmp(argv[1], "--child-cooperative-stop") == 0) { + struct sigaction action = {}; + action.sa_handler = cooperative_sigterm; + sigemptyset(&action.sa_mask); + if (sigaction(SIGTERM, &action, nullptr) < 0) return 110; + if (!write_all(STDOUT_FILENO, "ready\n", 6)) return 111; + while (!cooperative_stop) sleep_ms(1); + sleep_ms(350); + return write_all(STDOUT_FILENO, "cleanup complete\n", 17) ? 0 : 112; + } + if (strcmp(argv[1], "--child-window-streams") == 0) { + char bytes[4096]; + memset(bytes, 'w', sizeof(bytes)); + for (unsigned i = 0; i < 512; ++i) + if (!write_all(STDOUT_FILENO, bytes, sizeof(bytes)) || + !write_all(STDERR_FILENO, bytes, sizeof(bytes))) return 113; + return 0; + } if (strcmp(argv[1], "--child-flood") == 0) { static char bytes[65536]; memset(bytes, 'f', sizeof(bytes)); @@ -769,6 +790,41 @@ void test_repeated_start_and_root_direct_path() } } +void test_cooperative_stop_and_consumed_streams() +{ + ra::Process process; + const char *stop[] = {self_path, "--child-cooperative-stop", nullptr}; + check(process.start(stop), "start a worker with cooperative cleanup"); + double started = now_seconds(); + while (!process.output_size() && process.running() && now_seconds() - started < 2.0) { + process.step(8192); + sleep_ms(1); + } + check(process.output_size() == 6, "worker publishes readiness after installing its signal handler"); + check(process.request_stop(), "request_stop signals the worker leader"); + check(finish(process), "cooperative worker completes cleanup without forced escalation"); + check(process.exit_code() == 0 && strstr(process.output(), "cleanup complete"), + "worker survives cleanup longer than the generic cancellation kill grace"); + process.consume_output(6); + check(!strcmp(process.output(), "cleanup complete\n"), "consuming a prefix retains the following record"); + process.consume_output(static_cast(-1)); + check(!process.output_size() && !*process.output(), "oversized consume empties the captured output safely"); + + const char *streams[] = {self_path, "--child-window-streams", nullptr}; + check(process.start(streams), "start streaming worker for bounded capture windows"); + size_t output = 0, errors = 0; + started = now_seconds(); + while (process.running() && now_seconds() - started < 5.0) { + process.step(16384); + output += process.output_size(); errors += process.errors_size(); + process.consume_output(process.output_size()); process.consume_errors(process.errors_size()); + sleep_ms(1); + } + check(!process.running() && process.exit_code() == 0, "streaming worker exits while the consumer drains windows"); + check(output == 2u * 1024u * 1024u && errors == 2u * 1024u * 1024u && !process.truncated(), + "consumed stderr beyond the capture limit preserves every newer byte"); +} + } // namespace int main(int argc, char **argv) @@ -795,6 +851,7 @@ int main(int argc, char **argv) test_orphan_pipe_holder_is_cleaned("--child-orphan", "open"); test_orphan_pipe_holder_is_cleaned("--child-orphan-closed", "closed"); test_repeated_start_and_root_direct_path(); + test_cooperative_stop_and_consumed_streams(); free(const_cast(self_path)); if (failures) { diff --git a/userland/apps/installer/Kbuild b/userland/apps/installer/Kbuild index b39d48fd..80e31982 100644 --- a/userland/apps/installer/Kbuild +++ b/userland/apps/installer/Kbuild @@ -6,6 +6,10 @@ RELIEFOS_APP_OBJECTS += installer_tui.o installer_tui_job.o installer_tui_partit RELIEFOS_APP_C_OBJECTS += installer_tui.o installer_tui_job.o installer_tui_partitions.o installer_job.o RELIEFOS_APP_OBJECTS += installer_plan.o RELIEFOS_APP_C_OBJECTS += installer_plan.o +RELIEFOS_APP_OBJECTS += installer_update_protocol.o +RELIEFOS_APP_C_OBJECTS += installer_update_protocol.o +RELIEFOS_APP_OBJECTS += installer_update_supervisor.o +RELIEFOS_APP_C_OBJECTS += installer_update_supervisor.o RELIEFOS_APP_ASM_OBJECTS := apache_license.o ifneq ($(RELIEFOS_CAPTURE_APP_KBUILD),1) include $(srctree)/scripts/reliefos/Makefile.app-kbuild diff --git a/userland/apps/installer/installer_job.c b/userland/apps/installer/installer_job.c index 1d5591a1..73bcfd1a 100644 --- a/userland/apps/installer/installer_job.c +++ b/userland/apps/installer/installer_job.c @@ -10,17 +10,30 @@ #include #include #include +#include #include static int progress_fd = -1; static struct installer_job_packet pending; static size_t pending_offset, pending_size; +#ifndef INSTALLER_JOB_FINISH_TIMEOUT_MS +#define INSTALLER_JOB_FINISH_TIMEOUT_MS 2000 +#endif + +static uint64_t monotonic_ms(void) +{ + struct timespec now; + if (clock_gettime(CLOCK_MONOTONIC, &now) < 0) return 0; + return (uint64_t)now.tv_sec * 1000u + (uint64_t)now.tv_nsec / 1000000u; +} + int installer_job_is_worker(void) { return progress_fd >= 0; } /* A partially written record stays intact until the parent has consumed it. */ static int flush_packet(int wait) { + uint64_t start = monotonic_ms(); while (pending_offset < pending_size) { ssize_t count = write(progress_fd, (char *)&pending + pending_offset, pending_size - pending_offset); @@ -28,9 +41,13 @@ static int flush_packet(int wait) if (count < 0 && errno == EINTR) continue; if (count < 0 && (errno == EAGAIN || errno == EWOULDBLOCK)) { if (!wait) return 1; + uint64_t now = monotonic_ms(); + if (now < start || now - start >= INSTALLER_JOB_FINISH_TIMEOUT_MS) return -1; struct pollfd descriptor = {.fd = progress_fd, .events = POLLOUT}; int result; - do { result = poll(&descriptor, 1, -1); } while (result < 0 && errno == EINTR); + int remaining = INSTALLER_JOB_FINISH_TIMEOUT_MS - (int)(now - start); + result = poll(&descriptor, 1, remaining); + if (result < 0 && errno == EINTR) continue; if (result > 0 && !(descriptor.revents & (POLLERR | POLLHUP | POLLNVAL))) continue; } return -1; @@ -118,6 +135,7 @@ int installer_job_step(struct installer_job *job) budget -= (size_t)count; job->received += (size_t)count; if (job->received != sizeof(job->incoming)) continue; + if (job->complete || job->incoming.progress > 100) job->error = EPROTO; job->incoming.message[sizeof(job->incoming.message) - 1] = 0; job->incoming.detail[sizeof(job->incoming.detail) - 1] = 0; job->latest = job->incoming; @@ -129,8 +147,17 @@ int installer_job_step(struct installer_job *job) } if (!job->exited) { pid_t result = waitpid(job->pid, &job->status, WNOHANG); - if (result == job->pid) job->exited = 1; - else if (result < 0 && errno != EINTR) { job->exited = 1; job->error = errno; } + if (result == job->pid) { job->exited = 1; job->exited_ms = monotonic_ms(); } + else if (result < 0 && errno != EINTR) { + job->exited = 1; job->exited_ms = monotonic_ms(); job->error = errno; + } + } + if (job->exited && !job->eof) { + uint64_t now = monotonic_ms(); + if (now < job->exited_ms || now - job->exited_ms >= INSTALLER_JOB_FINISH_TIMEOUT_MS) { + job->eof = 1; + job->error = EPIPE; + } } if (!job->exited || !job->eof) return 1; close(job->fd); job->fd = -1; @@ -139,3 +166,9 @@ int installer_job_step(struct installer_job *job) return job->error ? -job->error : -EIO; return 0; } + +int installer_job_request_stop(struct installer_job *job) +{ + if (!job || job->pid <= 0 || job->exited) return -EINVAL; + return kill(job->pid, SIGTERM) < 0 ? -errno : 0; +} diff --git a/userland/apps/installer/installer_job.h b/userland/apps/installer/installer_job.h index c6822cf1..f52c4586 100644 --- a/userland/apps/installer/installer_job.h +++ b/userland/apps/installer/installer_job.h @@ -21,6 +21,7 @@ struct installer_job { pid_t pid; int fd, eof, exited, status, error, complete; size_t received; + uint64_t exited_ms; struct installer_job_packet incoming, latest, final; }; @@ -29,6 +30,9 @@ typedef int (*installer_job_fn)(void *, struct installer_job_packet *); int installer_job_start(struct installer_job *, installer_job_fn, void *, const char *log); /* Bounded nonblocking drain: 1 running, 0 complete, or negative errno. */ int installer_job_step(struct installer_job *); +/* Cooperatively stop a read-only check. The worker owns its resource cleanup; + * callers must keep pumping until its final result and exit arrive. */ +int installer_job_request_stop(struct installer_job *); /* Coalesce telemetry when the reader is slow; never wait in a copy callback. */ void installer_job_publish(const struct installer_job_packet *); int installer_job_is_worker(void); diff --git a/userland/apps/installer/installer_tty.c b/userland/apps/installer/installer_tty.c index 42bdf7e5..b49d951e 100644 --- a/userland/apps/installer/installer_tty.c +++ b/userland/apps/installer/installer_tty.c @@ -470,6 +470,10 @@ int installer_tty_main(const struct installer_tty_context *context) snprintf(job.esp_uuid, sizeof(job.esp_uuid), "%s", esp_uuid); int result = tui_run_job(context, &job); inspected = job.info; + if (result == -ECANCELED) { + snprintf(view.status, sizeof(view.status), "%s", T("Update check canceled. Run the checks again when ready.")); + continue; + } if (result) { error_message(result, T(inspected.failure)); continue; } update_checked = 1; bios = !!(inspected.boot_modes & 1); diff --git a/userland/apps/installer/installer_tui_job.c b/userland/apps/installer/installer_tui_job.c index 64150764..92ea2293 100644 --- a/userland/apps/installer/installer_tui_job.c +++ b/userland/apps/installer/installer_tui_job.c @@ -1,13 +1,118 @@ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif #include +#include #include #include #include +#include +#include +#include #include "installer_tui.h" #include "installer_job.h" #include "install_ops.h" #define T(s) gettext(s) +/* The ncurses loop never opens or reads the log filesystem. A small disposable + * reader sends one tail snapshot through a nonblocking pipe once per second. */ +static struct { + pid_t pid; + int fd, eof, stopped; + size_t used; + uint64_t started, refreshed; + char incoming[8192], text[8192]; +} log_reader = {.fd = -1}; + +static uint64_t now_ms(void) +{ + struct timespec now; + if (clock_gettime(CLOCK_MONOTONIC, &now) < 0) return 0; + return (uint64_t)now.tv_sec * 1000u + (uint64_t)now.tv_nsec / 1000000u; +} + +static void log_reader_stop(void) +{ + if (log_reader.fd >= 0) close(log_reader.fd); + log_reader.fd = -1; + log_reader.eof = log_reader.stopped = 1; + if (log_reader.pid > 0) { + (void)kill(log_reader.pid, SIGKILL); + /* A stuck kernel read must never block the UI during cleanup. A + * surviving reader is reaped by the next pump (or PID 1 on exit). */ + pid_t result = waitpid(log_reader.pid, NULL, WNOHANG); + if (result == log_reader.pid || (result < 0 && errno == ECHILD)) log_reader.pid = 0; + } +} + +static void log_reader_step(void) +{ + if (log_reader.pid <= 0) return; + while (log_reader.fd >= 0 && !log_reader.eof && log_reader.used < sizeof(log_reader.incoming) - 1) { + ssize_t count = read(log_reader.fd, log_reader.incoming + log_reader.used, + sizeof(log_reader.incoming) - 1 - log_reader.used); + if (count > 0) { log_reader.used += (size_t)count; continue; } + if (count < 0 && errno == EINTR) continue; + if (!count || (errno != EAGAIN && errno != EWOULDBLOCK)) log_reader.eof = 1; + break; + } + if (log_reader.used == sizeof(log_reader.incoming) - 1) log_reader.eof = 1; + int status = 0; + pid_t result = waitpid(log_reader.pid, &status, WNOHANG); + if (result == log_reader.pid || (result < 0 && errno == ECHILD)) { + if (!log_reader.stopped && result > 0 && WIFEXITED(status) && !WEXITSTATUS(status)) { + log_reader.incoming[log_reader.used] = 0; + memcpy(log_reader.text, log_reader.incoming, log_reader.used + 1); + } + if (log_reader.fd >= 0) close(log_reader.fd); + log_reader.fd = -1; + log_reader.pid = 0; + } else { + uint64_t now = now_ms(); + if (now < log_reader.started || now - log_reader.started >= 1000) log_reader_stop(); + } +} + +static void log_reader_start(const char *path) +{ + uint64_t now = now_ms(); + if (log_reader.pid > 0 || (log_reader.refreshed && now >= log_reader.refreshed && + now - log_reader.refreshed < 1000)) return; + log_reader.refreshed = now; + int descriptors[2]; + if (pipe(descriptors) < 0) return; + if (fcntl(descriptors[0], F_SETFL, O_NONBLOCK) < 0 || + fcntl(descriptors[0], F_SETFD, FD_CLOEXEC) < 0 || + fcntl(descriptors[1], F_SETFD, FD_CLOEXEC) < 0) { + close(descriptors[0]); close(descriptors[1]); return; + } + pid_t child = fork(); + if (child < 0) { close(descriptors[0]); close(descriptors[1]); return; } + if (!child) { + close(descriptors[0]); + signal(SIGTERM, SIG_DFL); signal(SIGINT, SIG_DFL); signal(SIGHUP, SIG_DFL); + signal(SIGPIPE, SIG_IGN); + char text[8192]; + tui_read_log(path, text, sizeof(text)); + size_t used = 0, length = strlen(text); + while (used < length) { + ssize_t count = write(descriptors[1], text + used, length - used); + if (count > 0) used += (size_t)count; + else if (count < 0 && errno == EINTR) continue; + else break; + } + close(descriptors[1]); + _exit(used == length ? 0 : 1); + } + close(descriptors[1]); + log_reader.pid = child; + log_reader.fd = descriptors[0]; + log_reader.eof = log_reader.stopped = 0; + log_reader.used = 0; + log_reader.started = now; +} + static int job_error(int error) { copy_text(status_text, sizeof(status_text), T("Operation failed")); @@ -94,8 +199,17 @@ int tui_run_job(const struct installer_tty_context *context, struct tui_job *job int result = installer_job_start(&state, run_job, &run, NULL); if (result) return job_error(result); struct tui_view view = {.previous_focus = -1}; - int show_log = 0; + int show_log = 0, cancel_requested = 0; + uint64_t stop_sent = 0; + log_reader_step(); + log_reader.text[0] = 0; + log_reader.refreshed = 0; while ((result = installer_job_step(&state)) > 0) { + log_reader_step(); + if (cancel_requested && now_ms() - stop_sent >= 500) { + (void)installer_job_request_stop(&state); + stop_sent = now_ms(); + } const struct installer_job_packet *packet = &state.latest; unsigned progress = packet->progress > 100 ? 100 : packet->progress; tui_begin(&view, job->kind == TUI_JOB_CHECK ? T("Checking installed system") @@ -111,11 +225,18 @@ int tui_run_job(const struct installer_tty_context *context, struct tui_job *job tui_text(&view, T("Disk operations are running. Please wait for completion.")); tui_text(&view, log_path); tui_button(&view, T("Show / hide log (F4)"), TUI_LOG); - char log[8192]; - if (show_log) { tui_read_log(log_path, log, sizeof(log)); tui_document(&view, log); } - if (installer_tui_signal) snprintf(view.status, sizeof(view.status), "%s", T("The terminal requested exit. Waiting for the disk operation to finish.")); - if (tui_step(&view, NULL, 0, 0, 100) == TUI_LOG) show_log = !show_log; + if (show_log) { log_reader_start(log_path); tui_document(&view, log_reader.text); } + if (cancel_requested) snprintf(view.status, sizeof(view.status), "%s", T("Canceling the update check. Waiting for cleanup.")); + else if (installer_tui_signal) snprintf(view.status, sizeof(view.status), "%s", T("The terminal requested exit. Waiting for the disk operation to finish.")); + int action = tui_step(&view, NULL, 0, job->kind == TUI_JOB_CHECK && !cancel_requested, 100); + if (action == TUI_LOG) show_log = !show_log; + if (action == TUI_CANCEL && job->kind == TUI_JOB_CHECK && !cancel_requested && + !installer_job_request_stop(&state)) { + cancel_requested = 1; + stop_sent = now_ms(); + } } + log_reader_stop(); if (result < 0) return job_error(result); const struct installer_job_packet *final = &state.final; *context->selected_partition = final->selected; diff --git a/userland/apps/installer/installer_update.h b/userland/apps/installer/installer_update.h index 47f1d1d7..5fa0c7e0 100644 --- a/userland/apps/installer/installer_update.h +++ b/userland/apps/installer/installer_update.h @@ -51,6 +51,14 @@ struct installer_update_checkpoint { char phase[32], root_uuid[37], index_sha256[65], database_sha256[65], world_sha256[65]; }; +/* A frontend accepts success only after a complete metadata snapshot and one + * terminal result. Protocol errors are sticky across later valid records. */ +struct installer_update_session { + uint32_t fields; + unsigned terminal, error; + int terminal_error; +}; + #ifdef __cplusplus extern "C" { #endif @@ -60,11 +68,18 @@ extern "C" { int installer_update_read_system(const char *root, struct installer_update_info *info); int installer_update_read_media(const char *root, const char *profile, struct installer_update_info *info); int installer_update_read_packages(const char *root, struct installer_update_packages *packages); +/* Conservatively sum positive installed-size changes for every media package, + * including upstream dependencies. Removed/shrinking/external packages never + * provide credit; largest includes every media package. Outputs stay zero on + * error. Both databases are bounded to 8192 uniquely named package records. */ +int installer_update_measure_growth(const char *installed_root, const char *media_root, + uint64_t *growth, uint64_t *largest); int installer_update_read_checkpoint(const char *root, struct installer_update_checkpoint *checkpoint); int installer_update_write_checkpoint(const char *root, const struct installer_update_checkpoint *checkpoint); /* The result's activity field is live during callbacks. Other result metadata - * becomes final only when check/apply returns; neither frontend runs disk I/O. */ + * becomes final only when check/apply returns. Run these calls in a worker so + * the frontend can service input while the storage stages execute. */ typedef void (*installer_update_observer)(void *context, unsigned progress, const char *message); int installer_update_activity_decode(struct installer_update_activity *activity, const char *line); int installer_update_activity_encode(const struct installer_update_activity *activity, char *line, size_t capacity); @@ -77,6 +92,9 @@ int installer_update_check(const char *disk, struct installer_update_info *info, int installer_update_check_target(const char *disk, const char *root_uuid, const char *esp_uuid, struct installer_update_info *info, installer_update_observer observer, void *context); +int installer_update_check_indices(const char *disk, int root_index, int esp_index, + struct installer_update_info *info, + installer_update_observer observer, void *context); int installer_update_apply(const struct installer_update_info *expected, unsigned boot_modes, struct installer_update_info *result, installer_update_observer observer, void *context); @@ -85,6 +103,13 @@ int installer_update_apply(const struct installer_update_info *expected, unsigne * progress, 3 for failure, 4 for activity, 0 for an unrelated line, or a negative errno. */ int installer_update_decode(struct installer_update_info *info, unsigned *progress, char *message, size_t capacity, const char *line); +/* Feed complete lines only; result records return 5. Finish returns the final + * worker errno or -EPROTO for incomplete, inconsistent or duplicate records. */ +int installer_update_session_line(struct installer_update_session *session, + struct installer_update_info *info, unsigned *progress, + char *message, size_t capacity, const char *line); +int installer_update_session_finish(const struct installer_update_session *session, + const struct installer_update_info *info); /* Run the isolated native backend before any FLTK initialization. */ int installer_update_worker(int argc, char **argv); diff --git a/userland/apps/installer/installer_update_engine.c b/userland/apps/installer/installer_update_engine.c index 3647c8ad..81e9cf25 100644 --- a/userland/apps/installer/installer_update_engine.c +++ b/userland/apps/installer/installer_update_engine.c @@ -2,6 +2,8 @@ #define _GNU_SOURCE 1 #endif #include "installer_update_internal.h" +#include "installer_update_supervisor.h" +#include #include "../../auth/standard_accounts.h" #include @@ -9,12 +11,15 @@ #include #include #include +#include +#include #include #include #include #include #include #include +#include #include #include #include @@ -22,10 +27,29 @@ #define N_(text) (text) +#ifndef UPDATE_ESP #define UPDATE_ESP "/install/esp" +#endif #define UPDATE_PACKAGES "/usr/share/reliefos/apk/repository" +#ifndef UPDATE_MEDIA_CONSOLE +#define UPDATE_MEDIA_CONSOLE "/install/root-console" +#define UPDATE_MEDIA_XFCE "/install/root-xfce" +#define UPDATE_MEDIA_XORG "/install/root" +#endif +#ifndef UPDATE_HELPER #define UPDATE_HELPER "/usr/lib/reliefos/reliefos-apk-update" +#endif +#ifndef UPDATE_LOG #define UPDATE_LOG "/var/log/installer-update.log" +#endif + +/* IPC contains no pointers. Only a stage child writes it; a sequence check + * prevents a pulse from consuming a partly published observation. */ +struct update_event { + unsigned sequence, progress; + char message[128]; + struct installer_update_activity activity; +}; struct update_run { installer_update_observer observer; @@ -33,12 +57,27 @@ struct update_run { FILE *log; unsigned progress; const char *stage; - struct timespec presented; struct installer_update_info *out; + struct update_event *event; + char message[128]; struct installer_update_activity activity; int applying; + const char *workspace; }; +static void publish_event(struct update_run *run) +{ + if (run->event) { + unsigned sequence = __atomic_load_n(&run->event->sequence, __ATOMIC_RELAXED); + __atomic_store_n(&run->event->sequence, sequence + 1, __ATOMIC_SEQ_CST); + run->event->progress = run->progress; + snprintf(run->event->message, sizeof(run->event->message), "%s", run->stage); + run->event->activity = run->activity; + __atomic_store_n(&run->event->sequence, sequence + 2, __ATOMIC_RELEASE); + } + if (run->observer) run->observer(run->context, run->progress, run->stage); +} + static void report(struct update_run *run, unsigned progress, const char *stage) { run->progress = progress; @@ -47,7 +86,7 @@ static void report(struct update_run *run, unsigned progress, const char *stage) if (run->out) run->out->activity = run->activity; fprintf(stderr, "[installer-update] %u%% %s\n", progress, stage); if (run->log) { fprintf(run->log, "[installer-update] %u%% %s\n", progress, stage); fflush(run->log); } - if (run->observer) run->observer(run->context, progress, stage); + publish_event(run); } /** @brief Present bounded helper telemetry while preserving monotonic progress. */ @@ -59,7 +98,7 @@ static void present_activity(struct update_run *run, const struct installer_upda run->stage = installer_update_activity_stage(activity->step); unsigned value = installer_update_activity_percent(activity, run->applying); if (value > run->progress) run->progress = value; - if (run->observer) run->observer(run->context, run->progress, run->stage); + publish_event(run); } /** @brief Decode complete helper lines only; ordinary command output stays data. */ @@ -98,7 +137,11 @@ static int command(struct update_run *run, const char *const arguments[], char * if (!result) result = posix_spawn_file_actions_adddup2(&actions, descriptors[1], STDOUT_FILENO); if (!result) result = posix_spawn_file_actions_adddup2(&actions, descriptors[1], STDERR_FILENO); if (!result) result = posix_spawn_file_actions_addclose(&actions, descriptors[1]); - char *const environment[] = {"PATH=/usr/sbin:/usr/bin:/sbin:/bin", "LC_ALL=C", "LANG=C", "HOME=/root", NULL}; + char temporary_environment[PATH_MAX + 8]; + snprintf(temporary_environment, sizeof(temporary_environment), "TMPDIR=%s", + run->workspace && run->workspace[0] ? run->workspace : "/run"); + char *const environment[] = {"PATH=/usr/sbin:/usr/bin:/sbin:/bin", "LC_ALL=C", "LANG=C", + "HOME=/root", temporary_environment, NULL}; pid_t child = -1; if (!result) result = posix_spawn(&child, arguments[0], &actions, NULL, (char *const *)arguments, environment); @@ -238,8 +281,8 @@ static int check_media(struct update_run *run, struct installer_update_target *t struct installer_update_packages installed, incoming; int result = installer_update_read_packages(target->root, &installed); if (result) return result; - const char *media = !strcmp(target->info.profile, "console") ? "/install/root-console" : - installed.has_xfce_session ? "/install/root-xfce" : "/install/root"; + const char *media = !strcmp(target->info.profile, "console") ? UPDATE_MEDIA_CONSOLE : + installed.has_xfce_session ? UPDATE_MEDIA_XFCE : UPDATE_MEDIA_XORG; result = installer_update_read_media(media, target->info.profile, &source); if (!result) result = installer_update_read_packages(media, &incoming); if (result) return result; @@ -275,24 +318,14 @@ static int check_media(struct update_run *run, struct installer_update_target *t uint64_t archives; result = repository_bytes(repository, &archives); if (result) return result; - uint64_t growth = incoming.installed_bytes > installed.installed_bytes - ? incoming.installed_bytes - installed.installed_bytes : 0; + uint64_t growth, largest; + result = installer_update_measure_growth(target->root, media, &growth, &largest); + if (result) return result; uint64_t reserve = 64u * 1024u * 1024u; if (UINT64_MAX - reserve < archives || UINT64_MAX - reserve - archives < growth || - UINT64_MAX - reserve - archives - growth < incoming.largest_package) return -EOVERFLOW; - target->info.required_bytes = reserve + archives + growth + incoming.largest_package; - return target->info.free_bytes < target->info.required_bytes ? -ENOSPC : 0; -} - -static void boot_progress(void *context) -{ - struct update_run *run = context; - struct timespec now; - if (!clock_gettime(CLOCK_MONOTONIC, &now) && - (now.tv_sec > run->presented.tv_sec || now.tv_nsec - run->presented.tv_nsec >= 500000000L)) { - run->presented = now; - if (run->observer) run->observer(run->context, run->progress, run->stage); - } + UINT64_MAX - reserve - archives - growth < largest) return -EOVERFLOW; + target->info.required_bytes = reserve + archives + growth + largest; + return 0; } static int save_checkpoint(struct installer_update_target *target, struct installer_update_checkpoint *state, @@ -316,7 +349,7 @@ static int recover_pending(struct update_run *run, struct installer_update_targe if (result) return result; char path[PATH_MAX], text[96]; snprintf(path, sizeof(path), "%s/run/reliefos-kernel-activation.defer", target->root); - int fd = open(path, O_RDONLY | O_NOFOLLOW | O_CLOEXEC); + int fd = open(path, O_RDONLY | O_NONBLOCK | O_NOFOLLOW | O_CLOEXEC); if (fd < 0) return errno == ENOENT ? 0 : -errno; struct stat status; if (fstat(fd, &status) < 0) { result = -errno; close(fd); return result; } @@ -339,201 +372,413 @@ static int recover_pending(struct update_run *run, struct installer_update_targe return unlink(path) < 0 ? -errno : 0; } +enum update_phase { + PHASE_IDENTIFY, PHASE_MEDIA, PHASE_BOOT_SOURCE, PHASE_BOOT_TARGET, + PHASE_PLAN, PHASE_WRITABLE, PHASE_RECOVER, PHASE_PACKAGES, + PHASE_ROOT_READY, PHASE_BOOT, PHASE_DONE, PHASE_CLEANUP, +}; + +struct update_transaction { + struct installer_update_target target; + struct installer_update_checkpoint checkpoint; + struct installer_update_info expected; + struct update_event event; + char disk[64], root_uuid[37], esp_uuid[37], repository[PATH_MAX]; + int root_index, esp_index, use_indices, applying; + unsigned modes; + enum update_phase phase; + struct update_run *coordinator; +}; + +static int boot_can_resume(const struct update_transaction *transaction); +static volatile sig_atomic_t update_cancelled; +static void request_cancel(int number) { (void)number; update_cancelled = 1; } + +/* The stage's process group borrows the coordinator's mounts. All paths and + * mount flags live in shared memory so a fault cannot erase cleanup state. */ +static int transaction_task(void *context) +{ + struct update_transaction *transaction = context; + struct installer_update_target *target = &transaction->target; + struct update_run run = *transaction->coordinator; + run.observer = NULL; + run.out = &target->info; + run.event = &transaction->event; + /* Keep helper scratch below the owned workspace so a stage killed before + * its shell trap runs cannot leak planning databases into later checks. */ + run.workspace = target->workspace; + struct reliefos_boot_install_options boot = { + .source = UPDATE_ESP, .boot_dir = target->boot, .disk_path = transaction->disk, + .install_bios = ((transaction->applying ? transaction->modes : target->info.boot_modes) & RELIEFOS_BOOT_BIOS) != 0, + .install_uefi = ((transaction->applying ? transaction->modes : target->info.boot_modes) & RELIEFOS_BOOT_UEFI) != 0, + .preserve_rollback = 1, .root_partuuid = target->info.root_uuid, + }; + /* flock belongs to the shared open file description. Helpers inherit it + * across exec so a dead coordinator cannot unlock a surviving writer. */ + if (target->lock_fd >= 0 && fcntl(target->lock_fd, F_SETFD, 0) < 0) return -errno; + int result = 0; + switch (transaction->phase) { + case PHASE_IDENTIFY: + if (transaction->use_indices) { + if (transaction->root_index >= 0) + result = reliefos_block_partition_uuid(transaction->disk, + transaction->root_index, transaction->root_uuid); + if (!result && transaction->esp_index >= 0) + result = reliefos_block_partition_uuid(transaction->disk, + transaction->esp_index, transaction->esp_uuid); + } + if (!result) result = installer_update_target_open(target, transaction->disk, + transaction->root_uuid, transaction->esp_uuid); + if (!result && reliefos_account_legacy_check(target->root) < 0) result = -errno; + break; + case PHASE_MEDIA: + result = check_media(&run, target, transaction->repository); + if (!result) result = installer_update_read_checkpoint(target->root, &transaction->checkpoint); + if (!result && transaction->checkpoint.phase[0] && strcmp(transaction->checkpoint.phase, "done")) { + if (strcmp(transaction->checkpoint.root_uuid, target->info.root_uuid)) result = -EXDEV; + else strcpy(target->info.pending, transaction->checkpoint.phase); + } + if (!result && !boot_can_resume(transaction) && target->info.free_bytes < target->info.required_bytes) + result = -ENOSPC; + if (!result && transaction->applying) { + const struct installer_update_info *expected = &transaction->expected; + if (strcmp(expected->disk, target->info.disk) || strcmp(expected->root_uuid, target->info.root_uuid) || + strcmp(expected->esp_uuid, target->info.esp_uuid) || strcmp(expected->index_sha256, target->info.index_sha256) || + strcmp(expected->database_sha256, target->info.database_sha256) || + strcmp(expected->world_sha256, target->info.world_sha256)) result = -ESTALE; + } + break; + case PHASE_BOOT_SOURCE: + result = reliefos_boot_validate_payload(&boot); + break; + case PHASE_BOOT_TARGET: + if (target->namespaced) result = reliefos_boot_validate_instance(&boot, target->esp); + if (!result) result = reliefos_boot_validate_target(&boot); + break; + case PHASE_PLAN: { + const char *const arguments[] = {"/bin/sh", UPDATE_HELPER, "--check", target->root, transaction->repository, NULL}; + result = command(&run, arguments, NULL, 0); + break; + } + case PHASE_WRITABLE: + result = installer_update_target_writable(target); + break; + case PHASE_RECOVER: + result = recover_pending(&run, target, &transaction->checkpoint); + break; + case PHASE_PACKAGES: { + result = save_checkpoint(target, &transaction->checkpoint, "packages"); + const char *const arguments[] = {"/bin/sh", UPDATE_HELPER, "--apply", target->root, + transaction->repository, target->info.index_sha256, NULL}; + if (!result) result = command(&run, arguments, NULL, 0); + if (result) (void)save_checkpoint(target, &transaction->checkpoint, "packages-failed"); + break; + } + case PHASE_ROOT_READY: + result = package_state(&run, target->root, &target->info); + if (!result) result = sync_root(target->root); + if (!result) result = save_checkpoint(target, &transaction->checkpoint, "root-ready"); + break; + case PHASE_BOOT: + result = save_checkpoint(target, &transaction->checkpoint, "boot"); + if (!result) result = target->namespaced + ? reliefos_boot_install_instance_at_root(&boot, target->root, target->esp) + : reliefos_boot_install_at_root(&boot, target->root); + if (result) (void)save_checkpoint(target, &transaction->checkpoint, "boot-failed"); + break; + case PHASE_DONE: + result = sync_root(target->root); + if (!result) result = save_checkpoint(target, &transaction->checkpoint, "done"); + if (!result) target->info.pending[0] = 0; + break; + case PHASE_CLEANUP: + result = installer_update_target_unmount(target); + break; + } + return result; +} + +static void transaction_pulse(void *context, int stopping_reason) +{ + struct update_transaction *transaction = context; + struct update_run *run = transaction->coordinator; + struct update_event *event = &transaction->event; + unsigned sequence = __atomic_load_n(&event->sequence, __ATOMIC_ACQUIRE); + if (!(sequence & 1u)) { + unsigned progress = event->progress; + struct installer_update_activity activity = event->activity; + char message[sizeof(event->message)]; + memcpy(message, event->message, sizeof(message)); + if (sequence == __atomic_load_n(&event->sequence, __ATOMIC_ACQUIRE) && sequence && message[0]) { + run->activity = activity; + run->out->activity = activity; + if (progress > run->progress) run->progress = progress; + memcpy(run->message, message, sizeof(run->message)); + run->message[sizeof(run->message) - 1] = 0; + run->stage = run->message; + } + } + const char *message = stopping_reason == -ECANCELED ? N_("Stopping update check and cleaning up") + : stopping_reason == -ETIMEDOUT ? N_("Update stage timed out; stopping its processes") + : run->stage; + if (run->observer) run->observer(run->context, run->progress, message); +} + +static int run_phase(struct update_transaction *transaction, enum update_phase phase, + unsigned progress, const char *message, unsigned seconds, int cancelable) +{ + struct update_run *run = transaction->coordinator; + transaction->phase = phase; + memset(&transaction->event, 0, sizeof(transaction->event)); + report(run, progress, message); + int result = installer_update_supervise(transaction_task, transaction, (uint64_t)seconds * 1000, + cancelable ? &update_cancelled : NULL, transaction_pulse, transaction); + transaction_pulse(transaction, 0); + fprintf(stderr, "[installer-update] phase=%u result=%d\n", (unsigned)phase, result); + if (run->log) { + fprintf(run->log, "[installer-update] phase=%u result=%d\n", (unsigned)phase, result); + fflush(run->log); + } + return result; +} + +static int boot_can_resume(const struct update_transaction *transaction) +{ + const struct installer_update_checkpoint *state = &transaction->checkpoint; + const struct installer_update_info *info = &transaction->target.info; + return (!strcmp(state->phase, "root-ready") || !strcmp(state->phase, "boot") || !strcmp(state->phase, "boot-failed")) && + !strcmp(state->root_uuid, info->root_uuid) && !strcmp(state->index_sha256, info->index_sha256) && + !strcmp(state->database_sha256, info->database_sha256) && !strcmp(state->world_sha256, info->world_sha256); +} + +/* One coordinator owns the update lock from discovery through unmount. Every + * blocking stage has a separate process group and hard deadline. Inspection + * never remounts writable and apply never reruns an independent --check. APK + * performs its own signature/solver preflight immediately before committing. */ static int execute(const char *disk, const struct installer_update_info *expected, unsigned modes, - struct installer_update_info *out, installer_update_observer observer, void *context, - const char *root_uuid, const char *esp_uuid) + struct installer_update_info *out, installer_update_observer observer, void *context, + const char *root_uuid, const char *esp_uuid, int use_indices, int root_index, int esp_index) { - struct installer_update_target target; - struct installer_update_checkpoint checkpoint = {0}; - struct update_run run = {.observer = observer, .context = context, .stage = N_("Checking update target"), - .out = out, .applying = expected != NULL}; - int applying = expected != NULL; memset(out, 0, sizeof(*out)); if (geteuid()) { out->error_number = EACCES; strcpy(out->failure, N_("Administrator privileges are required")); return -EACCES; } - int log_fd = open(UPDATE_LOG, O_WRONLY | O_APPEND | O_CREAT | O_NOFOLLOW | O_CLOEXEC, 0600); - if (log_fd >= 0) { - run.log = fdopen(log_fd, "a"); - if (!run.log) { int saved = errno; close(log_fd); errno = saved; } + struct update_transaction *transaction = mmap(NULL, sizeof(*transaction), PROT_READ | PROT_WRITE, + MAP_SHARED | MAP_ANONYMOUS, -1, 0); + if (transaction == MAP_FAILED) { out->error_number = errno; return -errno; } + memset(transaction, 0, sizeof(*transaction)); + struct update_run run = {.observer = observer, .context = context, .stage = N_("Preparing update session"), + .out = out, .applying = expected != NULL}; + transaction->coordinator = &run; + transaction->target.lock_fd = -1; + transaction->applying = expected != NULL; + transaction->modes = modes; + transaction->use_indices = use_indices; + transaction->root_index = root_index; transaction->esp_index = esp_index; + snprintf(transaction->disk, sizeof(transaction->disk), "%s", disk); + if (root_uuid) snprintf(transaction->root_uuid, sizeof(transaction->root_uuid), "%s", root_uuid); + if (esp_uuid) snprintf(transaction->esp_uuid, sizeof(transaction->esp_uuid), "%s", esp_uuid); + if (expected) { + transaction->expected = *expected; + strcpy(transaction->root_uuid, expected->root_uuid); + strcpy(transaction->esp_uuid, expected->esp_uuid); } - if (!run.log) { - out->error_number = errno; - strcpy(out->failure, N_("Writing the update log")); - return -out->error_number; + int log_fd = open(UPDATE_LOG, O_WRONLY | O_APPEND | O_CREAT | O_NOFOLLOW | O_CLOEXEC | O_NONBLOCK, 0600); + struct stat log_status; + int result = 0; + if (log_fd < 0) result = -errno; + else if (fstat(log_fd, &log_status) < 0) result = -errno; + else if (!S_ISREG(log_status.st_mode) || log_status.st_uid || log_status.st_nlink != 1) result = -EINVAL; + if (!result) { + run.log = fdopen(log_fd, "a"); + if (!run.log) result = -errno; } - report(&run, 2, N_("Identifying the installed system")); - int result = installer_update_target_open(&target, disk, expected ? expected->root_uuid : root_uuid, - expected ? expected->esp_uuid : esp_uuid); - if (result) goto done; - if (reliefos_account_legacy_check(target.root) < 0) { result = -errno; goto done; } - char repository[PATH_MAX]; - report(&run, 10, N_("Checking installation media and free space")); - result = check_media(&run, &target, repository); - if (result) goto done; - result = installer_update_read_checkpoint(target.root, &checkpoint); - if (result) goto done; - if (checkpoint.phase[0] && strcmp(checkpoint.phase, "done")) { - if (strcmp(checkpoint.root_uuid, target.info.root_uuid)) { result = -EXDEV; goto done; } - strcpy(target.info.pending, checkpoint.phase); + if (result) { + if (log_fd >= 0) close(log_fd); + strcpy(out->failure, N_("Writing the update log")); out->error_number = -result; + munmap(transaction, sizeof(*transaction)); return result; } - if (expected && (strcmp(expected->disk, target.info.disk) || strcmp(expected->esp_uuid, target.info.esp_uuid) || - strcmp(expected->root_uuid, target.info.root_uuid) || strcmp(expected->index_sha256, target.info.index_sha256) || - strcmp(expected->database_sha256, target.info.database_sha256) || - strcmp(expected->world_sha256, target.info.world_sha256))) { - report(&run, run.progress, N_("Target or media changed. Check the update again.")); - result = -ESTALE; - goto done; + update_cancelled = 0; + struct sigaction action = {.sa_handler = request_cancel}, old_term, old_int, old_hup; + sigemptyset(&action.sa_mask); + sigaction(SIGTERM, &action, &old_term); sigaction(SIGINT, &action, &old_int); sigaction(SIGHUP, &action, &old_hup); + result = installer_update_target_lock(&transaction->target); + if (result) goto finish; +#define PHASE(id, pct, text, limit) do { \ + result = run_phase(transaction, id, pct, text, limit, !transaction->applying); \ + if (result) goto finish; \ +} while (0) + PHASE(PHASE_IDENTIFY, 2, N_("Identifying the installed system"), 120); + PHASE(PHASE_MEDIA, 10, N_("Checking installation media and free space"), 180); + PHASE(PHASE_BOOT_SOURCE, 16, N_("Checking bootloader files on the installation media"), 300); + PHASE(PHASE_BOOT_TARGET, 20, N_("Checking the installed bootloader layout"), 180); + if (!transaction->applying) { + if (!boot_can_resume(transaction)) PHASE(PHASE_PLAN, 24, N_("Verifying signed packages and dependencies"), 900); + goto finish; } - struct reliefos_boot_install_options boot = { - .source = UPDATE_ESP, .boot_dir = target.boot, .disk_path = disk, - .install_bios = ((applying ? modes : target.info.boot_modes) & RELIEFOS_BOOT_BIOS) != 0, - .install_uefi = ((applying ? modes : target.info.boot_modes) & RELIEFOS_BOOT_UEFI) != 0, - .preserve_rollback = 1, .root_partuuid = target.info.root_uuid, - .progress = boot_progress, .progress_context = &run, - }; - report(&run, 16, N_("Checking bootloader compatibility")); - result = target.namespaced ? reliefos_boot_validate_instance(&boot, target.esp) : 0; - if (!result) result = reliefos_boot_validate_payload(&boot); - if (!result) result = reliefos_boot_validate_target(&boot); - if (result) goto done; - report(&run, 22, N_("Verifying signed packages and dependencies")); - const char *const check[] = {"/bin/sh", UPDATE_HELPER, "--check", target.root, repository, NULL}; - result = command(&run, check, NULL, 0); - if (result) goto done; - if (!applying) { report(&run, 100, N_("Update checks completed")); goto done; } - - int resume_boot = (!strcmp(checkpoint.phase, "root-ready") || !strcmp(checkpoint.phase, "boot") || - !strcmp(checkpoint.phase, "boot-failed")) && - !strcmp(checkpoint.root_uuid, target.info.root_uuid) && - !strcmp(checkpoint.index_sha256, target.info.index_sha256) && - !strcmp(checkpoint.database_sha256, target.info.database_sha256) && - !strcmp(checkpoint.world_sha256, target.info.world_sha256); - report(&run, 30, N_("Preparing the installed system for update")); - result = installer_update_target_writable(&target); - if (result) goto done; - result = recover_pending(&run, &target, &checkpoint); - if (result) goto done; + /* Cancellation cannot interrupt a commit. Deadlines still terminate failed + * commands; the durable checkpoint then selects a repair or boot retry. */ + int resume_boot = boot_can_resume(transaction); + PHASE(PHASE_WRITABLE, 30, N_("Preparing the installed system for update"), 120); + PHASE(PHASE_RECOVER, 32, N_("Recovering the previous update attempt"), 300); if (!resume_boot) { - result = save_checkpoint(&target, &checkpoint, "packages"); - if (result) goto done; - report(&run, 38, N_("Applying signed system packages")); - const char *const apply[] = {"/bin/sh", UPDATE_HELPER, "--apply", target.root, repository, target.info.index_sha256, NULL}; - result = command(&run, apply, NULL, 0); - if (result) { (void)save_checkpoint(&target, &checkpoint, "packages-failed"); goto done; } - result = package_state(&run, target.root, &target.info); - if (result) goto done; - report(&run, 78, N_("Synchronizing the updated root filesystem")); - result = sync_root(target.root); - if (!result) result = save_checkpoint(&target, &checkpoint, "root-ready"); - if (result) goto done; + PHASE(PHASE_PACKAGES, 38, N_("Applying signed system packages"), 3600); + PHASE(PHASE_ROOT_READY, 78, N_("Synchronizing the updated root filesystem"), 300); } - report(&run, 86, resume_boot ? N_("Resuming bootloader publication") : N_("Publishing kernel and bootloader files")); - result = save_checkpoint(&target, &checkpoint, "boot"); - if (!result) result = target.namespaced - ? reliefos_boot_install_instance_at_root(&boot, target.root, target.esp) - : reliefos_boot_install_at_root(&boot, target.root); - if (result) { (void)save_checkpoint(&target, &checkpoint, "boot-failed"); goto done; } - result = sync_root(target.root); - if (!result) result = save_checkpoint(&target, &checkpoint, "done"); - if (!result) report(&run, 98, N_("Finishing the system update")); -done: - *out = target.info; + PHASE(PHASE_BOOT, 86, N_("Publishing kernel and bootloader files"), 600); + PHASE(PHASE_DONE, 98, N_("Finishing the system update"), 300); +#undef PHASE +finish: + *out = transaction->target.info; out->activity = run.activity; - int cleanup = installer_update_target_close(&target); - if (!result) result = cleanup; + char failure[128]; + snprintf(failure, sizeof(failure), "%s", run.stage); + /* Cleanup has its own deadline and cannot be cancelled by another click. + * The parent retains its inherited file lock until all writers are reaped. */ + if (transaction->target.lock_fd >= 0) { + int cleanup = run_phase(transaction, PHASE_CLEANUP, run.progress, N_("Closing the update target"), 120, 0); + int unlock = installer_update_target_unlock(&transaction->target); + if (!result) { result = cleanup ? cleanup : unlock; if (result) snprintf(failure, sizeof(failure), "%s", run.stage); } + if (cleanup) fprintf(stderr, "[installer-update] cleanup failed: %s (%d)\n", strerror(-cleanup), cleanup); + } if (result) { out->error_number = -result; - snprintf(out->failure, sizeof(out->failure), "%s", run.stage); - fprintf(stderr, "[installer-update] %s failed with %s (%d)\n", run.stage, strerror(-result), result); - if (run.log) fprintf(run.log, "[installer-update] %s failed with %s (%d)\n", run.stage, strerror(-result), result); - char detail[768]; - if (!installer_update_activity_format(&out->activity, detail, sizeof(detail)) && *detail) { - fprintf(stderr, "[installer-update] %s\n", detail); - if (run.log) fprintf(run.log, "[installer-update] %s\n", detail); - } - } else if (applying) report(&run, 100, N_("System update completed successfully")); - if (run.log && fclose(run.log) && !result) { - result = -errno; - out->error_number = -result; - strcpy(out->failure, N_("Writing the update log")); - } + snprintf(out->failure, sizeof(out->failure), "%s", result == -ECANCELED ? N_("Update check cancelled") : failure); + fprintf(stderr, "[installer-update] %s: %s (%d)\n", out->failure, strerror(-result), result); + fprintf(run.log, "[installer-update] %s: %s (%d)\n", out->failure, strerror(-result), result); + } else report(&run, 100, transaction->applying ? N_("System update completed successfully") : N_("Update checks completed")); + if (fclose(run.log) && !result) { result = -errno; out->error_number = -result; strcpy(out->failure, N_("Writing the update log")); } + sigaction(SIGTERM, &old_term, NULL); sigaction(SIGINT, &old_int, NULL); sigaction(SIGHUP, &old_hup, NULL); + munmap(transaction, sizeof(*transaction)); return result; } int installer_update_check(const char *disk, struct installer_update_info *info, - installer_update_observer observer, void *context) + installer_update_observer observer, void *context) { - if (!disk || !info) { - if (info) { memset(info, 0, sizeof(*info)); info->error_number = EINVAL; } - return -EINVAL; - } - return execute(disk, NULL, 0, info, observer, context, NULL, NULL); + return installer_update_check_target(disk, NULL, NULL, info, observer, context); } int installer_update_check_target(const char *disk, const char *root_uuid, const char *esp_uuid, - struct installer_update_info *info, - installer_update_observer observer, void *context) + struct installer_update_info *info, installer_update_observer observer, void *context) +{ + if (!disk || !info || strlen(disk) >= sizeof(info->disk) || + (root_uuid && *root_uuid && strlen(root_uuid) != 36) || (esp_uuid && *esp_uuid && strlen(esp_uuid) != 36)) return -EINVAL; + return execute(disk, NULL, 0, info, observer, context, root_uuid, esp_uuid, 0, -1, -1); +} + +int installer_update_check_indices(const char *disk, int root_index, int esp_index, + struct installer_update_info *info, installer_update_observer observer, void *context) { - if (!disk || !info || (root_uuid && *root_uuid && strlen(root_uuid) != 36) || - (esp_uuid && *esp_uuid && strlen(esp_uuid) != 36)) return -EINVAL; - return execute(disk, NULL, 0, info, observer, context, root_uuid, esp_uuid); + if (!disk || !info || strlen(disk) >= sizeof(info->disk) || root_index < -1 || esp_index < -1) return -EINVAL; + return execute(disk, NULL, 0, info, observer, context, NULL, NULL, 1, root_index, esp_index); } int installer_update_apply(const struct installer_update_info *expected, unsigned modes, - struct installer_update_info *result, - installer_update_observer observer, void *context) + struct installer_update_info *result, installer_update_observer observer, void *context) { if (!expected || !result || !expected->root_uuid[0] || !expected->esp_uuid[0] || - strlen(expected->index_sha256) != 64 || strlen(expected->database_sha256) != 64 || - strlen(expected->world_sha256) != 64 || modes > 3) { + !memchr(expected->disk, 0, sizeof(expected->disk)) || + strnlen(expected->root_uuid, sizeof(expected->root_uuid)) != 36 || + strnlen(expected->esp_uuid, sizeof(expected->esp_uuid)) != 36 || + strnlen(expected->index_sha256, sizeof(expected->index_sha256)) != 64 || + strnlen(expected->database_sha256, sizeof(expected->database_sha256)) != 64 || + strnlen(expected->world_sha256, sizeof(expected->world_sha256)) != 64 || modes > 3) { if (result) { memset(result, 0, sizeof(*result)); result->error_number = EINVAL; } return -EINVAL; } - return execute(expected->disk, expected, modes, result, observer, context, NULL, NULL); + /* Copy before zeroing result: callers may reuse the inspected structure. */ + struct installer_update_info inspected = *expected; + return execute(inspected.disk, &inspected, modes, result, observer, context, NULL, NULL, 0, -1, -1); +} + + +/* Telemetry is dispensable; final metadata is not. A stalled reader can never + * hold the storage lock: writes are atomic bounded lines with a finite drain. */ +static int worker_line(int final, const char *format, ...) +{ + char line[512]; + va_list arguments; + va_start(arguments, format); + int size = vsnprintf(line, sizeof(line), format, arguments); + va_end(arguments); + if (size < 0 || (size_t)size >= sizeof(line)) return -EOVERFLOW; + for (unsigned retries = 0; ; ++retries) { + ssize_t count = write(STDOUT_FILENO, line, (size_t)size); + if (count == size) return 0; + if (count < 0 && errno == EINTR) continue; + if (count < 0 && (errno == EAGAIN || errno == EWOULDBLOCK) && final && retries < 20) { + struct pollfd descriptor = {.fd = STDOUT_FILENO, .events = POLLOUT}; + (void)poll(&descriptor, 1, 100); + continue; + } + return count < 0 ? -errno : -EIO; + } } static void worker_progress(void *context, unsigned progress, const char *message) { - printf("progress\t%u\t%s\n", progress, message); + (void)worker_line(0, "progress\t%u\t%s\n", progress, message); const struct installer_update_info *info = context; char activity[512]; if (info && info->activity.step && !installer_update_activity_encode(&info->activity, activity, sizeof(activity))) - puts(activity); - fflush(stdout); + (void)worker_line(0, "%s\n", activity); } -static void worker_info(const struct installer_update_info *info) +static int worker_info(const struct installer_update_info *info) { -#define FIELD(name) printf("info\t%s\t%s\n", #name, info->name) + int result = 0; +#define FIELD(name) if (!result) result = worker_line(1, "info\t%s\t%s\n", #name, info->name) FIELD(disk); FIELD(root_device); FIELD(esp_device); FIELD(root_uuid); FIELD(esp_uuid); FIELD(boot_file); FIELD(installed_version); FIELD(media_version); FIELD(profile); FIELD(installed_kernel); FIELD(media_kernel); FIELD(index_sha256); FIELD(database_sha256); FIELD(world_sha256); FIELD(pending); #undef FIELD - printf("info\tfree_bytes\t%llu\ninfo\trequired_bytes\t%llu\ninfo\tboot_modes\t%u\n", - (unsigned long long)info->free_bytes, (unsigned long long)info->required_bytes, info->boot_modes); + if (!result) result = worker_line(1, "info\tfree_bytes\t%llu\ninfo\trequired_bytes\t%llu\ninfo\tboot_modes\t%u\n", + (unsigned long long)info->free_bytes, (unsigned long long)info->required_bytes, info->boot_modes); + return result; +} + +static int worker_index(const char *text, int *value) +{ + char *end; + errno = 0; + long number = strtol(text, &end, 10); + if (errno || !*text || *end || number < -1 || number > INT_MAX) return -EINVAL; + *value = (int)number; + return 0; } int installer_update_worker(int argc, char **argv) { struct installer_update_info info = {0}; - int result; + int result = -EINVAL; setenv("PATH", "/usr/sbin:/usr/bin:/sbin:/bin", 1); + signal(SIGPIPE, SIG_IGN); + int flags = fcntl(STDOUT_FILENO, F_GETFL); + if (flags < 0 || fcntl(STDOUT_FILENO, F_SETFL, flags | O_NONBLOCK) < 0) return 1; if (argc == 4 && !strcmp(argv[2], "check")) { result = installer_update_check(argv[3], &info, worker_progress, &info); } else if (argc == 6 && !strcmp(argv[2], "check")) { result = installer_update_check_target(argv[3], argv[4], argv[5], &info, worker_progress, &info); + } else if (argc == 6 && !strcmp(argv[2], "check-index")) { + int root, esp; + result = worker_index(argv[4], &root); + if (!result) result = worker_index(argv[5], &esp); + if (!result) result = installer_update_check_indices(argv[3], root, esp, &info, worker_progress, &info); } else if (argc == 10 && !strcmp(argv[2], "apply")) { struct installer_update_info expected = {0}; - if (strlen(argv[3]) >= sizeof(expected.disk) || strlen(argv[4]) != 36 || strlen(argv[5]) != 36 || - strlen(argv[6]) != 64 || strlen(argv[7]) != 64 || strlen(argv[8]) != 64 || - strlen(argv[9]) != 1 || *argv[9] < '0' || *argv[9] > '3') return 2; - strcpy(expected.disk, argv[3]); strcpy(expected.root_uuid, argv[4]); strcpy(expected.esp_uuid, argv[5]); - strcpy(expected.index_sha256, argv[6]); strcpy(expected.database_sha256, argv[7]); - strcpy(expected.world_sha256, argv[8]); - result = installer_update_apply(&expected, (unsigned)(*argv[9] - '0'), &info, worker_progress, &info); - } else return 2; - worker_info(&info); - if (result) printf("error\t%d\t%s\n", -result, info.failure[0] ? info.failure : N_("Update worker failed")); - fflush(stdout); - return result ? 1 : 0; + if (strlen(argv[3]) < sizeof(expected.disk) && strlen(argv[4]) == 36 && strlen(argv[5]) == 36 && + strlen(argv[6]) == 64 && strlen(argv[7]) == 64 && strlen(argv[8]) == 64 && + strlen(argv[9]) == 1 && *argv[9] >= '0' && *argv[9] <= '3') { + strcpy(expected.disk, argv[3]); strcpy(expected.root_uuid, argv[4]); strcpy(expected.esp_uuid, argv[5]); + strcpy(expected.index_sha256, argv[6]); strcpy(expected.database_sha256, argv[7]); + strcpy(expected.world_sha256, argv[8]); + result = installer_update_apply(&expected, (unsigned)(*argv[9] - '0'), &info, worker_progress, &info); + } + } + int output = worker_info(&info); + if (result && !output) output = worker_line(1, "error\t%d\t%s\n", -result, + info.failure[0] ? info.failure : N_("Update worker failed")); + if (!output) output = worker_line(1, "result\t%d\t%s\n", result ? -result : 0, + result ? N_("Update worker failed") : N_("Update session completed")); + return result || output ? 1 : 0; } diff --git a/userland/apps/installer/installer_update_internal.h b/userland/apps/installer/installer_update_internal.h index 68b5b619..7f7f0502 100644 --- a/userland/apps/installer/installer_update_internal.h +++ b/userland/apps/installer/installer_update_internal.h @@ -9,10 +9,15 @@ struct installer_update_target { int lock_fd, root_mounted, boot_mounted, esp_mounted, namespaced; }; -/* Only the worker owns these mounts and the advisory installer lock. */ +/* The coordinator and all active descendants share the advisory file lock. + * The target lives in shared memory so the coordinator can recover mounts after + * a stage exits before publishing its mount flags. */ +int installer_update_target_lock(struct installer_update_target *target); int installer_update_target_open(struct installer_update_target *target, const char *disk, const char *expected_root, const char *expected_esp); int installer_update_target_writable(struct installer_update_target *target); +int installer_update_target_unmount(struct installer_update_target *target); +int installer_update_target_unlock(struct installer_update_target *target); int installer_update_target_close(struct installer_update_target *target); #endif diff --git a/userland/apps/installer/installer_update_journal.c b/userland/apps/installer/installer_update_journal.c index d47004eb..56e247aa 100644 --- a/userland/apps/installer/installer_update_journal.c +++ b/userland/apps/installer/installer_update_journal.c @@ -3,13 +3,14 @@ #include #include -#include #include #include #include #include #include +#define CHECKPOINT_MAX 1024 + static int state_directory(const char *root, int create) { static const char *const components[] = {"var", "lib", "reliefos", "installer-update"}; @@ -33,42 +34,75 @@ static int state_directory(const char *root, int create) return fd; } -static int valid_field(const char *text, size_t capacity) +static int phase_valid(const char *phase) { - return memchr(text, 0, capacity) && text[0] && - strspn(text, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_") == strlen(text); + static const char *const phases[] = { + "packages", "packages-failed", "root-ready", "boot", "boot-failed", "done", + }; + for (size_t i = 0; i < sizeof(phases) / sizeof(phases[0]); ++i) + if (!strcmp(phase, phases[i])) return 1; + return 0; +} + +static int digest_valid(const char *digest) +{ + return strnlen(digest, 65) == 64 && strspn(digest, "0123456789abcdef") == 64; +} + +static int uuid_valid(const char *uuid) +{ + if (strnlen(uuid, 37) != 36) return 0; + unsigned nonzero = 0; + for (unsigned i = 0; i < 36; ++i) { + if (i == 8 || i == 13 || i == 18 || i == 23) { + if (uuid[i] != '-') return 0; + } else { + if (!strchr("0123456789abcdef", uuid[i])) return 0; + nonzero |= uuid[i] != '0'; + } + } + return nonzero != 0; } +static int checkpoint_valid(const struct installer_update_checkpoint *state) +{ + return memchr(state->phase, 0, sizeof(state->phase)) && phase_valid(state->phase) && + uuid_valid(state->root_uuid) && digest_valid(state->index_sha256) && + digest_valid(state->database_sha256) && digest_valid(state->world_sha256); +} + +/** @brief Publish a durable checkpoint relative to its held directory. + * The new record becomes visible only after its contents are fsynced. A + * directory fsync after rename makes that publication survive a power loss. + */ int installer_update_write_checkpoint(const char *root, const struct installer_update_checkpoint *state) { - if (!root || !state || !valid_field(state->phase, sizeof(state->phase)) || - !valid_field(state->root_uuid, sizeof(state->root_uuid)) || - !valid_field(state->index_sha256, sizeof(state->index_sha256)) || - !valid_field(state->database_sha256, sizeof(state->database_sha256)) || - !valid_field(state->world_sha256, sizeof(state->world_sha256))) return -EINVAL; + if (!root || !state || !checkpoint_valid(state)) return -EINVAL; + char record[CHECKPOINT_MAX]; + int length = snprintf(record, sizeof(record), + "format=1\nphase=%s\nroot_uuid=%s\nindex_sha256=%s\ndatabase_sha256=%s\nworld_sha256=%s\n", + state->phase, state->root_uuid, state->index_sha256, state->database_sha256, state->world_sha256); + if (length < 0 || (size_t)length >= sizeof(record)) return -EOVERFLOW; int directory = state_directory(root, 1); if (directory < 0) return directory; - char path[PATH_MAX]; - int length = snprintf(path, sizeof(path), "%s/var/lib/reliefos/installer-update/.state-XXXXXX", root); - if (length < 0 || (size_t)length >= sizeof(path)) { close(directory); return -ENAMETOOLONG; } - int fd = mkstemp(path); + char temporary[64]; + int fd = -1; + for (unsigned attempt = 0; attempt < 128; ++attempt) { + snprintf(temporary, sizeof(temporary), ".state-%ld-%u", (long)getpid(), attempt); + fd = openat(directory, temporary, O_WRONLY | O_CREAT | O_EXCL | O_NOFOLLOW | O_CLOEXEC, 0600); + if (fd >= 0 || errno != EEXIST) break; + } if (fd < 0) { int result = -errno; close(directory); return result; } - const char *temporary = strrchr(path, '/') + 1; - if (fcntl(fd, F_SETFD, FD_CLOEXEC) < 0) { - int result = -errno; - close(fd); - (void)unlinkat(directory, temporary, 0); - close(directory); - return result; + int result = 0; + size_t used = 0; + while (used < (size_t)length) { + ssize_t count = write(fd, record + used, (size_t)length - used); + if (count < 0 && errno == EINTR) continue; + if (count <= 0) { result = count < 0 ? -errno : -EIO; break; } + used += (size_t)count; } - FILE *stream = fdopen(fd, "w"); - int result = stream ? 0 : -errno; - if (stream) { - if (fprintf(stream, "format=1\nphase=%s\nroot_uuid=%s\nindex_sha256=%s\ndatabase_sha256=%s\nworld_sha256=%s\n", - state->phase, state->root_uuid, state->index_sha256, state->database_sha256, state->world_sha256) < 0 || - fflush(stream) || fsync(fd)) result = -errno; - if (fclose(stream) && !result) result = -errno; - } else close(fd); + if (!result && fsync(fd) < 0) result = -errno; + if (close(fd) < 0 && !result) result = -errno; if (!result && renameat(directory, temporary, directory, "state") < 0) result = -errno; if (!result && fsync(directory) < 0) result = -errno; if (result) (void)unlinkat(directory, temporary, 0); @@ -83,38 +117,53 @@ int installer_update_read_checkpoint(const char *root, struct installer_update_c int directory = state_directory(root, 0); if (directory == -ENOENT) return 0; if (directory < 0) return directory; - int fd = openat(directory, "state", O_RDONLY | O_NOFOLLOW | O_CLOEXEC); + int fd = openat(directory, "state", O_RDONLY | O_NONBLOCK | O_NOFOLLOW | O_CLOEXEC); int result = fd < 0 ? -errno : 0; close(directory); if (result) return result == -ENOENT ? 0 : result; - FILE *stream = fdopen(fd, "r"); - if (!stream) { result = -errno; close(fd); return result; } - char line[160]; + struct stat status; + if (fstat(fd, &status) < 0) result = -errno; + else if (!S_ISREG(status.st_mode) || status.st_size <= 0) result = -EINVAL; + else if (status.st_size > CHECKPOINT_MAX) result = -EOVERFLOW; + char record[CHECKPOINT_MAX + 1]; + size_t used = 0; + while (!result && used < sizeof(record)) { + ssize_t count = read(fd, record + used, sizeof(record) - used); + if (count < 0 && errno == EINTR) continue; + if (count < 0) { result = -errno; break; } + if (!count) break; + used += (size_t)count; + } + if (close(fd) < 0 && !result) result = -errno; + if (!result && (used > CHECKPOINT_MAX || memchr(record, 0, used))) result = -EINVAL; + if (result) return result; + record[used] = 0; + struct installer_update_checkpoint candidate = {0}; unsigned fields = 0; - while (fgets(line, sizeof(line), stream)) { - if (!strchr(line, '\n')) { result = -EINVAL; break; } - line[strcspn(line, "\n")] = 0; + char *line = record; + while (*line) { + char *end = strchr(line, '\n'); + if (!end) return -EINVAL; + *end = 0; char *value = strchr(line, '='); - if (!value) { result = -EINVAL; break; } + if (!value) return -EINVAL; *value++ = 0; char *out = NULL; size_t capacity = 0; unsigned bit = 0; if (!strcmp(line, "format") && !strcmp(value, "1")) bit = 1; - else if (!strcmp(line, "phase")) { out = state->phase; capacity = sizeof(state->phase); bit = 2; } - else if (!strcmp(line, "root_uuid")) { out = state->root_uuid; capacity = sizeof(state->root_uuid); bit = 4; } - else if (!strcmp(line, "index_sha256")) { out = state->index_sha256; capacity = sizeof(state->index_sha256); bit = 8; } - else if (!strcmp(line, "database_sha256")) { out = state->database_sha256; capacity = sizeof(state->database_sha256); bit = 16; } - else if (!strcmp(line, "world_sha256")) { out = state->world_sha256; capacity = sizeof(state->world_sha256); bit = 32; } - else { result = -EINVAL; break; } - if ((fields & bit) || (out && (strlen(value) >= capacity || !valid_field(value, strlen(value) + 1)))) { - result = -EINVAL; - break; - } + else if (!strcmp(line, "phase")) { out = candidate.phase; capacity = sizeof(candidate.phase); bit = 2; } + else if (!strcmp(line, "root_uuid")) { out = candidate.root_uuid; capacity = sizeof(candidate.root_uuid); bit = 4; } + else if (!strcmp(line, "index_sha256")) { out = candidate.index_sha256; capacity = sizeof(candidate.index_sha256); bit = 8; } + else if (!strcmp(line, "database_sha256")) { out = candidate.database_sha256; capacity = sizeof(candidate.database_sha256); bit = 16; } + else if (!strcmp(line, "world_sha256")) { out = candidate.world_sha256; capacity = sizeof(candidate.world_sha256); bit = 32; } + else return -EINVAL; + if ((fields & bit) || (out && strlen(value) >= capacity)) return -EINVAL; if (out) strcpy(out, value); fields |= bit; + line = end + 1; } - if (!result && (fields != 63 || ferror(stream))) result = -EINVAL; - if (fclose(stream) && !result) result = -errno; - return result; + if (fields != 63 || !checkpoint_valid(&candidate)) return -EINVAL; + *state = candidate; + return 0; } diff --git a/userland/apps/installer/installer_update_model.c b/userland/apps/installer/installer_update_model.c index 2b0d482e..06eef9e6 100644 --- a/userland/apps/installer/installer_update_model.c +++ b/userland/apps/installer/installer_update_model.c @@ -10,6 +10,62 @@ #include #include +#define SYSTEM_METADATA_MAX (64u * 1024u) +#define PACKAGE_DATABASE_MAX (64u * 1024u * 1024u) +#define PACKAGE_COUNT_MAX 8192u + +/* Walk each ancestor through a held directory. O_NONBLOCK makes a replaced + * FIFO/device rejectable by fstat instead of hanging before type validation. */ +static int open_metadata(const char *root, const char *relative, off_t maximum) +{ + char path[PATH_MAX]; + if (!root || !relative || !*relative || *relative == '/' || strlen(relative) >= sizeof(path)) + return -EINVAL; + strcpy(path, relative); + int parent = open(root, O_RDONLY | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC); + if (parent < 0) return -errno; + char *state, *part = strtok_r(path, "/", &state); + while (part) { + if (!strcmp(part, ".") || !strcmp(part, "..")) { close(parent); return -EINVAL; } + char *next = strtok_r(NULL, "/", &state); + int fd = openat(parent, part, O_RDONLY | O_NONBLOCK | O_NOFOLLOW | O_CLOEXEC | + (next ? O_DIRECTORY : 0)); + int error = errno; + close(parent); + if (fd < 0) return -error; + if (!next) { + struct stat status; + int result = fstat(fd, &status) < 0 ? -errno : + !S_ISREG(status.st_mode) || status.st_size < 0 ? -EINVAL : + status.st_size > maximum ? -EOVERFLOW : 0; + if (result) { close(fd); return result; } + return fd; + } + parent = fd; + part = next; + } + close(parent); + return -EINVAL; +} + +static int metadata_line(FILE *stream, char *line, size_t capacity, size_t *remaining) +{ + size_t used = 0; + for (;;) { + int byte = fgetc(stream); + if (byte == EOF) { + if (ferror(stream)) return errno ? -errno : -EIO; + line[used] = 0; + return used != 0; + } + if (!*remaining || used + 1 >= capacity) return -EOVERFLOW; + --*remaining; + if (!byte) return -EINVAL; + line[used++] = (char)byte; + if (byte == '\n') { line[used] = 0; return 1; } + } +} + static int join_path(char *path, size_t capacity, const char *root, const char *relative) { int length = snprintf(path, capacity, "%s/%s", root, relative); @@ -68,8 +124,10 @@ static FILE *open_release(const char *root) result = join_path(path, sizeof(path), root, "usr/lib/os-release"); if (result) { errno = -result; return NULL; } } - int fd = open(path, O_RDONLY | O_NOFOLLOW | O_CLOEXEC); - if (fd < 0) return NULL; + const char *relative = path + strlen(root); + while (*relative == '/') ++relative; + int fd = open_metadata(root, relative, SYSTEM_METADATA_MAX); + if (fd < 0) { errno = -fd; return NULL; } FILE *stream = fdopen(fd, "r"); if (!stream) { int saved = errno; close(fd); errno = saved; } return stream; @@ -104,32 +162,34 @@ int installer_update_read_system(const char *root, struct installer_update_info if (!stream) return -errno; int result = 0; info->installed_version[0] = 0; - while (fgets(line, sizeof(line), stream)) { - if (!strchr(line, '\n') && !feof(stream)) { result = -EOVERFLOW; break; } + size_t remaining = SYSTEM_METADATA_MAX; + unsigned fields = 0; + int got; + while ((got = metadata_line(stream, line, sizeof(line), &remaining)) > 0) { line[strcspn(line, "\r\n")] = 0; char *value = strchr(line, '='); if (!value) continue; *value++ = 0; if (strcmp(line, "ID") && strcmp(line, "VERSION_ID")) continue; + unsigned bit = !strcmp(line, "ID") ? 1 : 2; + if (fields & bit) { result = -EINVAL; break; } + fields |= bit; result = unquote(value); if (!result) result = !strcmp(line, "ID") ? copy_field(id, sizeof(id), value) : copy_field(info->installed_version, sizeof(info->installed_version), value); if (result) break; } + if (got < 0 && !result) result = got; if (ferror(stream) && !result) result = -EIO; if (fclose(stream) && !result) result = -errno; if (result) return result; if (strcmp(id, "reliefos") && strcmp(id, "leonos")) return -ENODEV; if (!info->installed_version[0]) return -EINVAL; - if (join_path(path, sizeof(path), root, "etc/reliefos/desktop-backend")) return -ENAMETOOLONG; - int fd = open(path, O_RDONLY | O_CLOEXEC | O_NOFOLLOW); - if (fd < 0 && errno == ENOENT) { - if (join_path(path, sizeof(path), root, "etc/leonos/desktop-backend")) return -ENAMETOOLONG; - fd = open(path, O_RDONLY | O_CLOEXEC | O_NOFOLLOW); - } + int fd = open_metadata(root, "etc/reliefos/desktop-backend", sizeof(line) - 1); + if (fd == -ENOENT) fd = open_metadata(root, "etc/leonos/desktop-backend", sizeof(line) - 1); if (fd < 0) { - if (errno != ENOENT) return -errno; + if (fd != -ENOENT) return fd; strcpy(info->profile, "xorg"); return 0; } @@ -160,19 +220,73 @@ int installer_update_read_media(const char *root, const char *profile, struct in const char *const metadata[] = {"etc/apk/world", "lib/apk/db/installed", "usr/share/reliefos/apk/repository/packages.adb"}; for (size_t i = 0; i < sizeof(metadata) / sizeof(metadata[0]); ++i) { - char path[PATH_MAX]; + int fd = open_metadata(root, metadata[i], PACKAGE_DATABASE_MAX); + if (fd < 0) return fd; struct stat status; - result = join_path(path, sizeof(path), root, metadata[i]); + result = fstat(fd, &status) < 0 ? -errno : status.st_size <= 0 ? -EINVAL : 0; + if (close(fd) < 0 && !result) result = -errno; if (result) return result; - if (lstat(path, &status) < 0) return -errno; - if (!S_ISREG(status.st_mode) || status.st_size <= 0) return -EINVAL; } return 0; } -static int package_record(struct installer_update_packages *out, const char *name, - const char *version, uint64_t bytes) +typedef int (*package_visitor)(void *, const char *, const char *, uint64_t); + +static int finish_package(package_visitor visitor, void *context, const char *name, + const char *version, uint64_t bytes, unsigned fields, + unsigned *count) +{ + if (!fields) return 0; + if (fields != 15 || !*name || !*version || + strspn(name, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+_.-") != strlen(name) || + !strcmp(name, ".") || !strcmp(name, "..")) return -EINVAL; + if (*count == PACKAGE_COUNT_MAX) return -EOVERFLOW; + ++*count; + return visitor(context, name, version, bytes); +} + +/* One scanner validates the bounded text database for both profile discovery + * and space estimates. An incomplete or duplicate scalar must not silently + * replace a name/size used by the estimate. */ +static int walk_packages(const char *root, package_visitor visitor, void *context) { + char line[8192], name[128] = "", version[96] = ""; + uint64_t bytes = 0; + unsigned fields = 0, count = 0; + int fd = open_metadata(root, "lib/apk/db/installed", PACKAGE_DATABASE_MAX); + if (fd < 0) return fd; + FILE *stream = fdopen(fd, "r"); + if (!stream) { int result = -errno; close(fd); return result; } + size_t remaining = PACKAGE_DATABASE_MAX; + int got, result = 0; + while ((got = metadata_line(stream, line, sizeof(line), &remaining)) > 0) { + line[strcspn(line, "\r\n")] = 0; + if (!line[0]) { + result = finish_package(visitor, context, name, version, bytes, fields, &count); + name[0] = version[0] = 0; + bytes = 0; + fields = 0; + } else { + unsigned field = !strncmp(line, "P:", 2) ? 1u : + !strncmp(line, "V:", 2) ? 2u : !strncmp(line, "I:", 2) ? 4u : 0; + if (field && (fields & field)) { result = -EINVAL; break; } + fields |= field | 8u; + if (field == 1) result = copy_field(name, sizeof(name), line + 2); + else if (field == 2) result = copy_field(version, sizeof(version), line + 2); + else if (field == 4) result = parse_number(line + 2, &bytes); + } + if (result) break; + } + if (got < 0 && !result) result = got; + if (!result) result = ferror(stream) ? -EIO : + finish_package(visitor, context, name, version, bytes, fields, &count); + if (fclose(stream) && !result) result = -errno; + return result; +} + +static int package_record(void *context, const char *name, const char *version, uint64_t bytes) +{ + struct installer_update_packages *out = context; if (!strcmp(name, "xfce4-session")) out->has_xfce_session = 1; if (strncmp(name, "reliefos-", 9) && strncmp(name, "leonos-", 7)) return 0; if (UINT64_MAX - out->installed_bytes < bytes) return -EOVERFLOW; @@ -185,30 +299,72 @@ static int package_record(struct installer_update_packages *out, const char *nam int installer_update_read_packages(const char *root, struct installer_update_packages *out) { - char path[PATH_MAX], line[8192], name[128] = "", version[96] = ""; - uint64_t bytes = 0; if (!root || !out) return -EINVAL; memset(out, 0, sizeof(*out)); - int result = join_path(path, sizeof(path), root, "lib/apk/db/installed"); + return walk_packages(root, package_record, out); +} + +struct package_size { char name[128]; uint64_t bytes; }; +struct package_sizes { struct package_size *items; size_t count, capacity; }; + +static int collect_size(void *context, const char *name, const char *version, uint64_t bytes) +{ + (void)version; + struct package_sizes *table = context; + if (table->count == table->capacity) { + size_t capacity = table->capacity ? table->capacity * 2 : 64; + if (capacity > PACKAGE_COUNT_MAX) capacity = PACKAGE_COUNT_MAX; + if (capacity <= table->count || capacity > SIZE_MAX / sizeof(*table->items)) return -EOVERFLOW; + struct package_size *items = realloc(table->items, capacity * sizeof(*items)); + if (!items) return -ENOMEM; + table->items = items; + table->capacity = capacity; + } + struct package_size *item = &table->items[table->count++]; + strcpy(item->name, name); + item->bytes = bytes; + return 0; +} + +static int compare_size(const void *left, const void *right) +{ + const struct package_size *a = left, *b = right; + return strcmp(a->name, b->name); +} + +static int read_sizes(const char *root, struct package_sizes *table) +{ + int result = walk_packages(root, collect_size, table); if (result) return result; - int fd = open(path, O_RDONLY | O_NOFOLLOW | O_CLOEXEC); - if (fd < 0) return -errno; - FILE *stream = fdopen(fd, "r"); - if (!stream) { result = -errno; close(fd); return result; } - while (fgets(line, sizeof(line), stream)) { - if (!strchr(line, '\n') && !feof(stream)) { result = -EOVERFLOW; break; } - line[strcspn(line, "\r\n")] = 0; - if (!line[0]) { - result = package_record(out, name, version, bytes); - name[0] = version[0] = 0; - bytes = 0; - } else if (!strncmp(line, "P:", 2)) result = copy_field(name, sizeof(name), line + 2); - else if (!strncmp(line, "V:", 2)) result = copy_field(version, sizeof(version), line + 2); - else if (!strncmp(line, "I:", 2)) result = parse_number(line + 2, &bytes); - if (result) break; + if (table->count) qsort(table->items, table->count, sizeof(*table->items), compare_size); + for (size_t i = 1; i < table->count; ++i) + if (!strcmp(table->items[i - 1].name, table->items[i].name)) return -EINVAL; + return 0; +} + +int installer_update_measure_growth(const char *installed_root, const char *media_root, + uint64_t *growth, uint64_t *largest) +{ + if (!growth || !largest) return -EINVAL; + *growth = *largest = 0; + if (growth == largest || !installed_root || !media_root) return -EINVAL; + struct package_sizes installed = {0}, incoming = {0}; + int result = read_sizes(installed_root, &installed); + if (!result) result = read_sizes(media_root, &incoming); + uint64_t needed = 0, peak = 0; + for (size_t i = 0, old = 0; !result && i < incoming.count; ++i) { + const struct package_size *package = &incoming.items[i]; + while (old < installed.count && strcmp(installed.items[old].name, package->name) < 0) ++old; + uint64_t previous = old < installed.count && !strcmp(installed.items[old].name, package->name) + ? installed.items[old].bytes : 0; + uint64_t added = package->bytes > previous ? package->bytes - previous : 0; + if (UINT64_MAX - needed < added) result = -EOVERFLOW; + else needed += added; + if (peak < package->bytes) peak = package->bytes; } - if (!result) result = ferror(stream) ? -EIO : package_record(out, name, version, bytes); - if (fclose(stream) && !result) result = -errno; + free(installed.items); + free(incoming.items); + if (!result) { *growth = needed; *largest = peak; } return result; } diff --git a/userland/apps/installer/installer_update_protocol.c b/userland/apps/installer/installer_update_protocol.c new file mode 100644 index 00000000..8047a491 --- /dev/null +++ b/userland/apps/installer/installer_update_protocol.c @@ -0,0 +1,99 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +#include "installer_update.h" +#include +#include +#include + +static const char *const metadata[] = { + "disk", "root_device", "esp_device", "root_uuid", "esp_uuid", "boot_file", + "installed_version", "media_version", "profile", "installed_kernel", + "media_kernel", "index_sha256", "database_sha256", "world_sha256", "pending", + "free_bytes", "required_bytes", "boot_modes", +}; +#define ALL_METADATA ((UINT32_C(1) << (sizeof(metadata) / sizeof(metadata[0]))) - 1) + +static int uuid_valid(const char *text) +{ + if (strlen(text) != 36) return 0; + for (unsigned i = 0; i < 36; ++i) { + if (i == 8 || i == 13 || i == 18 || i == 23) { + if (text[i] != '-') return 0; + } else if (!strchr("0123456789abcdefABCDEF", text[i])) return 0; + } + return 1; +} + +static int digest_valid(const char *text) +{ + return strlen(text) == 64 && strspn(text, "0123456789abcdef") == 64; +} + +static int snapshot_valid(const struct installer_update_info *info) +{ + return !strncmp(info->disk, "/dev/", 5) && info->disk[5] && + !strncmp(info->root_device, "/dev/", 5) && info->root_device[5] && + !strncmp(info->esp_device, "/dev/", 5) && info->esp_device[5] && + uuid_valid(info->root_uuid) && uuid_valid(info->esp_uuid) && + digest_valid(info->index_sha256) && digest_valid(info->database_sha256) && + digest_valid(info->world_sha256) && *info->installed_version && *info->media_version && + (!strcmp(info->profile, "xorg") || !strcmp(info->profile, "console")) && info->boot_modes <= 3; +} + +int installer_update_session_line(struct installer_update_session *session, + struct installer_update_info *info, unsigned *progress, + char *message, size_t capacity, const char *line) +{ + if (!session || !info || !progress || !message || !capacity || !line) return -EINVAL; + if (session->error) return -EPROTO; + int result = -EPROTO; + if (session->terminal || strlen(line) >= 512 || strpbrk(line, "\r\n")) goto invalid; + if (!strncmp(line, "result\t", 7)) { + const char *value = line + 7; + if (*value < '0' || *value > '9') goto invalid; + char *end; + errno = 0; + unsigned long number = strtoul(value, &end, 10); + if (errno || number > 4095 || *end != '\t' || !end[1] || + strpbrk(end + 1, "\t\r\n") || strlen(end + 1) >= capacity) goto invalid; + if ((!number && (info->error_number || session->fields != ALL_METADATA || !snapshot_valid(info))) || + (info->error_number && info->error_number != (int)number)) goto invalid; + session->terminal = 1; + session->terminal_error = (int)number; + info->error_number = (int)number; + memcpy(message, end + 1, strlen(end + 1) + 1); + if (number && !info->failure[0]) { + size_t length = strlen(end + 1); + if (length >= sizeof(info->failure)) length = sizeof(info->failure) - 1; + memcpy(info->failure, end + 1, length); + info->failure[length] = 0; + } + return 5; + } + uint32_t field = 0; + if (!strncmp(line, "info\t", 5)) { + const char *tab = strchr(line + 5, '\t'); + if (!tab) goto invalid; + for (unsigned i = 0; i < sizeof(metadata) / sizeof(metadata[0]); ++i) { + if ((size_t)(tab - line - 5) == strlen(metadata[i]) && + !memcmp(line + 5, metadata[i], strlen(metadata[i]))) field = UINT32_C(1) << i; + } + if (!field || (session->fields & field)) goto invalid; + } + if (!strncmp(line, "error\t", 6) && info->error_number) goto invalid; + result = installer_update_decode(info, progress, message, capacity, line); + if (result <= 0) goto invalid; + if (result == 1) session->fields |= field; + return result; +invalid: + session->error = 1; + return result < 0 ? result : -EPROTO; +} + +int installer_update_session_finish(const struct installer_update_session *session, + const struct installer_update_info *info) +{ + if (!session || !info) return -EINVAL; + if (session->error || !session->terminal || info->error_number != session->terminal_error || + (!session->terminal_error && (session->fields != ALL_METADATA || !snapshot_valid(info)))) return -EPROTO; + return -session->terminal_error; +} diff --git a/userland/apps/installer/installer_update_supervisor.c b/userland/apps/installer/installer_update_supervisor.c new file mode 100644 index 00000000..472bb66c --- /dev/null +++ b/userland/apps/installer/installer_update_supervisor.c @@ -0,0 +1,110 @@ +#define _GNU_SOURCE 1 +#include "installer_update_supervisor.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct task_result { int result; unsigned complete; }; + +static int monotonic_ms(uint64_t *value) +{ + struct timespec now; + if (clock_gettime(CLOCK_MONOTONIC, &now) < 0) return -errno; + *value = (uint64_t)now.tv_sec * 1000u + (unsigned long)now.tv_nsec / 1000000u; + return 0; +} + +int installer_update_supervise(installer_update_task_fn task, void *context, + uint64_t timeout_ms, const volatile sig_atomic_t *cancelled, + installer_update_pulse_fn pulse, void *pulse_context) +{ + if (!task || !timeout_ms) return -EINVAL; + if (cancelled && *cancelled) return -ECANCELED; + uint64_t started; + int error = monotonic_ms(&started); + if (error) return error; + struct task_result *shared = mmap(NULL, sizeof(*shared), PROT_READ | PROT_WRITE, + MAP_SHARED | MAP_ANONYMOUS, -1, 0); + if (shared == MAP_FAILED) return -errno; + shared->complete = 0; + /* Linux can adopt grandchildren locally. ReliefNT reparents them to its + * system reaper and may reject this optional prctl. */ +#ifdef PR_SET_CHILD_SUBREAPER + (void)prctl(PR_SET_CHILD_SUBREAPER, 1, 0, 0, 0); +#endif + pid_t coordinator = getpid(); + pid_t child = fork(); + if (child < 0) { error = -errno; munmap(shared, sizeof(*shared)); return error; } + if (!child) { + /* Every command inherits this group and the transaction's flock. + * Only the coordinator publishes the terminal protocol. */ + if (setpgid(0, 0) < 0) _exit(125); +#ifdef PR_SET_PDEATHSIG + if (prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0) < 0 || getppid() != coordinator) _exit(125); +#endif + signal(SIGTERM, SIG_DFL); signal(SIGINT, SIG_DFL); signal(SIGHUP, SIG_DFL); + signal(SIGPIPE, SIG_IGN); + shared->result = task(context); + __atomic_store_n(&shared->complete, 1, __ATOMIC_RELEASE); + _exit(0); + } + if (setpgid(child, child) < 0 && errno != EACCES && errno != ESRCH) error = -errno; + uint64_t stopped = 0, presented = started; + int stopping = 0, killed = 0, status = 0; + for (;;) { + pid_t result = waitpid(child, &status, WNOHANG); + if (result == child) break; + if (result < 0 && errno != EINTR) { if (!error) error = -errno; break; } + uint64_t now = started; + int clock_error = monotonic_ms(&now); + if (clock_error && !error) error = clock_error; + if (!error && cancelled && *cancelled) error = -ECANCELED; + if (!error && now - started >= timeout_ms) error = -ETIMEDOUT; + if (error && !stopping) { + (void)kill(-child, SIGTERM); + stopped = now; stopping = 1; + } + if (stopping && !killed && (clock_error || now - stopped >= 1000)) { + (void)kill(-child, SIGKILL); + killed = 1; + } + if (pulse && (now - presented >= 250 || clock_error)) { + pulse(pulse_context, error); presented = now; + } + /* No read(), waitpid(0), or unbounded poll is allowed here. If a + * kernel operation cannot yet retire after SIGKILL, keep ownership + * and report liveness; never release the lock over a live writer. */ + (void)poll(NULL, 0, 25); + } + /* A successful leader must not leave a background command writing later. + * Reap direct children in this group; adopted descendants belong to PID 1. */ + (void)kill(-child, SIGKILL); + for (;;) { + int ignored; + pid_t result; + do { result = waitpid(-child, &ignored, WNOHANG); } while (result > 0); + if (kill(-child, 0) < 0 && errno == ESRCH) break; + if (pulse) pulse(pulse_context, error ? error : -EINPROGRESS); + (void)poll(NULL, 0, 25); + } + if (!error) { + if (!WIFEXITED(status) || WEXITSTATUS(status) || + !__atomic_load_n(&shared->complete, __ATOMIC_ACQUIRE)) { + if (WIFSIGNALED(status)) + fprintf(stderr, "[installer-update] stage process terminated signal=%d\n", WTERMSIG(status)); + else if (WIFEXITED(status)) + fprintf(stderr, "[installer-update] stage process exited status=%d without a result\n", WEXITSTATUS(status)); + error = -EIO; + } + else error = shared->result; + } + munmap(shared, sizeof(*shared)); + return error; +} diff --git a/userland/apps/installer/installer_update_supervisor.h b/userland/apps/installer/installer_update_supervisor.h new file mode 100644 index 00000000..63a6d11b --- /dev/null +++ b/userland/apps/installer/installer_update_supervisor.h @@ -0,0 +1,15 @@ +#ifndef RELIEFOS_INSTALLER_UPDATE_SUPERVISOR_H +#define RELIEFOS_INSTALLER_UPDATE_SUPERVISOR_H +#include +#include + +/* Run one blocking operation in an owned process group. The coordinator never + * runs storage code while waiting. timeout is a hard monotonic stage deadline; + * pulses report coordinator liveness and never extend it. A terminating group + * is reaped before this function returns, including on cancellation or fault. */ +typedef int (*installer_update_task_fn)(void *); +typedef void (*installer_update_pulse_fn)(void *, int stopping_reason); +int installer_update_supervise(installer_update_task_fn task, void *context, + uint64_t timeout_ms, const volatile sig_atomic_t *cancelled, + installer_update_pulse_fn pulse, void *pulse_context); +#endif diff --git a/userland/apps/installer/installer_update_target.c b/userland/apps/installer/installer_update_target.c index 91bef858..43f0a243 100644 --- a/userland/apps/installer/installer_update_target.c +++ b/userland/apps/installer/installer_update_target.c @@ -5,12 +5,14 @@ #include #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -51,38 +53,250 @@ static int acquire_lock(void) return result; } if (!S_ISREG(status.st_mode) || status.st_uid || status.st_nlink != 1) { close(fd); return -EPERM; } - struct flock lock = {.l_type = F_WRLCK, .l_whence = SEEK_SET}; - if (fcntl(fd, F_SETLK, &lock) < 0) { - int result = errno == EACCES || errno == EAGAIN ? -EBUSY : -errno; + /* The open-file-description lock stays held by a surviving stage or + * command after the coordinator dies. Closing one borrowed fd must never + * unlock another process's live update operation. */ + if (flock(fd, LOCK_EX | LOCK_NB) < 0) { + int result = errno == EWOULDBLOCK || errno == EAGAIN ? -EBUSY : -errno; close(fd); return result; } return fd; } -int installer_update_target_close(struct installer_update_target *target) +static int residual_mounts(void) { + static const char prefix[] = "/run/reliefos/update-"; + FILE *stream = setmntent("/proc/self/mounts", "r"); + if (!stream) return -errno; int result = 0; - if (target->boot_mounted) { - if (umount2(target->boot, 0) < 0) result = -errno; - else target->boot_mounted = 0; + struct mntent *entry; + while ((entry = getmntent(stream))) { + const char *path = entry->mnt_dir; + if (strncmp(path, prefix, sizeof(prefix) - 1)) continue; + path += sizeof(prefix) - 1; + if (strspn(path, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") != 6) + continue; + path += 6; + if (*path && *path != '/') continue; + /* A previous coordinator may have been killed before cleaning up, or + * an uninterruptible writer may still own these mounts. Refuse a new + * session without changing or deleting the previous workspace. */ + fprintf(stderr, "[installer-update] previous update mount remains: %s\n", entry->mnt_dir); + result = -EBUSY; + break; } - if (target->esp_mounted && !target->boot_mounted) { - if (umount2(target->esp, 0) < 0 && !result) result = -errno; - else if (!result) target->esp_mounted = 0; + if (!result && ferror(stream)) result = -EIO; + endmntent(stream); + return result; +} + +int installer_update_target_lock(struct installer_update_target *target) +{ + if (!target) return -EINVAL; + memset(target, 0, sizeof(*target)); + target->lock_fd = -1; + int fd = acquire_lock(); + if (fd < 0) return fd; + int result = residual_mounts(); + if (result) { close(fd); return result; } + target->lock_fd = fd; + return 0; +} + +/* Mount flags are hints, not proof: a stage can die immediately after a + * successful mount(2), before publishing its flag to the shared target. */ +static int mount_present(const char *path) +{ + FILE *stream = setmntent("/proc/self/mounts", "r"); + if (!stream) return -errno; + struct mntent *entry; + int found = 0; + while ((entry = getmntent(stream))) { + if (!strcmp(entry->mnt_dir, path)) { found = 1; break; } } - if (target->root_mounted && !target->boot_mounted && !target->esp_mounted) { - if (umount2(target->root, 0) < 0 && !result) result = -errno; - else if (!result) target->root_mounted = 0; + if (ferror(stream)) found = -EIO; + endmntent(stream); + return found; +} + +static int unmount_point(const char *path, int *mounted) +{ + int present = mount_present(path); + if (present < 0) return present; + *mounted = present; + if (!present) return 0; + if (umount2(path, 0) < 0) return -errno; + *mounted = 0; + return 0; +} + +/* Check the whole workspace, including possible bind mounts inside a planner. + * st_dev alone cannot distinguish a bind mount of the same filesystem. */ +static int workspace_unmounted(const char *workspace) +{ + FILE *stream = setmntent("/proc/self/mounts", "r"); + if (!stream) return -errno; + size_t length = strlen(workspace); + int result = 0; + struct mntent *entry; + while ((entry = getmntent(stream))) { + if (!strncmp(entry->mnt_dir, workspace, length) && + (!entry->mnt_dir[length] || entry->mnt_dir[length] == '/')) { + result = -EBUSY; + break; + } } - if (!target->root_mounted && target->root[0]) { - if (rmdir(target->root) < 0 && !result) result = -errno; - if (rmdir(target->workspace) < 0 && !result) result = -errno; + if (!result && ferror(stream)) result = -EIO; + endmntent(stream); + return result; +} + +static int planner_name(const char *name) +{ + static const char prefix[] = "reliefos-update."; + return !strncmp(name, prefix, sizeof(prefix) - 1) && + strlen(name) == sizeof(prefix) - 1 + 6 && + strspn(name + sizeof(prefix) - 1, + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") == 6; +} + +static int remove_plan_contents(int fd, dev_t device, unsigned depth, unsigned *remaining) +{ + if (depth > 32) return -EOVERFLOW; + int copy = fcntl(fd, F_DUPFD_CLOEXEC, 0); + if (copy < 0) return -errno; + DIR *directory = fdopendir(copy); + if (!directory) { int result = -errno; close(copy); return result; } + int result = 0; + for (;;) { + errno = 0; + struct dirent *entry = readdir(directory); + if (!entry) { if (errno) result = -errno; break; } + if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..")) continue; + if (!*remaining) { result = -EOVERFLOW; break; } + --*remaining; + struct stat status; + if (fstatat(fd, entry->d_name, &status, AT_SYMLINK_NOFOLLOW) < 0) { result = -errno; break; } + if (status.st_dev != device) { result = -EXDEV; break; } + if (S_ISDIR(status.st_mode)) { + int child = openat(fd, entry->d_name, O_RDONLY | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC); + if (child < 0) { result = -errno; break; } + struct stat opened; + if (fstat(child, &opened) < 0) result = -errno; + else if (opened.st_dev != status.st_dev || opened.st_ino != status.st_ino) result = -ESTALE; + else result = remove_plan_contents(child, device, depth + 1, remaining); + if (close(child) < 0 && !result) result = -errno; + if (!result && unlinkat(fd, entry->d_name, AT_REMOVEDIR) < 0) result = -errno; + } else if (unlinkat(fd, entry->d_name, 0) < 0) result = -errno; + if (result) break; + } + if (closedir(directory) < 0 && !result) result = -errno; + return result; +} + +/** @brief Remove only owned planner metadata after every stage has been reaped. + * The mounted target has already been detached. Never follow directory links, + * recurse onto another filesystem or discard unknown workspace contents. */ +static int cleanup_plans(const char *workspace) +{ + int result = workspace_unmounted(workspace); + if (result) return result; + int fd = open(workspace, O_RDONLY | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC); + if (fd < 0) return errno == ENOENT ? 0 : -errno; + struct stat owner; + if (fstat(fd, &owner) < 0) result = -errno; + else if (owner.st_uid || (owner.st_mode & 0777) != 0700) result = -EPERM; + DIR *directory = NULL; + int copy = result ? -1 : fcntl(fd, F_DUPFD_CLOEXEC, 0); + if (!result && copy < 0) result = -errno; + if (!result) { + directory = fdopendir(copy); + if (!directory) { result = -errno; close(copy); } } - if (target->lock_fd >= 0) { - if (close(target->lock_fd) < 0 && !result) result = -errno; - target->lock_fd = -1; + /* Validate the entire top level before deleting anything. In particular, + * a leftover target root or an unrelated administrator file is an error. */ + for (int pass = 0; directory && pass < 2 && !result; ++pass) { + if (pass) rewinddir(directory); + unsigned remaining = 65536; + for (;;) { + errno = 0; + struct dirent *entry = readdir(directory); + if (!entry) { if (errno) result = -errno; break; } + if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..")) continue; + if (!remaining) { result = -EOVERFLOW; break; } + --remaining; + if (!planner_name(entry->d_name)) { result = -ENOTEMPTY; break; } + struct stat status; + if (fstatat(fd, entry->d_name, &status, AT_SYMLINK_NOFOLLOW) < 0) { result = -errno; break; } + if (!S_ISDIR(status.st_mode) || status.st_dev != owner.st_dev || + (status.st_mode & 0777) != 0700) { result = -EPERM; break; } + if (!pass) continue; + int plan = openat(fd, entry->d_name, O_RDONLY | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC); + if (plan < 0) { result = -errno; break; } + struct stat opened; + if (fstat(plan, &opened) < 0) result = -errno; + else if (opened.st_dev != status.st_dev || opened.st_ino != status.st_ino || opened.st_uid) result = -ESTALE; + else result = remove_plan_contents(plan, owner.st_dev, 0, &remaining); + if (close(plan) < 0 && !result) result = -errno; + if (!result && unlinkat(fd, entry->d_name, AT_REMOVEDIR) < 0) result = -errno; + if (result) break; + } } + if (directory && closedir(directory) < 0 && !result) result = -errno; + if (close(fd) < 0 && !result) result = -errno; + return result; +} + +/** @brief Recover only this transaction's exact mountpoints, deepest first. + * Never infer ownership from a stale flag or remove a workspace whose mount + * could not be released. The coordinator retains the advisory lock throughout. + */ +int installer_update_target_unmount(struct installer_update_target *target) +{ + static const char prefix[] = "/run/reliefos/update-"; + if (!target) return -EINVAL; + if (!target->workspace[0]) return 0; + size_t length = strnlen(target->workspace, sizeof(target->workspace)); + if (length == sizeof(target->workspace) || + strncmp(target->workspace, prefix, sizeof(prefix) - 1) || + length != sizeof(prefix) - 1 + 6 || + strspn(target->workspace + sizeof(prefix) - 1, + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") != 6) + return -EINVAL; + char *paths[] = {target->root, target->boot, target->esp}; + const char *suffixes[] = {"/root", "/root/boot", "/root/efi"}; + for (unsigned i = 0; i < 3; ++i) { + int n = snprintf(paths[i], sizeof(target->root), "%s%s", target->workspace, suffixes[i]); + if (n < 0 || n >= (int)sizeof(target->root)) return -ENAMETOOLONG; + } + int result = unmount_point(target->boot, &target->boot_mounted); + if (!result) result = unmount_point(target->esp, &target->esp_mounted); + if (!result) result = unmount_point(target->root, &target->root_mounted); + if (result) return result; + result = workspace_unmounted(target->workspace); + if (result) return result; + if (rmdir(target->root) < 0 && errno != ENOENT) return -errno; + result = cleanup_plans(target->workspace); + if (result) return result; + if (rmdir(target->workspace) < 0 && errno != ENOENT) return -errno; + target->workspace[0] = target->root[0] = target->boot[0] = target->esp[0] = 0; + return 0; +} + +int installer_update_target_unlock(struct installer_update_target *target) +{ + if (!target) return -EINVAL; + if (target->lock_fd < 0) return 0; + int fd = target->lock_fd; + target->lock_fd = -1; + return close(fd) < 0 ? -errno : 0; +} + +int installer_update_target_close(struct installer_update_target *target) +{ + int result = installer_update_target_unmount(target); + if (!result) result = installer_update_target_unlock(target); return result; } @@ -157,11 +371,8 @@ int installer_update_target_open(struct installer_update_target *target, struct reliefos_block_partition parts[RELIEFOS_BLOCK_MAX_PARTITIONS]; uint32_t count = 0; int result, esp = -1, found = -1; - memset(target, 0, sizeof(*target)); - target->lock_fd = -1; - if (!disk || strncmp(disk, "/dev/", 5) || strlen(disk) >= sizeof(target->info.disk)) return -EINVAL; - target->lock_fd = acquire_lock(); - if (target->lock_fd < 0) return target->lock_fd; + if (!target || !disk || strncmp(disk, "/dev/", 5) || strlen(disk) >= sizeof(target->info.disk)) return -EINVAL; + if (target->lock_fd < 0 || target->workspace[0]) return -EBUSY; result = reliefos_block_list_partitions(disk, parts, RELIEFOS_BLOCK_MAX_PARTITIONS, &count); if (result) return result; if (count > RELIEFOS_BLOCK_MAX_PARTITIONS) return -EOVERFLOW; diff --git a/userland/apps/installer/main.cpp b/userland/apps/installer/main.cpp index 3504dc29..92e3adf6 100644 --- a/userland/apps/installer/main.cpp +++ b/userland/apps/installer/main.cpp @@ -116,8 +116,9 @@ static ra::Process update_process; static struct installer_update_info update_info; static Fl_Text_Buffer *update_log_buffer; static Fl_Text_Display *update_log_display; -static size_t update_stdout_offset, update_stderr_offset; static int update_job, update_checked, update_protocol_error; +static int update_cancel_requested; +static struct installer_update_session update_session; static char update_message[256]; static struct installer_job install_job; static char installed_boot_file[128]; @@ -295,8 +296,9 @@ static void update_footer(void) else back_button->deactivate(); if (primary_disabled()) primary_button->deactivate(); else primary_button->activate(); - if (installer_model_can_cancel((enum installer_page)page, install_success) && - !ui_busy) cancel_button->activate(); + cancel_button->copy_label(update_job == 1 ? T("Cancel check") : T("Cancel")); + if ((update_job == 1 && !update_cancel_requested) || + (installer_model_can_cancel((enum installer_page)page, install_success) && !ui_busy)) cancel_button->activate(); else cancel_button->deactivate(); } @@ -409,17 +411,19 @@ static void update_pump(void *) update_process.step(16384); const char *output = update_process.output(); size_t length = update_process.output_size(); + size_t update_stdout_offset = 0; while (update_stdout_offset < length) { const char *line = output + update_stdout_offset; const char *end = static_cast(memchr(line, '\n', length - update_stdout_offset)); if (!end) break; size_t bytes = static_cast(end - line); char text[512]; - if (bytes < sizeof(text)) { + if (bytes < sizeof(text) && !memchr(line, '\0', bytes)) { memcpy(text, line, bytes); text[bytes] = 0; unsigned value = progress_value; - int result = installer_update_decode(&update_info, &value, update_message, sizeof(update_message), text); + int result = installer_update_session_line(&update_session, &update_info, &value, + update_message, sizeof(update_message), text); if (result < 0) update_protocol_error = 1; if (result == 2 || result == 3) { progress_value = value; @@ -431,31 +435,47 @@ static void update_pump(void *) sizeof(update_activity_text))) update_protocol_error = 1; } - } + } else update_protocol_error = 1; update_stdout_offset += bytes + 1; } + update_process.consume_output(update_stdout_offset); + if (update_process.output_size() >= 512 || update_process.truncated()) { + update_protocol_error = 1; + update_process.consume_output(update_process.output_size()); + } size_t errors = update_process.errors_size(); - if (errors > update_stderr_offset) { + if (errors) { const char *logs = update_process.errors(); - fwrite(logs + update_stderr_offset, 1, errors - update_stderr_offset, stderr); - update_stderr_offset = errors; if (update_log_buffer) { - size_t start = errors > 65536 ? errors - 65536 : 0; - while (start < errors && (static_cast(logs[start]) & 0xc0) == 0x80) ++start; - update_log_buffer->text(logs + start); + update_log_buffer->append(logs); + if (update_log_buffer->length() > 65536) { + int start = update_log_buffer->length() - 65536; + while (start < update_log_buffer->length() && + (static_cast(update_log_buffer->byte_at(start)) & 0xc0) == 0x80) ++start; + update_log_buffer->remove(0, start); + } if (update_log_display) { update_log_display->insert_position(update_log_buffer->length()); update_log_display->show_insert_position(); } } + update_process.consume_errors(errors); } refresh_status_widgets(); if (update_process.running()) { Fl::repeat_timeout(0.08, update_pump); return; } + if (update_process.output_size()) update_protocol_error = 1; + int session_result = installer_update_session_finish(&update_session, &update_info); int checking = update_job == 1; update_job = 0; ui_busy = 0; install_running = 0; - if (update_process.exit_code() == 0 && !update_protocol_error && !update_info.error_number) { + if (checking && !update_protocol_error && (session_result == -ECANCELED || + (update_cancel_requested && !session_result && update_process.exit_code() == 0))) { + update_checked = 0; + page = INSTALLER_PAGE_DISK; + memset(&update_info, 0, sizeof(update_info)); + set_status(T("Update check canceled"), T("Select a disk or run the checks again.")); + } else if (update_process.exit_code() == 0 && !update_protocol_error && !session_result) { if (checking) { update_checked = 1; fprintf(stderr, "[installer.elf] inspection complete\n"); @@ -473,7 +493,8 @@ static void update_pump(void *) } else { page = INSTALLER_PAGE_FINISH; install_success = 0; - int error = update_info.error_number ? update_info.error_number + int error = update_protocol_error || session_result == -EPROTO ? EPROTO + : update_info.error_number ? update_info.error_number : update_process.exec_error() ? update_process.exec_error() : EIO; char detail[128]; snprintf(detail, sizeof(detail), "%s (%d)", strerror(error), error); @@ -489,9 +510,10 @@ static void start_update_job(int applying) if (!applying) memset(&update_info, 0, sizeof(update_info)); update_checked = 0; update_protocol_error = 0; + update_cancel_requested = 0; + memset(&update_session, 0, sizeof(update_session)); memset(&update_info.activity, 0, sizeof(update_info.activity)); update_activity_text[0] = 0; - update_stdout_offset = update_stderr_offset = 0; if (!update_log_buffer) update_log_buffer = new Fl_Text_Buffer(); update_log_buffer->text(""); char executable[PATH_MAX], modes[2] = { @@ -505,24 +527,14 @@ static void start_update_job(int applying) return; } executable[bytes] = 0; - char root_uuid[37] = {0}, esp_uuid[37] = {0}; - if (!applying) { - int error = 0; - if (installer_root_partition >= 0) - error = reliefos_block_partition_uuid(disks[selected_disk].path, installer_root_partition, root_uuid); - if (!error && installer_esp_partition >= 0) - error = reliefos_block_partition_uuid(disks[selected_disk].path, installer_esp_partition, esp_uuid); - if (error) { - set_error_status(T("Cannot identify the selected partitions"), error); - schedule_render(); - return; - } - } - const char *check[] = {executable, "--update-worker", "check", disks[selected_disk].path, root_uuid, esp_uuid, NULL}; + char root_index[16], esp_index[16]; + snprintf(root_index, sizeof(root_index), "%d", installer_root_partition); + snprintf(esp_index, sizeof(esp_index), "%d", installer_esp_partition); + const char *check[] = {executable, "--update-worker", "check-index", disks[selected_disk].path, root_index, esp_index, NULL}; const char *apply[] = {executable, "--update-worker", "apply", update_info.disk, update_info.root_uuid, update_info.esp_uuid, update_info.index_sha256, update_info.database_sha256, update_info.world_sha256, modes, NULL}; - if (!update_process.start(applying ? apply : check, false, ra::AuthMode::Sudo, false)) { + if (!update_process.start(applying ? apply : check, false, ra::AuthMode::Sudo, !applying)) { page = INSTALLER_PAGE_FINISH; install_success = 0; set_status(T("Cannot start the update worker"), strerror(update_process.exec_error() ? update_process.exec_error() : EIO)); @@ -551,6 +563,16 @@ static void close_now(void) static void cancel_setup(Fl_Widget *, void *) { + if (update_job == 1) { + if (!update_cancel_requested && update_process.request_stop()) { + update_cancel_requested = 1; + copy_text(status_text, sizeof(status_text), T("Canceling the update check")); + copy_text(progress_text, sizeof(progress_text), T("Waiting for the check to release its resources.")); + update_footer(); + refresh_status_widgets(); + } + return; + } if (ui_busy || !installer_model_can_cancel((enum installer_page)page, install_success)) return; if (page != INSTALLER_PAGE_FINISH && fl_choice("%s", T("Keep configuring"), T("Exit installer"), NULL, diff --git a/userland/apps/reliefapk/process.cpp b/userland/apps/reliefapk/process.cpp index 93df07f9..ce6e5ef1 100644 --- a/userland/apps/reliefapk/process.cpp +++ b/userland/apps/reliefapk/process.cpp @@ -985,6 +985,30 @@ size_t Process::errors_size() const return state ? state->errors_length : 0; } +void Process::consume_output(size_t count) +{ + State *state = static_cast(state_); + if (!state || !count) return; + if (count > state->output_length) count = state->output_length; + state->output_length -= count; + if (state->output_data) { + memmove(state->output_data, state->output_data + count, state->output_length); + state->output_data[state->output_length] = 0; + } +} + +void Process::consume_errors(size_t count) +{ + State *state = static_cast(state_); + if (!state || !count) return; + if (count > state->errors_length) count = state->errors_length; + state->errors_length -= count; + if (state->errors_data) { + memmove(state->errors_data, state->errors_data + count, state->errors_length); + state->errors_data[state->errors_length] = 0; + } +} + bool Process::truncated() const { const State *state = static_cast(state_); @@ -1044,4 +1068,11 @@ bool Process::cancel() return true; } +bool Process::request_stop() +{ + State *state = static_cast(state_); + if (!state || !state->active || state->reaped || state->pid <= 0 || !state->cancelable) return false; + return kill(state->pid, SIGTERM) == 0; +} + } // namespace ra diff --git a/userland/apps/reliefapk/process.h b/userland/apps/reliefapk/process.h index f4a7f024..c4d9f0e5 100644 --- a/userland/apps/reliefapk/process.h +++ b/userland/apps/reliefapk/process.h @@ -24,11 +24,18 @@ class Process { size_t output_size() const; const char *errors() const; size_t errors_size() const; + /* Consume parsed stream prefixes so long-running clients can retain a + * bounded window without discarding newer records at the capture limit. */ + void consume_output(size_t count); + void consume_errors(size_t count); bool truncated() const; bool password_requested() const; bool provide_password(const char *secret); void cancel_auth(); bool cancel(); + /* Ask only the worker leader to stop cooperatively. Unlike cancel(), this + * never kills its process group or skips the worker's cleanup protocol. */ + bool request_stop(); private: void *state_; diff --git a/userland/storage/reliefos-apk-update b/userland/storage/reliefos-apk-update index 7b516dde..a35b74cb 100755 --- a/userland/storage/reliefos-apk-update +++ b/userland/storage/reliefos-apk-update @@ -1,6 +1,7 @@ #!/bin/sh -# Signed offline package transactions for the installer. Inspection uses a -# private database and accepts a read-only installed root. +# Signed offline package transactions for the installer. Only bounded planning +# metadata lives in /run; signed archives are read directly from the medium. +# Inspection never changes the installed system or materializes an APK cache. set -eu PATH=/usr/sbin:/usr/bin:/sbin:/bin LC_ALL=C @@ -21,17 +22,36 @@ case "$target:$repository" in /*:/*) ;; *) die 'absolute target and repository p target=$(CDPATH= cd -- "$target" && pwd -P) repository=$(CDPATH= cd -- "$repository" && pwd -P) [ "$target" != / ] || die 'boot the installation media to update an offline system' -for file in "$target/etc/apk/world" "$target/lib/apk/db/installed" "$repository/packages.adb"; do - [ -s "$file" ] && [ ! -L "$file" ] || die "missing or unsafe package metadata: $file" +# Reject nonregular objects before any reader can block on a FIFO/device, and +# put explicit bounds on data copied into the private planning database. +regular_file() { + [ -f "$1" ] && [ ! -L "$1" ] || die "missing or unsafe package file: $1" + file_size=$(/bin/busybox stat -c %s "$1") + case "$file_size" in ''|*[!0-9]*) die "invalid package file size: $1" ;; esac + [ "$file_size" -gt 0 ] && [ "$file_size" -le "$2" ] || die "package file exceeds its size limit or is empty: $1" +} +regular_file "$target/etc/apk/world" 1048576 +regular_file "$target/lib/apk/db/installed" 67108864 +regular_file "$repository/packages.adb" 16777216 +for relative in etc etc/apk etc/apk/keys lib lib/apk lib/apk/db; do + [ -d "$target/$relative" ] && [ ! -L "$target/$relative" ] || die "unsafe installed package directory: $relative" +done +key_count=0 +for key in "$target/etc/apk/keys/"*.pub; do + [ -e "$key" ] || [ -L "$key" ] || continue + regular_file "$key" 65536 + key_count=$((key_count + 1)) + [ "$key_count" -le 64 ] || die 'too many installed package trust keys' done -[ -d "$target/etc/apk/keys" ] && [ ! -L "$target/etc/apk/keys" ] || die 'installed package trust keys are missing' +[ "$key_count" -gt 0 ] || die 'installed package trust keys are missing' index_sha=$(/bin/busybox sha256sum "$repository/packages.adb") index_sha=${index_sha%% *} [ -z "$expected_index" ] || [ "$index_sha" = "$expected_index" ] || die 'installation media changed after inspection; check the update again' -# Early init mounts /run as tmpfs. The private database and verified archives -# must not consume the installation medium's fixed-size runtime root. -temporary=$(/bin/busybox mktemp -d /run/reliefos-update.XXXXXX) +# The supervisor supplies an owned workspace so it can clean up after a killed +# worker. Standalone callers use /run. Keep only bounded metadata here; package +# payloads stay on the read-only installation medium until APK applies them. +temporary=$(/bin/busybox mktemp -d "${TMPDIR:-/run}/reliefos-update.XXXXXX") update_step=repository update_action=step update_package=- update_status=0 files_done=0 files_total=0 bytes_done=0 bytes_total=0 bytes_reused=0 cache_temporary= @@ -92,7 +112,7 @@ trap 'exit 130' INT trap 'exit 143' TERM plan=$temporary/root -/bin/busybox mkdir -p "$plan/etc/apk" "$plan/lib/apk/db" "$plan/var/cache/apk" "$temporary/repository" +/bin/busybox mkdir -p "$plan/etc/apk" "$plan/lib/apk/db" "$plan/var/cache/apk" /bin/busybox cp "$target/lib/apk/db/installed" "$plan/lib/apk/db/installed" /bin/busybox cp "$target/lib/apk/db/installed" "$temporary/installed-before" /bin/busybox cp -p "$target/etc/apk/world" "$temporary/world-before" @@ -145,8 +165,8 @@ plan=$temporary/root } } ' "$temporary/world-before" "$temporary/world-before" > "$plan/etc/apk/world" -if [ -f "$target/etc/apk/arch" ]; then - [ ! -L "$target/etc/apk/arch" ] || die 'unsafe installed architecture file' +if [ -e "$target/etc/apk/arch" ] || [ -L "$target/etc/apk/arch" ]; then + regular_file "$target/etc/apk/arch" 128 /bin/busybox cp "$target/etc/apk/arch" "$plan/etc/apk/arch" fi @@ -175,12 +195,11 @@ write_repositories() { while IFS= read -r tag; do number=$((number + 1)) tagged_repository=$tag_repositories/$number - /bin/busybox mkdir -p "$tagged_repository" - /bin/busybox cp "$source_repository/packages.adb" "$tagged_repository/packages.adb" - for archive in "$source_repository"/*.apk; do - [ -f "$archive" ] || continue - /bin/busybox ln -s "$archive" "$tagged_repository/${archive##*/}" - done + [ "$number" -le 64 ] || die 'too many installed repository tags' + /bin/busybox mkdir -p "$tag_repositories" + # APK distinguishes repository masks by URL. A private directory link + # gives each tag its own URL without copying indexes or archive data. + /bin/busybox ln -s "$source_repository" "$tagged_repository" # Distinct index URLs keep APK's default/tagged repository masks # separate, preserving the installed origin tag of retained extras. printf 'ndx @%s %s/packages.adb\n' "$tag" "$tagged_repository" @@ -259,16 +278,61 @@ done # Replacement commands are world selections, no longer dependencies of local # wrappers. Include them in the verified archive set before the solver runs. upstream_packages=$(/bin/busybox sort -u "$temporary/upstream-packages") +# Verify regular local archives in place, one at a time. APK's verifier streams +# their signatures/data; no archive, including a large dependency, is copied to +# tmpfs. Validate all directory entries before asking APK to open any archive. +stage verify +: > "$temporary/media-archives" +for archive in "$repository"/*.apk; do + [ -e "$archive" ] || [ -L "$archive" ] || continue + update_package=${archive##*/} + case "$update_package" in ''|*[!a-zA-Z0-9+_.-]*) die 'unsafe package archive name' ;; esac + regular_file "$archive" 4294967296 + files_total=$((files_total + 1)) + [ "$files_total" -le 8192 ] || die 'too many package archives' + bytes_total=$((bytes_total + file_size)) + printf '%s\t%s\n' "$file_size" "$update_package" >> "$temporary/media-archives" +done +[ "$files_total" -gt 0 ] || die 'the signed repository has no package archives' +tab=$(printf '\t') +while IFS="$tab" read -r size name; do + update_package=$name update_action=checking + activity + apk --root "$plan" --keys-dir "$target/etc/apk/keys" --no-network verify "$repository/$name" + files_done=$((files_done + 1)) bytes_done=$((bytes_done + size)) update_action=complete + activity +done < "$temporary/media-archives" + +# Enumerate every signed-index entry, including unselected packages and older +# versions: the complete index will be published in the installed offline +# cache. Use an empty private cwd to avoid fetch's same-sized-file shortcut. +# --from repositories excludes installed packages absent from the medium. stage fetch +( + cd "$temporary" + apk --root "$plan" --keys-dir "$target/etc/apk/keys" \ + --repositories-file "$configuration" --no-network fetch \ + --from repositories --all-matches --simulate --url '*' +) > "$temporary/selected-urls" +: > "$temporary/selected-archives" +while IFS= read -r archive || [ -n "$archive" ]; do + name=${archive##*/} + case "$name" in ''|*[!a-zA-Z0-9+_.-]*) die 'invalid selected package archive' ;; *.apk) ;; *) die 'invalid selected package archive' ;; esac + case "$archive" in "$repository/$name"|"$temporary/tagged-media/"*/"$name") ;; *) die 'selected archive is outside the installation repository' ;; esac + regular_file "$repository/$name" 4294967296 + printf '%s\n' "$name" >> "$temporary/selected-archives" +done < "$temporary/selected-urls" +# APK verifies every archive's identity against the signed index while streaming +# it to stdout. --stdout bypasses cwd's same-sized-file shortcut. Drain into +# /dev/null: --url alone still downloads into cwd, and --simulate alone does not +# perform this identity check. No package is staged. apk --root "$plan" --keys-dir "$target/etc/apk/keys" \ - --repositories-file "$configuration" --no-network fetch --recursive \ - --output "$temporary/repository" $packages $repair_packages $upstream_packages -stage verify -apk --root "$plan" --keys-dir "$target/etc/apk/keys" --no-network \ - verify "$temporary/repository/"*.apk -/bin/busybox cp "$repository/packages.adb" "$temporary/repository/packages.adb" -write_repositories "$temporary/repository" "$temporary/tagged-verified" > "$temporary/verified.repositories" -configuration=$temporary/verified.repositories + --repositories-file "$configuration" --no-network fetch \ + --from repositories --all-matches --stdout '*' > /dev/null +# Preserve the complete verified media repository, including equal-version +# packages omitted from the solver's download set on retries. Unindexed files +# never enter the cache, and all archive versions named by its index are kept. +/bin/busybox sort -u "$temporary/selected-archives" > "$temporary/verified-archives" echo 'Calculating the offline package transaction' stage plan if [ -n "$repair_packages" ]; then @@ -320,8 +384,10 @@ destination=$target/usr/share/reliefos/apk/repository # Comparisons avoid rewriting an unchanged cache on update retries. An I/O # error is not a content difference and must not be hidden by a replacement. : > "$temporary/cache-files" -for package in "$temporary/repository"/*.apk "$temporary/repository/packages.adb"; do - name=${package##*/} +/bin/busybox cp "$temporary/verified-archives" "$temporary/cache-names" +printf '%s\n' packages.adb >> "$temporary/cache-names" +while IFS= read -r name; do + package=$repository/$name update_package=$name case "$name" in ''|*[!a-zA-Z0-9+_.-]*) die 'unsafe verified archive name' ;; esac [ -f "$package" ] && [ ! -L "$package" ] || die "unsafe verified archive: $package" @@ -330,7 +396,7 @@ for package in "$temporary/repository"/*.apk "$temporary/repository/packages.adb [ "$next" -ge "$bytes_total" ] || die 'offline cache size overflow' bytes_total=$next files_total=$((files_total + 1)) printf '%s\t%s\n' "$size" "$name" >> "$temporary/cache-files" -done +done < "$temporary/cache-names" tab=$(printf '\t') while IFS="$tab" read -r size name; do update_package=$name update_action=checking @@ -339,7 +405,7 @@ while IFS="$tab" read -r size name; do reuse=0 if [ -e "$existing" ] || [ -L "$existing" ]; then [ -f "$existing" ] && [ ! -L "$existing" ] || die "unsafe cached archive: $existing" - if /bin/busybox cmp -s "$temporary/repository/$name" "$existing"; then reuse=1 + if /bin/busybox cmp -s "$repository/$name" "$existing"; then reuse=1 else compare_status=$? [ "$compare_status" -eq 1 ] || die "cannot compare cached archive: $existing" @@ -353,8 +419,8 @@ while IFS="$tab" read -r size name; do update_action=copying activity cache_temporary=$(/bin/busybox mktemp "$destination/.update-cache.XXXXXX") - /bin/busybox cp "$temporary/repository/$name" "$cache_temporary" - /bin/busybox cmp -s "$temporary/repository/$name" "$cache_temporary" || die "cache copy verification failed: $name" + /bin/busybox cp "$repository/$name" "$cache_temporary" + /bin/busybox cmp -s "$repository/$name" "$cache_temporary" || die "cache copy verification failed: $name" /bin/busybox chmod 0644 "$cache_temporary" /bin/busybox mv "$cache_temporary" "$existing" cache_temporary= update_action=complete @@ -376,4 +442,4 @@ for component in sl ncurses sqlite; do done done stage sync -/bin/busybox sync +/bin/busybox sync -f "$target"