How do you make a list/file for pacman to install from?
Solution 1:
pacman -Qqen > pkglist.txt
To install:
pacman -S - < pkglist.txt
From ArchWiki: https://wiki.archlinux.org/index.php/Pacman/Tips_and_tricks#List_of_installed_packages
Solution 2:
I know this is old but I wish to propose a more comprehensive solution.
The way I do it utilises the same idea and proposed in archlinux.org site.
-
First you need the list of packages, this can be done with
pacman -Qqe > pkglist.txt
Here
pacman -Q
queries all installed programs, the-q
removes version numbers and the-e
is for listing the explicitly installed programs. -
Now, when we want to restore/install the programs, I prefer doing
installable_packages=$(comm -12 <(pacman -Slq | sort) <(sort pkglist.txt)) pacman -S --needed $installable_packages
Here we only get the packages from the list are available from pacman. That is done with the
comm -12 file1 file2
command. The-12
flag suppresses unique lines in file 1 and 2 and leaves us with the intersection of the two files; i.e., the installable packages.