![如何使用 apt-ftparchive 在发布文件中设置附加字段?](https://linux22.com/image/735538/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%20apt-ftparchive%20%E5%9C%A8%E5%8F%91%E5%B8%83%E6%96%87%E4%BB%B6%E4%B8%AD%E8%AE%BE%E7%BD%AE%E9%99%84%E5%8A%A0%E5%AD%97%E6%AE%B5%EF%BC%9F.png)
apt-ftparchive 的手册页如下:
release
The release command generates a Release file from a directory tree. It
recursively searches the given directory for uncompressed and compressed
Packages, Sources, Contents, Components and icons files as well as Release,
Index and md5sum.txt files by default
(APT::FTPArchive::Release::Default-Patterns). Additional filename patterns can
be added by listing them in APT::FTPArchive::Release::Patterns. It then writes
to stdout a Release file containing (by default) an MD5, SHA1, SHA256 and
SHA512 digest for each file.
Values for the additional metadata fields in the Release file are taken
from the corresponding variables under APT::FTPArchive::Release, e.g.
APT::FTPArchive::Release::Origin. The supported fields are Origin, Label,
Suite, Version, Codename, Date, NotAutomatic, ButAutomaticUpgrades,
Acquire-By-Hash, Valid-Until, Signed-By, Architectures, Components and
Description.
我需要在生成的Release
文件中设置这些字段,如下所示:
user@server:/srv/repo/dists/ascii$ apt-ftparchive release . > Release
我怎样才能做到这一点?
这些变量是什么APT::FTPArchive::Release::...
以及如何设置它们?
答案1
该命令apt-config
的手册页显示它可以用来设置这些变量,并带有一个--option
选项。
不幸的是,选项无法保留,这使得设置它们apt-config
毫无意义。(可能有原因,只是我还不太清楚。)
幸运的是,这个--option
选项也适用于apt-ftparchive
,我只是忽略了手册页的那部分:
-o, --option
Set a Configuration Option; This will set an arbitrary configuration option.
The syntax is -o Foo::Bar=bar.
-o and --option can be used multiple times to set different options.
因此完整的命令行是:
user@server:/srv/repo/dists/ascii$ apt-ftparchive \
-o APT::FTPArchive::Release::Origin="Devuan" \
-o APT::FTPArchive::Release::Label="Devuan" \
-o APT::FTPArchive::Release::Suite="stable" \
-o APT::FTPArchive::Release::Version="2.0" \
-o APT::FTPArchive::Release::Codename="ascii" \
-o APT::FTPArchive::Release::Architectures="armhf" \
-o APT::FTPArchive::Release::Components="main" \
release . > Release
答案2
您还可以创建一个release.conf
文件:
APT::FTPArchive::Release::Origin="Devuan"
APT::FTPArchive::Release::Label="Devuan"
APT::FTPArchive::Release::Suite="stable"
APT::FTPArchive::Release::Version="2.0"
APT::FTPArchive::Release::Codename="ascii"
APT::FTPArchive::Release::Architectures="armhf"
APT::FTPArchive::Release::Components="main"
然后运行
user@server:/srv/repo/dists/ascii$ apt-ftparchive release -c release.conf . > Release