newvers.sh revision 1.52.18.2 1 #!/bin/sh -
2 #
3 # $NetBSD: newvers.sh,v 1.52.18.2 2010/03/11 15:03:20 yamt Exp $
4 #
5 # Copyright (c) 1984, 1986, 1990, 1993
6 # The Regents of the University of California. All rights reserved.
7 #
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions
10 # are met:
11 # 1. Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
13 # 2. Redistributions in binary form must reproduce the above copyright
14 # notice, this list of conditions and the following disclaimer in the
15 # documentation and/or other materials provided with the distribution.
16 # 3. Neither the name of the University nor the names of its contributors
17 # may be used to endorse or promote products derived from this software
18 # without specific prior written permission.
19 #
20 # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 # SUCH DAMAGE.
31 #
32 # @(#)newvers.sh 8.1 (Berkeley) 4/20/94
33
34 if [ ! -e version ]; then
35 echo 0 > version
36 fi
37
38 v=$(cat version)
39 t=$(LC_ALL=C date)
40 u=${USER-root}
41 h=$(hostname)
42 d=$(pwd)
43 cwd=$(dirname $0)
44 copyright=$(awk '{ printf("\"%s\\n\"", $0); }' ${cwd}/copyright)
45
46 while [ $# -gt 0 ]; do
47 case "$1" in
48 -r)
49 rflag=true
50 ;;
51 -i)
52 id="$2"
53 shift
54 ;;
55 -n)
56 nflag=true
57 ;;
58 esac
59 shift
60 done
61
62 if [ -z "${id}" ]; then
63 if [ -f ident ]; then
64 id="$(cat ident)"
65 else
66 id=$(basename ${d})
67 fi
68 fi
69
70 osrelcmd=${cwd}/osrelease.sh
71
72 ost="NetBSD"
73 osr=$(sh $osrelcmd)
74
75 if [ ! -z "${rflag}" ]; then
76 fullversion="${ost} ${osr} (${id})\n"
77 else
78 fullversion="${ost} ${osr} (${id}) #${v}: ${t}\n\t${u}@${h}:${d}\n"
79 fi
80
81 echo $(expr ${v} + 1) > version
82
83 cat << _EOF > vers.c
84 /*
85 * Automatically generated file from $0
86 * Do not edit.
87 */
88 #include <sys/cdefs.h>
89 #include <sys/types.h>
90 #include <sys/param.h>
91 #include <sys/exec.h>
92 #include <sys/exec_elf.h>
93
94 const char ostype[] = "${ost}";
95 const char osrelease[] = "${osr}";
96 const char sccs[] = "@(#)${fullversion}";
97 const char version[] = "${fullversion}";
98 const char kernel_ident[] = "${id}";
99 const char copyright[] =
100 ${copyright}
101 "\n";
102 _EOF
103
104 [ ! -z "${nflag}" ] && exit 0
105
106 cat << _EOF >> vers.c
107
108 /*
109 * NetBSD identity note.
110 */
111 #ifdef __arm__
112 #define _SHT_NOTE %note
113 #else
114 #define _SHT_NOTE @note
115 #endif
116
117 #define _S(TAG) __STRING(TAG)
118 __asm(
119 ".section\t\".note.netbsd.ident\", \"\"," _S(_SHT_NOTE) "\n"
120 "\t.p2align\t2\n"
121 "\t.long\t" _S(ELF_NOTE_NETBSD_NAMESZ) "\n"
122 "\t.long\t" _S(ELF_NOTE_NETBSD_DESCSZ) "\n"
123 "\t.long\t" _S(ELF_NOTE_TYPE_NETBSD_TAG) "\n"
124 "\t.ascii\t" _S(ELF_NOTE_NETBSD_NAME) "\n"
125 "\t.long\t" _S(__NetBSD_Version__) "\n"
126 "\t.p2align\t2\n"
127 );
128
129 _EOF
130