recover installed package list based on file list content of /usr/local/bin

I'm going to say, you're screwed. There's pkg-which(8) which might be useful, but that too relies on information stored in /var. So you're left with a lot of guesswork. It's usually quite obvious where things came from but it's going to take a lot of work and guessing to figure it out.
 
You may compare the content with the pkg-plist files in the ports, that should give you a good idea. Kernel modules will not be found that way. Some shell-fu with a |sort|uniq will give you a starting point.
My shell skills are not up to speed any my linear thinking mode is offline since I'm busy since oh-dark-stupid (0430 to be precise).
 
Lol. Luckely i have found a two months old "pkg info" output .
In fact I'll write a daily "pkg info" script in crontab. Lessons learned.
 
Lol. Luckely i have found a two months old "pkg info" output .
In fact I'll write a daily "pkg info" script in crontab. Lessons learned.
Don’t you have a regular backup of that machine? You can simply recover /var/db/pkg from your latest backup.
 
Theoretically, this should work: Set up a test system, and install *all* packages on it. Then, for every thing you find in /usr/local/bin run "pkg which <thing>", and collate the output. Let's assume you have a complete list of file names in old_system.list, then seomthing like this should work (not tested):
Code:
( cat old_system.list | \
  while  read old_file
  do
    pkg which $old_file | \
    awk '{print $NF}'
  done ) | \
sort | uniq -c
That should give a list of packages, sorted, with a count of how many files were found for each. This is sort of the thing that crivens suggested above, just using a sacrificial test system instead of parsing the package plists.
 
Have you looked at your user history file for possible pkg clues?
I typically increase history threshold to "set history = 10000" in .cshrc for exactly this reason.

pkg install &{up key}

Obviously this would only work for pkg based installs.
 
In fact I'll write a daily "pkg info" script in crontab.
Loosely based on my backup:

pkg info > /path/to/mount/packages_all.txt
pkg query -e '%a = 0' %o > /path/to/mount/packages_base.txt
pkg query -e '%#r == 0' '%n-%v' > /path/to/mount/packages_nodeps.txt


pkg info is the least important - would only result in having packages restored as manually installed while they were automatic before. Only makes sense for a final comparison. But the other two are also great to set up new machines ;)
 
My root user has an "install.sh" script which contains all the commands I use for installing. One only needs to add to it. It also takes care of ports with changed flags or versions, like lame and drm-kmod.
Just my 2c.
 
Loosely based on my backup:

pkg info > /path/to/mount/packages_all.txt
pkg query -e '%a = 0' %o > /path/to/mount/packages_base.txt
pkg query -e '%#r == 0' '%n-%v' > /path/to/mount/packages_nodeps.txt


pkg info is the least important - would only result in having packages restored as manually installed while they were automatic before. Only makes sense for a final comparison. But the other two are also great to set up new machines ;)
I find descriptive aliases for leaf & prime-* in pkg alias. IMHO better use these, especially in a posting, because we can quickly guess what these commands do, instead of looking it up by pkg help query.
My root user has an "install.sh" script which contains all the commands I use for installing. One only needs to add to it. It also takes care of ports with changed flags or versions, like lame and drm-kmod.
Just my 2c.
Please post that script to Usefull Scripts?
 
Back
Top