tools/sunw-history-package
author Mohana Rao Gorai <mohana.gorai@oracle.com>
Mon, 24 Mar 2014 09:57:22 -0700
branchs11u1-sru
changeset 3001 b96508535208
parent 62 519e6e3788ce
child 5682 94c0ca64c022
permissions -rwxr-xr-x
16242256 linkUpDownNotifications does not work as described in snmpd.conf man page 15819411 SUNBT7201970 There is no "PORTNUMBER" info for "traphandle" in solaris11 snmptra 15754602 SUNBT7111031 snmpd dumping during walk as strs test suite winds down its connect
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
62
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     1
#!/usr/perl5/bin/perl
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     2
#
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     3
# CDDL HEADER START
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     4
#
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     5
# The contents of this file are subject to the terms of the
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     6
# Common Development and Distribution License (the "License").
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     7
# You may not use this file except in compliance with the License.
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     8
#
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     9
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    10
# or http://www.opensolaris.org/os/licensing.
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    11
# See the License for the specific language governing permissions
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    12
# and limitations under the License.
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    13
#
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    14
# When distributing Covered Code, include this CDDL HEADER in each
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    15
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    16
# If applicable, add the following below this CDDL HEADER, with the
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    17
# fields enclosed by brackets "[]" replaced with your own identifying
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    18
# information: Portions Copyright [yyyy] [name of copyright owner]
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    19
#
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    20
# CDDL HEADER END
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    21
#
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    22
# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    23
#
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    24
# sunw-history-package
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    25
#  A simple program to generate the actions contained in the SUNW package
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    26
#  that maps between the old (pre build-133) and new ips package names.
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    27
#
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    28
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    29
$|=1;
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    30
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    31
use Getopt::Long;
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    32
use File::Basename /qw basename/;
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    33
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    34
my $PKG = '/usr/bin/pkg';
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    35
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    36
sub generate_manifest {
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    37
	local ($package_name) = @_;
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    38
	my ($package, %depends) = ();
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    39
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    40
	# gather some data
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    41
	open($FP, "$PKG contents -r -H -o action.raw $package_name |");
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    42
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    43
	while (<$FP>) {	# save what we want
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    44
		if (m{set\s+name=pkg.fmri\s+value=pkg://.+/(.+):.+$}) {
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    45
			$package = $1;
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    46
		} elsif (m{depend fmri=(.+)\s+type=require$}) {
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    47
			$depends{$1} = 1;
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    48
		}
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    49
	}
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    50
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    51
	close($FP);
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    52
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    53
	# generate the manifest actions
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    54
	print <<EOF;
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    55
set name=pkg.fmri value=pkg:/$package
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    56
set name=pkg.renamed value=true
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    57
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    58
set name=org.opensolaris.consolidation value=\$(CONSOLIDATION)
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    59
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    60
set name=variant.opensolaris.zone value=global value=nonglobal
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    61
set name=variant.arch value=\$(ARCH)
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    62
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    63
EOF
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    64
	foreach (sort keys %depends) {
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    65
		(m{^consolidation/}) ||
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    66
			print "depend fmri=$_ type=require\n"
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    67
	}
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    68
}
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    69
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    70
sub usage {
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    71
	my $program = basename($0);
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    72
	print <<EOF;
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    73
Usage: $program (--package (new-ips-name)) ...
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    74
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    75
EOF
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    76
	exit(1);
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    77
}
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    78
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    79
sub main {
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    80
	my (@current_packages, %SUNWpackages) = ();
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    81
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    82
	GetOptions('package:s' => \@current_packages);
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    83
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    84
	($#current_packages == -1) && usage();
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    85
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    86
	# find all SUNW packages that require the supplied packages
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    87
	foreach (@current_packages) {
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    88
		open($FP, "$PKG search -r -H -o pkg.name 'SUNW*:depend::*/$_' |");
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    89
	
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    90
		while (<$FP>) {
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    91
			chomp;
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    92
			$SUNWpackages{$_} = 1;
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    93
		}
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    94
	
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    95
		close($FP);
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    96
	}
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    97
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    98
	# generate manifests for each SUNWpackage
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    99
	foreach (sort keys %SUNWpackages) {
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   100
		print "\n\n$_.p5m actions:\n";
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   101
		generate_manifest($_);
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   102
	}
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   103
}
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   104
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   105
#
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   106
# Main execution starts here.
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   107
#
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   108
main();