Sometimes you have need to backup installed packages.  I realize most port
management tools do this automatically, but if you're on a system with a lot
of packages installed and one port management tool fails and you use another
to fix it, /usr/ports/packages can become jumbled.  Anyways, I've written a
simple python script which will create a fresh snapshot of all installed
packages.  These are convenient for backups or installing on a new system.

For anyone interested:

from subprocess import Popen, PIPE
import os
s = Popen('pkg_info -a | grep : | grep
Information',shell=True,stdout=PIPE).communicate()[0]

pkg_location = '/data/packages'

packages = []
for line in s.split('\n'):
    info = line.replace('Information for ', '').replace(':','')
    packages.append(info)

os.chdir(pkg_location)

for package in packages:
    s = Popen('pkg_create -b ' +
package,shell=True,stdout=PIPE).communicate()[0]

-- 
Adam Vande More
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"

Reply via email to