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作为下载器。由于维基链接到这篇(https://bbs.archlinux.org/viewtopic.php?id=192072(文章,我在/etc/pacman.conf 中使用以下命令来使用 aria2XferCommand = 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
当然,第一件事是完全消除回声。这行得通。但是由于"下载结果"(文件下载完成后由 aria2 自动打印(向我的终端发送了大量垃圾邮件,我无法阅读任何内容,所以我在 pacman-aria2.conf 中添加了删除此输出的行。但是现在写入输出的所有内容如下所示:[#b72206 3.9MiB/5.2MiB(75%) CN:3 DL:5.0MiB]
所以我不知道它实际上下载了什么,这很烦人,尤其是当 pacman 一次下载很多东西时(例如pacman -Syu
(因此需要"回声%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
不是由脚本解释的,您需要使用"$1"
:
echo Downloading "$1" ...
/usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf "$1"
吃豆人:
XferCommand = /usr/local/bin/pacman-aria2.sh %u