2009-12-04 11:50:48 -05:00
|
|
|
#! /usr/bin/perl
|
|
|
|
|
|
|
|
# ex:ts=8 sw=4:
|
2009-12-05 06:19:08 -05:00
|
|
|
# $OpenBSD: Quirks.pm,v 1.3 2009/12/05 11:19:08 espie Exp $
|
2009-12-04 11:50:48 -05:00
|
|
|
#
|
|
|
|
# Copyright (c) 2009 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;
|
|
|
|
use OpenBSD::PackageName;
|
|
|
|
|
|
|
|
package OpenBSD::Quirks;
|
|
|
|
|
|
|
|
sub new
|
|
|
|
{
|
|
|
|
my ($class, $version) = @_;
|
2009-12-05 06:19:08 -05:00
|
|
|
if ($version == 1) {
|
|
|
|
return OpenBSD::Quirks1->new;
|
2009-12-04 11:50:48 -05:00
|
|
|
} else {
|
|
|
|
return undef;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-05 06:19:08 -05:00
|
|
|
package OpenBSD::Quirks1;
|
2009-12-04 11:50:48 -05:00
|
|
|
use Config;
|
|
|
|
sub new
|
|
|
|
{
|
|
|
|
my $class = shift;
|
|
|
|
|
|
|
|
bless {}, $class;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# ->tweak_list(\@l, $state):
|
|
|
|
# allows Quirks to do anything to the list of packages to install,
|
|
|
|
# if something is needed. Usually, it won't do anything
|
|
|
|
sub tweak_list
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
# packages to remove
|
|
|
|
# stem => existing file hash table
|
|
|
|
# if file exists, then it's now in base and we can remove it.
|
|
|
|
|
|
|
|
my $perllib = $Config{archlib};
|
|
|
|
my $base_exceptions = {
|
|
|
|
'p5-version' => "/usr/libdata/perl5/version.pm"
|
|
|
|
};
|
|
|
|
|
2009-12-05 06:19:08 -05:00
|
|
|
my $stem_extensions = {
|
|
|
|
foo => 'bar'
|
|
|
|
};
|
|
|
|
|
2009-12-04 11:50:48 -05:00
|
|
|
# ->is_base_system($handle, $state):
|
|
|
|
# checks whether an existing handle is now part of the base system
|
|
|
|
# and thus no longer needed.
|
|
|
|
|
|
|
|
sub is_base_system
|
|
|
|
{
|
|
|
|
my ($self, $handle, $state) = @_;
|
|
|
|
my $stem = OpenBSD::PackageName::splitstem($handle->pkgname);
|
|
|
|
my $test = $base_exceptions->{$stem};
|
|
|
|
if (defined $test && -e $test) {
|
2009-12-05 05:12:58 -05:00
|
|
|
$state->say("Removing ", $handle->pkgname,
|
|
|
|
" (part of base system now)");
|
2009-12-04 11:50:48 -05:00
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-05 06:19:08 -05:00
|
|
|
# ->tweak_search(\@s, $handle, $state):
|
|
|
|
# tweaks the normal search for a given handle, in case (for instance)
|
2009-12-04 11:50:48 -05:00
|
|
|
# of a stem name change.
|
|
|
|
|
2009-12-05 06:19:08 -05:00
|
|
|
sub tweak_search
|
2009-12-04 11:50:48 -05:00
|
|
|
{
|
2009-12-05 06:19:08 -05:00
|
|
|
my ($self, $l, $handle, $state) = @_;
|
|
|
|
|
|
|
|
if (@$l != 1 || !$l->[0]->can("add_stem")) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
my $stem = OpenBSD::PackageName::splitstem($handle->pkgname);
|
|
|
|
if (defined $stem_extensions->{$stem}) {
|
|
|
|
$l->[0]->add_stem($stem_extensions->{$stem});
|
|
|
|
}
|
2009-12-04 11:50:48 -05:00
|
|
|
}
|
2009-12-05 06:19:08 -05:00
|
|
|
|
2009-12-04 11:50:48 -05:00
|
|
|
1;
|