From owner-freebsd-current Sat Jun 22 16:22:36 2002 Delivered-To: freebsd-current@freebsd.org Received: from maul.immure.com (ns.immure.com [207.8.42.72]) by hub.freebsd.org (Postfix) with ESMTP id 88C0D37B405 for ; Sat, 22 Jun 2002 16:22:29 -0700 (PDT) Received: (from root@localhost) by maul.immure.com (8.11.5/8.11.2) id g5MNMTV67972 for freebsd-current@freebsd.org; Sat, 22 Jun 2002 18:22:29 -0500 (CDT) (envelope-from bob@immure.com) Received: from luke.immure.com (luke.vieo.com [10.1.132.3]) by maul.immure.com (8.11.5/8.11.2) with ESMTP id g5MNMSw67932 for ; Sat, 22 Jun 2002 18:22:28 -0500 (CDT) (envelope-from bob@immure.com) Received: (from root@localhost) by luke.immure.com (8.12.3/8.12.3) id g5MNMS70050987 for freebsd-current@freebsd.org; Sat, 22 Jun 2002 18:22:28 -0500 (CDT) (envelope-from bob@luke.immure.com) Received: from luke.immure.com (localhost [127.0.0.1]) by luke.immure.com (8.12.3/8.12.3) with ESMTP id g5MNMRxO050958 for ; Sat, 22 Jun 2002 18:22:27 -0500 (CDT) (envelope-from bob@luke.immure.com) Received: (from bob@localhost) by luke.immure.com (8.12.3/8.12.3/Submit) id g5MNMRqa050957 for freebsd-current@freebsd.org; Sat, 22 Jun 2002 18:22:27 -0500 (CDT) Date: Sat, 22 Jun 2002 18:22:27 -0500 From: Bob Willcox To: freebsd-current@freebsd.org Subject: locate.mklocatedb requires perl which may not be installed Message-ID: <20020622232227.GA50787@luke.immure.com> Reply-To: Bob Willcox Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.99i X-scanner: scanned by Inflex 1.0.12.3 on luke.immure.com X-scanner: scanned by Inflex 0.1.5c+ on maul.immure.com Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 Willcox If practice makes perfect, and nobody's perfect, bob@vieo.com why practice? Austin, TX To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message