#! /usr/bin/perl # ex:ts=8 sw=4: # $OpenBSD: Quirks.pm,v 1.3 2009/12/05 11:19:08 espie Exp $ # # Copyright (c) 2009 Marc Espie # # 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) = @_; if ($version == 1) { return OpenBSD::Quirks1->new; } else { return undef; } } package OpenBSD::Quirks1; 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" }; my $stem_extensions = { foo => 'bar' }; # ->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) { $state->say("Removing ", $handle->pkgname, " (part of base system now)"); return 1; } else { return 0; } } # ->tweak_search(\@s, $handle, $state): # tweaks the normal search for a given handle, in case (for instance) # of a stem name change. sub tweak_search { 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}); } } 1;