Home | History | Annotate | Line # | Download | only in conf
newvers_stand.sh revision 1.6
      1  1.1  jdolecek #!/bin/sh -
      2  1.1  jdolecek #
      3  1.6     perry # $NetBSD: newvers_stand.sh,v 1.6 2008/07/15 20:10:06 perry Exp $
      4  1.1  jdolecek #
      5  1.3  jdolecek # Copyright (c) 2000 The NetBSD Foundation, Inc.
      6  1.3  jdolecek # All rights reserved.
      7  1.3  jdolecek #
      8  1.3  jdolecek # This code is derived from software contributed to The NetBSD Foundation
      9  1.3  jdolecek # by Jaromir Dolecek.
     10  1.1  jdolecek #
     11  1.1  jdolecek # Redistribution and use in source and binary forms, with or without
     12  1.1  jdolecek # modification, are permitted provided that the following conditions
     13  1.1  jdolecek # are met:
     14  1.1  jdolecek # 1. Redistributions of source code must retain the above copyright
     15  1.1  jdolecek #    notice, this list of conditions and the following disclaimer.
     16  1.1  jdolecek # 2. Redistributions in binary form must reproduce the above copyright
     17  1.1  jdolecek #    notice, this list of conditions and the following disclaimer in the
     18  1.1  jdolecek #    documentation and/or other materials provided with the distribution.
     19  1.1  jdolecek #
     20  1.3  jdolecek # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     21  1.3  jdolecek # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     22  1.3  jdolecek # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     23  1.3  jdolecek # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     24  1.3  jdolecek # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     25  1.3  jdolecek # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     26  1.3  jdolecek # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     27  1.3  jdolecek # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     28  1.3  jdolecek # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     29  1.3  jdolecek # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     30  1.3  jdolecek # POSSIBILITY OF SUCH DAMAGE.
     31  1.3  jdolecek 
     32  1.3  jdolecek # Script for generating of vers.c file from given template. Used in
     33  1.3  jdolecek # bootblock build on various architectures.
     34  1.1  jdolecek #
     35  1.3  jdolecek # Called as:
     36  1.3  jdolecek #	sh ${S}/conf/newvers_stand.sh [-NDM] VERSION_FILE ARCH [EXTRA_MSG]
     37  1.3  jdolecek 
     38  1.6     perry cwd=$(dirname $0)
     39  1.6     perry 
     40  1.3  jdolecek add_name=yes
     41  1.3  jdolecek add_date=yes
     42  1.3  jdolecek add_maker=yes
     43  1.6     perry add_kernrev=yes
     44  1.1  jdolecek 
     45  1.3  jdolecek # parse command args
     46  1.6     perry while getopts "NDMK?" OPT; do
     47  1.3  jdolecek 	case $OPT in
     48  1.3  jdolecek 	N)	add_name=no;;
     49  1.3  jdolecek 	D)	add_date=no;;
     50  1.3  jdolecek 	M)	add_maker=no;;
     51  1.6     perry 	K)	add_kernrev=no;;
     52  1.6     perry 	?)	echo "Syntax: newvers_stand.sh [-NDMK] VERSION_TEMPLATE ARCH EXTRA_COMMENT" >&2
     53  1.3  jdolecek 		exit 1;;
     54  1.3  jdolecek 	esac
     55  1.3  jdolecek done
     56  1.3  jdolecek 
     57  1.3  jdolecek shift `expr $OPTIND - 1`
     58  1.1  jdolecek 
     59  1.4       mrg r=`awk -F: '$1 ~ /^[0-9.]*$/ { it = $1; } END { print it }' $1`
     60  1.1  jdolecek 
     61  1.3  jdolecek # always add revision info
     62  1.3  jdolecek echo "const char bootprog_rev[] = \"${r}\";" > vers.c
     63  1.3  jdolecek 
     64  1.3  jdolecek if [ $add_name = yes ]; then
     65  1.3  jdolecek 	a="$2"		# architecture name
     66  1.3  jdolecek 	extra=${3:+" $3"}
     67  1.3  jdolecek 
     68  1.3  jdolecek 	echo "const char bootprog_name[] = \"NetBSD/${a}${extra}\";" >> vers.c
     69  1.3  jdolecek fi
     70  1.3  jdolecek 
     71  1.3  jdolecek if [ $add_date = yes ]; then
     72  1.3  jdolecek 	t=`date`
     73  1.3  jdolecek 	echo "const char bootprog_date[] = \"${t}\";" >> vers.c
     74  1.1  jdolecek fi
     75  1.1  jdolecek 
     76  1.3  jdolecek if [ $add_maker = yes ]; then
     77  1.3  jdolecek 	u=${USER-root} h=`hostname`
     78  1.3  jdolecek 	echo "const char bootprog_maker[] = \"${u}@${h}\";" >> vers.c
     79  1.3  jdolecek fi
     80  1.6     perry 
     81  1.6     perry if [ $add_kernrev = yes ]; then
     82  1.6     perry 	osr=$(sh ${cwd}/osrelease.sh)
     83  1.6     perry 	echo "const char bootprog_kernrev[] = \"${osr}\";" >> vers.c
     84  1.6     perry fi
     85