osrelease.sh revision 1.118
11.1Slukem#!/bin/sh 21.1Slukem# 31.118Sdsl# $NetBSD: osrelease.sh,v 1.118 2009/11/15 13:39:00 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.118Sdslwhile 391.118Sdsl read define ver_tag release comment || exit 1 401.118Sdsldo 411.118Sdsl [ "$define" = "#define" ] || continue; 421.118Sdsl [ "$ver_tag" = "__NetBSD_Version__" ] || continue 431.118Sdsl break 441.118Sdsldone 451.118Sdsl 461.118Sdsl# ${release} is [M]Mmm00pp00 471.118Sdsl# 481.118Sdsl# default: return MM.mm.pp 491.118Sdsl# -m: return MM, representing only the major number; however, for -current, 501.117Sapb# return the next major number (e.g. for 5.99.nn, return 6) 511.118Sdsl# -n: return MM.mm 521.118Sdsl# -s: return MMmmpp (no dots) 531.118Sdsl 541.118Sdslrelease=${release%??} 551.118Sdsl 561.118Sdslrel_MMmm=${release%????} 571.118Sdslrel_MM=${rel_MMmm%??} 581.118Sdslrel_mm=${rel_MMmm#${rel_MM}} 591.118Sdslrel_pp=${release#${rel_MMmm}00} 601.113Sperry 611.111Srizcase $1 in 621.113Sperry-m) 631.118Sdsl echo "$(((${rel_MMmm}+1)/100))" 641.113Sperry ;; 651.116Sjoerg-n) 661.118Sdsl echo "$rel_MM.$rel_mm" 671.116Sjoerg ;; 681.111Sriz-s) 691.118Sdsl echo "$rel_MM$rel_mm$rel_pp" 701.111Sriz ;; 711.111Sriz*) 721.118Sdsl echo "$rel_MM.$rel_mm.$rel_pp" 731.111Sriz ;; 741.111Srizesac 75