pacman xfercommand 不适用于 echo 和 aria2
pacman xfercommand not working with echo and aria2
TLDR:
XferCommand = echo Downloading %u ... && /usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf %u
在pacman.conf输出
Downloading https://mirror.23media.com/manjaro/stable/core/x86_64/core.db ... && /usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf https://mirror.23media.com/manjaro/stable/core/x86_64/core.db
并且第二个 aria2 命令永远不会执行 - pacman.conf 和 pacman-aria2.conf 在底部,长版本低于 TLDR
简介:
我想要实现的是使用带有 pacman 的外部下载器来说明它当前正在下载什么,而不用不必要的信息填充终端输出。
由于 pacman 的奇怪下载速度问题,我尝试使用 wiki 推荐的内容:使用 /etc/pacman.conf 中的 XferCommand 来使用 aria2 作为下载器。由于 wiki 链接到这篇 (https://bbs.archlinux.org/viewtopic.php?id=192072) 文章,我在 /etc/pacman.conf 中使用以下命令来使用 aria2
XferCommand = echo Downloading %u ... && /usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf %u
您可以在底部找到完整的 pacman.conf 以及 pacman-aria2.conf。
在终端中执行(并且 %u 更改为其他内容)此命令有效。遗憾的是,当在 pacman.conf 中执行时,echo 只会打印出整行,包括“&&”等等。 pacman -Syy
的完整输出是
Downloading https://mirror.23media.com/manjaro/stable/extra/x86_64/extra.db ... && /usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf https://mirror.23media.com/manjaro/stable/extra/x86_64/extra.db
Downloading https://mirror.23media.com/manjaro/stable/community/x86_64/community.db ... && /usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf https://mirror.23media.com/manjaro/stable/community/x86_64/community.db
Downloading https://mirror.23media.com/manjaro/stable/multilib/x86_64/multilib.db ... && /usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf https://mirror.23media.com/manjaro/stable/multilib/x86_64/multilib.db
sudo pacman -S 0ad
的完整输出(pacman中的第一个条目,有很多依赖项,文件很大):
resolving dependencies...
looking for conflicting packages...
Packages (6) 0ad-data-a23.1-1 enet-1.3.14-1 gloox-1.0.22-1 miniupnpc-2.1.20190408-1 wxgtk2-3.0.4-2 0ad-a23.1-7
Total Download Size: 8,95 MiB
Total Installed Size: 2055,95 MiB
:: Proceed with installation? [Y/n]
:: Retrieving packages...
Downloading https://mirror.23media.com/manjaro/stable/community/x86_64/gloox-1.0.22-1-x86_64.pkg.tar.xz ... && /usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf https://mirror.23media.com/manjaro/stable/community/x86_64/gloox-1.0.22-1-x86_64.pkg.tar.xz
Downloading https://mirror.23media.com/manjaro/stable/community/x86_64/miniupnpc-2.1.20190408-1-x86_64.pkg.tar.xz ... && /usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf https://mirror.23media.com/manjaro/stable/community/x86_64/miniupnpc-2.1.20190408-1-x86_64.pkg.tar.xz
Downloading https://mirror.23media.com/manjaro/stable/community/x86_64/0ad-a23.1-7-x86_64.pkg.tar.xz ... && /usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf https://mirror.23media.com/manjaro/stable/community/x86_64/0ad-a23.1-7-x86_64.pkg.tar.xz
(6/6) checking keys in keyring [####################################################] 100%
^C/6) checking package integrity [----------------------------------------------------] 0%
Interrupt signal received
我打断了,因为完整性测试没有进行,我可以看出它没有下载任何东西,因为它根本不需要时间,而且程序应该至少有 1GB
当然首先要彻底消除回声。这行得通。但是由于 "Download Result"(文件下载完成后由 aria2 自动打印)向我的终端发送大量垃圾邮件,我无法阅读任何内容,因此我在 pacman-aria2.conf 中添加了删除此行的行输出。但现在写入输出的所有内容如下所示:
[#b72206 3.9MiB/5.2MiB(75%) CN:3 DL:5.0MiB]
所以我不知道它实际下载的是什么,这很烦人,尤其是当 pacman 一次下载很多东西时(例如 pacman -Syu
)因此需要 "echo %u".
其他修复尝试:
在我的 pacman.conf 中,您可以看到我尝试修复(错误)的一些遗迹。入围名单如下:
改变生成的两个命令的顺序Exception caught
Exception: [download_helper.cc:451] errorCode=1 Unrecognized URI or unsupported protocol: &&
编写一个小的 bash 脚本 (/usr/local/bin/pacman-aria2.sh),它只在两行中包含两个命令,结果如下:
Exception caught
Exception: [download_helper.cc:451] errorCode=1 Unrecognized URI or unsupported protocol: %u
我认为这是由于我没有将变量发送到脚本造成的,但我不知道如何正确地做到这一点
wget、curl 和 wiki 的原始命令都没有产生想要的输出:wget 再次向控制台和 wiki 命令发送垃圾邮件,另一方面,curl 完全没有任何信息。
结论:
由于 wiki 和 pacman 的手册页都没有说明有关 XferCommand 的更多信息,所以我无法猜测。任何提示表示赞赏。如果您需要更多信息,我会尽力提供。
可能相关信息:
uname -srv: Linux 5.4.2-1-MANJARO #1 SMP PREEMPT Thu Dec 5 09:55:57 UTC 2019
pacman -V: Pacman v5.2.1 - libalpm v12.0.1
architecture: x86_64
文件:
/etc/pacman.conf:
#
# /etc/pacman.conf
#
# See the pacman.conf(5) manpage for option and repository directives
#
# GENERAL OPTIONS
#
[options]
# The following paths are commented out with their default values listed.
# If you wish to use different paths, uncomment and update the paths.
#RootDir = /
#DBPath = /var/lib/pacman/
CacheDir = /var/cache/pacman/pkg/
#LogFile = /var/log/pacman.log
#GPGDir = /etc/pacman.d/gnupg/
#HookDir = /etc/pacman.d/hooks/
HoldPkg = pacman glibc manjaro-system
# If upgrades are available for these packages they will be asked for first
SyncFirst = manjaro-system archlinux-keyring manjaro-keyring
#XferCommand = /usr/bin/curl -C - -f %u > %o
#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u
XferCommand = /usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf %u
#XferCommand = /usr/bin/aria2c --allow-overwrite=true --continue=true --file-allocation=none --log-level=error --max-tries=2 --max-connection-per-server=2 --max-file-not-found=5 --min-split-size=5M --no-conf --remote-time=true --summary-interval=60 --timeout=5 --dir=/ --out %o %u
#XferCommand = /usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf %u && echo Downloading %u ...
#XferCommand = echo Downloading %u ... && /usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf %u
#XferCommand = /usr/local/bin/pacman-aria2.sh
#CleanMethod = KeepInstalled
#UseDelta = 0.7
Architecture = auto
# Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup
#IgnorePkg =
#IgnoreGroup =
#NoUpgrade =
#NoExtract =
# Misc options
#UseSyslog
Color
#TotalDownload
# We cannot check disk space from within a chroot environment
CheckSpace
#VerbosePkgLists
# By default, pacman accepts packages signed by keys that its local keyring
# trusts (see pacman-key and its man page), as well as unsigned packages.
SigLevel = Required DatabaseOptional
LocalFileSigLevel = Optional
#RemoteFileSigLevel = Required
# NOTE: You must run `pacman-key --init` before first using pacman; the local
# keyring can then be populated with the keys of all official Manjaro Linux
# packagers with `pacman-key --populate archlinux manjaro`.
#
# REPOSITORIES
# - can be defined here or included from another file
# - pacman will search repositories in the order defined here
# - local/custom mirrors can be added here or in separate files
# - repositories listed first will take precedence when packages
# have identical names, regardless of version number
# - URLs will have $repo replaced by the name of the current repo
# - URLs will have $arch replaced by the name of the architecture
#
# Repository entries are of the format:
# [repo-name]
# Server = ServerName
# Include = IncludePath
#
# The header [repo-name] is crucial - it must be present and
# uncommented to enable the repo.
#
# The testing repositories are disabled by default. To enable, uncomment the
# repo name header and Include lines. You can add preferred servers immediately
# after the header, and they will be used before the default mirrors.
[core]
SigLevel = PackageRequired DatabaseNever
Include = /etc/pacman.d/mirrorlist
[extra]
SigLevel = PackageRequired DatabaseNever
Include = /etc/pacman.d/mirrorlist
[community]
SigLevel = PackageRequired DatabaseNever
Include = /etc/pacman.d/mirrorlist
# If you want to run 32 bit applications on your x86_64 system,
# enable the multilib repositories as required here.
[multilib]
SigLevel = PackageRequired DatabaseNever
Include = /etc/pacman.d/mirrorlist
# An example of a custom package repository. See the pacman manpage for
# tips on creating your own repositories.
#[custom]
#SigLevel = Optional TrustAll
#Server = file:///home/custompkgs
/etc/pacman-aria2.conf:
timeout=60
connect-timeout=30
max-tries=5
retry-wait=10
max-file-not-found=1
# downloading
split=3
max-connection-per-server=3
min-split-size=1M
max-concurrent-downloads=1
file-allocation=none
remote-time=true
conditional-get=true
no-netrc=true
# resuming
continue=true
allow-overwrite=true
always-resume=false
# proxy
#http-proxy=127.0.0.1:8080
#https-proxy=127.0.0.1:8080
#ftp-proxy=127.0.0.1:8080
# console
#quiet=true
download-result=hide
console-log-level=warn
summary-interval=0
#enable-color=false
#human-readable=false
#show-console-readout=false
#truncate-console-readout=false
# logging
log-level=warn
log=/var/log/pacman-aria2.log
根据 https://git.archlinux.org/pacman.git/commit/?id=808a4f15ce82d2ed7eeb06de73d0f313620558ee,pacman 不再通过 shell 调用 XferCommand,因此 shell 语法不起作用。
您使用单独脚本的想法是正确的:
echo Downloading %u ...
/usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf %u
但是,显然%u
不是脚本解释的,你需要使用""
:
echo Downloading "" ...
/usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf ""
pacman.conf:
XferCommand = /usr/local/bin/pacman-aria2.sh %u
TLDR:
XferCommand = echo Downloading %u ... && /usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf %u
在pacman.conf输出
Downloading https://mirror.23media.com/manjaro/stable/core/x86_64/core.db ... && /usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf https://mirror.23media.com/manjaro/stable/core/x86_64/core.db
并且第二个 aria2 命令永远不会执行 - pacman.conf 和 pacman-aria2.conf 在底部,长版本低于 TLDR
简介:
我想要实现的是使用带有 pacman 的外部下载器来说明它当前正在下载什么,而不用不必要的信息填充终端输出。
由于 pacman 的奇怪下载速度问题,我尝试使用 wiki 推荐的内容:使用 /etc/pacman.conf 中的 XferCommand 来使用 aria2 作为下载器。由于 wiki 链接到这篇 (https://bbs.archlinux.org/viewtopic.php?id=192072) 文章,我在 /etc/pacman.conf 中使用以下命令来使用 aria2
XferCommand = echo Downloading %u ... && /usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf %u
您可以在底部找到完整的 pacman.conf 以及 pacman-aria2.conf。
在终端中执行(并且 %u 更改为其他内容)此命令有效。遗憾的是,当在 pacman.conf 中执行时,echo 只会打印出整行,包括“&&”等等。 pacman -Syy
的完整输出是
Downloading https://mirror.23media.com/manjaro/stable/extra/x86_64/extra.db ... && /usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf https://mirror.23media.com/manjaro/stable/extra/x86_64/extra.db
Downloading https://mirror.23media.com/manjaro/stable/community/x86_64/community.db ... && /usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf https://mirror.23media.com/manjaro/stable/community/x86_64/community.db
Downloading https://mirror.23media.com/manjaro/stable/multilib/x86_64/multilib.db ... && /usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf https://mirror.23media.com/manjaro/stable/multilib/x86_64/multilib.db
sudo pacman -S 0ad
的完整输出(pacman中的第一个条目,有很多依赖项,文件很大):
resolving dependencies...
looking for conflicting packages...
Packages (6) 0ad-data-a23.1-1 enet-1.3.14-1 gloox-1.0.22-1 miniupnpc-2.1.20190408-1 wxgtk2-3.0.4-2 0ad-a23.1-7
Total Download Size: 8,95 MiB
Total Installed Size: 2055,95 MiB
:: Proceed with installation? [Y/n]
:: Retrieving packages...
Downloading https://mirror.23media.com/manjaro/stable/community/x86_64/gloox-1.0.22-1-x86_64.pkg.tar.xz ... && /usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf https://mirror.23media.com/manjaro/stable/community/x86_64/gloox-1.0.22-1-x86_64.pkg.tar.xz
Downloading https://mirror.23media.com/manjaro/stable/community/x86_64/miniupnpc-2.1.20190408-1-x86_64.pkg.tar.xz ... && /usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf https://mirror.23media.com/manjaro/stable/community/x86_64/miniupnpc-2.1.20190408-1-x86_64.pkg.tar.xz
Downloading https://mirror.23media.com/manjaro/stable/community/x86_64/0ad-a23.1-7-x86_64.pkg.tar.xz ... && /usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf https://mirror.23media.com/manjaro/stable/community/x86_64/0ad-a23.1-7-x86_64.pkg.tar.xz
(6/6) checking keys in keyring [####################################################] 100%
^C/6) checking package integrity [----------------------------------------------------] 0%
Interrupt signal received
我打断了,因为完整性测试没有进行,我可以看出它没有下载任何东西,因为它根本不需要时间,而且程序应该至少有 1GB
当然首先要彻底消除回声。这行得通。但是由于 "Download Result"(文件下载完成后由 aria2 自动打印)向我的终端发送大量垃圾邮件,我无法阅读任何内容,因此我在 pacman-aria2.conf 中添加了删除此行的行输出。但现在写入输出的所有内容如下所示:
[#b72206 3.9MiB/5.2MiB(75%) CN:3 DL:5.0MiB]
所以我不知道它实际下载的是什么,这很烦人,尤其是当 pacman 一次下载很多东西时(例如 pacman -Syu
)因此需要 "echo %u".
其他修复尝试: 在我的 pacman.conf 中,您可以看到我尝试修复(错误)的一些遗迹。入围名单如下:
改变生成的两个命令的顺序Exception caught
Exception: [download_helper.cc:451] errorCode=1 Unrecognized URI or unsupported protocol: &&
编写一个小的 bash 脚本 (/usr/local/bin/pacman-aria2.sh),它只在两行中包含两个命令,结果如下:
Exception caught
Exception: [download_helper.cc:451] errorCode=1 Unrecognized URI or unsupported protocol: %u
我认为这是由于我没有将变量发送到脚本造成的,但我不知道如何正确地做到这一点
wget、curl 和 wiki 的原始命令都没有产生想要的输出:wget 再次向控制台和 wiki 命令发送垃圾邮件,另一方面,curl 完全没有任何信息。
结论: 由于 wiki 和 pacman 的手册页都没有说明有关 XferCommand 的更多信息,所以我无法猜测。任何提示表示赞赏。如果您需要更多信息,我会尽力提供。
可能相关信息:
uname -srv: Linux 5.4.2-1-MANJARO #1 SMP PREEMPT Thu Dec 5 09:55:57 UTC 2019
pacman -V: Pacman v5.2.1 - libalpm v12.0.1
architecture: x86_64
文件:
/etc/pacman.conf:
#
# /etc/pacman.conf
#
# See the pacman.conf(5) manpage for option and repository directives
#
# GENERAL OPTIONS
#
[options]
# The following paths are commented out with their default values listed.
# If you wish to use different paths, uncomment and update the paths.
#RootDir = /
#DBPath = /var/lib/pacman/
CacheDir = /var/cache/pacman/pkg/
#LogFile = /var/log/pacman.log
#GPGDir = /etc/pacman.d/gnupg/
#HookDir = /etc/pacman.d/hooks/
HoldPkg = pacman glibc manjaro-system
# If upgrades are available for these packages they will be asked for first
SyncFirst = manjaro-system archlinux-keyring manjaro-keyring
#XferCommand = /usr/bin/curl -C - -f %u > %o
#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u
XferCommand = /usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf %u
#XferCommand = /usr/bin/aria2c --allow-overwrite=true --continue=true --file-allocation=none --log-level=error --max-tries=2 --max-connection-per-server=2 --max-file-not-found=5 --min-split-size=5M --no-conf --remote-time=true --summary-interval=60 --timeout=5 --dir=/ --out %o %u
#XferCommand = /usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf %u && echo Downloading %u ...
#XferCommand = echo Downloading %u ... && /usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf %u
#XferCommand = /usr/local/bin/pacman-aria2.sh
#CleanMethod = KeepInstalled
#UseDelta = 0.7
Architecture = auto
# Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup
#IgnorePkg =
#IgnoreGroup =
#NoUpgrade =
#NoExtract =
# Misc options
#UseSyslog
Color
#TotalDownload
# We cannot check disk space from within a chroot environment
CheckSpace
#VerbosePkgLists
# By default, pacman accepts packages signed by keys that its local keyring
# trusts (see pacman-key and its man page), as well as unsigned packages.
SigLevel = Required DatabaseOptional
LocalFileSigLevel = Optional
#RemoteFileSigLevel = Required
# NOTE: You must run `pacman-key --init` before first using pacman; the local
# keyring can then be populated with the keys of all official Manjaro Linux
# packagers with `pacman-key --populate archlinux manjaro`.
#
# REPOSITORIES
# - can be defined here or included from another file
# - pacman will search repositories in the order defined here
# - local/custom mirrors can be added here or in separate files
# - repositories listed first will take precedence when packages
# have identical names, regardless of version number
# - URLs will have $repo replaced by the name of the current repo
# - URLs will have $arch replaced by the name of the architecture
#
# Repository entries are of the format:
# [repo-name]
# Server = ServerName
# Include = IncludePath
#
# The header [repo-name] is crucial - it must be present and
# uncommented to enable the repo.
#
# The testing repositories are disabled by default. To enable, uncomment the
# repo name header and Include lines. You can add preferred servers immediately
# after the header, and they will be used before the default mirrors.
[core]
SigLevel = PackageRequired DatabaseNever
Include = /etc/pacman.d/mirrorlist
[extra]
SigLevel = PackageRequired DatabaseNever
Include = /etc/pacman.d/mirrorlist
[community]
SigLevel = PackageRequired DatabaseNever
Include = /etc/pacman.d/mirrorlist
# If you want to run 32 bit applications on your x86_64 system,
# enable the multilib repositories as required here.
[multilib]
SigLevel = PackageRequired DatabaseNever
Include = /etc/pacman.d/mirrorlist
# An example of a custom package repository. See the pacman manpage for
# tips on creating your own repositories.
#[custom]
#SigLevel = Optional TrustAll
#Server = file:///home/custompkgs
/etc/pacman-aria2.conf:
timeout=60
connect-timeout=30
max-tries=5
retry-wait=10
max-file-not-found=1
# downloading
split=3
max-connection-per-server=3
min-split-size=1M
max-concurrent-downloads=1
file-allocation=none
remote-time=true
conditional-get=true
no-netrc=true
# resuming
continue=true
allow-overwrite=true
always-resume=false
# proxy
#http-proxy=127.0.0.1:8080
#https-proxy=127.0.0.1:8080
#ftp-proxy=127.0.0.1:8080
# console
#quiet=true
download-result=hide
console-log-level=warn
summary-interval=0
#enable-color=false
#human-readable=false
#show-console-readout=false
#truncate-console-readout=false
# logging
log-level=warn
log=/var/log/pacman-aria2.log
根据 https://git.archlinux.org/pacman.git/commit/?id=808a4f15ce82d2ed7eeb06de73d0f313620558ee,pacman 不再通过 shell 调用 XferCommand,因此 shell 语法不起作用。
您使用单独脚本的想法是正确的:
echo Downloading %u ...
/usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf %u
但是,显然%u
不是脚本解释的,你需要使用""
:
echo Downloading "" ...
/usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf ""
pacman.conf:
XferCommand = /usr/local/bin/pacman-aria2.sh %u