Repository navigation
feat(module): add mscorefonts module for Microsoft core fonts (Times New Roman, Arial, ...) - #421
Merged
Merged
Conversation
…New Roman, Arial, ...) ttf-mscorefonts-installer only downloads the fonts when the msttcorefonts/accepted-mscorefonts-eula debconf answer is true. When the package is pulled in non-interactively as a dependency the answer is false: the postinst removes every font and leaves a License-refused README, so dpkg reports the package as installed while Times New Roman is missing and fontconfig falls back to Liberation Serif. The module judges is_installed by the font files rather than dpkg alone, preseeds the EULA answer before installing, and uses apt-get install --reinstall when the package is already present so the downloader runs again. doctor also checks that fc-match resolves Times New Roman to the real font.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
新增
mscorefonts模組,用來安裝 Microsoft 核心字型(Times New Roman、Arial、Courier New、Georgia、Verdana 等),並能修復「套件顯示已安裝、但字型其實不存在」的狀態。目前沒有對應的 issue(本次只要求補上這個字型),所以沒有
Closes #N。起因:一台機器上
fc-list找不到 Times New Roman,文件會退回 Liberation Serif。實際追查後發現ttf-mscorefonts-installer是被某個辦公軟體的.deb當成依賴自動帶進來的,安裝時沒有跳出授權確認,debconf 的msttcorefonts/accepted-mscorefonts-eula記錄成false。這個套件只是下載器,授權沒接受時 postinst 會移除所有字型並留下一個 "License refused." 的 README,所以 dpkg 顯示ii(已安裝),字型目錄裡卻只有 README。Changes
module/mscorefonts.module.sh(新增):apt archetype 加上手寫的install、is_installed、doctor。is_installed:除了 dpkg 顯示ii,還要檢查字型檔(Times_New_Roman.ttf或times.ttf)確實存在,所以「授權被拒」的狀態會被判定為未安裝。install:先用debconf-set-selections預設授權答案為true,再安裝。套件已存在但字型缺失時改用apt-get install --reinstall,讓 postinst 重新下載。透過sudo env DEBIAN_FRONTEND=noninteractive傳遞非互動旗標。安裝後字型仍不存在則回傳失敗,因此不會寫入 sidecar(ADR-0015)。doctor:除了is_installed,還確認fc-match 'Times New Roman'解析到真正的字型,而不是 Liberation Serif 這類替代字型。WARN_MESSAGE(en / zh-TW)明確說明安裝本模組等於代為接受 Microsoft 授權條款。CATEGORY=optional、僅desktop、is_recommended永遠為否(專有字型,必須明確指定才會安裝)。test/unit/module/mscorefonts_spec.bats(新增):67 個測試。doc/module/INDEX.md:用script/gen-module-index.sh重新產生(90 → 91 個模組)。doc/changelog/CHANGELOG.md:在[Unreleased]的 Added 加上條目。請優先看
is_installed與install兩個函式。Decision
font模組:font是 user-home 安裝、不需要 sudo、從 GitHub 下載 Nerd Font;這個是 sudo、apt、還有授權條款,屬於不同的 archetype 與風險。is_installed以字型檔為準,不只看 dpkg:預設的 apt 檢查在「授權被拒」的狀態下會回傳已安裝,module_skip_if_installed就會永遠跳過安裝,無法自我修復。true,並在WARN_MESSAGE與 CHANGELOG 中明確揭露。不預設接受的話,非互動安裝一定會得到空的字型目錄。WARN_MESSAGE。multiverse元件:Ubuntu 桌面與官方 Docker 映像預設已啟用。shellcheck disable。Tests
just -f justfile.ci lint:ShellCheck、fish 語法、Hadolint 全部通過。just -f justfile.ci test-unit mscorefonts:67 個測試全部通過。just -f justfile.ci test-unit(完整單元測試):7566 個通過、0 失敗、1 個 skip。ubuntu:24.04容器內實際執行。ttf-mscorefonts-installer,重現問題狀態(目錄只有 README,fc-match "Times New Roman"回傳 Liberation Serif)。is-installed回傳非 0(正確判定為未安裝)。install後下載了 60 個字型檔,fc-match回傳Times_New_Roman.ttf,is-installed、doctor、verify皆回傳 0。install會回報 already installed 並跳過(冪等)。