3edf445cce90224c4218c6987d6709e8481cae58ab#!/usr/bin/perl -w
3edf445cce90224c4218c6987d6709e8481cae58ab#
3edf445cce90224c4218c6987d6709e8481cae58ab# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
3edf445cce90224c4218c6987d6709e8481cae58ab# Use is subject to license terms.
3edf445cce90224c4218c6987d6709e8481cae58ab#
3edf445cce90224c4218c6987d6709e8481cae58ab# CDDL HEADER START
3edf445cce90224c4218c6987d6709e8481cae58ab#
3edf445cce90224c4218c6987d6709e8481cae58ab# The contents of this file are subject to the terms of the
3edf445cce90224c4218c6987d6709e8481cae58ab# Common Development and Distribution License (the "License").
3edf445cce90224c4218c6987d6709e8481cae58ab# You may not use this file except in compliance with the License.
3edf445cce90224c4218c6987d6709e8481cae58ab#
3edf445cce90224c4218c6987d6709e8481cae58ab# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
3edf445cce90224c4218c6987d6709e8481cae58ab# or http://www.opensolaris.org/os/licensing.
3edf445cce90224c4218c6987d6709e8481cae58ab# See the License for the specific language governing permissions
3edf445cce90224c4218c6987d6709e8481cae58ab# and limitations under the License.
3edf445cce90224c4218c6987d6709e8481cae58ab#
3edf445cce90224c4218c6987d6709e8481cae58ab# When distributing Covered Code, include this CDDL HEADER in each
3edf445cce90224c4218c6987d6709e8481cae58ab# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
3edf445cce90224c4218c6987d6709e8481cae58ab# If applicable, add the following below this CDDL HEADER, with the
3edf445cce90224c4218c6987d6709e8481cae58ab# fields enclosed by brackets "[]" replaced with your own identifying
3edf445cce90224c4218c6987d6709e8481cae58ab# information: Portions Copyright [yyyy] [name of copyright owner]
3edf445cce90224c4218c6987d6709e8481cae58ab#
3edf445cce90224c4218c6987d6709e8481cae58ab# CDDL HEADER END
3edf445cce90224c4218c6987d6709e8481cae58ab#
3edf445cce90224c4218c6987d6709e8481cae58ab#pragma ident "%Z%%M% %I% %E% SMI"
3edf445cce90224c4218c6987d6709e8481cae58ab
3edf445cce90224c4218c6987d6709e8481cae58ab
3edf445cce90224c4218c6987d6709e8481cae58ab#
3edf445cce90224c4218c6987d6709e8481cae58ab# Generate a revision number for the sgs linker components, based
3edf445cce90224c4218c6987d6709e8481cae58ab# on usr/src/cmd/sgs/packages/common/SUNWonld-README.
3edf445cce90224c4218c6987d6709e8481cae58ab#
3edf445cce90224c4218c6987d6709e8481cae58ab# usage: readme_revision [-d] [readme-file]
3edf445cce90224c4218c6987d6709e8481cae58ab#
3edf445cce90224c4218c6987d6709e8481cae58ab# This revision number used to be the SCCS revision id for that file,
3edf445cce90224c4218c6987d6709e8481cae58ab# in the form 1.xxx (where xxx was the revision). There were two benefits:
3edf445cce90224c4218c6987d6709e8481cae58ab#
3edf445cce90224c4218c6987d6709e8481cae58ab# (1) You could examine the sccs revision log to determine the CR
3edf445cce90224c4218c6987d6709e8481cae58ab# of the putback that created the revision.
3edf445cce90224c4218c6987d6709e8481cae58ab# (2) The revisions were monotonically increasing.
3edf445cce90224c4218c6987d6709e8481cae58ab#
3edf445cce90224c4218c6987d6709e8481cae58ab# In order to remove the hard wired dependence on sccs, this script generates
3edf445cce90224c4218c6987d6709e8481cae58ab# a replacement revision number, by returning the string '1.xxx', where
3edf445cce90224c4218c6987d6709e8481cae58ab# xxx is an integer giving the number of unique CR lines found in the file.
3edf445cce90224c4218c6987d6709e8481cae58ab# This means that the revision goes up by one for each CR we fix, which
3edf445cce90224c4218c6987d6709e8481cae58ab# makes intutive sense, and is similar to the way the SCCS revision worked.
3edf445cce90224c4218c6987d6709e8481cae58ab#
3edf445cce90224c4218c6987d6709e8481cae58ab# If this is a debug/development build (-d option), then we include
3edf445cce90224c4218c6987d6709e8481cae58ab# additional information at the end of the revision:
3edf445cce90224c4218c6987d6709e8481cae58ab#
3edf445cce90224c4218c6987d6709e8481cae58ab# - Workspace name
3edf445cce90224c4218c6987d6709e8481cae58ab# - user
3edf445cce90224c4218c6987d6709e8481cae58ab# - CR # of last item in the readme file
3edf445cce90224c4218c6987d6709e8481cae58ab# - date,
3edf445cce90224c4218c6987d6709e8481cae58ab#
3edf445cce90224c4218c6987d6709e8481cae58ab# This extra information is useful when we need to identify SUNWonld
3edf445cce90224c4218c6987d6709e8481cae58ab# linker packages in the field, and provides the information previously
3edf445cce90224c4218c6987d6709e8481cae58ab# supplied by (1) above.
3edf445cce90224c4218c6987d6709e8481cae58ab#
3edf445cce90224c4218c6987d6709e8481cae58ab
3edf445cce90224c4218c6987d6709e8481cae58abuse vars qw($script $usage $readme $cnt);
3edf445cce90224c4218c6987d6709e8481cae58abuse vars qw($debug $last_cr $wsname $date);
3edf445cce90224c4218c6987d6709e8481cae58ab
3edf445cce90224c4218c6987d6709e8481cae58ab# Use the basename of the name we're invoked under as the script name
3edf445cce90224c4218c6987d6709e8481cae58ab@_ = split /\//, $0;
3edf445cce90224c4218c6987d6709e8481cae58ab$script = $_[$#_];
3edf445cce90224c4218c6987d6709e8481cae58ab$usage = "usage: $script [-d] [readme-file]\n";
3edf445cce90224c4218c6987d6709e8481cae58ab
3edf445cce90224c4218c6987d6709e8481cae58ab$debug = 0;
3edf445cce90224c4218c6987d6709e8481cae58ab# Process the options
3edf445cce90224c4218c6987d6709e8481cae58abwhile ((scalar(@ARGV) > 0) && ($_ = $ARGV[0],/^-/)) {
3edf445cce90224c4218c6987d6709e8481cae58ab ARG: {
3edf445cce90224c4218c6987d6709e8481cae58ab if (/^-d$/) {
3edf445cce90224c4218c6987d6709e8481cae58ab $debug = 1;
3edf445cce90224c4218c6987d6709e8481cae58ab last ARG;
3edf445cce90224c4218c6987d6709e8481cae58ab }
3edf445cce90224c4218c6987d6709e8481cae58ab
3edf445cce90224c4218c6987d6709e8481cae58ab
3edf445cce90224c4218c6987d6709e8481cae58ab # If it gets here, the option is unknown.
3edf445cce90224c4218c6987d6709e8481cae58ab die $usage;
3edf445cce90224c4218c6987d6709e8481cae58ab }
3edf445cce90224c4218c6987d6709e8481cae58ab shift;
3edf445cce90224c4218c6987d6709e8481cae58ab}
3edf445cce90224c4218c6987d6709e8481cae58ab
3edf445cce90224c4218c6987d6709e8481cae58ab# Plain argument
3edf445cce90224c4218c6987d6709e8481cae58ab$cnt = scalar @ARGV;
3edf445cce90224c4218c6987d6709e8481cae58ab{
3edf445cce90224c4218c6987d6709e8481cae58ab if ($cnt == 0) {
3edf445cce90224c4218c6987d6709e8481cae58ab $readme = 'SUNWonld-README';
3edf445cce90224c4218c6987d6709e8481cae58ab next;
3edf445cce90224c4218c6987d6709e8481cae58ab }
3edf445cce90224c4218c6987d6709e8481cae58ab
3edf445cce90224c4218c6987d6709e8481cae58ab if ($cnt == 1) {
3edf445cce90224c4218c6987d6709e8481cae58ab $readme = $ARGV[0];
3edf445cce90224c4218c6987d6709e8481cae58ab next;
3edf445cce90224c4218c6987d6709e8481cae58ab }
3edf445cce90224c4218c6987d6709e8481cae58ab
3edf445cce90224c4218c6987d6709e8481cae58ab die $usage;
3edf445cce90224c4218c6987d6709e8481cae58ab}
3edf445cce90224c4218c6987d6709e8481cae58ab
3edf445cce90224c4218c6987d6709e8481cae58ab
3edf445cce90224c4218c6987d6709e8481cae58abopen(FILE, $readme) || die "$script: Unable to open $readme\n";
3edf445cce90224c4218c6987d6709e8481cae58ab
3edf445cce90224c4218c6987d6709e8481cae58ab# At the date this script was put into service, the SCCS revision
3edf445cce90224c4218c6987d6709e8481cae58ab# of SUNWonld-README was 1.627, and SUNWonld-README had 588 unique
3edf445cce90224c4218c6987d6709e8481cae58ab# CRs. Revisions are supposed to always increase monotonically, so
3edf445cce90224c4218c6987d6709e8481cae58ab# we add 1000 to the number of unique CRs.
3edf445cce90224c4218c6987d6709e8481cae58ab#
3edf445cce90224c4218c6987d6709e8481cae58ab# This means that any linker with a version <1000 was built using
3edf445cce90224c4218c6987d6709e8481cae58ab# the SCCS revision, and any linker with version >=1000 was built
3edf445cce90224c4218c6987d6709e8481cae58ab# with this script.
3edf445cce90224c4218c6987d6709e8481cae58ab$cnt = 1000;
3edf445cce90224c4218c6987d6709e8481cae58ab
3edf445cce90224c4218c6987d6709e8481cae58abwhile ($_ = <FILE>) {
3edf445cce90224c4218c6987d6709e8481cae58ab chomp $_;
3edf445cce90224c4218c6987d6709e8481cae58ab
3edf445cce90224c4218c6987d6709e8481cae58ab # If the line starts with a number, it is taken as a CR.
3edf445cce90224c4218c6987d6709e8481cae58ab if ($_ =~ /^(\d+)\s/) {
3edf445cce90224c4218c6987d6709e8481cae58ab $cnt++;
3edf445cce90224c4218c6987d6709e8481cae58ab $last_cr = $1;
3edf445cce90224c4218c6987d6709e8481cae58ab }
3edf445cce90224c4218c6987d6709e8481cae58ab}
3edf445cce90224c4218c6987d6709e8481cae58abclose FILE;
3edf445cce90224c4218c6987d6709e8481cae58ab
3edf445cce90224c4218c6987d6709e8481cae58ab# If this is a standard build, the revision # is all we want
3edf445cce90224c4218c6987d6709e8481cae58abif ($debug == 0) {
3edf445cce90224c4218c6987d6709e8481cae58ab print "1.$cnt\n";
3edf445cce90224c4218c6987d6709e8481cae58ab exit 0;
3edf445cce90224c4218c6987d6709e8481cae58ab}
3edf445cce90224c4218c6987d6709e8481cae58ab
3edf445cce90224c4218c6987d6709e8481cae58ab# For debug mode, add diagnostic data
3edf445cce90224c4218c6987d6709e8481cae58ab#
3edf445cce90224c4218c6987d6709e8481cae58ab($wsname = $ENV{'CODEMGR_WS'}) ne '' || ($wsname = 'unknown');
3edf445cce90224c4218c6987d6709e8481cae58ab@wsname = split /\//, $wsname;
3edf445cce90224c4218c6987d6709e8481cae58ab$wsname = $wsname[$#wsname];
3edf445cce90224c4218c6987d6709e8481cae58ab
3edf445cce90224c4218c6987d6709e8481cae58ab$date = `date +%m/%d/%y`;
3edf445cce90224c4218c6987d6709e8481cae58ab
3edf445cce90224c4218c6987d6709e8481cae58abprint "1.$cnt:$wsname-$ENV{USER}-$last_cr-$date\n";
3edf445cce90224c4218c6987d6709e8481cae58ab
3edf445cce90224c4218c6987d6709e8481cae58abexit 0;