Date: Sat, 25 Sep 2010 02:30:08 GMT From: jhell <jhell@DataIX.net> To: freebsd-bugs@FreeBSD.org Subject: Re: misc/149510: [build] [patch] CFT: sys/conf/newvers.sh: Cleanup and additions. Message-ID: <201009250230.o8P2U8FA027956@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR misc/149510; it has been noted by GNATS. From: jhell <jhell@DataIX.net> To: bug-followup@FreeBSD.org Cc: Subject: Re: misc/149510: [build] [patch] CFT: sys/conf/newvers.sh: Cleanup and additions. Date: Fri, 24 Sep 2010 22:22:32 -0400 This is a multi-part message in MIME format. --------------050000080808040400030703 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit The following are updated patches to what is already here for current and stable/8. Links are respective to where they should be applied. http://bit.ly/newvers-head-r213132-patch 1 file changed, 61 insertions(+), 38 deletions(-) http://bit.ly/newvers-stable8-r213132-patch 1 file changed, 55 insertions(+), 40 deletions(-) These are also both attached but linked to just to be sure in case they are somehow garbled. After these two patches are applied both stable/8 and head will be in sync with the changes that were made in r213077 & r213078 These were tested locally only with stable/8 and could use verification for those using git(1) locally in either /usr/src/.git or /usr/src/sys/.git on stable/8 & head. Included with these changes and attributed to "Anonymous" <- thanks for the heads-up, you also have the ability to use LOCALBASE. This could use some testing to whether it works or not so I will leave that to others for feedback. Regards & Happy Hacking, -- jhell,v --------------050000080808040400030703 Content-Type: text/plain; name="newvers.sh-head-r213132.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="newvers.sh-head-r213132.patch" Index: sys/conf/newvers.sh =================================================================== --- sys/conf/newvers.sh (revision 213142) +++ sys/conf/newvers.sh (working copy) @@ -38,7 +38,10 @@ fi RELEASE="${REVISION}-${BRANCH}" VERSION="${TYPE} ${RELEASE}" -SYSDIR=$(dirname $0)/.. + +# These are here so we don't have to work in reverse later on. +SRCDIR=$(dirname $0)/../.. +SYSDIR=${SRCDIR}/sys if [ "X${PARAMFILE}" != "X" ]; then RELDATE=$(awk '/__FreeBSD_version.*propagated to newvers/ {print $3}' \ @@ -78,57 +81,77 @@ " LC_ALL=C; export LC_ALL -if [ ! -r version ] -then - echo 0 > version +if [ ! -r version ]; then + echo 0 >version fi -touch version v=`cat version` u=${USER:-root} d=`pwd` h=${HOSTNAME:-`hostname`} t=`date` i=`${MAKE:-make} -V KERN_IDENT` -for dir in /bin /usr/bin /usr/local/bin; do - if [ -d "${SYSDIR}/.svn" -a -x "${dir}/svnversion" ] ; then - svnversion=${dir}/svnversion - break +if [ -d "${SRCDIR}/.svn" -o -d "${SYSDIR}/.svn" ]; then + for dir in /usr/bin ${LOCALBASE:-/usr/local}/bin; do + if [ -x "${dir}/svn" ]; then + svnversion=${dir}/svnversion + break + fi + done + if [ -n "$svnversion" ] ; then + svnrev=" r`cd ${SYSDIR} && $svnversion`" fi - if [ -d "${SYSDIR}/../.git" -a -x "${dir}/git" ] ; then - git_cmd="${dir}/git --git-dir=${SYSDIR}/../.git" - break +fi + +if [ -d "${SRCDIR}/.hg" -o -d "${SYSDIR}/.hg" ]; then + for dir in /usr/bin ${LOCALBASE:-/usr/local}/bin; do + if [ -x "${dir}/hg" ]; then + hg=${dir}/hg + break + fi + done + if [ -n "$hg" ]; then + hgrev=" `cd ${SYSDIR} && $hg tip --template '{rev}:{node|short}'`" fi -done +fi + +if [ -d "${SRCDIR}/.git" -o -d "${SYSDIR}/.git" ]; then + for dir in /usr/bin ${LOCALBASE:-/usr/local}; do + if [ -x "${dir}/git" ]; then + if [ -d "${SRCDIR}/.git" ]; then + git="${dir}/git --git-dir=${SRCDIR}/.git" + git="${git} --work-tree=${SRCDIR}" + else + git="${dir}/git --git-dir=${SYSDIR}/.git" + git="${git} --work-tree=${SYSDIR}" + fi + break + fi + done -if [ -n "$svnversion" ] ; then - echo "$svnversion" - svn=" r`cd ${SYSDIR} && $svnversion`" -fi - -if [ -n "$git_cmd" ] ; then - git=`$git_cmd rev-parse --verify --short HEAD 2>/dev/null` - svn=`$git_cmd svn find-rev $git 2>/dev/null` - if [ -n "$svn" ] ; then - svn=" r${svn}" - git="=${git}" - else - svn=`$git_cmd log | fgrep 'git-svn-id:' | head -1 | \ - sed -n 's/^.*@\([0-9][0-9]*\).*$/\1/p'` - if [ -n $svn ] ; then - svn=" r${svn}" - git="+${git}" + 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 - git=" ${git}" + gitsvnid="`$git log |sed -n '/git-svn-id:/ { + s/.*@\([[:digit:]]\{1,\}\).*/\1/p; q; }'`" + if [ -n "${gitsvnid}" ]; then + svnrev=" r${gitsvnid}" + gitrev="+${gitrev}" + else + gitrev=" ${gitrev}" + fi + fi + if [ -n "`$git diff-index --name-only HEAD`" ]; then + gitrev="${gitrev}-dirty" fi - fi - if $git_cmd --work-tree=${SYSDIR}/.. diff-index \ - --name-only HEAD | read dummy; then - git="${git}-dirty" fi fi cat << EOF > vers.c $COPYRIGHT -#define SCCSSTR "@(#)${VERSION} #${v}${svn}${git}: ${t}" -#define VERSTR "${VERSION} #${v}${svn}${git}: ${t}\\n ${u}@${h}:${d}\\n" +#define SCCSSTR "@(#)${VERSION} #${v}${svnrev}${gitrev}${hgrev} ${t}" +#define VERSTR "${VERSION} #${v}${svnrev}${gitrev}${hgrev} ${t}\\n ${u}@${h}:${d}\\n" #define RELSTR "${RELEASE}" char sccs[sizeof(SCCSSTR) > 128 ? sizeof(SCCSSTR) : 128] = SCCSSTR; @@ -139,4 +162,4 @@ char kern_ident[] = "${i}"; EOF -echo `expr ${v} + 1` > version +echo $((${v}+1)) >version --------------050000080808040400030703 Content-Type: text/plain; name="newvers.sh-stable8-r213132.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="newvers.sh-stable8-r213132.patch" Index: sys/conf/newvers.sh =================================================================== --- sys/conf/newvers.sh (revision 213132) +++ sys/conf/newvers.sh (working copy) @@ -39,15 +39,18 @@ RELEASE="${REVISION}-${BRANCH}" VERSION="${TYPE} ${RELEASE}" +# These are here so we don't have to work in reverse later on. +SRCDIR=$(dirname $0)/../.. +SYSDIR=${SRCDIR}/sys + if [ "X${PARAMFILE}" != "X" ]; then RELDATE=$(awk '/__FreeBSD_version.*propagated to newvers/ {print $3}' \ ${PARAMFILE}) else RELDATE=$(awk '/__FreeBSD_version.*propagated to newvers/ {print $3}' \ - $(dirname $0)/../sys/param.h) + ${SYSDIR}/sys/param.h) fi - b=share/examples/etc/bsd-style-copyright year=`date '+%Y'` # look for copyright template @@ -78,65 +81,77 @@ " LC_ALL=C; export LC_ALL -if [ ! -r version ] -then - echo 0 > version +if [ ! -r version ]; then + echo 0 >version fi -touch version v=`cat version` u=${USER:-root} d=`pwd` h=${HOSTNAME:-`hostname`} t=`date` i=`${MAKE:-make} -V KERN_IDENT` -case "$d" in -*/sys/*) - SRCDIR=${d##*obj} - if [ -n "$MACHINE" ]; then - SRCDIR=${SRCDIR##/$MACHINE} +if [ -d "${SRCDIR}/.svn" -o -d "${SYSDIR}/.svn" ]; then + for dir in /usr/bin ${LOCALBASE:-/usr/local}/bin; do + if [ -x "${dir}/svn" ]; then + svnversion=${dir}/svnversion + break + fi + done + if [ -n "$svnversion" ] ; then + svnrev=" r`cd ${SYSDIR} && $svnversion`" fi - SRCDIR=${SRCDIR%%/sys/*} +fi - for dir in /bin /usr/bin /usr/local/bin; do - if [ -d "${SRCDIR}/sys/.svn" -a -x "${dir}/svnversion" ] ; then - svnversion=${dir}/svnversion +if [ -d "${SRCDIR}/.hg" -o -d "${SYSDIR}/.hg" ]; then + for dir in /usr/bin ${LOCALBASE:-/usr/local}/bin; do + if [ -x "${dir}/hg" ]; then + hg=${dir}/hg break fi - if [ -d "${SRCDIR}/.git" -a -x "${dir}/git" ] ; then - git_cmd="${dir}/git --git-dir=${SRCDIR}/.git" + done + if [ -n "$hg" ]; then + hgrev=" `cd ${SYSDIR} && $hg tip --template '{rev}:{node|short}'`" + fi +fi + +if [ -d "${SRCDIR}/.git" -o -d "${SYSDIR}/.git" ]; then + for dir in /usr/bin ${LOCALBASE:-/usr/local}; do + if [ -x "${dir}/git" ]; then + if [ -d "${SRCDIR}/.git" ]; then + git="${dir}/git --git-dir=${SRCDIR}/.git" + git="${git} --work-tree=${SRCDIR}" + else + git="${dir}/git --git-dir=${SYSDIR}/.git" + git="${git} --work-tree=${SYSDIR}" + fi break fi done - if [ -n "$svnversion" ] ; then - svn=" r`cd ${SRCDIR}/sys && $svnversion`" - fi - if [ -n "$git_cmd" ] ; then - git=`$git_cmd rev-parse --verify --short HEAD 2>/dev/null` - svn=`$git_cmd svn find-rev $git 2>/dev/null` - if [ -n "$svn" ] ; then - svn=" r${svn}" - git="=${git}" + 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 - svn=`$git_cmd log | fgrep 'git-svn-id:' | head -1 | \ - sed -n 's/^.*@\([0-9][0-9]*\).*$/\1/p'` - if [ -n $svn ] ; then - svn=" r${svn}" - git="+${git}" + gitsvnid="`$git log |sed -n '/git-svn-id:/ { + s/.*@\([[:digit:]]\{1,\}\).*/\1/p; q; }'`" + if [ -n "${gitsvnid}" ]; then + svnrev=" r${gitsvnid}" + gitrev="+${gitrev}" else - git=" ${git}" + gitrev=" ${gitrev}" fi fi - if $git_cmd --work-tree=${SRCDIR} diff-index \ - --name-only HEAD | read dummy; then - git="${git}-dirty" + if [ -n "`$git diff-index --name-only HEAD`" ]; then + gitrev="${gitrev}-dirty" fi fi - ;; -esac +fi cat << EOF > vers.c $COPYRIGHT -#define SCCSSTR "@(#)${VERSION} #${v}${svn}${git}: ${t}" -#define VERSTR "${VERSION} #${v}${svn}${git}: ${t}\\n ${u}@${h}:${d}\\n" +#define SCCSSTR "@(#)${VERSION} #${v}${svnrev}${gitrev}${hgrev} ${t}" +#define VERSTR "${VERSION} #${v}${svnrev}${gitrev}${hgrev} ${t}\\n ${u}@${h}:${d}\\n" #define RELSTR "${RELEASE}" char sccs[sizeof(SCCSSTR) > 128 ? sizeof(SCCSSTR) : 128] = SCCSSTR; @@ -147,4 +162,4 @@ char kern_ident[] = "${i}"; EOF -echo `expr ${v} + 1` > version +echo $((${v}+1)) >version --------------050000080808040400030703--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201009250230.o8P2U8FA027956>