Subject: osrelease.sh and param.h - final take
To: None <tech-kern@netbsd.org>
From: Simon Burge <simonb@netbsd.org>
List: tech-kern
Date: 08/08/1999 00:08:25
Time to clean up (or throw out) some of the things I've been sitting on
for a while. First off, the idea of only changing the OS version in a
single file. Last I mentioned this, Chris Demetriou had some useful
input in cleaning up the script. Perry had an objection:
> Having done a lot of the recent version changes, I'm not sure the pain
> is worth the inflexibility and the ugly script. Also, I don't like
> burning the last two digits that way.
We've never used those last two digits - is it likely that we ever will?
I've been using the following without problems since early May... As I
said, time to bin it or keep it. Opinions?
Here's what __NetBSD_Version__ would be defined as:
* #define __NetBSD_Version__ MMmmrrppRl
*
* M = major version
* m = minor version
* r = release ["",A-Z but numeric]
* p = patchlevel
* R = release status (0 pre release, 1 released)
* l = (pre)release level (1 for alpha, 2 for beta, ...)
*
* So:
* NetBSD-1.2D = 102040000
* And:
* NetBSD-1.2.1_BETA = 102000102
* And:
* NetBSD-1.2.1 = 102000110
and here's the new osrelease.sh:
#!/bin/sh
#
# $NetBSD: osrelease.sh,v 1.25 1999/08/05 18:10:20 thorpej Exp $
#
# Copyright (c) 1999 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Simon Burge.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by the NetBSD
# Foundation, Inc. and its contributors.
# 4. Neither the name of The NetBSD Foundation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# DO NOT UPDATE THIS FILE WITH THE KERNEL VERSION.
# UPDATE sys/sys/param.h
# Get the release number to use
paramh=`dirname $0`/../sys/param.h
# Parse $1 to the awk script and remove '.'s if it is "-s"
awk '/^#define[ \t]*__NetBSD_Version__/ {
# Use "."s between fields?
if (ARGV[2] == "-s") {
sep = ""
delete ARGV[2]
}
else {
sep = "."
}
# assign components to variables
level = $3 % 10
$3 = ($3 - level) / 10
released = $3 % 10
$3 = ($3 - released) / 10
patchlevel = $3 % 100
$3 = ($3 - patchlevel) / 100
release = $3 % 100
$3 = ($3 - release) / 100
minor = $3 % 100
$3 = ($3 - minor) / 100
major = $3 % 100
$3 = ($3 - major) / 100
# Always major.minor
rel = major sep minor
# Add patch level if non-zero
if (patchlevel > 0) {
rel = rel sep patchlevel
}
# Add release if non-zero
if (release > 0) {
release = sprintf("%c", release + 64); # 64 = "A" - 1
rel = rel release
}
# released should be 0 for pre-release
if (released == 0) {
tag = ""
# Need to go further than DELTA?
if (level == 1) tag = "_ALPHA"
else if (level == 2) tag = "_BETA"
else if (level == 3) tag = "_GAMMA"
else if (level == 4) tag = "_DELTA"
rel = rel tag
}
print rel
# Dont process any more...
exit
}' $paramh $1