5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
22 # Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
24 # sunw-history-package
25 # A simple program to generate the actions contained in the SUNW package
26 # that maps between the old (pre build-133) and new ips package names.
32 use File
::Basename
/qw basename/;
34 my $PKG = '/usr/bin/pkg';
36 sub generate_manifest
{
37 local ($package_name) = @_;
38 my ($package, %depends) = ();
41 open($FP, "$PKG contents -r -H -o action.raw $package_name |");
43 while (<$FP>) { # save what we want
44 if (m{set\s+name=pkg.fmri\s+value=pkg://.+/(.+):.+$}) {
46 } elsif (m{depend fmri=(.+)\s+type=require$}) {
53 # generate the manifest actions
55 set name=pkg.fmri value=pkg:/$package
56 set name=pkg.renamed value=true
58 set name=org.opensolaris.consolidation value=\$(CONSOLIDATION)
60 set name=variant.opensolaris.zone value=global value=nonglobal
61 set name=variant.arch value=\$(ARCH)
64 foreach (sort keys %depends) {
65 (m{^consolidation/}) ||
66 print "depend fmri=$_ type=require\n"
71 my $program = basename
($0);
73 Usage: $program (--package (new-ips-name)) ...
80 my (@current_packages, %SUNWpackages) = ();
82 GetOptions
('package:s' => \
@current_packages);
84 ($#current_packages == -1) && usage
();
86 # find all SUNW packages that require the supplied packages
87 foreach (@current_packages) {
88 open($FP, "$PKG search -r -H -o pkg.name 'SUNW*:depend::*/$_' |");
92 $SUNWpackages{$_} = 1;
98 # generate manifests for each SUNWpackage
99 foreach (sort keys %SUNWpackages) {
100 print "\n\n$_.p5m actions:\n";
101 generate_manifest
($_);
106 # Main execution starts here.