I know that, when you are trying to install archlinux to a different root path
you should create the dbpath before or add your own dbpath as a command line option.
# mkdir -pv /mnt/var/lib/pacman # pacman -Sy base -r /mnt -v -y
# pacman -Sy base -r /mnt --dbpath /var/lib/pacman -v -y
the above examples are two different things, but you get my point (hopefully)
Whouldn't be possible pacman to use /var/lib/pacman (system folder) by default ?
No, the whole point of the --root option is to tell Pacman to use paths within that root. If you had to manually configure each and every path (db, cache, gpg) then not only would the --root option be useless, setting roots would also be highly error-prone.
If you don't want to use the --dbpath command-line option, create a custom pacman.conf file and use that with the "--config" option to install to a different root.
thats reasonable enough. Every dir must be under the new root path.
I cant use the first example without creating the var/lib/pacman dir inside root path first.
For me, an error about initialize alpm library is something that i can handle but it could be more user friendly (bad words ?) if pacman could create the var/lib/pacman inside the new root path.
You mean this message?
$ pacman -Syr foo/ error: failed to initialize alpm library (could not find or read directory)
I agree, it is not helpful. You can submit a request for auto-creation of missing directories to the pacman-dev mailing list, or at least request a more helpful message. The devs will likely tell you to submit a patch, but given how simple this should be, one of them may do it for you.
The existing directory requirement is useful imo, it prevents you for accidentally installing things to the wrong place with -r, because of user error (e.g. using '-r /mnt' instead of '-r /mnt/newroot').
Mobo: ASUS P8Z77-V PRO // Processor: Intel Core i7-3770K 3.4GHz // GFX: nVidia GeForce GTX 970 Ti // RAM: 32GB (4x 8GB) Corsair DDR3 (@ 2133MHz) // Storage: 1x 3TB Seagate SATAII 5x 1TB Samsung SATAII, 2x 120GB Corsair SSD
Making lemonade from lemons since 2015.