diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2014-04-14 10:56:12 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2014-04-14 10:56:12 +0000 |
commit | a4a189a60038c2dd0ba4081553962b855c24692e (patch) | |
tree | c0c5600bc3fbc710b8ba16c082e2581b3f542634 /usr.sbin/pkg_add/OpenBSD | |
parent | 5dba3ff8e21227de27c29cecb33223aa5aff027e (diff) |
extract the code that walks setlist, to be able to use it in pkg_check
(waiting for theo to synch sets to commit the rest)
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/SetList.pm | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/SetList.pm b/usr.sbin/pkg_add/OpenBSD/SetList.pm new file mode 100644 index 00000000000..03292a54e4e --- /dev/null +++ b/usr.sbin/pkg_add/OpenBSD/SetList.pm @@ -0,0 +1,83 @@ +# ex:ts=8 sw=4: +# $OpenBSD: SetList.pm,v 1.1 2014/04/14 10:56:11 espie Exp $ +# +# Copyright (c) 2003-2014 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. + +# Provides an interface to the setlists of src/xenocara. +# requires a state object derived from OpenBSD::State, for printing out error +# this object should provide $state->build_tag('src', $set, $rev); +# and $state->process_entry for the actual walking. + +package OpenBSD::SetList; +use strict; +use warnings; + +my ($rev, $arch); +sub findos +{ + my $cmd = OpenBSD::Paths->uname." -mr"; + ($rev, $arch) = split(/\s+/o, `$cmd`); + chomp $arch; + $rev =~ s/\.//; +} + +sub walk +{ + my ($class, $state, $src) = @_; + findos() if !defined $arch; + my $dir = "$src/distrib/sets/lists"; + for my $set ($class->sets) { + $state->build_tag($class->base_tag, $set, $rev); + my $output = 0; + for my $f ("$dir/$set/mi", "$dir/$set/md.$arch") { + open my $l, '<', $f or next; + while (my $e = <$l>) { + chomp $e; + $e =~ s/^\.//; + $state->process_entry($e); + $output = 1; + } + } + if (!$output) { + $state->fatal("Couldn't find set #1", $set); + } + } +} + +package OpenBSD::SetList::Source; +our @ISA = qw(OpenBSD::SetList); +sub sets +{ + return (qw(base comp etc game)); +} + +sub base_tag +{ + return 'src'; +} + +package OpenBSD::SetList::Xenocara; +our @ISA = qw(OpenBSD::SetList); +sub sets +{ + return (qw(xbase xetc xfont xserv xshare)); +} + +sub base_tag +{ + return 'xenocara'; +} + +1; |