Re: regenerating /var/db/pkg
On Mon, Apr 26, 2010 at 5:33 AM, Doug Barton do...@freebsd.org wrote: FWIW, this looks fine to me. Have you submitted a PR? Yes, http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/145957 ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: regenerating /var/db/pkg
2010/4/25 Doug Barton do...@freebsd.org: On 04/25/10 19:44, Garrett Cooper wrote: On Thu, Apr 22, 2010 at 10:05 AM, Eitan Adler eitanadlerl...@gmail.com wrote: Same as before - if all is good I'll send a PR #!/bin/sh # # $FreeBSD: src/etc/periodic/daily/210.backup-aliases,v 1.6.36.1.2.1 2009/10/25 01:10:29 kensmith 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 bak=/var/backups db_loc=$(/usr/bin/make -f/usr/share/mk/bsd.port.mk -V PKG_DBDIR 2/dev/null) bk_loc=$bak/pkgdb.bak.tar.bz2 case $daily_backup_pkgdb_enable in [Yy][Ee][Ss]) This could be done via rc.subr's checkyesno function. It's periodic, not rc.d. :) It would be nice if some of the more usable functions got moved out of rc.subr though :(... It would cure 20 lines of duplicate code here and elsewhere outside of rc land... if [ ! -d $db_loc ] Please quote the string. I generally do quote the string as a matter of paranoia, however the practical result is likely to be the same. Yes, and you're assuming that users won't do: PKG_DBDIR := /my /super /special/ directory with spaces Granted, a lot of things probably won't work that way, but just compounding to the issue of not quoting variables seems like a silly mistake to make :/. Thanks, -Garrett ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: regenerating /var/db/pkg
It would be nice if some of the more usable functions got moved out of rc.subr though :(... It would cure 20 lines of duplicate code here and elsewhere outside of rc land... Where should they go? I'll gladly work on a patch to make them available to periodic scripts. Yes, and you're assuming that users won't do: PKG_DBDIR := /my /super /special/ directory with spaces Granted, a lot of things probably won't work that way, but just compounding to the issue of not quoting variables seems like a silly mistake to make :/. IMHO a user that uses crazy things should know that things will break Almost no program around correctly handles all filenames: http://www.dwheeler.com/essays/filenames-in-shell.html ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: regenerating /var/db/pkg
On Thu, 22 Apr 2010 20:05:48 +0300 Eitan Adler eitanadlerl...@gmail.com wrote: bak=/var/backups This should be configurable IMO. ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: regenerating /var/db/pkg
On Mon, Apr 26, 2010 at 2:01 PM, RW rwmailli...@googlemail.com wrote: On Thu, 22 Apr 2010 20:05:48 +0300 Eitan Adler eitanadlerl...@gmail.com wrote: bak=/var/backups This should be configurable IMO. This currently isn't configurable in 210.backup-aliases which is where I copied this from. I'm going to submit a *separate* PR with an enhancement allowing configuration of the backup location. If accepted I'll update my 220.backup.pkgdb script. ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: regenerating /var/db/pkg
FWIW, this looks fine to me. Have you submitted a PR? Doug On 04/22/10 10:05, Eitan Adler wrote: Same as before - if all is good I'll send a PR #!/bin/sh # # $FreeBSD: src/etc/periodic/daily/210.backup-aliases,v 1.6.36.1.2.1 2009/10/25 01:10:29 kensmith 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 bak=/var/backups db_loc=$(/usr/bin/make -f/usr/share/mk/bsd.port.mk -V PKG_DBDIR 2/dev/null) bk_loc=$bak/pkgdb.bak.tar.bz2 case $daily_backup_pkgdb_enable in [Yy][Ee][Ss]) if [ ! -d $db_loc ] then echo '$daily_backup_pkgdb_enable is enabled but' \ $db_loc doesn't exist rc=2 else rc=0 echo echo Backing up package db directory: [ -e $bk_loc ] unlink $bk_loc tar -cjf $bk_loc $db_loc || rc=3 fi;; *) rc=0;; esac exit $rc -- ... and that's just a little bit of history repeating. -- Propellerheads Improve the effectiveness of your Internet presence with a domain name makeover!http://SupersetSolutions.com/ ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: regenerating /var/db/pkg
On Thu, Apr 22, 2010 at 10:05 AM, Eitan Adler eitanadlerl...@gmail.com wrote: Same as before - if all is good I'll send a PR #!/bin/sh # # $FreeBSD: src/etc/periodic/daily/210.backup-aliases,v 1.6.36.1.2.1 2009/10/25 01:10:29 kensmith 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 bak=/var/backups db_loc=$(/usr/bin/make -f/usr/share/mk/bsd.port.mk -V PKG_DBDIR 2/dev/null) bk_loc=$bak/pkgdb.bak.tar.bz2 case $daily_backup_pkgdb_enable in [Yy][Ee][Ss]) This could be done via rc.subr's checkyesno function. if [ ! -d $db_loc ] Please quote the string. then echo '$daily_backup_pkgdb_enable is enabled but' \ $db_loc doesn't exist rc=2 else rc=0 echo echo Backing up package db directory: [ -e $bk_loc ] unlink $bk_loc Please quote. tar -cjf $bk_loc $db_loc || rc=3 Same here. fi;; *) rc=0;; esac exit $rc Thanks, -Garrett ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: regenerating /var/db/pkg
On 04/25/10 19:44, Garrett Cooper wrote: On Thu, Apr 22, 2010 at 10:05 AM, Eitan Adler eitanadlerl...@gmail.com wrote: Same as before - if all is good I'll send a PR #!/bin/sh # # $FreeBSD: src/etc/periodic/daily/210.backup-aliases,v 1.6.36.1.2.1 2009/10/25 01:10:29 kensmith 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 bak=/var/backups db_loc=$(/usr/bin/make -f/usr/share/mk/bsd.port.mk -V PKG_DBDIR 2/dev/null) bk_loc=$bak/pkgdb.bak.tar.bz2 case $daily_backup_pkgdb_enable in [Yy][Ee][Ss]) This could be done via rc.subr's checkyesno function. It's periodic, not rc.d. :) if [ ! -d $db_loc ] Please quote the string. I generally do quote the string as a matter of paranoia, however the practical result is likely to be the same. Doug -- ... and that's just a little bit of history repeating. -- Propellerheads Improve the effectiveness of your Internet presence with a domain name makeover!http://SupersetSolutions.com/ ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: regenerating /var/db/pkg
On 04/25/10 19:55, Doug Barton wrote: if [ ! -d $db_loc ] I generally do quote the string as a matter of paranoia, however the practical result is likely to be the same. ... unless it's possible that the path name will have spaces in it, which is the main reason for my paranoia. -- ... and that's just a little bit of history repeating. -- Propellerheads Improve the effectiveness of your Internet presence with a domain name makeover!http://SupersetSolutions.com/ ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: regenerating /var/db/pkg
On Thu, Apr 22, 2010 at 08:56:39AM -0500, Dan Rue wrote: On Thu, Apr 22, 2010 at 03:21:16PM +0300, Eitan Adler wrote: Just asking opinions, if people want this, I'll make a patch and file a PR. Is this script correct? We're starting to use SSDs for boot drives in our freebsd boxes. We'd like to have /var on a memory backed FS, but losing the package database on every reboot is troublesome. This script would be a decent solution to my problem as well, You can look into how NanoBSD does things if you want to go this route. -- WXS ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: regenerating /var/db/pkg
I once coded a shellscript to do that, restore from corrupted pkgdb I have it at work (if you can wait until next monday) the easyest way I found was to pkg_add -Ff every package missing in pkg_info, and extract missing files from packages still there but you would need a package list to do that Samuel Martín Moro {EPITECH.} tek4 CamTrace S.A.S On Thu, Apr 22, 2010 at 7:43 AM, Doug Barton do...@freebsd.org wrote: a ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: regenerating /var/db/pkg
On Wed, Apr 21, 2010 at 10:43:37PM -0700, Doug Barton typed: On 4/20/2010 7:11 PM, Aryeh M. Friedman wrote: I acciddentally rm'ed my /var/db/pkg and want to know is it possible to rgenerate it (I have portmaster and portupgrade installed) Portmaster certainly can't do this, it uses the information from /var/db/pkg. I'm not sure if portupgrade can do it or not. Your most likely course of success is to generate a list of ports that you know you're using (root and leaf ports in portmaster terminology), back up any config or other key files from /usr/local, then delete everything and reinstall. This question (how to restore /var/db/pkg) comes up fairly regularly. How about adding a /etc/periodic/daily/220.backup-pkgdb script or something? Just asking opinions, if people want this, I'll make a patch and file a PR. Ruben ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: regenerating /var/db/pkg
Just asking opinions, if people want this, I'll make a patch and file a PR. Is this script correct? #!/bin/sh # # $FreeBSD: src/etc/periodic/daily/210.backup-aliases,v 1.6.36.1.2.1 2009/10/25 01:10:29 kensmith 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 bak=/var/backups db_loc=/var/db/pkg; bk_loc=/$bak/pkgdb.bak.tar case $daily_backup_pkgdb_enable in [Yy][Ee][Ss]) if [ ! -d $db_loc ] then echo '$daily_backup_pkgdb_enable is enabled but' \ $db_loc doesn't exist rc=2 else rc=0 echo echo Backing up mail aliases: if [ ! -f $bk_loc ] then echo no $bk_loc tar -cjf $bk_loc $db_loc || rc=3 fi fi;; *) rc=0;; esac exit $rc ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: regenerating /var/db/pkg
On Tue, Apr 20, 2010 at 10:11:24PM -0400, Aryeh M. Friedman wrote: I acciddentally rm'ed my /var/db/pkg and want to know is it possible to rgenerate it (I have portmaster and portupgrade installed) You would have to write a script which went through each file in /usr/local/bin and /usr/local/lib (mostly sufficient) and examined every single pkg-plist looking for the corresponding file. Then you know what port the file was generated by. Needless to say, this would be somewhat horrible. - Diane -- - d...@freebsd.org d...@db.net http://www.db.net/~db ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: regenerating /var/db/pkg
Hmm, I guess you shouldn't backup /var/foo to /var/bar. If /var is lost, your backup is gone, too. I took the backup location from one of the other periodic scripts. Where should it be backed up to then? ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: regenerating /var/db/pkg
On Thu, Apr 22, 2010 at 03:21:16PM +0300, Eitan Adler wrote: Just asking opinions, if people want this, I'll make a patch and file a PR. Is this script correct? #!/bin/sh # # $FreeBSD: src/etc/periodic/daily/210.backup-aliases,v 1.6.36.1.2.1 2009/10/25 01:10:29 kensmith 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 bak=/var/backups db_loc=/var/db/pkg; bk_loc=/$bak/pkgdb.bak.tar case $daily_backup_pkgdb_enable in [Yy][Ee][Ss]) if [ ! -d $db_loc ] then echo '$daily_backup_pkgdb_enable is enabled but' \ $db_loc doesn't exist rc=2 else rc=0 echo echo Backing up mail aliases: if [ ! -f $bk_loc ] then echo no $bk_loc tar -cjf $bk_loc $db_loc || rc=3 fi fi;; *) rc=0;; esac exit $rc Hmm, I guess you shouldn't backup /var/foo to /var/bar. If /var is lost, your backup is gone, too. pgpP1ekZ55zoj.pgp Description: PGP signature
Re: regenerating /var/db/pkg
On Thu, Apr 22, 2010 at 04:12:08PM +0300, Eitan Adler wrote: Hmm, I guess you shouldn't backup /var/foo to /var/bar. If /var is lost, your backup is gone, too. In your crontab MAILTO=... @weekly /usr/sbin/pkg_info -I -a Once a week is reasonable. - Diane -- - d...@freebsd.org d...@db.net http://www.db.net/~db ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: regenerating /var/db/pkg
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Thu, 22 Apr 2010 15:21+0300, Eitan Adler wrote: Just asking opinions, if people want this, I'll make a patch and file a PR. Is this script correct? #!/bin/sh # # $FreeBSD: src/etc/periodic/daily/210.backup-aliases,v 1.6.36.1.2.1 2009/10/25 01:10:29 kensmith 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 bak=/var/backups db_loc=/var/db/pkg; bk_loc=/$bak/pkgdb.bak.tar It's really no big deal, but from a pragmatic view I'd write: bk_loc=$bak/pkgdb.bak.tar Otherwise $bk_loc will contain: //var/backups/pkgdb.bak.tar case $daily_backup_pkgdb_enable in [Yy][Ee][Ss]) if [ ! -d $db_loc ] then echo '$daily_backup_pkgdb_enable is enabled but' \ $db_loc doesn't exist rc=2 else rc=0 echo echo Backing up mail aliases: It's really the package directory, no? if [ ! -f $bk_loc ] then echo no $bk_loc tar -cjf $bk_loc $db_loc || rc=3 How do you plan to capture changes made to /var/db/pkg? If we're supposed to manually delete /var/backups/pkgdb.bak.tar from time to time, then the presented code is probably ok. fi fi;; *) rc=0;; esac exit $rc Just my $0.02, Trond. - -- - -- Trond Endrestøl | trond.endres...@fagskolen.gjovik.no ACM, NAS, NUUG, SAGE, USENIX |FreeBSD 8.0-STABLE Alpine 2.00 -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAkvQWvIACgkQbYWZalUoEluyegCfYq/FMpdT9/wRGQyGF8+2WgKQ aGIAn2S2br054BRHc38IpB4uWYVYH94I =GA9V -END PGP SIGNATURE-___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: regenerating /var/db/pkg
On Thu, Apr 22, 2010 at 03:21:16PM +0300, Eitan Adler wrote: Just asking opinions, if people want this, I'll make a patch and file a PR. Is this script correct? We're starting to use SSDs for boot drives in our freebsd boxes. We'd like to have /var on a memory backed FS, but losing the package database on every reboot is troublesome. This script would be a decent solution to my problem as well, Dan ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: regenerating /var/db/pkg
On Thu, Apr 22, 2010 at 08:56:39AM -0500, Dan Rue wrote: We're starting to use SSDs for boot drives in our freebsd boxes. We'd like to have /var on a memory backed FS, but losing the package database on every reboot is troublesome. Tried using a symlink from /var/db/pkg to /usr/local/.pkgdb or so? Joerg ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: regenerating /var/db/pkg
taking into account your feedback here is the new version If all is good I'll submit a PR #!/bin/sh # # $FreeBSD: src/etc/periodic/daily/210.backup-aliases,v 1.6.36.1.2.1 2009/10/25 01:10:29 kensmith 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 bak=/var/backups db_loc=/var/db/pkg; bk_loc=$bak/pkgdb.bak.tar case $daily_backup_pkgdb_enable in [Yy][Ee][Ss]) if [ ! -d $db_loc ] then echo '$daily_backup_pkgdb_enable is enabled but' \ $db_loc doesn't exist rc=2 else rc=0 echo echo Backing up package db directory: rm -f $bk_loc tar -cjf $bk_loc $db_loc || rc=3 fi;; *) rc=0;; esac exit $rc ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: regenerating /var/db/pkg
On 4/22/2010 6:44 AM, Diane Bruce wrote: On Thu, Apr 22, 2010 at 04:12:08PM +0300, Eitan Adler wrote: Hmm, I guess you shouldn't backup /var/foo to /var/bar. If /var is lost, your backup is gone, too. In your crontab MAILTO=... @weekly /usr/sbin/pkg_info -I -a pkg_info -o -a would probably be more useful from the standpoint of rebuilding ports after a lost /var/db/pkg. For portmaster users 'portmaster --list-origins' would give you a list that you could then do 'portmaster `cat list`' to rebuild everything for you. hth, Doug -- ... and that's just a little bit of history repeating. -- Propellerheads Improve the effectiveness of your Internet presence with a domain name makeover!http://SupersetSolutions.com/ ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: regenerating /var/db/pkg
On 4/22/2010 9:08 AM, Eitan Adler wrote: taking into account your feedback here is the new version If all is good I'll submit a PR #!/bin/sh # # $FreeBSD: src/etc/periodic/daily/210.backup-aliases,v 1.6.36.1.2.1 2009/10/25 01:10:29 kensmith 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 bak=/var/backups db_loc=/var/db/pkg; The trailing ; here is superfluous. Also, a better invocation might be: db_loc=`pm_make -f/usr/share/mk/bsd.port.mk -V PKG_DBDIR 2/dev/null` to support people who redefine it. bk_loc=$bak/pkgdb.bak.tar Since you (properly) compress the archive on the tar command line, that should be: bk_loc=$bak/pkgdb.bak.tar.bz2 case $daily_backup_pkgdb_enable in [Yy][Ee][Ss]) if [ ! -d $db_loc ] then echo '$daily_backup_pkgdb_enable is enabled but' \ $db_loc doesn't exist rc=2 else rc=0 echo echo Backing up package db directory: rm -f $bk_loc [ -e $bk_loc ] unlink $bk_loc tar -cjf $bk_loc $db_loc || rc=3 fi;; *) rc=0;; esac exit $rc hth, Doug -- ... and that's just a little bit of history repeating. -- Propellerheads Improve the effectiveness of your Internet presence with a domain name makeover!http://SupersetSolutions.com/ ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: regenerating /var/db/pkg
On 4/22/2010 9:54 AM, Doug Barton wrote: Also, a better invocation might be: db_loc=`pm_make -f/usr/share/mk/bsd.port.mk -V PKG_DBDIR 2/dev/null` Make that just /usr/bin/make instead of pm_make, I should have looked more carefully at what I pasted. :) Doug -- ... and that's just a little bit of history repeating. -- Propellerheads Improve the effectiveness of your Internet presence with a domain name makeover!http://SupersetSolutions.com/ ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: regenerating /var/db/pkg
Same as before - if all is good I'll send a PR #!/bin/sh # # $FreeBSD: src/etc/periodic/daily/210.backup-aliases,v 1.6.36.1.2.1 2009/10/25 01:10:29 kensmith 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 bak=/var/backups db_loc=$(/usr/bin/make -f/usr/share/mk/bsd.port.mk -V PKG_DBDIR 2/dev/null) bk_loc=$bak/pkgdb.bak.tar.bz2 case $daily_backup_pkgdb_enable in [Yy][Ee][Ss]) if [ ! -d $db_loc ] then echo '$daily_backup_pkgdb_enable is enabled but' \ $db_loc doesn't exist rc=2 else rc=0 echo echo Backing up package db directory: [ -e $bk_loc ] unlink $bk_loc tar -cjf $bk_loc $db_loc || rc=3 fi;; *) rc=0;; esac exit $rc ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: regenerating /var/db/pkg
On Thu, Apr 22, 2010 at 09:48:37AM -0700, Doug Barton wrote: On 4/22/2010 6:44 AM, Diane Bruce wrote: On Thu, Apr 22, 2010 at 04:12:08PM +0300, Eitan Adler wrote: ... MAILTO=... @weekly /usr/sbin/pkg_info -I -a pkg_info -o -a would probably be more useful from the standpoint of The sensible thing to do is to be putting a thumb drive on your machine and backing up the /var/db/pkg after updating. An e-mailed list of any sort would be a last resort and having it fairly compact is a compromise, since you do have the thumb drive to fall back on right? rebuilding ports after a lost /var/db/pkg. For portmaster users 'portmaster --list-origins' would give you a list that you could then do 'portmaster `cat list`' to rebuild everything for you. YMMV ;-) - Diane -- - d...@freebsd.org d...@db.net http://www.db.net/~db ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: regenerating /var/db/pkg
Am 22.04.2010 14:49, schrieb Diane Bruce: On Tue, Apr 20, 2010 at 10:11:24PM -0400, Aryeh M. Friedman wrote: I acciddentally rm'ed my /var/db/pkg and want to know is it possible to rgenerate it (I have portmaster and portupgrade installed) You would have to write a script which went through each file in /usr/local/bin and /usr/local/lib (mostly sufficient) and examined every single pkg-plist looking for the corresponding file. Then you know what port the file was generated by. Needless to say, this would be somewhat horrible. Diane, it's not *that* bad. Consider this algorithm: 1. scan for files under /usr/local/{bin,include,lib,libexec,sbin} and sort or hash the list - perhaps guess just a port name from an executable in /usr/local/bin 2. Repeat: 2.1 use the next file from the list and search for it 2.2 once you have a port name for this file, obtain the packing list and remove it from the file list in 1. This cuts down the list from 1 quite a bit. 3. Now print the list of ports found, and print the list of files not found in ports Surely and index of plist files in port default configurations could help big time, but even a blunt ( cd /usr/ports find . -mindepth 3 -maxdepth 3 -name pkg-plist -exec egrep FILENAME '{}' + ) might be reasonable given sufficient RAM so that it runs from cache for the 2nd file you inquire. If that is too slow, a step between 1 and 2 could procure all pkg-plists as some sort of FILEINDEX file to accelerate searches. HTH Matthias ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: regenerating /var/db/pkg
hi, have you tried pkgdb -u ? -- psr มะฃาม ฅินเดินดน มะไฟ ฅนเหลิงฟ้า http://makham.blogspot.com Quoting Diane Bruce d...@db.net: On Tue, Apr 20, 2010 at 10:11:24PM -0400, Aryeh M. Friedman wrote: I acciddentally rm'ed my /var/db/pkg and want to know is it possible to rgenerate it (I have portmaster and portupgrade installed) You would have to write a script which went through each file in /usr/local/bin and /usr/local/lib (mostly sufficient) and examined every single pkg-plist looking for the corresponding file. Then you know what port the file was generated by. Needless to say, this would be somewhat horrible. - Diane -- - d...@freebsd.org d...@db.net http://www.db.net/~db ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org This message was sent using IMP, the Internet Messaging Program. ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: regenerating /var/db/pkg
Am 22.04.2010 14:49, schrieb Diane Bruce: On Tue, Apr 20, 2010 at 10:11:24PM -0400, Aryeh M. Friedman wrote: I acciddentally rm'ed my /var/db/pkg and want to know is it possible to rgenerate it (I have portmaster and portupgrade installed) You would have to write a script which went through each file in /usr/local/bin and /usr/local/lib (mostly sufficient) and examined every single pkg-plist looking for the corresponding file. Then you know what port the file was generated by. Needless to say, this would be somewhat horrible. Diane, it's not *that* bad. Consider this algorithm: 1. scan for files under /usr/local/{bin,include,lib,libexec,sbin} and sort or hash the list - perhaps guess just a port name from an executable in /usr/local/bin 2. Repeat: 2.1 use the next file from the list and search for it 2.2 once you have a port name for this file, obtain the packing list and remove it from the file list in 1. This cuts down the list from 1 quite a bit. 3. Now print the list of ports found, and print the list of files not found in ports Surely and index of plist files in port default configurations could help big time, but even a blunt ( cd /usr/ports find . -mindepth 3 -maxdepth 3 -name pkg-plist -exec egrep FILENAME '{}' + ) might be reasonable given sufficient RAM so that it runs from cache for the 2nd file you inquire. If that is too slow, a step between 1 and 2 could procure all pkg-plists as some sort of FILEINDEX file to accelerate searches. HTH Matthias By the time you account for CONFLICTS, dynamic plists, substitutions in plists, etc., I'd have to agree with Diane that this is a pain. It could be done, and would help to reconstruct most if not all of an average user's /var/db/pkg, but it's laborious. b. ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: regenerating /var/db/pkg
Doug Barton wrote: On 4/20/2010 7:11 PM, Aryeh M. Friedman wrote: I acciddentally rm'ed my /var/db/pkg and want to know is it possible to rgenerate it (I have portmaster and portupgrade installed) Portmaster certainly can't do this, it uses the information from /var/db/pkg. I'm not sure if portupgrade can do it or not. Your most likely course of success is to generate a list of ports that you know you're using (root and leaf ports in portmaster terminology), back up any config or other key files from /usr/local, then delete everything and reinstall. With regard to portupgrade, if your pkgdb file is intact, you should be able to reconstruct /var/db/pkg, although it may not be very convenient to do so. Unfortunately, by default the pkgdb file is /var/db/pkg/pkgdb.db, so it is often wiped out along with the rest of /var/db/pkg. However, if it is intact, make sure you first back it up before attempting to use it's contents, because most of the pkgtools attempt to edit it to correspond with the current state of /var/db/pkg (performing the equivalent of pkgdb -u/-aF) when invoked. You may be able to disable this editing via the -O flag, but I haven't checked this lately. If you have a list of installed packages, and a corresponding ports tree, you could reconstruct most but probably not all of /var/db/pkg by running make generate-plist fake-pkg in the ports tree origin of each package (if you built the packages with non-default options, you should have an intact /var/db/ports for this to fully work). The directories for packages with dynamic plists might not be fully restored without rebuilding the ports, but this may be enough for a first pass. You could then prune or account for files in PREFIX/LOCALBASE that aren't listed as belonging to a registered package, via something like: find /usr/local -type f -print0 | xargs -0 pkg_which -v | fgrep '?' or with something similar using pkg_info -W... instead of pkg_which -v. Alternatively, if you have backups of all the installed packages, or can obtain them from a server, you could use their packing lists to restore /var/db/pkg. But as Doug suggests, a full cleanup of PREFIX/LOCALBASE and reinstallation of all leaf packages may be easier than a reconstruction of /var/db/pkg. b. ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: regenerating /var/db/pkg
On Thu, Apr 22, 2010 at 06:48:43PM +, b. f. wrote: Doug Barton wrote: On 4/20/2010 7:11 PM, Aryeh M. Friedman wrote: ... find /usr/local -type f -print0 | xargs -0 pkg_which -v | fgrep '?' libchk would also be useful. ... But as Doug suggests, a full cleanup of PREFIX/LOCALBASE and reinstallation of all leaf packages may be easier than a reconstruction of /var/db/pkg. ... I also agree with Doug here. The key thing is to have a record or a good idea of what you had installed in the first place. I reiterate, having a thumb drive with copies of your /etc,/var/db/pkg /usr/local/etc, you get the idea, is very useful to have around. - Diane __ - d...@freebsd.org d...@db.net http://www.db.net/~db ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Re: regenerating /var/db/pkg
On 4/20/2010 7:11 PM, Aryeh M. Friedman wrote: I acciddentally rm'ed my /var/db/pkg and want to know is it possible to rgenerate it (I have portmaster and portupgrade installed) Portmaster certainly can't do this, it uses the information from /var/db/pkg. I'm not sure if portupgrade can do it or not. Your most likely course of success is to generate a list of ports that you know you're using (root and leaf ports in portmaster terminology), back up any config or other key files from /usr/local, then delete everything and reinstall. Good luck, Doug -- ... and that's just a little bit of history repeating. -- Propellerheads Improve the effectiveness of your Internet presence with a domain name makeover!http://SupersetSolutions.com/ ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org