From owner-freebsd-current@FreeBSD.ORG Wed Aug 11 01:11:05 2010 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 11D26106566C for ; Wed, 11 Aug 2010 01:11:05 +0000 (UTC) (envelope-from swell.k@gmail.com) Received: from mail-qy0-f175.google.com (mail-qy0-f175.google.com [209.85.216.175]) by mx1.freebsd.org (Postfix) with ESMTP id B29FE8FC17 for ; Wed, 11 Aug 2010 01:11:04 +0000 (UTC) Received: by qyk11 with SMTP id 11so4196107qyk.13 for ; Tue, 10 Aug 2010 18:11:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:cc:subject:in-reply-to :message-id:references:user-agent:received:date:mime-version :content-type; bh=Vp2GHSJzYP1zFUc1NN58axtTtpjJO74hvHv0pRX7n4Y=; b=VNkCSlyA1Y4iE+zZSQ230nZI5dWt6iXYY1xvQM/V9lAaFonfkMFDjRsSrAv9YQp+9t Bqh8pF5vegmVLZtu+qJT4eD9HD/tN+bkrwHBT+3CjyBPEg6S8sI3Rglo4b7H9v1WXg3l bxUeT/22dPftN/RhmlcXhHOkbKVCLRwrS1ta8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:cc:subject:in-reply-to:message-id:references:user-agent:date :mime-version:content-type; b=dJ1R1QxGUIP8aZh0S8ea/V39hEkt3ulf/7ZwJSV/NnGBWnOaYXvbceUrdDLT95nnSz Lismakj+waqMM22ng7cS7trZ/Y5AIpmLk4durT4izllb27IG+MmrYTmbdYlerr5zT4L2 MWocsm0OcqndrcGLuOboOZvm6bWIm0oA/Mxzg= Received: by 10.229.224.81 with SMTP id in17mr8938017qcb.140.1281489063819; Tue, 10 Aug 2010 18:11:03 -0700 (PDT) Received: from localhost ([94.75.253.73]) by mx.google.com with ESMTPS id q8sm6095201qcs.0.2010.08.10.18.11.00 (version=SSLv3 cipher=RC4-MD5); Tue, 10 Aug 2010 18:11:03 -0700 (PDT) From: Anonymous Cc: freebsd-current@freebsd.org In-Reply-To: <4C61C50E.8040900__28807.0786548362$1281476071$gmane$org@dataix.net> (jhell@dataix.net's message of "Tue, 10 Aug 2010 17:30:54 -0400") Message-ID: <86hbj2qc0n.fsf@gmail.com> References: <4C61C50E.8040900__28807.0786548362$1281476071$gmane$org@dataix.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (berkeley-unix) Received: from localhost (193-107-160-12.maconet.cz [193.107.160.12]) by mx.google.com with ESMTPS id b36sm2581181faq.11.2010.08.10.16.33.06 (version=SSLv3 cipher=RC4-MD5); Tue, 10 Aug 2010 16:33:09 -0700 (PDT) Date: Wed, 11 Aug 2010 05:10:56 +0400 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Subject: Re: [CFT] [sys/conf/newvers.sh] Cleanup and additions. X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2010 01:11:05 -0000 --=-=-= (a copy for current@) jhell writes: > * Adjust the paths that are checked for binaries to be of only > /usr/local/bin and /usr/bin. "/bin" is highly unlikely to hold svn(1), > git(1) or hg(1). Please, look at conf/146828. That script shouldn't blindly assume where user installs his packages[1]. [1] using non-default LOCALBASE is a convenient way to identify non-conforming ports > + gitsvnid="`$git log |fgrep 'git-svn-id:' |head -1 |\ > + sed -n 's/^.*@\([0-9][0-9]*\).*$/\1/p'`" The above line can be sed-only. A few parts can be simplified, too. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=a.diff diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh index 40761bb..568b1fe 100644 --- a/sys/conf/newvers.sh +++ b/sys/conf/newvers.sh @@ -83,61 +83,59 @@ LC_ALL=C; export LC_ALL v=`cat version` u=${USER:-root} d=`pwd` h=${HOSTNAME:-`hostname`} t=`date` i=`${MAKE:-make} -V KERN_IDENT` +find-bin() { + local c prog PATH + + PATH=${LOCALBASE-/usr/local}/bin + + for c; do + prog=$(command -v $c) + if [ -x "$prog" ]; then + eval $c=$prog + fi + done +} + case "$d" in */sys/*) - SRCDIR=${d##*obj} + SRCDIR=${d##*${MAKEOBJDIRPREFIX:-/usr/obj}} if [ -n "$MACHINE" ]; then SRCDIR=${SRCDIR##/$MACHINE} fi SRCDIR=${SRCDIR%%/sys/*} + find-bin svnversion hg git + if [ -d "${SRCDIR}/.svn" -o -d "${SRCDIR}/sys/.svn" ]; then - for dir in /usr/local/bin; do - if [ -x "${dir}/svn" ]; then - svnversion=${dir}/svnversion - break - fi - done if [ -n "$svnversion" ] ; then svnrev=" r`cd ${SRCDIR}/sys && $svnversion`" fi fi if [ -d "${SRCDIR}/.hg" -o -d "${SRCDIR}/sys/.hg" ]; then - for dir in /usr/local/bin; do - if [ -x "${dir}/hg" ]; then - hg=${dir}/hg - break - fi - done if [ -n "$hg" ]; then hgrev=" `cd ${SRCDIR}/sys && $hg tip --template '{rev}:{node|short}'`" fi fi if [ -d "${SRCDIR}/.git" -o -d "${SRCDIR}/sys/.git" ]; then - for dir in /usr/local/bin; do - if [ -x "${dir}/git" ]; then + if [ -n "$git" ]; then if [ -d "${SRCDIR}/.git" ]; then - git="${dir}/git --git-dir=${SRCDIR}/.git" + git="${git} --git-dir=${SRCDIR}/.git" git="${git} --work-tree=${SRCDIR}" else - git="${dir}/git --git-dir=${SRCDIR}/sys/.git" + git="${git} --git-dir=${SRCDIR}/sys/.git" git="${git} --work-tree=${SRCDIR}/sys" fi - break - fi - done - if [ -n "$git" ] ; then gitrev="`$git rev-parse --verify --short HEAD 2>/dev/null`" gitsvnrev="`$git svn find-rev $gitrev 2>/dev/null`" if [ -n "${gitsvnrev}" ] ; then svnrev=" r${gitsvnrev}" gitrev="=${gitrev}" else - gitsvnid="`$git log |fgrep 'git-svn-id:' |head -1 |\ - sed -n 's/^.*@\([0-9][0-9]*\).*$/\1/p'`" + gitsvnid="`$git log | sed -n '/git-svn-id:/ { + s/.*@\([[:digit:]]\{1,\}\).*/\1/p; q; }'`" if [ -n "${gitsvnid}" ]; then svnrev=" r${gitsvnid}" gitrev="+${gitrev}" --=-=-=--