TLDR:
XferCommand = echo Downloading %u ... && /usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf %u
in pacman.conf outputs
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
and the second aria2 command is never executed - pacman.conf and pacman-aria2.conf at the bottom, long version below the TLDR
Introduction:
What I'm trying to achieve is using an external downloader with pacman that states what its currently downloading without filling the terminal output with unneccesary info.
Because of strange downloading speed problems with pacman I tried to use what the wiki recommended: Using the XferCommand in /etc/pacman.conf to use aria2 as a downloader. Since the wiki linked to this (https://bbs.archlinux.org/viewtopic.php?id=192072) article I used the following command in /etc/pacman.conf to use aria2
XferCommand = echo Downloading %u ... && /usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf %u
you can find the full pacman.conf at the bottom as well as the pacman-aria2.conf.
Executed in the terminal (and %u changed to something else) this command works. Sadly when executed in pacman.conf the echo just prints out the whole line, including the "&&" and so on. Full output of pacman -Syy
is
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
Full output of sudo pacman -S 0ad
(The first entry in pacman with many dependencies and a large file size):
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
I interrupted because the integrity test did not proceed and I could tell it did not download anything because it took no time at all and the program should have at least 1GB
Of course the first thing was to remove the echo completely. This works. But since the "Download Result" (that is automatically printed by aria2 when a file download is complete) spammed my terminal so much I couldn't read anything, I added the line in the pacman-aria2.conf that removes this output. But now all that is written to the output looks like this:
[#b72206 3.9MiB/5.2MiB(75%) CN:3 DL:5.0MiB]
So I dont know what its actually downloading which is rather annoying especially when pacman is downloading many things at once (e.g. pacman -Syu
) hence the need for the "echo %u".
Other Fixing Attempts: In my pacman.conf you can see the remains of what were some tries of me (bug)fixing. Here the short list:
Changing the order of the two commands produced Exception caught
Exception: [download_helper.cc:451] errorCode=1 Unrecognized URI or unsupported protocol: &&
Writing a small bash script (/usr/local/bin/pacman-aria2.sh) which just contained the two commands in two seperate lines produced this:
Exception caught
Exception: [download_helper.cc:451] errorCode=1 Unrecognized URI or unsupported protocol: %u
which I assume is caused by me not sending the variables to the script but I dont know how to do that properly
neither wget nor curl nor the original command from the wiki produce the wanted output: wget again spams the console as well as the wiki command, curl on the other hand is completely without any info.
Conclusion: Since neither the wiki nor the man page of pacman state more information on the XferCommand I'm out of guesses. Any tip is appreciated. If you need more info I'll try to provide it.
Maybe Relevant Info:
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
Files:
/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
As per https://git.archlinux.org/pacman.git/commit/?id=808a4f15ce82d2ed7eeb06de73d0f313620558ee pacman no longer invokes the XferCommand via a shell, so shell syntax does not work.
You were on the right track with your idea to use a separate script:
echo Downloading %u ...
/usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf %u
However, obviously %u
is not interpreted by the script, you need to use "$1"
:
echo Downloading "$1" ...
/usr/bin/aria2c --conf-path=/etc/pacman-aria2.conf "$1"
pacman.conf:
XferCommand = /usr/local/bin/pacman-aria2.sh %u