From owner-svn-src-all@freebsd.org Thu May 23 17:18:49 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6A30215B01D7; Thu, 23 May 2019 17:18:49 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 100C075692; Thu, 23 May 2019 17:18:49 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C27D08276; Thu, 23 May 2019 17:18:48 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4NHImkN026423; Thu, 23 May 2019 17:18:48 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4NHImrT026422; Thu, 23 May 2019 17:18:48 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201905231718.x4NHImrT026422@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Thu, 23 May 2019 17:18:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r348175 - head/sys/conf X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/sys/conf X-SVN-Commit-Revision: 348175 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 100C075692 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.93 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.995,0]; NEURAL_HAM_SHORT(-0.94)[-0.935,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 May 2019 17:18:49 -0000 Author: imp Date: Thu May 23 17:18:48 2019 New Revision: 348175 URL: https://svnweb.freebsd.org/changeset/base/348175 Log: Implement "VARS_ONLY=1" via special command line args Add -v to print TYPE REVISION BRANCH RELEASE VERSION RELDATE variables Add -V var to print var's value Both of these in ${var}="${val}" format suitable for eval $(sh newvers.sh -v) in shell scripts / makefiles. Add -c to print the copyright / license comment text only. Document these, and remove soon-to-be obsolete comment. Minor code motion as well bunded here to put functions after VARS_ONLY and command line argument parsing. Differential Revision: https://reviews.freebsd.org/D19849 Modified: head/sys/conf/newvers.sh Modified: head/sys/conf/newvers.sh ============================================================================== --- head/sys/conf/newvers.sh Thu May 23 16:05:47 2019 (r348174) +++ head/sys/conf/newvers.sh Thu May 23 17:18:48 2019 (r348175) @@ -34,25 +34,105 @@ # Command line options: # -# -r Reproducible build. Do not embed directory names, user -# names, time stamps or other dynamic information into -# the output file. This is intended to allow two builds -# done at different times and even by different people on -# different hosts to produce identical output. +# -c Print the copyright / license statement as a C comment and exit # -# -R Reproducible build if the tree represents an unmodified -# checkout from a version control system. Metadata is -# included if the tree is modified. +# -r Reproducible build. Do not embed directory names, user names, +# time stamps or other dynamic information into the output file. +# This is intended to allow two builds done at different times +# and even by different people on different hosts to produce +# identical output. +# +# -R Reproducible build if the tree represents an unmodified +# checkout from a version control system. Metadata is included +# if the tree is modified. +# +# -V var Print ${var}="${val-of-var}" and exit +# +# -v Print TYPE REVISION BRANCH RELEASE VERSION RELDATE variabkes +# like the -V command +# -# Note: usr.sbin/amd/include/newvers.sh assumes all variable assignments of -# upper case variables starting in column 1 are on one line w/o continuation. - TYPE="FreeBSD" REVISION="13.0" BRANCH=${BRANCH_OVERRIDE:-CURRENT} RELEASE="${REVISION}-${BRANCH}" VERSION="${TYPE} ${RELEASE}" +if [ -z "${SYSDIR}" ]; then + SYSDIR=$(dirname $0)/.. +fi + +RELDATE=$(awk '/__FreeBSD_version.*propagated to newvers/ {print $3}' ${PARAMFILE:-${SYSDIR}/sys/param.h}) + +if [ -r "${SYSDIR}/../COPYRIGHT" ]; then + year=$(sed -Ee '/^Copyright .* The FreeBSD Project/!d;s/^.*1992-([0-9]*) .*$/\1/g' ${SYSDIR}/../COPYRIGHT) +else + year=$(date +%Y) +fi +# look for copyright template +b=share/examples/etc/bsd-style-copyright +for bsd_copyright in $b ../$b ../../$b ../../../$b /usr/src/$b /usr/$b +do + if [ -r "$bsd_copyright" ]; then + COPYRIGHT=$(sed \ + -e "s/\[year\]/1992-$year/" \ + -e 's/\[your name here\]\.* /The FreeBSD Project./' \ + -e 's/\[your name\]\.*/The FreeBSD Project./' \ + -e '/\[id for your version control system, if any\]/d' \ + $bsd_copyright) + break + fi +done + +# no copyright found, use a dummy +if [ -z "$COPYRIGHT" ]; then + COPYRIGHT="/*- + * Copyright (c) 1992-$year The FreeBSD Project. + * + */" +fi + +# add newline +COPYRIGHT="$COPYRIGHT +" + +include_metadata=true +while getopts crRvV: opt; do + case "$opt" in + c) + echo "$COPYRIGHT" + exit 0 + ;; + r) + include_metadata= + ;; + R) + if [ -z "${modified}" ]; then + include_metadata= + fi + ;; + v) + # Only put variables that are single lines here. + for v in TYPE REVISION BRANCH RELEASE VERSION RELDATE; do + eval val=\$${v} + echo ${v}=\"${val}\" + done + exit 0 + ;; + V) + v=$OPTARG + eval val=\$${v} + echo ${v}=\"${val}\" + exit 0 + ;; + esac +done +shift $((OPTIND - 1)) + +# VARS_ONLY means no files should be generated, this is just being +# included. +[ -n "$VARS_ONLY" ] && return 0 + # # findvcs dir # Looks up directory dir at world root and up the filesystem @@ -103,49 +183,6 @@ git_tree_modified() return 1 } - -if [ -z "${SYSDIR}" ]; then - SYSDIR=$(dirname $0)/.. -fi - -RELDATE=$(awk '/__FreeBSD_version.*propagated to newvers/ {print $3}' ${PARAMFILE:-${SYSDIR}/sys/param.h}) - -if [ -r "${SYSDIR}/../COPYRIGHT" ]; then - year=$(sed -Ee '/^Copyright .* The FreeBSD Project/!d;s/^.*1992-([0-9]*) .*$/\1/g' ${SYSDIR}/../COPYRIGHT) -else - year=$(date +%Y) -fi -# look for copyright template -b=share/examples/etc/bsd-style-copyright -for bsd_copyright in ../$b ../../$b ../../../$b /usr/src/$b /usr/$b -do - if [ -r "$bsd_copyright" ]; then - COPYRIGHT=$(sed \ - -e "s/\[year\]/1992-$year/" \ - -e 's/\[your name here\]\.* /The FreeBSD Project./' \ - -e 's/\[your name\]\.*/The FreeBSD Project./' \ - -e '/\[id for your version control system, if any\]/d' \ - $bsd_copyright) - break - fi -done - -# no copyright found, use a dummy -if [ -z "$COPYRIGHT" ]; then - COPYRIGHT="/*- - * Copyright (c) 1992-$year The FreeBSD Project. - * - */" -fi - -# add newline -COPYRIGHT="$COPYRIGHT -" - -# VARS_ONLY means no files should be generated, this is just being -# included. -[ -n "$VARS_ONLY" ] && return 0 - LC_ALL=C; export LC_ALL if [ ! -r version ] then @@ -274,20 +311,6 @@ if [ -n "$hg_cmd" ] ; then hg=" ${hg}" fi fi - -include_metadata=true -while getopts rR opt; do - case "$opt" in - r) - include_metadata= - ;; - R) - if [ -z "${modified}" ]; then - include_metadata= - fi - esac -done -shift $((OPTIND - 1)) if [ -z "${include_metadata}" ]; then VERINFO="${VERSION}${svn}${git}${hg} ${i}"