2010-08-20 09:40:13 -04:00
|
|
|
# ex:ts=8 sw=4:
|
2013-01-20 21:01:08 -05:00
|
|
|
# $OpenBSD: PortInfo.pm,v 1.23 2013/01/21 02:01:08 espie Exp $
|
2010-08-20 09:40:13 -04:00
|
|
|
#
|
|
|
|
# Copyright (c) 2010 Marc Espie <espie@openbsd.org>
|
|
|
|
#
|
|
|
|
# Permission to use, copy, modify, and distribute this software for any
|
|
|
|
# purpose with or without fee is hereby granted, provided that the above
|
|
|
|
# copyright notice and this permission notice appear in all copies.
|
|
|
|
#
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
package AddInfo;
|
|
|
|
|
|
|
|
sub add
|
|
|
|
{
|
2010-12-06 08:20:45 -05:00
|
|
|
my ($class, $var, $o, $value, $parent) = @_;
|
2010-08-20 09:40:13 -04:00
|
|
|
return if $value =~ m/^[\s\-]*$/;
|
2010-12-06 08:20:45 -05:00
|
|
|
$o->{$var} = $class->new($value, $o, $parent);
|
2010-08-20 09:40:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
sub new
|
|
|
|
{
|
|
|
|
my ($class, $value) = @_;
|
|
|
|
bless \$value, $class;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub string
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
return $$self;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub quickie
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-09-28 06:13:51 -04:00
|
|
|
package AddIgnore;
|
|
|
|
our @ISA = qw(AddInfo);
|
|
|
|
sub string
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
my $msg = $$self;
|
|
|
|
$msg =~ s/\\//g;
|
|
|
|
$msg =~ s/\"\s+\"/\; /g;
|
|
|
|
return $msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-06-15 06:06:22 -04:00
|
|
|
package AddYesNo;
|
|
|
|
our @ISA = qw(AddInfo);
|
|
|
|
|
|
|
|
sub add
|
|
|
|
{
|
|
|
|
my ($class, $var, $o, $value, $parent) = @_;
|
|
|
|
return if $value =~ m/^no$/i;
|
|
|
|
$o->{$var} = $class->new($value, $o, $parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub new
|
|
|
|
{
|
|
|
|
my ($class, $value) = @_;
|
|
|
|
my $a = 1;
|
|
|
|
bless \$a, $class;
|
|
|
|
}
|
|
|
|
|
2012-01-14 07:26:21 -05:00
|
|
|
# micro-optimisation: to save space and time, we only create value if
|
|
|
|
# PERMIT_DISTFILES* is != yes.
|
|
|
|
|
|
|
|
package AddNegative;
|
|
|
|
our @ISA = qw(AddInfo);
|
|
|
|
|
|
|
|
sub add
|
|
|
|
{
|
|
|
|
my ($class, $var, $o, $value, $parent) = @_;
|
|
|
|
return if $value =~ m/^yes$/i;
|
|
|
|
$o->{$var} = $class->new($value, $o, $parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub new
|
|
|
|
{
|
|
|
|
my ($class, $value) = @_;
|
|
|
|
my $a = 0;
|
|
|
|
bless \$a, $class;
|
|
|
|
}
|
|
|
|
|
2010-08-20 09:40:13 -04:00
|
|
|
package AddInfoShow;
|
|
|
|
our @ISA = qw(AddInfo);
|
|
|
|
sub quickie
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
package AddList;
|
|
|
|
our @ISA = qw(AddInfo);
|
|
|
|
|
|
|
|
sub make_list
|
|
|
|
{
|
|
|
|
my ($class, $value) = @_;
|
|
|
|
$value =~ s/^\s+//;
|
|
|
|
$value =~ s/\s+$//;
|
|
|
|
return split(/\s+/, $value);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub new
|
|
|
|
{
|
|
|
|
my ($class, $value) = @_;
|
|
|
|
my %values = map {($_, 1)} $class->make_list($value);
|
|
|
|
bless \%values, $class;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub string
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
return join(', ', keys %$self);
|
|
|
|
}
|
|
|
|
|
2011-03-22 15:48:01 -04:00
|
|
|
package AddOrderedList;
|
|
|
|
our @ISA = qw(AddList);
|
|
|
|
sub new
|
|
|
|
{
|
|
|
|
my ($class, $value) = @_;
|
|
|
|
bless [$class->make_list($value)], $class;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub string
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
return join(' ', @$self);
|
|
|
|
}
|
|
|
|
|
2011-05-22 04:21:38 -04:00
|
|
|
package FetchManually;
|
|
|
|
our @ISA = qw(AddOrderedList);
|
|
|
|
sub add
|
|
|
|
{
|
|
|
|
my ($class, $var, $o, $value, $parent) = @_;
|
2011-11-13 05:28:32 -05:00
|
|
|
return if $value =~ /^\s*no\*$/i;
|
2011-05-22 04:21:38 -04:00
|
|
|
$class->SUPER::add($var, $o, $value, $parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub make_list
|
|
|
|
{
|
|
|
|
my ($class, $value) = @_;
|
|
|
|
$value =~ s/^\s*\"//;
|
|
|
|
$value =~ s/\"\s*$//;
|
|
|
|
return split(/\"\s*\"/, $value);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub string
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
return join("\n", @$self);
|
|
|
|
}
|
|
|
|
|
2010-08-20 09:40:13 -04:00
|
|
|
package AddDepends;
|
|
|
|
our @ISA = qw(AddList);
|
2011-06-15 06:06:22 -04:00
|
|
|
sub extra
|
|
|
|
{
|
|
|
|
return 'EXTRA';
|
|
|
|
}
|
|
|
|
|
2010-08-20 09:40:13 -04:00
|
|
|
sub new
|
|
|
|
{
|
2010-12-06 08:20:45 -05:00
|
|
|
my ($class, $value, $self, $parent) = @_;
|
2010-08-20 09:40:13 -04:00
|
|
|
my $r = {};
|
|
|
|
for my $_ ($class->make_list($value)) {
|
|
|
|
my $copy = $_;
|
|
|
|
next if m/^$/;
|
2010-11-14 02:44:53 -05:00
|
|
|
s/^\:+//;
|
|
|
|
s/^[^\/]*\://;
|
2010-08-20 09:40:13 -04:00
|
|
|
if (s/\:(?:patch|build|configure)$//) {
|
2011-06-15 06:06:22 -04:00
|
|
|
Extra->add($class->extra, $self, $_);
|
2010-08-20 09:40:13 -04:00
|
|
|
} else {
|
|
|
|
s/\:$//;
|
|
|
|
if (m/[:<>=]/) {
|
|
|
|
die "Error: invalid *DEPENDS $copy";
|
|
|
|
} else {
|
|
|
|
my $info = DPB::PkgPath->new($_);
|
2010-12-06 08:20:45 -05:00
|
|
|
$info->{parent} //= $parent;
|
2011-10-10 14:56:50 -04:00
|
|
|
$info->{wantbuild} = 1;
|
2010-08-20 09:40:13 -04:00
|
|
|
$r->{$info} = $info;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bless $r, $class;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub string
|
|
|
|
{
|
|
|
|
my $self = shift;
|
2011-06-02 07:53:55 -04:00
|
|
|
return '['.join(';', map {$_->logname} (values %$self)).']';
|
2010-08-20 09:40:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
sub quickie
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2011-06-15 06:06:22 -04:00
|
|
|
package AddRegressDepends;
|
|
|
|
our @ISA = qw(AddDepends);
|
|
|
|
sub extra
|
|
|
|
{
|
|
|
|
return 'EXTRA2';
|
|
|
|
}
|
|
|
|
|
2010-08-20 09:40:13 -04:00
|
|
|
package Extra;
|
|
|
|
our @ISA = qw(AddDepends);
|
|
|
|
|
|
|
|
sub add
|
|
|
|
{
|
2010-12-06 08:20:45 -05:00
|
|
|
my ($class, $key, $self, $value, $parent) = @_;
|
2010-08-20 09:40:13 -04:00
|
|
|
$self->{$key} //= bless {}, $class;
|
2010-12-07 05:56:26 -05:00
|
|
|
my $path = DPB::PkgPath->new($value);
|
2011-10-10 14:56:50 -04:00
|
|
|
$path->{wantinfo} = 1;
|
2010-12-07 05:56:26 -05:00
|
|
|
$path->{parent} //= $parent;
|
|
|
|
$self->{$key}{$path} = $path;
|
2010-08-20 09:40:13 -04:00
|
|
|
return $self;
|
|
|
|
}
|
|
|
|
|
|
|
|
package DPB::PortInfo;
|
|
|
|
my %adder = (
|
2012-10-11 04:05:03 -04:00
|
|
|
# actual info from dump-vars
|
2010-08-20 09:40:13 -04:00
|
|
|
FULLPKGNAME => "AddInfoShow",
|
|
|
|
RUN_DEPENDS => "AddDepends",
|
|
|
|
BUILD_DEPENDS => "AddDepends",
|
|
|
|
LIB_DEPENDS => "AddDepends",
|
|
|
|
SUBPACKAGE => "AddInfo",
|
2012-09-23 14:13:32 -04:00
|
|
|
BUILD_PACKAGES => "AddList",
|
|
|
|
DPB_PROPERTIES => "AddList",
|
2011-09-28 06:13:51 -04:00
|
|
|
IGNORE => "AddIgnore",
|
2011-10-03 04:53:49 -04:00
|
|
|
FLAVOR => "AddList",
|
2011-03-22 15:48:01 -04:00
|
|
|
DISTFILES => 'AddList',
|
|
|
|
PATCHFILES => 'AddList',
|
2011-05-29 07:06:23 -04:00
|
|
|
SUPDISTFILES => 'AddList',
|
2011-06-04 08:56:54 -04:00
|
|
|
DIST_SUBDIR => 'AddInfo',
|
2011-03-22 15:48:01 -04:00
|
|
|
CHECKSUM_FILE => 'AddInfo',
|
2011-05-22 04:21:38 -04:00
|
|
|
FETCH_MANUALLY => 'FetchManually',
|
2011-11-13 05:28:32 -05:00
|
|
|
MISSING_FILES => 'AddList',
|
2011-03-22 15:48:01 -04:00
|
|
|
MASTER_SITES => 'AddOrderedList',
|
|
|
|
MASTER_SITES0 => 'AddOrderedList',
|
|
|
|
MASTER_SITES1 => 'AddOrderedList',
|
|
|
|
MASTER_SITES2 => 'AddOrderedList',
|
|
|
|
MASTER_SITES3 => 'AddOrderedList',
|
|
|
|
MASTER_SITES4 => 'AddOrderedList',
|
|
|
|
MASTER_SITES5 => 'AddOrderedList',
|
|
|
|
MASTER_SITES6 => 'AddOrderedList',
|
|
|
|
MASTER_SITES7 => 'AddOrderedList',
|
|
|
|
MASTER_SITES8 => 'AddOrderedList',
|
|
|
|
MASTER_SITES9 => 'AddOrderedList',
|
2012-01-14 07:26:21 -05:00
|
|
|
PERMIT_DISTFILES_FTP => 'AddNegative',
|
|
|
|
PERMIT_DISTFILES_CDROM => 'AddNegative',
|
2012-10-11 04:05:03 -04:00
|
|
|
# not yet used, provision for regression
|
|
|
|
REGRESS_DEPENDS => "AddRegressDepends",
|
|
|
|
NO_REGRESS => "AddYesNo",
|
|
|
|
REGRESS_IS_INTERACTIVE => "AddYesNo",
|
|
|
|
# extra stuff we're generating
|
|
|
|
DEPENDS => "AddDepends", # all BUILD_DEPENDS/LIB_DEPENDS
|
|
|
|
EXTRA => "Extra", # extract stuff and things in DEPENDS
|
|
|
|
EXTRA2 => "Extra", # extract stuff and things in REGRESS_DEPENDS
|
|
|
|
BEXTRA => "Extra", # EXTRA moved from todo to done
|
|
|
|
BDEPENDS => "AddDepends",# DEPENDS moved from todo to done
|
|
|
|
RDEPENDS => "AddDepends",# RUN_DEPENDS moved from todo to done
|
|
|
|
DIST => "AddDepends", # all DISTFILES with all info
|
|
|
|
FDEPENDS => "AddDepends",# DISTFILES too, but after DISTIGNORE,
|
|
|
|
# and shrinking
|
|
|
|
# DISTIGNORE should be there ?
|
2010-08-20 09:40:13 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
sub wanted
|
|
|
|
{
|
|
|
|
my ($class, $var) = @_;
|
|
|
|
return $adder{$var};
|
|
|
|
}
|
|
|
|
|
|
|
|
sub new
|
|
|
|
{
|
|
|
|
my ($class, $pkgpath) = @_;
|
2010-12-07 05:56:26 -05:00
|
|
|
$pkgpath->{info} = bless {}, $class;
|
2010-08-20 09:40:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
sub add
|
|
|
|
{
|
2010-12-06 08:20:45 -05:00
|
|
|
my ($self, $var, $value, $parent) = @_;
|
|
|
|
$adder{$var}->add($var, $self, $value, $parent);
|
2010-08-20 09:40:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
sub dump
|
|
|
|
{
|
|
|
|
my ($self, $fh) = @_;
|
|
|
|
for my $k (sort keys %adder) {
|
|
|
|
print $fh "\t $k = ", $self->{$k}->string, "\n"
|
|
|
|
if defined $self->{$k};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-05 14:27:13 -04:00
|
|
|
my $string = "ignored already";
|
|
|
|
my $s2 = "stub name";
|
|
|
|
my $stub_info = bless { IGNORE => bless(\$string, "AddIgnore"),
|
|
|
|
FULLPKGNAME => bless(\$s2, "AddInfoShow")}, __PACKAGE__;
|
|
|
|
|
|
|
|
sub stub
|
|
|
|
{
|
|
|
|
return $stub_info;
|
|
|
|
}
|
|
|
|
|
2010-08-20 09:40:13 -04:00
|
|
|
use Data::Dumper;
|
|
|
|
sub quick_dump
|
|
|
|
{
|
|
|
|
my ($self, $fh) = @_;
|
|
|
|
for my $k (sort keys %adder) {
|
|
|
|
if (defined $self->{$k} and $adder{$k}->quickie) {
|
|
|
|
print $fh "\t $k = ";
|
|
|
|
if (ref($self->{$k}) eq 'HASH') {
|
|
|
|
print $fh "????\n";
|
|
|
|
} else {
|
|
|
|
print $fh $self->{$k}->string, "\n" ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub fullpkgname
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
return (defined $self->{FULLPKGNAME}) ?
|
|
|
|
$self->{FULLPKGNAME}->string : undef;
|
|
|
|
}
|
|
|
|
|
2013-01-10 05:26:34 -05:00
|
|
|
sub has_property
|
|
|
|
{
|
|
|
|
my ($self, $name) = @_;
|
|
|
|
return defined $self->{DPB_PROPERTIES} &&
|
|
|
|
$self->{DPB_PROPERTIES}{$name};
|
|
|
|
}
|
|
|
|
|
2013-01-20 21:01:08 -05:00
|
|
|
sub solve_depends
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
if (!defined $self->{solved}) {
|
|
|
|
my $dep = {};
|
|
|
|
for my $k (qw(DEPENDS BDEPENDS)) {
|
|
|
|
|
|
|
|
if (exists $self->{$k}) {
|
|
|
|
for my $d (values %{$self->{$k}}) {
|
|
|
|
$dep->{$d->fullpkgname} = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
next unless exists $self->{BEXTRA};
|
|
|
|
for my $two (values %{$self->{BEXTRA}}) {
|
|
|
|
next unless exists $two->{info}{$k};
|
|
|
|
for my $d (values %{$two->{info}{$k}}) {
|
|
|
|
$dep->{$d->fullpkgname} = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bless $dep, 'AddList';
|
|
|
|
$self->{solved} = $dep;
|
|
|
|
}
|
|
|
|
return $self->{solved};
|
|
|
|
}
|
|
|
|
|
2010-08-20 09:40:13 -04:00
|
|
|
1;
|