Changeset View
Changeset View
Standalone View
Standalone View
sys/conf/newvers.sh
Show All 28 Lines | |||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
# SUCH DAMAGE. | # SUCH DAMAGE. | ||||
# | # | ||||
# @(#)newvers.sh 8.1 (Berkeley) 4/20/94 | # @(#)newvers.sh 8.1 (Berkeley) 4/20/94 | ||||
# $FreeBSD$ | # $FreeBSD$ | ||||
# Command line options: | # Command line options: | ||||
# | # | ||||
# XXX Add more | |||||
# -r Reproducible build. Do not embed directory names, user | # -r Reproducible build. Do not embed directory names, user | ||||
# names, time stamps or other dynamic information into | # names, time stamps or other dynamic information into | ||||
# the output file. This is intended to allow two builds | # the output file. This is intended to allow two builds | ||||
# done at different times and even by different people on | # done at different times and even by different people on | ||||
# different hosts to produce identical output. | # different hosts to produce identical output. | ||||
# | # | ||||
# -R Reproducible build if the tree represents an unmodified | # -R Reproducible build if the tree represents an unmodified | ||||
# checkout from a version control system. Metadata is | # checkout from a version control system. Metadata is | ||||
# included if the tree is modified. | # included if the tree is modified. | ||||
# Note: usr.sbin/amd/include/newvers.sh assumes all variable assignments of | # 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. | # upper case variables starting in column 1 are on one line w/o continuation. | ||||
TYPE="FreeBSD" | TYPE="FreeBSD" | ||||
REVISION="13.0" | REVISION="13.0" | ||||
BRANCH=${BRANCH_OVERRIDE:-CURRENT} | BRANCH=${BRANCH_OVERRIDE:-CURRENT} | ||||
RELEASE="${REVISION}-${BRANCH}" | RELEASE="${REVISION}-${BRANCH}" | ||||
VERSION="${TYPE} ${RELEASE}" | 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 crRovV: opt; do | |||||
case "$opt" in | |||||
c) | |||||
echo "$COPYRIGHT" | |||||
exit 0 | |||||
;; | |||||
o) | |||||
VARS_ONLY=t | |||||
;; | |||||
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 | # findvcs dir | ||||
# Looks up directory dir at world root and up the filesystem | # Looks up directory dir at world root and up the filesystem | ||||
# | # | ||||
findvcs() | findvcs() | ||||
{ | { | ||||
local savedir | local savedir | ||||
Show All 34 Lines | if ! $git_cmd --work-tree=${VCSTOP} diff --quiet -- "${file}"; then | ||||
return 0 | return 0 | ||||
fi | fi | ||||
done < $fifo | done < $fifo | ||||
# No files with content differences. | # No files with content differences. | ||||
rm $fifo | rm $fifo | ||||
return 1 | 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 | LC_ALL=C; export LC_ALL | ||||
if [ ! -r version ] | if [ ! -r version ] | ||||
then | then | ||||
echo 0 > version | echo 0 > version | ||||
fi | fi | ||||
touch version | touch version | ||||
v=$(cat version) | v=$(cat version) | ||||
▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | hgsvn=$($hg_cmd svn info 2>/dev/null | \ | ||||
awk -F': ' '/Revision/ { print $2 }') | awk -F': ' '/Revision/ { print $2 }') | ||||
if [ -n "$hgsvn" ] ; then | if [ -n "$hgsvn" ] ; then | ||||
svn=" r${hgsvn}" | svn=" r${hgsvn}" | ||||
fi | fi | ||||
if [ -n "$hg" ] ; then | if [ -n "$hg" ] ; then | ||||
hg=" ${hg}" | hg=" ${hg}" | ||||
fi | fi | ||||
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 | if [ -z "${include_metadata}" ]; then | ||||
VERINFO="${VERSION}${svn}${git}${hg} ${i}" | VERINFO="${VERSION}${svn}${git}${hg} ${i}" | ||||
VERSTR="${VERINFO}\\n" | VERSTR="${VERINFO}\\n" | ||||
else | else | ||||
VERINFO="${VERSION} #${v}${svn}${git}${hg}: ${t}" | VERINFO="${VERSION} #${v}${svn}${git}${hg}: ${t}" | ||||
VERSTR="${VERINFO}\\n ${u}@${h}:${d}\\n" | VERSTR="${VERINFO}\\n ${u}@${h}:${d}\\n" | ||||
fi | fi | ||||
Show All 22 Lines |