6679212 sgs use of SCCS id for versioning is obstacle to mercurial migration
authorab196087
Mon, 31 Mar 2008 09:50:54 -0700
changeset 6322 c7bf2a887dd4
parent 6321 3b1d2b6ce4a3
child 6323 f6133eef3be2
6679212 sgs use of SCCS id for versioning is obstacle to mercurial migration
usr/src/cmd/sgs/include/sgs.h
usr/src/cmd/sgs/libconv/Makefile.com
usr/src/cmd/sgs/libconv/Makefile.targ
usr/src/cmd/sgs/libconv/common/bld_vernote.ksh
usr/src/cmd/sgs/packages/Makefile.targ
usr/src/cmd/sgs/packages/common/SUNWonld-README
usr/src/cmd/sgs/packages/common/bld_awk_pkginfo.ksh
usr/src/cmd/sgs/packages/common/readme_revision
--- a/usr/src/cmd/sgs/include/sgs.h	Mon Mar 31 03:12:24 2008 -0700
+++ b/usr/src/cmd/sgs/include/sgs.h	Mon Mar 31 09:50:54 2008 -0700
@@ -24,7 +24,7 @@
  *	  All Rights Reserved
  *
  *
- * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  *
  * Global include file for all sgs.
@@ -66,8 +66,14 @@
 
 #ifndef _ASM
 
-extern const char link_ver_string[];	/* Linker version id  */
-					/*   see libconv/{plat}/vernote.s */
+/*
+ * link_ver_string[] contains a version string for use by the link-editor
+ * and all other linker components. It is found in libconv, and is
+ * generated by sgs/libconv/common/bld_vernote.ksh. That script produces
+ * libconv/{plat}/vernote.s, which is in turn assembled/linked into
+ * libconv.
+ */
+extern const char link_ver_string[];
 /*
  * Macro to round to next double word boundary.
  */
--- a/usr/src/cmd/sgs/libconv/Makefile.com	Mon Mar 31 03:12:24 2008 -0700
+++ b/usr/src/cmd/sgs/libconv/Makefile.com	Mon Mar 31 09:50:54 2008 -0700
@@ -20,7 +20,7 @@
 #
 
 #
-# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 # ident	"%Z%%M%	%I%	%E% SMI"
@@ -80,6 +80,7 @@
 
 CTFCONVERT_O=
 
+README_REVISION=../../packages/common/readme_revision
 ONLDREADME=	../../packages/common/SUNWonld-README
 
 PICS=		$(OBJECTS:%=pics/%)
@@ -101,7 +102,13 @@
 LINTSRCS32 =	$(COMOBJS32:%32.o=../common/%.c)
 LINTSRCS64 =	$(COMOBJS64:%64.o=../common/%.c)
 
-VERNOTE_DEBUG= -D
+# INTERNAL_RELEASE_BUILD is defined by standard full builds (nightly),
+# but not for sgs builds we do for development. The result of these
+# two lines is that dev builds pass -d to the readme_revision script,
+# generating a more detailed version string for the linker components
+# that includes the workspace, user, CR, and date. Official builds get
+# a simpler uncluttered version string.
+VERNOTE_DEBUG= -d
 $(INTERNAL_RELEASE_BUILD)VERNOTE_DEBUG=
 
 SGSMSGTARG=	$(COMOBJS:%.o=../common/%.msg) \
--- a/usr/src/cmd/sgs/libconv/Makefile.targ	Mon Mar 31 03:12:24 2008 -0700
+++ b/usr/src/cmd/sgs/libconv/Makefile.targ	Mon Mar 31 09:50:54 2008 -0700
@@ -20,7 +20,7 @@
 #
 
 #
-# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 # ident	"%Z%%M%	%I%	%E% SMI"
@@ -67,8 +67,10 @@
 		@ cd $(SGSTOOLS)/$(MACH); pwd; $(MAKE) catalog
 		@ pwd
 
-vernote.s:	bld_vernote $(ONLDREADME)
-		./bld_vernote $(VERNOTE_DEBUG) -R $(ONLDREADME) \
+vernote.s:	bld_vernote $(README_REVISION) $(ONLDREADME)
+		./bld_vernote \
+			-R `perl $(README_REVISION) $(VERNOTE_DEBUG) \
+				$(ONLDREADME)` \
 			-r "$(RELEASE)" -o $@
 
 bld_vernote:	../common/bld_vernote.ksh
--- a/usr/src/cmd/sgs/libconv/common/bld_vernote.ksh	Mon Mar 31 03:12:24 2008 -0700
+++ b/usr/src/cmd/sgs/libconv/common/bld_vernote.ksh	Mon Mar 31 09:50:54 2008 -0700
@@ -3,9 +3,8 @@
 # CDDL HEADER START
 #
 # The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
 #
 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 # or http://www.opensolaris.org/os/licensing.
@@ -23,13 +22,13 @@
 #
 # ident	"%Z%%M%	%I%	%E% SMI"
 #
-# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 
 usage()
 {
-	echo "usage: bld_vernote [-D] -R <SUNWonld-README> -r <release> -o <outfile.s>"
+	echo "usage: bld_vernote -R <revision> -r <release> -o <outfile.s>"
 }
 
 pad_notestring()
@@ -47,7 +46,7 @@
 
 build_sparcnote()
 {
-	notestring="\tSolaris Link Editors: $release-$readmerev\n\0"
+	notestring="\tSolaris Link Editors: $release-$revision\n\0"
 	#
 	# The 'adjustment' is for the '\t\n\0'
 	#
@@ -70,14 +69,14 @@
 	.global		link_ver_string
 link_ver_string:
 	.type		link_ver_string, #object
-	.ascii	"${release}-${readmerev}\0"
+	.ascii	"${release}-${revision}\0"
 	.size	link_ver_string, .-link_ver_string
 EOF
 }
 
 build_i386note()
 {
-	notestring="\tSolaris Link Editors: $release-$readmerev\n"
+	notestring="\tSolaris Link Editors: $release-$revision\n"
 	#
 	# The 'adjustment' is for the '\t\n' and the
 	# fact that the x86/amd64 assembler automatically
@@ -101,7 +100,7 @@
 	.globl		link_ver_string
 link_ver_string:
 	.type	link_ver_string,@object
-	.string	"${release}-${readmerev}\0"
+	.string	"${release}-${revision}\0"
 	.size	link_ver_string, .-link_ver_string
 EOF
 }
@@ -109,15 +108,11 @@
 
 notefile=""
 release=""
-readme=""
-debug=""
+revision=""
 
 while getopts DR:o:r: c
 do
 	case $c in
-	D)
-		debug="1"
-		;;
 	o)
 		notefile=$OPTARG
 		;;
@@ -125,7 +120,7 @@
 		release=$OPTARG
 		;;
 	R)
-		readme=$OPTARG
+		revision=$OPTARG
 		;;
 	\?)
 		usage
@@ -134,44 +129,12 @@
 	esac
 done
 
-if [[ ( -z $notefile ) || ( -z $release ) || ( -z $readme ) ]]; then
+if [[ ( -z $notefile ) || ( -z $release ) || ( -z $revision ) ]]; then
 	usage
 	exit 1
 fi
 
 
-identstring=$(head -10 $readme | grep '^#ident')
-if [[ -z $identstring ]]; then
-	echo "*** Fatal Error: building vernote.s: unable to find "
-	echo "*** '#ident' string in first 10 lines of $readme"
-	exit 1
-fi
-
-readmerev=$(echo $identstring | awk '{print $3;}')
-
-if [[ ( -z $readmerev ) || ( $readmerev = "%""I""%" ) ]]; then
-	opwd=$(pwd)
-	readdir=$(dirname $readme)
-	readbase=$(basename $readme)
-	cd $readdir
-	readmerev=$(sccs get -p $readbase 2>/dev/null | \
-		grep '^#ident' | \
-		awk '{print $3;}')
-	if [[ -z $readmerev ]]; then
-		readmerev='0.0'
-	fi
-	cd $opwd
-	debug="1"
-fi
-
-if [[ ! -z $debug ]]; then
-	wsname=
-	if [[ ! -z $CODEMGR_WS ]]; then
-		wsname=$(basename $CODEMGR_WS)
-	fi
-	readmerev=${readmerev}":"${wsname}"-${USER}-"$(date +%m/%d/%y)
-fi
-
 if [[ $MACH = "sparc" ]]; then
 	build_sparcnote
 elif [[ $MACH = "i386" ]]; then
--- a/usr/src/cmd/sgs/packages/Makefile.targ	Mon Mar 31 03:12:24 2008 -0700
+++ b/usr/src/cmd/sgs/packages/Makefile.targ	Mon Mar 31 09:50:54 2008 -0700
@@ -21,7 +21,7 @@
 #
 # ident	"%Z%%M%	%I%	%E% SMI"
 #
-# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 
 pkginfo: ../common/pkginfo.tmpl awk_pkginfo
@@ -38,8 +38,9 @@
 $(DATAFILES): ../common/$$@
 	$(RM) $@; cp ../common/$@ $@
 
-awk_pkginfo:	../bld_awk_pkginfo ../common/$(README)
-	../bld_awk_pkginfo -R ../common/$(README) $(VERDEBUG) \
+awk_pkginfo:	../bld_awk_pkginfo ../common/readme_revision ../common/$(README)
+	../bld_awk_pkginfo \
+		-R `perl ../common/readme_revision -d ../common/$(README)` \
 		-m $(MACH) -r "$(RELEASE)" -o $@
 
 clean: FRC
--- a/usr/src/cmd/sgs/packages/common/SUNWonld-README	Mon Mar 31 03:12:24 2008 -0700
+++ b/usr/src/cmd/sgs/packages/common/SUNWonld-README	Mon Mar 31 09:50:54 2008 -0700
@@ -1330,4 +1330,5 @@
 6568447 bcp is broken by 6551627 (link-editor components only)
 6675591 elfwrap - wrap data in an ELF file (D,P)
 	PSARC/2008/198 elfwrap - wrap data in an ELF file
-6678244 elfdump dymamic section sanity checking needs refinement
+6678244 elfdump dynamic section sanity checking needs refinement
+6679212 sgs use of SCCS id for versioning is obstacle to mercurial migration
--- a/usr/src/cmd/sgs/packages/common/bld_awk_pkginfo.ksh	Mon Mar 31 03:12:24 2008 -0700
+++ b/usr/src/cmd/sgs/packages/common/bld_awk_pkginfo.ksh	Mon Mar 31 09:50:54 2008 -0700
@@ -3,9 +3,8 @@
 # CDDL HEADER START
 #
 # The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
 #
 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 # or http://www.opensolaris.org/os/licensing.
@@ -23,8 +22,8 @@
 #
 #pragma ident	"%Z%%M%	%I%	%E% SMI"
 #
-# Copyright (c) 1993-2001 by Sun Microsystems, Inc.
-# All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
 #
 # Simple script which builds the awk_pkginfo awk script.  This awk script
 # is used to convert the pkginfo.tmpl files into pkginfo files
@@ -34,7 +33,7 @@
 
 usage()
 {
-   echo "usage: bld_awk_pkginfo -R <readme> -r <release> -m <mach> -o <awk_script>"
+   echo "usage: bld_awk_pkginfo -R <revision> -r <release> -m <mach> -o <awk_script>"
 }
 #
 # Awk strings
@@ -50,15 +49,11 @@
 mach=""
 release=""
 awk_script=""
-readme=""
-debug=""
+revision=""
 
 while getopts DR:o:r:m: c
 do
    case $c in
-   D)
-   	debug=1
-	;;
    o)
       awk_script=$OPTARG
       ;;
@@ -69,7 +64,7 @@
       release=$OPTARG
       ;;
    R)
-   	readme=$OPTARG
+   	revision=$OPTARG
 	;;
    \?)
       usage
@@ -79,7 +74,7 @@
 done
 
 if [[ ( -z $release ) || ( -z $mach ) || ( -z $awk_script ) \
-    || ( -z $readme) ]]
+    || ( -z $revision) ]]
 then
    usage
    exit 1
@@ -98,32 +93,8 @@
 #
 # Build PRODVERS string - same as in libconv/common/bld_vernote.ksh
 #
-readmerev=$(grep '^#pragma ident' $readme | awk '{print $4;}')
+prodver="${release}-${revision}"
 
-if [[ ( -z $readmerev ) || ( $readmerev = "%""I""%" ) ]]; then
-	opwd=$(pwd)
-	readdir=$(dirname $readme)
-	readbase=$(basename $readme)
-	cd $readdir
-	readmerev=$(sccs get -p $readbase 2>/dev/null | \
-		grep '^#pragma ident' | \
-		awk '{print $4;}')
-	if [[ -z $readmerev ]]; then
-		readmerev='0.0'
-	fi
-	cd $opwd
-	debug="1"
-fi
-
-if [[ ! -z $debug ]]; then
-	wsname=
-	if [[ ! -z $CODEMGR_WS ]]; then
-		wsname=$(basename $CODEMGR_WS)
-	fi
-	readmerev=${readmerev}":"${wsname}"-${USER}-"$(date +%m/%d/%y)
-fi
-
-prodver="${release}-${readmerev}"
 #
 # Build awk script which will process all the
 # pkginfo.tmpl files.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/packages/common/readme_revision	Mon Mar 31 09:50:54 2008 -0700
@@ -0,0 +1,143 @@
+#!/usr/bin/perl -w
+#
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+
+
+#
+# Generate a revision number for the sgs linker components, based
+# on usr/src/cmd/sgs/packages/common/SUNWonld-README.
+#
+#	usage: readme_revision [-d] [readme-file]
+#
+# This revision number used to be the SCCS revision id for that file,
+# in the form 1.xxx (where xxx was the revision). There were two benefits:
+#
+#	(1) You could examine the sccs revision log to determine the CR
+#		of the putback that created the revision.
+#	(2) The revisions were monotonically increasing.
+#
+# In order to remove the hard wired dependence on sccs, this script generates
+# a replacement revision number, by returning the string '1.xxx', where
+# xxx is an integer giving the number of unique CR lines found in the file.
+# This means that the revision goes up by one for each CR we fix, which
+# makes intutive sense, and is similar to the way the SCCS revision worked.
+#
+# If this is a debug/development build (-d option), then we include
+# additional information at the end of the revision:
+#
+#	- Workspace name
+#	- user
+#	- CR # of last item in the readme file
+#	- date,
+#
+# This extra information is useful when we need to identify SUNWonld
+# linker packages in the field, and provides the information previously
+# supplied by (1) above.
+#
+
+use vars qw($script $usage $readme $cnt);
+use vars qw($debug $last_cr $wsname $date);
+
+# Use the basename of the name we're invoked under as the script name
+@_ = split /\//, $0;
+$script = $_[$#_];
+$usage = "usage: $script [-d] [readme-file]\n";
+
+$debug = 0;
+# Process the options
+while ((scalar(@ARGV) > 0) && ($_ = $ARGV[0],/^-/)) {
+  ARG: {
+	if (/^-d$/) {
+		$debug = 1;
+		last ARG;
+	}
+
+
+      # If it gets here, the option is unknown.
+      die $usage;
+  }
+    shift;
+}
+
+# Plain argument
+$cnt = scalar @ARGV;
+{
+	if ($cnt == 0) {
+		$readme = 'SUNWonld-README';
+		next;
+	}
+
+	if ($cnt == 1) {
+		$readme = $ARGV[0];
+		next;
+	}
+
+	die $usage;
+}
+
+
+open(FILE, $readme) || die "$script: Unable to open $readme\n";
+
+# At the date this script was put into service, the SCCS revision
+# of SUNWonld-README was 1.627, and SUNWonld-README had 588 unique
+# CRs. Revisions are supposed to always increase monotonically, so
+# we add 1000 to the number of unique CRs.
+#
+# This means that any linker with a version <1000 was built using
+# the SCCS revision, and any linker with version >=1000 was built
+# with this script.
+$cnt = 1000;
+
+while ($_ = <FILE>) {
+	chomp $_;
+
+	# If the line starts with a number, it is taken as a CR.
+	if ($_ =~ /^(\d+)\s/) {
+		$cnt++;
+		$last_cr = $1;
+	}
+}
+close FILE;
+
+# If this is a standard build, the revision # is all we want
+if ($debug == 0) {
+	print "1.$cnt\n";
+	exit 0;
+}
+
+# For debug mode, add diagnostic data
+#
+# Note: CODEMGR_WS is a Teamware dependent environment variable. This
+#	will need to change to accommodate other revision control systems.
+# 
+($wsname = $ENV{'CODEMGR_WS'}) ne '' || ($wsname = 'unknown');
+@wsname = split /\//, $wsname;
+$wsname = $wsname[$#wsname];
+
+$date = `date +%m/%d/%y`;
+
+print "1.$cnt:$wsname-$ENV{USER}-$last_cr-$date\n";
+
+exit 0;