summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorespie <espie@openbsd.org>2004-04-28 06:50:21 +0000
committerespie <espie@openbsd.org>2004-04-28 06:50:21 +0000
commitf7e1ce99a73cb5f4b34442158ad75f97d01d4499 (patch)
treef95f922181af3714728aff851042792bf9cd6455
parentBlech, SFS yields weird mount/df shit. (diff)
downloadwireguard-openbsd-f7e1ce99a73cb5f4b34442158ad75f97d01d4499.tar.xz
wireguard-openbsd-f7e1ce99a73cb5f4b34442158ad75f97d01d4499.zip
slightly more intricate selectors code.
Approved by at least sturm@ and fries@
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackingList.pm70
1 files changed, 56 insertions, 14 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackingList.pm b/usr.sbin/pkg_add/OpenBSD/PackingList.pm
index 82e9c4a944b..1fd3740d751 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackingList.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackingList.pm
@@ -1,4 +1,4 @@
-# $OpenBSD: PackingList.pm,v 1.6 2004/02/23 21:47:48 espie Exp $
+# $OpenBSD: PackingList.pm,v 1.7 2004/04/28 06:50:21 espie Exp $
#
# Copyright (c) 2003 Marc Espie.
#
@@ -48,31 +48,73 @@ sub read
} else {
$plist = new $a;
}
+ $code = \&defaultCode if !defined $code;
+ &$code($fh,
+ sub {
+ local $_ = shift;
+ next if m/^\s*$/;
+ chomp;
+ OpenBSD::PackingElement::Factory($_, $plist);
+ });
+ return $plist;
+}
+
+sub defaultCode
+{
+ my ($fh, $cont) = @_;
+ local $_;
while (<$fh>) {
- next if m/^\s*$/;
- next if defined $code and !&$code;
- chomp;
- OpenBSD::PackingElement::Factory($_, $plist);
+ &$cont($_);
}
- return $plist;
}
-# XXX Please don't define other selectors yourself, as this is a hack
-# XXX that is bound to change in the future.
+sub DirrmOnly
+{
+ my ($fh, $cont) = @_;
+ local $_;
+ while (<$fh>) {
+ next unless m/^\@cwd/ || m/^\@dirrm/ || m/^\@name/;
+ &$cont($_);
+ }
+}
-sub OpenBSD::PackingList::DirrmOnly
+sub FilesOnly
{
- m/^\@cwd/ || m/^\@dirrm/ || m/^\@name/;
+ my ($fh, $cont) = @_;
+ local $_;
+ while (<$fh>) {
+ next unless m/^\@cwd/ || m/^\@name/ || !m/^\@/;
+ &$cont($_);
+ }
}
-sub OpenBSD::PackingList::FilesOnly
+sub ConflictOnly
{
- m/^\@cwd/ || m/^\@name/ || !m/^\@/;
+ my ($fh, $cont) = @_;
+ local $_;
+ while (<$fh>) {
+ next unless m/^\@pkgcfl/ || m/^\@option/ || m/^\@name/;
+ &$cont($_);
+ }
}
-sub OpenBSD::PackingList::ConflictOnly
+sub SharedStuffOnly
{
- m/^\@pkgcfl/ || m/^\@option/ || m/^\@name/;
+ my ($fh, $cont) = @_;
+ local $_;
+MAINLOOP:
+ while (<$fh>) {
+ if (m/^\@shared/) {
+ &$cont($_);
+ while(<$fh>) {
+ redo MAINLOOP unless m/^\@md5/ || m/^\@size/;
+ &$cont($_);
+ }
+ } else {
+ next unless m/^\@cwd/ || m/^\@dirrm/ || m/^\@name/;
+ }
+ &$cont($_);
+ }
}
sub write