Home | History | Annotate | Line # | Download | only in conf
newvers_stand.sh revision 1.8
      1  1.1  jdolecek #!/bin/sh -
      2  1.1  jdolecek #
      3  1.8     joerg # $NetBSD: newvers_stand.sh,v 1.8 2011/01/22 19:19:25 joerg 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.8     joerg #	sh ${S}/conf/newvers_stand.sh [-N] 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.8     joerg add_date=no
     42  1.6     perry add_kernrev=yes
     43  1.1  jdolecek 
     44  1.3  jdolecek # parse command args
     45  1.8     joerg while getopts "DKN?" OPT; do
     46  1.3  jdolecek 	case $OPT in
     47  1.8     joerg 	D)	add_date=yes;;
     48  1.8     joerg 	K)	add_kernrev=no;;
     49  1.3  jdolecek 	N)	add_name=no;;
     50  1.6     perry 	?)	echo "Syntax: newvers_stand.sh [-NDMK] VERSION_TEMPLATE ARCH EXTRA_COMMENT" >&2
     51  1.3  jdolecek 		exit 1;;
     52  1.3  jdolecek 	esac
     53  1.3  jdolecek done
     54  1.3  jdolecek 
     55  1.3  jdolecek shift `expr $OPTIND - 1`
     56  1.1  jdolecek 
     57  1.4       mrg r=`awk -F: '$1 ~ /^[0-9.]*$/ { it = $1; } END { print it }' $1`
     58  1.8     joerg t=`LC_ALL=C date`
     59  1.1  jdolecek 
     60  1.8     joerg if [ $add_date = yes ]; then
     61  1.8     joerg 	echo "const char bootprog_rev[] = \"${r} (${t})\";" > vers.c
     62  1.8     joerg else
     63  1.8     joerg 	echo "const char bootprog_rev[] = \"${r}\";" > vers.c
     64  1.8     joerg fi
     65  1.3  jdolecek 
     66  1.3  jdolecek if [ $add_name = yes ]; then
     67  1.3  jdolecek 	a="$2"		# architecture name
     68  1.3  jdolecek 	extra=${3:+" $3"}
     69  1.3  jdolecek 
     70  1.3  jdolecek 	echo "const char bootprog_name[] = \"NetBSD/${a}${extra}\";" >> vers.c
     71  1.3  jdolecek fi
     72  1.3  jdolecek 
     73  1.6     perry if [ $add_kernrev = yes ]; then
     74  1.6     perry 	osr=$(sh ${cwd}/osrelease.sh)
     75  1.6     perry 	echo "const char bootprog_kernrev[] = \"${osr}\";" >> vers.c
     76  1.6     perry fi
     77