regenerating /var/db/pkg

Garrett Cooper yanefbsd at gmail.com
Mon Apr 26 07:59:12 UTC 2010


2010/4/25 Doug Barton <dougb at freebsd.org>:
> On 04/25/10 19:44, Garrett Cooper wrote:
>> On Thu, Apr 22, 2010 at 10:05 AM, Eitan Adler <eitanadlerlist at 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


More information about the freebsd-hackers mailing list