tools/sunw-history-package
author Mike Sullivan <Mike.Sullivan@Oracle.COM>
Fri, 13 May 2016 17:33:30 -0700
changeset 5983 f10ab5ae99d7
parent 5682 94c0ca64c022
permissions -rwxr-xr-x
Close of build 99.3.
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
#
5682
94c0ca64c022 15558602 TCL_LD_SEARCH_FLAGS is wrongly defined in tclConfig.sh
Shawn Walker-Salas <shawn.walker@oracle.com>
parents: 62
diff changeset
    22
94c0ca64c022 15558602 TCL_LD_SEARCH_FLAGS is wrongly defined in tclConfig.sh
Shawn Walker-Salas <shawn.walker@oracle.com>
parents: 62
diff changeset
    23
#
62
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    24
# 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
    25
#
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    26
# 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
    27
#  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
    28
#  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
    29
#
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
$|=1;
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    32
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    33
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
    34
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
    35
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    36
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
    37
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    38
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
    39
	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
    40
	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
    41
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    42
	# 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
    43
	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
    44
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    45
	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
    46
		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
    47
			$package = $1;
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    48
		} 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
    49
			$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
    50
		}
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    51
	}
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
	close($FP);
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    54
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    55
	# 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
    56
	print <<EOF;
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    57
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
    58
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
    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=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
    61
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    62
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
    63
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
    64
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    65
EOF
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    66
	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
    67
		(m{^consolidation/}) ||
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    68
			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
    69
	}
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    70
}
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    71
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    72
sub usage {
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    73
	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
    74
	print <<EOF;
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    75
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
    76
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    77
EOF
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    78
	exit(1);
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    79
}
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    80
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    81
sub main {
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    82
	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
    83
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    84
	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
    85
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    86
	($#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
    87
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    88
	# 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
    89
	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
    90
		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
    91
	
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    92
		while (<$FP>) {
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    93
			chomp;
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    94
			$SUNWpackages{$_} = 1;
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    95
		}
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
		close($FP);
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    98
	}
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    99
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   100
	# 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
   101
	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
   102
		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
   103
		generate_manifest($_);
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
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 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
   109
#
519e6e3788ce 7013265 userland could use a tool to aid in SUNW package generation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   110
main();