open-src/common/pkg-manifest-generate.pl
author Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
Tue, 26 Mar 2013 12:39:28 -0700
changeset 1339 4f152696e5f2
parent 1265 0b5cc5c013e4
permissions -rwxr-xr-x
16167547 Update copyright & license display & metadata in X packages
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
970
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
     1
#! /usr/perl5/bin/perl
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
     2
#
1339
4f152696e5f2 16167547 Update copyright & license display & metadata in X packages
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1265
diff changeset
     3
# Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
970
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
     4
#
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
     5
# Permission is hereby granted, free of charge, to any person obtaining a
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
     6
# copy of this software and associated documentation files (the "Software"),
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
     7
# to deal in the Software without restriction, including without limitation
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
     8
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
     9
# and/or sell copies of the Software, and to permit persons to whom the
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    10
# Software is furnished to do so, subject to the following conditions:
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    11
#
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    12
# The above copyright notice and this permission notice (including the next
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    13
# paragraph) shall be included in all copies or substantial portions of the
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    14
# Software.
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    15
#
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    16
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    17
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    18
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    19
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    20
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    21
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    22
# DEALINGS IN THE SOFTWARE.
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    23
#
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    24
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    25
#
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    26
# Script to generate a package manifest for use with pkg(5) from a
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    27
# temporary proto area
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    28
#
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    29
# Usage: pkg-manifest-generate.pl [<attribute>=<value>...]
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    30
#
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    31
#  If <manifest input> exists, it is merged into the output.
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    32
#  If <manifest input> does not exist, <license file> is included in the output
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    33
#  The result is written to <manifest output>, or stdout if not specified
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    34
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    35
use strict;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    36
use warnings;
1339
4f152696e5f2 16167547 Update copyright & license display & metadata in X packages
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1265
diff changeset
    37
use POSIX qw(strftime);
970
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    38
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    39
my %options;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    40
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    41
foreach my $arg (@ARGV) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    42
  my ($attr, $val) = split /=/, $arg, 2;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    43
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    44
  push @{$options{$attr}}, $val;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    45
}
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    46
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    47
sub required_option_list {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    48
  my ($opt, $message) = @_;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    49
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    50
  if (!exists $options{$opt}) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    51
    die ("Must specify $opt $message\n");
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    52
  }
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    53
  return $options{$opt};
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    54
}
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    55
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    56
sub required_option {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    57
  my ($opt, $message) = @_;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    58
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    59
  my $opt_list_ref = required_option_list(@_);
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    60
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    61
  if (scalar(@{$opt_list_ref}) != 1) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    62
    die ("Must specify only one value for $opt $message\n");
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    63
  }
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    64
  return $opt_list_ref->[0];
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    65
}
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    66
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    67
my %actions_seen = ();
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    68
my @manifest_header;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
    69
1172
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
    70
sub next_action_seen {
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
    71
    my ($FH) = @_;
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
    72
    my $action = "";
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
    73
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
    74
    while (my $l = <$FH>) {
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
    75
      chomp($l);
1265
0b5cc5c013e4 7083537 Xorg 1.12 & associated module updates
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents: 1172
diff changeset
    76
      if ($l =~ m{^\#}) { # comment
0b5cc5c013e4 7083537 Xorg 1.12 & associated module updates
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents: 1172
diff changeset
    77
	$action .= $l;
0b5cc5c013e4 7083537 Xorg 1.12 & associated module updates
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents: 1172
diff changeset
    78
	return $action;
0b5cc5c013e4 7083537 Xorg 1.12 & associated module updates
Niveditha Rau <Niveditha.Rau@Oracle.COM>
parents: 1172
diff changeset
    79
      } elsif ($l =~ m{^(.*)\\$}) {  # Line continues
1172
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
    80
	$action .= $1 . " ";
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
    81
      } else {
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
    82
	$action .= $l;
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
    83
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
    84
	$action =~ s{\s+}{ }g;
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
    85
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
    86
	next if $action =~ m{^\s*$};
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
    87
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
    88
	if ($action =~ m{ path=(\S+)}) {
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
    89
	  $actions_seen{$1} = $action;
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
    90
	} else {
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
    91
	  $actions_seen{$action} = $action;
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
    92
	}
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
    93
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
    94
	return $action;
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
    95
      }
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
    96
    }
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
    97
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
    98
    return undef;
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
    99
}
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
   100
970
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   101
# Check if there is an existing manifest to merge with
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   102
if (exists $options{'input_manifest'}) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   103
  foreach my $mf (@{$options{'input_manifest'}}) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   104
    next if (! -f $mf);
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   105
    open my $INPUT_MF, '<', $mf or die "Cannot open input_manifest $mf: $!\n";
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   106
    my $action = "";
1172
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
   107
    while (my $action = next_action_seen($INPUT_MF)) {
970
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   108
	push @manifest_header, $action;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   109
    }
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   110
    close $INPUT_MF;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   111
  }
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   112
}
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   113
1172
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
   114
# Manifest listing entries not to include in manifest
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
   115
if (exists $options{'exception_manifest'}) {
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
   116
  foreach my $mf (@{$options{'exception_manifest'}}) {
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
   117
    next if (! -f $mf);
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
   118
    open my $EXCEPT_MF, '<', $mf or 
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
   119
	die "Cannot open exception_manifest $mf: $!\n";
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
   120
    while (my $action = next_action_seen($EXCEPT_MF)) {
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
   121
	# Just adding it to action_seen, nothing more to do 
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
   122
    }
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
   123
    close $EXCEPT_MF;
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
   124
  }
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
   125
}
4597acbe535f 7041659 X packages should not deliver dir actions for directories defined elsewhere
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1088
diff changeset
   126
970
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   127
# Generate a manifest header if not merging into an existing file
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   128
if (!@manifest_header) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   129
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   130
  my $manifest_license_listref = required_option_list
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   131
    ('manifest_license', 'when not merging with existing manifest.');
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   132
1339
4f152696e5f2 16167547 Update copyright & license display & metadata in X packages
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1265
diff changeset
   133
  # substitute the current year for @YEARS@ in the license template
4f152696e5f2 16167547 Update copyright & license display & metadata in X packages
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1265
diff changeset
   134
  my $current_year = strftime '%Y', localtime;
4f152696e5f2 16167547 Update copyright & license display & metadata in X packages
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1265
diff changeset
   135
970
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   136
  foreach my $lf (@{$options{'manifest_license'}}) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   137
    open my $LICENSE, '<', $lf or die "Cannot open manifest_license $lf: $!\n";
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   138
    while (my $ll = <$LICENSE>) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   139
      chomp($ll);
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   140
      if ($ll !~ m{^\#}) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   141
	$ll = '# ' . $ll;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   142
      }
1339
4f152696e5f2 16167547 Update copyright & license display & metadata in X packages
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1265
diff changeset
   143
      $ll =~ s{\@YEARS\@}{$current_year};
970
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   144
      push @manifest_header, $ll;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   145
    }
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   146
    close $LICENSE;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   147
  }
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   148
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   149
  my $pkg_name = required_option ('pkg_name',
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   150
				  'when not merging with existing manifest.');
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   151
1088
1c99106ccbe0 6983602 Xorg 1.9 integration [PSARC/2011/008]
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 970
diff changeset
   152
  my $pkg_vers = '$(PKGVERS)';
1c99106ccbe0 6983602 Xorg 1.9 integration [PSARC/2011/008]
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 970
diff changeset
   153
  if (exists $options{'version'}) {
1c99106ccbe0 6983602 Xorg 1.9 integration [PSARC/2011/008]
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 970
diff changeset
   154
    $pkg_vers = $options{'version'}->[0];
1c99106ccbe0 6983602 Xorg 1.9 integration [PSARC/2011/008]
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 970
diff changeset
   155
  }
1c99106ccbe0 6983602 Xorg 1.9 integration [PSARC/2011/008]
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 970
diff changeset
   156
970
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   157
  push @manifest_header, join('', 'set name=pkg.fmri value=pkg:/',
1088
1c99106ccbe0 6983602 Xorg 1.9 integration [PSARC/2011/008]
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 970
diff changeset
   158
			      $pkg_name, '@', $pkg_vers);
970
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   159
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   160
  push @manifest_header, 'set name=pkg.description ' .
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   161
    'value="XXX: Please provide a descriptive paragraph for the package."';
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   162
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   163
  my $pkg_summary = '';
1339
4f152696e5f2 16167547 Update copyright & license display & metadata in X packages
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1265
diff changeset
   164
  if (exists $options{'summary'}) {
4f152696e5f2 16167547 Update copyright & license display & metadata in X packages
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1265
diff changeset
   165
    $pkg_summary = $options{'summary'}->[0];
4f152696e5f2 16167547 Update copyright & license display & metadata in X packages
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1265
diff changeset
   166
  }
970
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   167
1339
4f152696e5f2 16167547 Update copyright & license display & metadata in X packages
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1265
diff changeset
   168
  if ($pkg_summary =~ m{^\s*$}) {
970
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   169
SDIR:  foreach my $sdir (@{$options{'source_dir'}}) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   170
    foreach my $bdir (glob("build-*/$sdir")) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   171
      # First try looking in a README file for a short summary
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   172
      my $rf = join('/', $bdir, 'README');
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   173
      if (open my $README, '<', $rf) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   174
	while (my $readme = <$README>) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   175
	  chomp($readme);
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   176
	  last if $readme =~ m{^[\-=\s]*$};
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   177
	  $readme =~ s{[\t\n]+}{ }g;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   178
	  if ($pkg_summary =~ m{\S$}) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   179
	    $pkg_summary .= ' ';
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   180
	  }
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   181
	  $pkg_summary .= $readme;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   182
	}
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   183
	close $README;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   184
	last SDIR if $pkg_summary ne '';
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   185
      }
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   186
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   187
      # Then try looking in man pages
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   188
      my @manpage = glob("$bdir/man/*.man");
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   189
      push @manpage, glob("$bdir/*.man");
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   190
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   191
      foreach my $manpage (@manpage) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   192
	if ($manpage && (-f $manpage)) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   193
	  my $desc;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   194
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   195
	  open(my $MANPAGE, '<', $manpage) or warn "Cannot read $manpage\n";
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   196
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   197
	  while (my $l = <$MANPAGE>) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   198
	    if ($l =~ /^.SH NAME/) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   199
	      $desc = <$MANPAGE>;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   200
	      last;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   201
	    }
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   202
	  }
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   203
	  close($MANPAGE);
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   204
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   205
	  chomp($desc);
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   206
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   207
	  # Remove backslashes, such as \- instead of -
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   208
	  $desc =~ s/\\//g;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   209
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   210
	  if ($sdir =~ /^xf86-(input|video)-(.*)-.*$/) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   211
	    $desc =~ s/driver$/driver for the Xorg X server/;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   212
	  }
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   213
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   214
	  if ($desc !~ m{^\s*$}) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   215
	    $pkg_summary = $desc;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   216
	    last SDIR;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   217
	  }
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   218
	}
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   219
      }
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   220
    }
1339
4f152696e5f2 16167547 Update copyright & license display & metadata in X packages
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 1265
diff changeset
   221
   }
970
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   222
  }
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   223
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   224
  if ($pkg_summary eq '') {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   225
    $pkg_summary =
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   226
      'XXX: Please provide a short name for the package';
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   227
  } else {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   228
    $pkg_summary =~ s{^\s+}{};
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   229
    $pkg_summary =~ s{\s+$}{};
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   230
  }
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   231
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   232
  push @manifest_header, join('', 'set name=pkg.summary ',
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   233
			      'value="', $pkg_summary, '"');
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   234
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   235
  if (exists $options{'classification'}) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   236
    my $pkg_class = $options{'classification'};
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   237
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   238
    push @manifest_header, join('', 'set name=info.classification ',
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   239
				'value="org.opensolaris.category.2008:',
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   240
				$pkg_class, '"');
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   241
  }
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   242
}
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   243
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   244
## Contents
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   245
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   246
my @manifest_contents;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   247
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   248
my $subdir64 = required_option('subdir_64',
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   249
   'with the name used for the subdirectory containing 64-bit objects');
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   250
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   251
my $proto_area_ref = required_option_list('proto_area',
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   252
					  'for files to include in manifest');
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   253
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   254
foreach my $proto_area (@{$proto_area_ref}) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   255
  my $pkgsend_cmd = join(' ', 'pkgsend', 'generate', $proto_area);
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   256
  open my $PKGSEND, '-|', $pkgsend_cmd or die "Cannot run $pkgsend_cmd: $!\n";
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   257
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   258
  while (my $ps = <$PKGSEND>) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   259
    chomp($ps);
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   260
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   261
    # Skip -uninstalled.pc files, since those are only used during build
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   262
    next if $ps =~ m{^file\b.*\bpath=.*-uninstalled.pc\b};
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   263
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   264
    # Convert 64-bit subdirectories to platform-independent form
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   265
    $ps =~ s{([=/])${subdir64}\b}{$1\$(ARCH64)}g;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   266
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   267
    # Don't add duplicates of actions we've already got
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   268
    my $action = $ps;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   269
    if ($ps =~ m{ path=(\S+)}) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   270
      $action = $1;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   271
    } else {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   272
      $action =~ s{\s+}{ }g;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   273
    }
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   274
    next if exists $actions_seen{$action};
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   275
    $actions_seen{$action} = $ps;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   276
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   277
    # Drop file path from file actions, so we always use the path attribute
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   278
    $ps =~ s{^file (\S+) (.* path=\1)}{file $2};
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   279
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   280
    # Drop attributes that will be generated during package build
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   281
    push @manifest_contents,
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   282
      join(" ", grep (! /^(mode|group|owner|pkg.size|timestamp)=/,
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   283
		      split /\s+/, $ps));
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   284
  }
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   285
  close $PKGSEND;
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   286
}
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   287
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   288
my $pkgfmt_cmd = 'pkgfmt';
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   289
if (exists $options{'pkgfmt'}) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   290
  $pkgfmt_cmd = join(' ', @{$options{'pkgfmt'}});
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   291
}
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   292
open my $PKGFMT, '|-', $pkgfmt_cmd or die "Cannot run $pkgfmt_cmd: $!\n";
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   293
foreach my $line (@manifest_header, @manifest_contents) {
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   294
  print $PKGFMT $line, "\n";
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   295
}
272328fe1b4a 6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
diff changeset
   296
close $PKGFMT;