userland-incorporator revision 500
500N/A#!/usr/bin/perl
500N/A#
500N/A# CDDL HEADER START
500N/A#
500N/A# The contents of this file are subject to the terms of the
500N/A# Common Development and Distribution License (the "License").
500N/A# You may not use this file except in compliance with the License.
500N/A#
500N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
500N/A# or http://www.opensolaris.org/os/licensing.
500N/A# See the License for the specific language governing permissions
500N/A# and limitations under the License.
500N/A#
500N/A# When distributing Covered Code, include this CDDL HEADER in each
500N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
500N/A# If applicable, add the following below this CDDL HEADER, with the
500N/A# fields enclosed by brackets "[]" replaced with your own identifying
500N/A# information: Portions Copyright [yyyy] [name of copyright owner]
500N/A#
500N/A# CDDL HEADER END
500N/A#
500N/A# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
500N/A#
500N/A#
500N/A# incorporator - an utility to incorporate packages in a repo
500N/A#
500N/A
500N/Ause Getopt::Long;
500N/A
500N/Asub enumerate_packages {
500N/A local ($repository, @fmris) = @_;
500N/A my @packages = ();
500N/A
500N/A #printf "/usr/bin/pkg list -ng $repository @fmris\n";
500N/A open($fp, "-|", "/usr/bin/pkg", "list", "-ng", $repository, @fmris) ||
500N/A die "pkg: $!";
500N/A while (<$fp>) {
500N/A
500N/A if (/^(\S+)\s\((\S+)\)\s+([\d.]+)-([\d.]+)\s+...$/) {
500N/A my ($package) = ();
500N/A
500N/A $package->{name} = $1;
500N/A $package->{publisher} = $2;
500N/A $package->{version} = $3;
500N/A $package->{branch} = $4;
500N/A
500N/A push(@packages, $package);
500N/A }
500N/A }
500N/A
500N/A #printf "returning %s\n", $_->{name} for (@packages);
500N/A
500N/A return @packages;
500N/A}
500N/A
500N/Asub print_incorporate {
500N/A local (%package) = @_;
500N/A my $facet = "facet.version-lock.$package->{name}";
500N/A
500N/A printf "depend fmri=%s@%s-%s %s=true type=incorporate\n",
500N/A $package->{name}, $package->{version}, $package->{branch},
500N/A $facet;
500N/A}
500N/A
500N/Amy ($repository, $fmri, $summary, $description, $consolidation) = ();
500N/A
500N/A$consolidation = 'userland';
500N/A
500N/AGetOptions("R|repository=s" => \$repository, "v|version=s" => \$version,
500N/A "s|summary=s" => \$summary, "d|description=s" => \$description,
500N/A "p|package=s" => \$fmri, "f|fmri=s" => \@fmris,
500N/A "c|consolidation=s" => \$consolidation);
500N/A
500N/A#
500N/A# print the incorporation
500N/A#
500N/Aprintf "set name=pkg.fmri value=%s\n", $fmri;
500N/Aprintf "set name=pkg.summary value='%s'\n", $summary;
500N/Aprintf "set name=pkg.description value='%s'\n", $description;
500N/Aprintf "set name=org.opensolaris.consolidation value=%s\n",
500N/A $consolidation;
500N/Aprintf "set name=pkg.depend.install-hold value=core-os.%s\n",
500N/A $consolidation;
500N/Aprintf "set name=info.classification value='org.opensolaris.category.2008:Meta Packages/Incorporations'\n";
500N/A
500N/A@packages = enumerate_packages($repository, @fmris);
500N/Afor (@packages) {
500N/A printf "depend fmri=pkg:/%s@%s-%s %s=true type=incorporate\n",
500N/A %$_->{name}, %$_->{version}, %$_->{branch},
500N/A "facet.version-lock.".%$_->{name};
500N/A}