Re: Recovering loss of /var/db/pkg ?
Robert Huff wrote: > Unfortunately, I know of no way of rebuilding the contents of >/var/db/pkg without re-(compiling, installing) every component of every >port. If it does not exist, this would be a _killer_ ability to have; >it's not often required (one hopes!) but when it is it would be a total >lifesaver. Well, if you know which ports were installed, and if the installed ports correspond to the versions in your ports tree, and if both make.conf and /var/db/ports are intact (a lot of ifs here ...), you can reconstruct it by running : make generate-plist fake-pkg in the origin of each of the installed ports, which doesn't require rebuilds. IF there is cruft left in /var/db/pkg, then you need to do this with FORCE_PKG_REGISTER=yes, or empty /var/db/pkg first. b. ___ 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"
Re: Recovering loss of /var/db/pkg ?
On 8/8/09, Mel Flynn wrote: > On Saturday 08 August 2009 03:02:05 b. f. wrote: > >> 2) write a script to get the names of all files that belonged to ports >> and swing through a ports tree, associating the files with ports via >> the pkg-plist and PLIST_FILES variables; or > > This is quite complex, time consuming and prone to error the more ports tree > and installed ports are out of sync. Either way, you will want to compare > files against the generate-plist target (and the resulting contents of > $TMPPLIST), as more and more ports use dynamic package list features. Yes, but then I was supposing that a complete reconstruction wasn't necessary -- just a listing of the majority of the ports, or at least the majority of the leaf ports. And grep is usually faster than many invocations of make. There are other shortcuts: if /var/db/ports is intact, you can look at the ports that you've had to config -- this will account for the majority of the larger, more complex ports at the top of the tree, with many dependencies, and so will cheaply give you many of your ports. Also don't forget your file database! 'locate /var/db/pkg' could give you many of your ports, if things haven't changed too much since the last time you updated your database, and the database is intact. > > To prevent this from happening in the future, I've written a small periodic > script that you can put in /usr/local/etc/periodic/daily and backs up the > list > of origins of installed ports. > Could come in handy. I usually keep a listing of 'portmaster -l' and a compressed backup /var/db/ports in a safe place. b. ___ 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"
Re: Recovering loss of /var/db/pkg ?
On Saturday 08 August 2009 03:02:05 b. f. wrote: > 2) write a script to get the names of all files that belonged to ports > and swing through a ports tree, associating the files with ports via > the pkg-plist and PLIST_FILES variables; or This is quite complex, time consuming and prone to error the more ports tree and installed ports are out of sync. Either way, you will want to compare files against the generate-plist target (and the resulting contents of $TMPPLIST), as more and more ports use dynamic package list features. To prevent this from happening in the future, I've written a small periodic script that you can put in /usr/local/etc/periodic/daily and backs up the list of origins of installed ports. On the first run (or more to the point, if /var/backup/pkglist.prev doesn't exist), it will dump the current list. Otherwise, it will compare with the previous run and provide a diff if anything changed. So: - if you set $daily_backup_pkglist_enable to YES in /etc/periodic.conf - if you have daily reports mailed to an off-machine address - and if you keep the first run and all diffs You can recreate an accurate list of installed ports, when applying all diffs in sequence, even if you newfs'd /var on the machine. -- Mel #!/bin/sh # # $Coar: periodic/daily/203.backup-pkglist.sh,v 1.3 2009/08/08 17:04:41 mel Exp $ # # If there is a global system configuration file, suck it in. # if [ -r /etc/defaults/periodic.conf ] then . /etc/defaults/periodic.conf source_periodic_confs fi daily_backup_pkglist_enable=${daily_backup_pkglist_enable:-"NO"} daily_backup_pkglist_dbdir=${daily_backup_pkglist_dbdir:-"/var/db/pkg"} create_pkglist() { local f f=$1 for CFILE in ${daily_backup_pkglist_dbdir}/*/+CONTENTS; do sed -ne 's,^...@comment ORIGIN:,,p' ${CFILE} done | sort > ${f} } case "$daily_backup_pkglist_enable" in [Yy][Ee][Ss]) if [ ! -d ${daily_backup_pkglist_dbdir} ] then echo '$daily_backup_pkglist_enable is enabled but' \ "${daily_backup_pkglist_dbdir} doesn't exist" rc=2 else bak=/var/backups rc=0 echo "" echo "Backing up list of package origins:" create_pkglist $bak/pkglist.cur if [ ! -f $bak/pkglist.prev ] then echo "no $bak/pkglist.prev. Dumping full list for prosperity:" cat $bak/pkglist.cur cp -p $bak/pkglist.cur $bak/pkglist.prev fi if ! cmp -s $bak/pkglist.prev $bak/pkglist.cur then [ $rc -lt 1 ] && rc=1 echo "$host pkglist diffs:" diff -u $bak/pkglist.prev $bak/pkglist.cur mv $bak/pkglist.cur $bak/pkglist.prev fi fi;; *) rc=0;; esac exit $rc ___ 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"
Re: Recovering loss of /var/db/pkg ?
Volodymyr Kostyrko wrote: I'll just say it plainly: /var/db/pkg is long gone and there is no backup. It was not copied to new a machine. Is there is any hope of being able to use the ports or packages system in a meangingful way again? My sense is that some recovery is possible, but may be prohibitively expensive. Thanks for any tips! There are a lot of common places the files would be installed such as bin, sbin, lib, libexec under %%PREFIX%%. If the OP's intention is to be able to reconstruct the dependency tree, he's hosed. If the intention is to find out what was installed, there is some hope. This method works under the following conditions: 1) you were using ports (it may or may not work for packages) 2) you have not deleted /usr/ports/distfiles Basically, sweep through /usr/ports/distfiles. Most entries can be pretty easily mapped to the associated port, including version number. Unfortunately, I know of no way of rebuilding the contents of /var/db/pkg without re-(compiling, installing) every component of every port. If it does not exist, this would be a _killer_ ability to have; it's not often required (one hopes!) but when it is it would be a total lifesaver. Robert Huff ___ 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"
Re: Recovering loss of /var/db/pkg ?
>There are a lot of common places the files would be installed such as >bin, sbin, lib, libexec under %%PREFIX%%. You can use `find dir -type f >| xargs -n1 -Ifoo sh -c "echo -n foo:; pkg_which foo"` to obtain the >list of known files (pkg_which is part of ports-mgmt/portsupgrade). >After that you can reinstall all packages that provide files with >missing origin. I bet you should use the same /usr/ports you have last >time when /var/db/pkg was full, just to be very close to pkg-plist. Er, except that pkg_which uses the portupgrade package database which is installed by default in -- you guessed it -- /var/db/pkg. So if you don't have it backed up somewhere, or don't have PKG_DBDIR defined to a non-default location, you're out of luck. And if it is still intact, __back it up__ before calling any of the pkgtools -- or you may wipe it out as pkg_which does an automatic update of the pkgdb after seeing that /var/db/pkg has been modified more recently than the database. Just use pkg_glob -qOa -- no need to use pkg_which. If you don't have it, you can: 1) use data recovery tools to try to read the names of the subdirectories of /var/db/pkg from the disk; or 2) write a script to get the names of all files that belonged to ports and swing through a ports tree, associating the files with ports via the pkg-plist and PLIST_FILES variables; or 3) rip out all the old junk, and try to start afresh. b. ___ 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"
Re: Recovering loss of /var/db/pkg ?
Mark Stosberg wrote: I'll just say it plainly: /var/db/pkg is long gone and there is no backup. It was not copied to new a machine. Is there is any hope of being able to use the ports or packages system in a meangingful way again? My sense is that some recovery is possible, but may be prohibitively expensive. Thanks for any tips! There are a lot of common places the files would be installed such as bin, sbin, lib, libexec under %%PREFIX%%. You can use `find dir -type f | xargs -n1 -Ifoo sh -c "echo -n foo:; pkg_which foo"` to obtain the list of known files (pkg_which is part of ports-mgmt/portsupgrade). After that you can reinstall all packages that provide files with missing origin. I bet you should use the same /usr/ports you have last time when /var/db/pkg was full, just to be very close to pkg-plist. Other ways can include moving all %%PREFIX%% to %%PREFIX%%.old and building all ports from scratch. -- Sphinx of black quartz judge my vow. ___ 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"
Re: Recovering loss of /var/db/pkg ?
You could try to recover the file from the disk if it has not been reallocated using something like The Sleuth Kit: http://www.sleuthkit.org/ You can use fls to find the location of the file on the disk and then icat to recover. On Wed, Apr 8, 2009 at 12:29 PM, Mark Stosberg wrote: > > I'll just say it plainly: > > /var/db/pkg is long gone and there is no backup. It was not copied to > new a machine. > > Is there is any hope of being able to use the ports or packages system in a > meangingful way again? > > My sense is that some recovery is possible, but may be prohibitively > expensive. > > Thanks for any tips! > > Mark > > > ___ > 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" > -- Thx Joshua Gimer ___ 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"
Re: Recovering loss of /var/db/pkg ?
Lowell Gilbert writes: > > /var/db/pkg is long gone and there is no backup. It was not copied to > > new a machine. > > > > Is there is any hope of being able to use the ports or packages > > system in a meangingful way again? > > You can do a forced reinstall of all your ports, and you'll end > up with a repopulated ports database. It will take a lot of > clock time, but not much human time. Assuming everything goes cleanly. > It's not necessarily easy to figure out what all of the ports > were, but there are a number of choices. It will make life ... interesting ... if the OP ever wants to update. I'm not sure I fully understand the original question. However: I have ~950 ports on the current box. At one point I lost /var/db/pkg and needed to rebuild. Remembering some of what was installed was easy - OpenOffice, FireFox, java, gnome/kde, etc., all of which draw in large numbers of (cummonly-used) dependencies. But there were others I would have had no hope of even remembering I had installed. Then I realized I still had /usr/ports/distfiles, and most of the tarball names give you enough clue you can correctly guess the package from /usr/ports INDEX. If I knew anything about the MASTER_SITES (I think) variable(s ?) I could porbably have written a script. (For those who go this route, the "pkg_sort" program that comes with portupgrade will be useful.) Robert huff ___ 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"
Re: Recovering loss of /var/db/pkg ?
Mark Stosberg writes: > I'll just say it plainly: > > /var/db/pkg is long gone and there is no backup. It was not copied to > new a machine. > > Is there is any hope of being able to use the ports or packages system in a > meangingful way again? > > My sense is that some recovery is possible, but may be prohibitively > expensive. You can do a forced reinstall of all your ports, and you'll end up with a repopulated ports database. It will take a lot of clock time, but not much human time. It's not necessarily easy to figure out what all of the ports were, but there are a number of choices. If you can wipe out most of /usr/local and rebuild the ports, you can reinstall everything you want, and the database will be repopulated in the process. That's the easiest approach to understand, but involves considerable downtime. Another alternative would be to install all the ports to a non-standard PREFIX, and use the results of that to tell you which ports need to be reinstalled to the standard PREFIX. -- Lowell Gilbert, embedded/networking software engineer, Boston area http://be-well.ilk.org/~lowell/ ___ 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"