locate.mklocatedb requires perl which may not be installed

2002-06-22 Thread Bob Willcox

Hi,

I just installed a system today using the 5.0-CURRENT-20020621-JPSNAP.iso
CDROM and noticed that when I attempted to run /etc/periodic/weekly/310.locate
so that I could use locate to find some files that it spewed out:

Perl is not installed, try 'pkg_add -r perl'

Rather than simply installing perl (I'll get to that later)
I decided to track down what was calling it. Turns out that
/usr/libexec/locate.mklocatedb was the culprit. I then modified
locate.mklocatedb to use awk rather than perl. Here's the diff:


--- locate.mklocatedb.orig  Thu Jun 20 17:07:43 2002
+++ locate.mklocatedb   Sat Jun 22 18:09:03 2002
@@ -76,14 +76,15 @@
 
 $code $bigrams  $filelist || exit 1
 locate -d $filelist / | $bigram | $sort -nr | head -128 |
-perl -ne '/^\s*[0-9]+\s(..)$/  print $1 || exit 1'   $bigrams || exit 1
+awk '{if (/^[   ]*[0-9]+[   ]+..$/) {printf(%s,$2)} else {exit 1}}'  
+$bigrams
+   || exit 1
 locate -d $filelist / | $code $bigrams || exit 1
 exit   
 
 else
 if $sortcmd $sortopt  $filelist; then
 $bigram  $filelist | $sort -nr | 
-   perl -ne '/^\s*[0-9]+\s(..)$/  print $1 || exit 1'  $bigrams 
+   awk '{if (/^[   ]*[0-9]+[   ]+..$/) {printf(%s,$2)} else {exit 1}}'  
+$bigrams
|| exit 1
 $code $bigrams  $filelist || exit 1
 else


This seems to be working for me. It could likely be improved upon by the
perl and/or awk some expert out there. (I'm actually more familiar with
awk than perl but I wouldn't claim that my awk translation is the most
efficient either.)

-- 
Bob WillcoxIf practice makes perfect, and nobody's perfect,
[EMAIL PROTECTED]   why practice?
Austin, TX


To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-current in the body of the message



Re: locate.mklocatedb requires perl which may not be installed

2002-06-22 Thread David O'Brien

On Sat, Jun 22, 2002 at 06:22:27PM -0500, Bob Willcox wrote:
 Rather than simply installing perl (I'll get to that later)
 I decided to track down what was calling it. Turns out that
 /usr/libexec/locate.mklocatedb was the culprit. I then modified
 locate.mklocatedb to use awk rather than perl. Here's the diff:

Thanks, committed.
BTW, please take care about how your MUA handles ^I's vs. ' '. :-)

To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-current in the body of the message



Re: locate.mklocatedb requires perl which may not be installed

2002-06-22 Thread Bob Willcox

On Sat, Jun 22, 2002 at 05:55:47PM -0700, David O'Brien wrote:
 On Sat, Jun 22, 2002 at 06:22:27PM -0500, Bob Willcox wrote:
  Rather than simply installing perl (I'll get to that later)
  I decided to track down what was calling it. Turns out that
  /usr/libexec/locate.mklocatedb was the culprit. I then modified
  locate.mklocatedb to use awk rather than perl. Here's the diff:
 
 Thanks, committed.
 BTW, please take care about how your MUA handles ^I's vs. ' '. :-)

Hmm, strange. The first awk line had the ^I's converted to spaces and
the second one didn't. Digging into this abit deeper, it seems that my
MUA (mutt) probably wasn't to blame afterall. It appears that I must
have hosed this up myself while editing the file. :-(

Bob

-- 
Bob WillcoxIf practice makes perfect, and nobody's perfect,
[EMAIL PROTECTED]   why practice?
Austin, TX


To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-current in the body of the message