OFFSET偏移
← 文章目录OFFSET / FIELD NOTESNO. 063

informant:Arch 新闻与 Pacman Hook

在安装或升级事务前提示未读 Arch 新闻,并保留独立的阅读与配置入口。

所在专题Arch Linux ↗
约 12 分钟阅读开始阅读

来源与许可:本篇包含 Bradford Smith 的 informant 项目说明的节选与整理。Copyright (c) 2018-2024 Bradford Smith。所保留的上游材料按 MIT License(完整版权、许可与免责声明) 提供。本篇调整了编排与部分说明,并补充使用边界;2026-10-09 补充本许可说明。该许可适用于上述上游材料,不改变本站其他内容的权利归属。

来源与用途#

本文来自 bradford-smith94/informant 的项目说明。以下保留其子命令、Hook 行为和配置格式;具体行为以安装版本的帮助和手册为准。

An Arch Linux News reader designed to also be used as a pacman hook. The project interrupts pacman transactions when unread news is detected rather than attempting an interactive prompt inside the hook.

Installation#

You can install from the project’s AUR package. In case anyone wants to use Github to create issues or contribute to the AUR package the author has also mirrored the PKGBUILD. Requirements are in requirements.txt. If you want to install it manually. NOTE: The provided pip requirements likely won't be as up to date as the Arch packages that AUR-installed informant will depend on, so your mileage may vary if you take this approach. On the first run informant assumes that you have not read any of the most recent news items. Use the informant read command specified below to mark items as read.

How does it work?#

informant provides 3 subcommands, 'check', 'list' and 'read'. informant check - will check for any unread news items, if there is only one unread item it will print it and mark it as read. Informant check will exit with return code equal to the number of unread news items (even if there is only one). This is the command used by the pacman hook, so that if there are unread news items it will interrupt your pacman transaction. informant list - will list the titles of the most recent news items (regardless of whether or not they have been read, unless the '--unread' option is given). There is also a '--reverse' option if you prefer to see them newest to oldest. informant read - if given a news item, will print that item and mark it as read. You can specify a news item as either an index or a string matching the title. If you want to use an index it must only be that shown when running informant list (without '--unread' or '--reverse'). If no item is given, will begin looping through all unread items, printing each one and marking them as read with a prompt to continue. Passing the '--all' flag will mark all items as read without printing them. More options can be found by reading informant --help or man informant.

About the pacman hook

informant provides a PreTransaction pacman hook, so that it can interrupt a pacman transaction if there are unread Arch Linux News items. This hook runs on Upgrades and Installs, but not Removes. If for some reason the hook (or informant) breaks in such a way that you cannot run a successful pacman transaction (even after trying to read the news) you should be able to pacman -Rsn informant. informant installs its hook to /usr/share/libalpm/hooks/ so you should also be able to override the pacman hook by placing a new hook in /etc/pacman.d/hooks/00-informant.hook or disable it by placing a symlink to /dev/null in that location (e.g. sudo ln -s /dev/null /etc/pacman.d/hooks/00-informant.hook, only after checking the destination does not already contain a custom override). More information on pacman hooks can be found in man alpm-hooks.

Configuration#

Informant can be configured to check multiple feeds instead of just the Arch Linux News feed (whether having it do so is actually useful or not is left up to the user). Informant will check for an informantrc.json file in a few places. It will check in this order:

  • CLI provided option
  • $HOME/.informantrc.json
  • $XDG_CONFIG_HOME/informantrc.json
  • /etc/informantrc.json
  • for each directory ($d) in $XDG_CONFIG_DIRS it will look for $d/informantrc.json

NOTE: If you want the configuration file to be used in the pacman hook make sure to use a save location that will be accessible to informant when running as root/sudo.

Configuration Syntax

The syntax of informantrc.json is a JSON object containing one key (feeds) that is a list describing the feeds you want informant to check. Each feed is represented as a JSON object with the following keys:

  • name (optional) - used to show which feed each news item is from
  • url (required) - the feed URL
  • title-key (optional) - defaults to title, the key used to reference the news item title in the feed
  • body-key (optional) - defaults to summary, the key used to reference the news item body in the feed
  • timestamp-key (optional) - defaults to published, the key used to reference the news item date in the feed

An example is provided here as informanrc.json.example which configures informant to check the Arch Linux News feed as well as the Arch Linux 32 News feed.

使用边界#

read --all 只修改已读状态,不能证明已完成新闻要求的人工干预。临时禁用 Hook 后,仍需自行阅读 Arch News。该程序运行在 pacman 的权限上下文中;系统级配置应对该上下文可读,不将私有 feed 凭据写入公开文章。

参考与延伸

  1. bradford-smith94/informant 原项目 ↗
  2. AUR:informant ↗
  3. alpm-hooks(5) ↗
  4. informant:完整 MIT 版权与许可声明 ↗
  5. 上游 MIT License ↗

根据技术笔记重新整理,示例使用通用名称。

沿专题继续阅读

Arch Linux

  1. 01Arch Linux 的哲学与安装规划
  2. 02内核管理、systemd-boot 与 UKI
  3. 03Pacman Hook、AUR 与构建安全
  4. 04Btrfs 子卷布局与 Snapper 快照
  5. 05LUKS2、Secure Boot 与 TPM2 加固
  6. 06性能选择与日常维护清单
  7. 07Pacman 常用命令与参数记忆
  8. 08Pacman 下载慢的诊断与镜像选择
  9. 09informant:Arch 新闻与 Pacman Hook
  10. 10Arch Linux 与 Btrfs:手动安装和 archinstall
  11. 11GNOME 桌面、输入法与快照配置
  12. 12GNOME 笔记本管理与桌面美化
  13. 13Arch Linux 的 KVM、GPU 直通与游戏
  14. 14Arch 桌面的交换空间、内核与排障
CONTINUE READING / 下一篇Arch Linux 与 Btrfs:手动安装和 archinstall

完整梳理 UEFI、Btrfs 子卷、基础系统、GRUB 和 archinstall 的安装流程。