osrelease.sh revision 1.119
11.1Slukem#!/bin/sh
21.1Slukem#
31.119Sdsl#	$NetBSD: osrelease.sh,v 1.119 2009/11/15 14:40:18 dsl Exp $
41.1Slukem#
51.1Slukem# Copyright (c) 1997 The NetBSD Foundation, Inc.
61.1Slukem# All rights reserved.
71.1Slukem#
81.1Slukem# This code is derived from software contributed to The NetBSD Foundation
91.1Slukem# by Luke Mewburn.
101.1Slukem#
111.1Slukem# Redistribution and use in source and binary forms, with or without
121.1Slukem# modification, are permitted provided that the following conditions
131.1Slukem# are met:
141.1Slukem# 1. Redistributions of source code must retain the above copyright
151.1Slukem#    notice, this list of conditions and the following disclaimer.
161.1Slukem# 2. Redistributions in binary form must reproduce the above copyright
171.1Slukem#    notice, this list of conditions and the following disclaimer in the
181.1Slukem#    documentation and/or other materials provided with the distribution.
191.1Slukem#
201.1Slukem# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
211.1Slukem# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
221.1Slukem# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
231.4Sjtc# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
241.4Sjtc# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
251.1Slukem# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
261.1Slukem# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
271.1Slukem# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
281.1Slukem# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
291.1Slukem# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
301.1Slukem# POSSIBILITY OF SUCH DAMAGE.
311.1Slukem#
321.1Slukem
331.107Sjdolecek# We use the number specified in <sys/param.h>
341.111Sriz
351.118Sdslpath="./$0"
361.118Sdslexec < ${path%/*}/../sys/param.h
371.111Sriz
381.119Sdsl# Search for line
391.119Sdsl# #define __NetBSD_Version__ <ver_num> /* NetBSD <ver_text> */
401.119Sdsl#
411.119Sdsl# <ver_num> and <ver_text> should match!
421.119Sdsl
431.118Sdslwhile
441.119Sdsl	read define ver_tag rel_num comment_start NetBSD rel_text rest || exit 1
451.118Sdsldo
461.118Sdsl	[ "$define" = "#define" ] || continue;
471.118Sdsl	[ "$ver_tag" = "__NetBSD_Version__" ] || continue
481.118Sdsl	break
491.118Sdsldone
501.118Sdsl
511.118Sdsl# default: return MM.mm.pp
521.118Sdsl# -m: return MM, representing only the major number; however, for -current,
531.117Sapb#     return the next major number (e.g. for 5.99.nn, return 6)
541.118Sdsl# -n: return MM.mm
551.118Sdsl# -s: return MMmmpp (no dots)
561.118Sdsl
571.119Sdsloption="$1"
581.118Sdsl
591.119Sdsl# ${rel_num} is [M]Mmm00pp00
601.119Sdslrel_num=${rel_num%??}
611.119Sdslrel_MMmm=${rel_num%????}
621.118Sdslrel_MM=${rel_MMmm%??}
631.118Sdslrel_mm=${rel_MMmm#${rel_MM}}
641.119Sdsl# rel_pp=${rel_num#${rel_MMmm}00}
651.119Sdsl
661.119Sdsl# Get patch from text version
671.119SdslIFS=.
681.119Sdslset -- - $rel_text
691.119Sdslshift 3
701.119SdslIFS=' '
711.119Sdslset -- $rel_MM ${rel_mm#0} $*
721.113Sperry
731.119Sdslcase "$option" in
741.113Sperry-m)
751.118Sdsl	echo "$(((${rel_MMmm}+1)/100))"
761.113Sperry	;;
771.116Sjoerg-n)
781.119Sdsl	echo "${rel_MM}.${rel_mm#0}"
791.116Sjoerg	;;
801.111Sriz-s)
811.119Sdsl	IFS=
821.119Sdsl	echo "$*"
831.111Sriz	;;
841.111Sriz*)
851.119Sdsl	IFS=.
861.119Sdsl	echo "$*"
871.111Sriz	;;
881.111Srizesac
89