tools/userland-incorporator
author Mike Sullivan <Mike.Sullivan@Oracle.COM>
Mon, 29 Apr 2013 11:33:18 -0700
changeset 1285 95c29b5f89d2
parent 830 bb9a661e5885
child 1517 a0e586ad53a2
child 2855 576d5a7857b7
permissions -rwxr-xr-x
Close of build 21.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
500
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     1
#!/usr/bin/perl
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     2
#
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     3
# CDDL HEADER START
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     4
#
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     5
# The contents of this file are subject to the terms of the
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     6
# Common Development and Distribution License (the "License").
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     7
# You may not use this file except in compliance with the License.
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     8
#
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     9
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    10
# or http://www.opensolaris.org/os/licensing.
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    11
# See the License for the specific language governing permissions
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    12
# and limitations under the License.
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    13
#
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    14
# When distributing Covered Code, include this CDDL HEADER in each
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    15
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    16
# If applicable, add the following below this CDDL HEADER, with the
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    17
# fields enclosed by brackets "[]" replaced with your own identifying
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    18
# information: Portions Copyright [yyyy] [name of copyright owner]
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    19
#
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    20
# CDDL HEADER END
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    21
#
827
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents: 500
diff changeset
    22
# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
500
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    23
#
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    24
#
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    25
# incorporator - an utility to incorporate packages in a repo
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    26
#
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    27
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    28
use Getopt::Long;
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    29
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    30
sub enumerate_packages {
827
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents: 500
diff changeset
    31
	local ($repository, $publisher, @fmris) = @_;
500
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    32
        my @packages = ();
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    33
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    34
	#printf "/usr/bin/pkg list -ng $repository @fmris\n";
827
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents: 500
diff changeset
    35
	open($fp, "-|", "/usr/bin/pkgrepo", "list", "-H", "-s", $repository,
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents: 500
diff changeset
    36
		  "-p", $publisher, @fmris) ||
500
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    37
                  die "pkg: $!";
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    38
	while (<$fp>) {
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    39
827
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents: 500
diff changeset
    40
		# lines should be in the form:
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents: 500
diff changeset
    41
		#   publisher   package   [r|o] version,branch:timestamp
830
bb9a661e5885 7169052 Integrate Visual Panels into Userland (fix incorporator)
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 827
diff changeset
    42
		if (/^(\S+)\s+(\S+)\s+\S?\s+([\d.]+),[\d.]+-([\d.]+):.+$/) {
500
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    43
			my ($package) = ();
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    44
827
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents: 500
diff changeset
    45
			$package->{publisher} = $1;
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents: 500
diff changeset
    46
			$package->{name} = $2;
500
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    47
			$package->{version} = $3;
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    48
			$package->{branch} = $4;
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    49
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    50
			push(@packages, $package);
827
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents: 500
diff changeset
    51
		} else {
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents: 500
diff changeset
    52
			printf STDERR "SKIP: %s", $_;
500
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    53
		}
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    54
	}
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    55
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    56
	#printf "returning %s\n", $_->{name} for (@packages);
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    57
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    58
	return @packages;
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    59
}
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    60
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    61
sub print_incorporate {
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    62
	local (%package) = @_;
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    63
	my $facet = "facet.version-lock.$package->{name}";
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    64
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    65
	printf "depend fmri=%[email protected]%s-%s %s=true type=incorporate\n",
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    66
		$package->{name}, $package->{version}, $package->{branch},
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    67
		$facet;
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    68
}
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    69
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    70
my ($repository, $fmri, $summary, $description, $consolidation) = ();
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    71
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    72
$consolidation = 'userland';
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    73
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    74
GetOptions("R|repository=s" => \$repository, "v|version=s" => \$version,
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    75
	   "s|summary=s" => \$summary, "d|description=s" => \$description,
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    76
	   "p|package=s" => \$fmri, "f|fmri=s" => \@fmris,
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    77
	   "c|consolidation=s" => \$consolidation);
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    78
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    79
#
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    80
# print the incorporation
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    81
#
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    82
printf "set name=pkg.fmri value=%s\n", $fmri;
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    83
printf "set name=pkg.summary value='%s'\n", $summary;
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    84
printf "set name=pkg.description value='%s'\n", $description;
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    85
printf "set name=org.opensolaris.consolidation value=%s\n",
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    86
		$consolidation;
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    87
printf "set name=pkg.depend.install-hold value=core-os.%s\n",
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    88
		$consolidation;
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    89
printf "set name=info.classification value='org.opensolaris.category.2008:Meta Packages/Incorporations'\n";
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    90
827
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents: 500
diff changeset
    91
@packages = enumerate_packages($repository, $consolidation, @fmris);
500
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    92
for (@packages) {
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    93
	printf "depend fmri=pkg:/%[email protected]%s-%s %s=true type=incorporate\n",
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    94
		%$_->{name}, %$_->{version}, %$_->{branch},
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    95
		"facet.version-lock.".%$_->{name};
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    96
}