tools/userland-incorporator
author Mike Sullivan <Mike.Sullivan@Oracle.COM>
Wed, 18 Dec 2013 10:04:53 -0800
branchs11-update
changeset 2855 576d5a7857b7
parent 830 bb9a661e5885
child 3476 c35c8f1a6df1
permissions -rwxr-xr-x
16404201 serialize pkglinting of components 16666374 userland misses opensolaris.org very much, but must move on to java.net's love 16703472 more userland components could benefit from resolve.deps files 16921386 move to parfait 1.2.0.1 16991973 some things ain't parfait'n 17361780 LD_Z_TEXT should, ya know, contain -z text not -z direct 17389915 default userland gcc should be gcc4 17621943 move to build 32 breaks userland-incorporation 17785723 gdb shouldn't override CC/CXX 17852021 userland-incorporator should detect duplicate packages 17899000 libtool doesn't build properly in non-C locale
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
#
2855
576d5a7857b7 16404201 serialize pkglinting of components
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 830
diff changeset
    22
# Copyright (c) 2011, 2013, 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:
2855
576d5a7857b7 16404201 serialize pkglinting of components
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 830
diff changeset
    41
		#   publisher   package   [r|o] version,5.12-branch:timestamp
576d5a7857b7 16404201 serialize pkglinting of components
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 830
diff changeset
    42
		# or lines should be in the form:
576d5a7857b7 16404201 serialize pkglinting of components
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 830
diff changeset
    43
		#   publisher   package   [r|o] version-branch:timestamp
576d5a7857b7 16404201 serialize pkglinting of components
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 830
diff changeset
    44
		if ((/^(\S+)\s+(\S+)\s+\S?\s+([\d.]+),[\d.]+-([\d.]+):.+$/) ||
576d5a7857b7 16404201 serialize pkglinting of components
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 830
diff changeset
    45
		   (/^(\S+)\s+(\S+)\s+\S?\s+([\d.]+)-([\d.]+):.+$/)) { 
500
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    46
			my ($package) = ();
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    47
827
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents: 500
diff changeset
    48
			$package->{publisher} = $1;
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents: 500
diff changeset
    49
			$package->{name} = $2;
500
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    50
			$package->{version} = $3;
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    51
			$package->{branch} = $4;
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    52
2855
576d5a7857b7 16404201 serialize pkglinting of components
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 830
diff changeset
    53
			if ($package->{name} !~ m/incorporation/) {
576d5a7857b7 16404201 serialize pkglinting of components
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 830
diff changeset
    54
				push(@packages, $package);
576d5a7857b7 16404201 serialize pkglinting of components
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 830
diff changeset
    55
			} 
827
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents: 500
diff changeset
    56
		} else {
2855
576d5a7857b7 16404201 serialize pkglinting of components
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 830
diff changeset
    57
			die "error: cannot handle: ", $_;
500
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    58
		}
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
	#printf "returning %s\n", $_->{name} for (@packages);
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    62
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    63
	return @packages;
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
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    66
sub print_incorporate {
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    67
	local (%package) = @_;
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    68
	my $facet = "facet.version-lock.$package->{name}";
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
	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
    71
		$package->{name}, $package->{version}, $package->{branch},
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    72
		$facet;
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
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    75
my ($repository, $fmri, $summary, $description, $consolidation) = ();
2855
576d5a7857b7 16404201 serialize pkglinting of components
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 830
diff changeset
    76
my %seen = ();
500
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    77
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    78
$consolidation = 'userland';
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
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
    81
	   "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
    82
	   "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
    83
	   "c|consolidation=s" => \$consolidation);
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    84
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    85
#
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    86
# print the incorporation
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    87
#
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    88
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
    89
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
    90
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
    91
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
    92
		$consolidation;
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    93
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
    94
		$consolidation;
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    95
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
    96
827
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents: 500
diff changeset
    97
@packages = enumerate_packages($repository, $consolidation, @fmris);
2855
576d5a7857b7 16404201 serialize pkglinting of components
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 830
diff changeset
    98
500
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    99
for (@packages) {
2855
576d5a7857b7 16404201 serialize pkglinting of components
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 830
diff changeset
   100
	if ($seen->{$_->{name}} == 1) {
576d5a7857b7 16404201 serialize pkglinting of components
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 830
diff changeset
   101
		die "error: duplicate package ", $_->{name};
576d5a7857b7 16404201 serialize pkglinting of components
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 830
diff changeset
   102
	}
500
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   103
	printf "depend fmri=pkg:/%[email protected]%s-%s %s=true type=incorporate\n",
2855
576d5a7857b7 16404201 serialize pkglinting of components
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 830
diff changeset
   104
		$_->{name}, $_->{version}, $_->{branch},
576d5a7857b7 16404201 serialize pkglinting of components
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 830
diff changeset
   105
		"facet.version-lock.".$_->{name}; 
576d5a7857b7 16404201 serialize pkglinting of components
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 830
diff changeset
   106
	$seen->{$_->{name}} = 1;
500
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   107
}