#!/bin/sh -1#2# $NetBSD: newvers.sh,v 1.1 1997/07/26 01:50:38 thorpej Exp $3#4# Copyright (c) 1984, 1986, 1990, 19935# The Regents of the University of California. All rights reserved.6#7# Redistribution and use in source and binary forms, with or without8# modification, are permitted provided that the following conditions9# are met:10# 1. Redistributions of source code must retain the above copyright11# notice, this list of conditions and the following disclaimer.12# 2. Redistributions in binary form must reproduce the above copyright13# notice, this list of conditions and the following disclaimer in the14# documentation and/or other materials provided with the distribution.15# 3. Neither the name of the University nor the names of its contributors16# may be used to endorse or promote products derived from this software17# without specific prior written permission.18#19# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND20# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE21# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE22# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE23# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL24# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS25# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)26# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT27# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY28# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF29# SUCH DAMAGE.3031tempfile=$(mktemp tmp.XXXXXX) || exit32trap "rm -f $tempfile" EXIT INT TERM3334include_metadata=true35while getopts r opt; do36case "$opt" in37r)38include_metadata=39;;40esac41done42shift $((OPTIND - 1))4344LC_ALL=C; export LC_ALL45u=${USER-root} h=${HOSTNAME-`hostname`}46if [ -n "$SOURCE_DATE_EPOCH" ]; then47if ! t=$(date -ur $SOURCE_DATE_EPOCH 2>/dev/null); then48echo "Invalid SOURCE_DATE_EPOCH" >&249exit 150fi51else52t="${NEWVERS_DATE:-`date`}"53fi54r=`awk -F: ' /^[0-9]\.[0-9]+:/ { print $1; exit }' $1`5556bootprog_info="FreeBSD/${3} ${2}, Revision ${r}\\n"57if [ -n "${include_metadata}" ]; then58bootprog_info="$bootprog_info(${t} ${u}@${h})\\n"59if [ -n "$BUILD_UTC" ]; then60# We can use what(1) to extract BUILD_UTC61bootprog_info="$bootprog_info\\0@(#)BUILD_UTC=$BUILD_UTC"62fi63fi6465cat > $tempfile <<EOF66char bootprog_info[] = "$bootprog_info";67unsigned bootprog_rev = ${r%%.*} * 1000 + ${r##*.};68EOF69mv $tempfile vers.c707172