How to reinstall automatically all the packages generated with the command "pkg-static info -g -Ea"

Hello.

I've generated the list with all packages that I have installed on my system using this command :

Code:
/usr/local/sbin/pkg-static info -g -Ea

that has produced this list :

https://pastebin.ubuntu.com/p/3fCY3hFRCG/

someone wrote a nice script that can reinstall automatically every package saved on that list ? I mean,the script should cut all the unnecessary stuff and should be able to create automatically something like this :

pkg install -Rf package1 package2 package3 and so on,until the last one.

I think that it would be very useful.
 
/usr/local/etc/pkg.conf has aliases in it.
prime-list: "query -e '%a = 0' '%n'", prime-origins: "query -e '%a = 0' '%o'",

are very useful
 
I'm not sure that your solution fits my needs. I imagine that I need to explain what's the context. My system was damaged. For a compiler error I couldn't compile ports. I've been able to fix it by exchanging some system files with another working installation. I have fixed the error,but in the while some of the previous system files aren't stored anymore on the system that I'm running at the moment. I want to restore them. Take in consideration that I use mainly packages,so I think that the easiest solution is to reinstall all the packages that are written on that list. I can't create a new list based on how the system is configured now,because now there are a lot of missing files and packages.
 
I can't create a new list based on how the system is now,because now there are a lot of missing files and packages.
As long as /var/db/pkg/local.sqlite is still good. That's where the 'records' of the installed packages are kept. It's irrelevant if the actual package files are there or not. If the registration of the package is in the database you can simply do pkg upgrade -f to have everything reinstalled.
 
If you install the shortlist of packages that were non-automated: this should bring in everything else that's required (as automated packages).
 
IMHO using a list that was produced via pkg info for reinstalling packages (e.g. to rebuild a host) is *really* bad, because all packages that are/were just dependencies (and hence might change or go stale) are marked as manually installed; so a pkg autoremove could never clean up unneeded packages.
To re-install packages e.g. after a reinstall always use lists produced via pkg prime-list or pkg prime-origins; otherwise to just refresh all packages (e.g. from a custom repository) use pkg upgrade -f as SirDice already suggested
 
Back
Top