osrelease.sh revision 1.120
11.1Slukem#!/bin/sh 21.1Slukem# 31.120Sdsl# $NetBSD: osrelease.sh,v 1.120 2009/11/15 18:41:08 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.120Sdslpath="$0" 361.120Sdsl[ "${path#/*}" = "$path" ] && path="./$path" 371.118Sdslexec < ${path%/*}/../sys/param.h 381.111Sriz 391.119Sdsl# Search for line 401.119Sdsl# #define __NetBSD_Version__ <ver_num> /* NetBSD <ver_text> */ 411.119Sdsl# 421.119Sdsl# <ver_num> and <ver_text> should match! 431.119Sdsl 441.118Sdslwhile 451.119Sdsl read define ver_tag rel_num comment_start NetBSD rel_text rest || exit 1 461.118Sdsldo 471.118Sdsl [ "$define" = "#define" ] || continue; 481.118Sdsl [ "$ver_tag" = "__NetBSD_Version__" ] || continue 491.118Sdsl break 501.118Sdsldone 511.118Sdsl 521.118Sdsl# default: return MM.mm.pp 531.118Sdsl# -m: return MM, representing only the major number; however, for -current, 541.117Sapb# return the next major number (e.g. for 5.99.nn, return 6) 551.118Sdsl# -n: return MM.mm 561.118Sdsl# -s: return MMmmpp (no dots) 571.118Sdsl 581.119Sdsloption="$1" 591.118Sdsl 601.119Sdsl# ${rel_num} is [M]Mmm00pp00 611.119Sdslrel_num=${rel_num%??} 621.119Sdslrel_MMmm=${rel_num%????} 631.118Sdslrel_MM=${rel_MMmm%??} 641.118Sdslrel_mm=${rel_MMmm#${rel_MM}} 651.119Sdsl# rel_pp=${rel_num#${rel_MMmm}00} 661.119Sdsl 671.119Sdsl# Get patch from text version 681.119SdslIFS=. 691.119Sdslset -- - $rel_text 701.119Sdslshift 3 711.119SdslIFS=' ' 721.119Sdslset -- $rel_MM ${rel_mm#0} $* 731.113Sperry 741.119Sdslcase "$option" in 751.113Sperry-m) 761.118Sdsl echo "$(((${rel_MMmm}+1)/100))" 771.113Sperry ;; 781.116Sjoerg-n) 791.119Sdsl echo "${rel_MM}.${rel_mm#0}" 801.116Sjoerg ;; 811.111Sriz-s) 821.119Sdsl IFS= 831.119Sdsl echo "$*" 841.111Sriz ;; 851.111Sriz*) 861.119Sdsl IFS=. 871.119Sdsl echo "$*" 881.111Sriz ;; 891.111Srizesac 90