fatal messages.
zap $opt_x from pkg_mklocated, do things like other commands do.
# ex:ts=8 sw=4:
-# $OpenBSD: ArcCheck.pm,v 1.17 2010/06/30 10:51:04 espie Exp $
+# $OpenBSD: ArcCheck.pm,v 1.18 2010/07/28 12:19:54 espie Exp $
#
# Copyright (c) 2005-2006 Marc Espie <espie@openbsd.org>
#
if (!defined $item->{owner} && !$o->isSymLink) {
if ($o->{uname} ne 'root' && $o->{uname} ne 'bin') {
- print STDERR "Error: no \@owner for ",
- $item->fullname, " (", $o->{uname}, ")\n";
+ $o->errsay("Error: no \@owner for #1 (#2)",
+ $item->fullname, $o->{uname});
$result = 0;
}
}
if (!defined $item->{group} && !$o->isSymLink) {
if ($o->{gname} ne 'bin' && $o->{gname} ne 'wheel') {
if (($o->{mode} & (S_ISUID | S_ISGID | S_IWGRP)) != 0) {
- print STDERR "Error: no \@group for ",
- $item->fullname, " (", $o->{uname},
- "), which has mode ",
- sprintf("%4o", $o->{mode} & (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID)), "\n";
+ $o->errsay("Error: no \@group for #1 (#2), which has mode #3",
+ $item->fullname, $o->{uname},
+ sprintf("%4o", $o->{mode} & (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID)));
$result = 0;
} else {
- print STDERR "Warning: no \@group for ",
- $item->fullname, " (", $o->{gname}, ")\n";
+ $o->errsay("Warning: no \@group for #1 (#2)",
+ $item->fullname, $o->{gname});
}
}
}
if (!defined $item->{mode} && $o->isFile) {
if (($o->{mode} & (S_ISUID | S_ISGID | S_IWOTH)) != 0) {
- print STDERR "Error: weird mode for ",
- $item->fullname, ": ",
- sprintf("%4o", $o->{mode} & (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID)), "\n";
+ $o->errsay("Error: weird mode for #1: #2",
+ $item->fullname,
+ sprintf("%4o", $o->{mode} & (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID)));
$result = 0;
}
}
my $filename = $item->name;
my $entry = $self->prepare($filename);
if (!defined $entry->{uname}) {
- die "No user name for ", $entry->name, " (uid ", $entry->{uid}, ")";
+ $self->fatal("No user name for #1 (uid #2)",
+ $entry->name, $entry->{uid});
}
if (!defined $entry->{gname}) {
- die "No group name for ", $entry->name, " (gid ", $entry->{gid}. ")";
+ $self->fatal("No group name for #1 (uid #2)",
+ $entry->name, $entry->{gid});
}
my ($prefix, $name) = split_name($entry->name);
if (length($name) > MAXFILENAME || length($prefix) > MAXPREFIX) {
# ex:ts=8 sw=4:
-# $OpenBSD: PackageLocation.pm,v 1.22 2010/06/30 10:51:04 espie Exp $
+# $OpenBSD: PackageLocation.pm,v 1.23 2010/07/28 12:19:54 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
{
my ($class, $repository, $name, $arch) = @_;
- my $self = { repository => $repository, name => $repository->canonicalize($name)};
+ my $self = { repository => $repository, name => $repository->canonicalize($name), state => $repository->{state} };
if (defined $arch) {
$self->{arch} = $arch;
}
return;
}
require OpenBSD::Ustar;
- my $archive = new OpenBSD::Ustar $fh;
+ my $archive = OpenBSD::Ustar->new($fh, $self->{state});
$self->{_archive} = $archive;
if (defined $self->{_current}) {
#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: PkgCreate.pm,v 1.21 2010/07/09 12:42:43 espie Exp $
+# $OpenBSD: PkgCreate.pm,v 1.22 2010/07/28 12:19:54 espie Exp $
#
# Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org>
#
sub create_archive
{
- my ($self, $filename, $dir) = @_;
+ my ($self, $state, $filename, $dir) = @_;
open(my $fh, "|-", OpenBSD::Paths->gzip, "-f", "-o", $filename);
- return OpenBSD::Ustar->new($fh, $dir);
+ return OpenBSD::Ustar->new($fh, $state, $dir);
}
sub sign_existing_package
$self->add_signature($plist, $cert, $privkey);
$plist->save;
my $tmp = OpenBSD::Temp::permanent_file(".", "pkg");
- my $wrarc = $self->create_archive($tmp, ".");
+ my $wrarc = $self->create_archive($state, $tmp, ".");
$plist->copy_over($wrarc, $true_package);
$wrarc->close;
$true_package->wipe_info;
local $SIG{'HUP'} = $h;
local $SIG{'KILL'} = $h;
local $SIG{'TERM'} = $h;
- $state->{archive} = $self->create_archive($wname, $plist->infodir);
+ $state->{archive} = $self->create_archive($state, $wname,
+ $plist->infodir);
$state->set_status("archiving");
$state->progress->visit_with_size($plist, 'create_package', $state);
$state->end_status;
}
if ($state->opt('n')) {
- $state->{archive} = OpenBSD::Ustar->new(undef, $plist->infodir);
+ $state->{archive} = OpenBSD::Ustar->new(undef, $state,
+ $plist->infodir);
$plist->pretend_to_archive($state);
} else {
$self->create_package($state, $plist, $wname);
# ex:ts=8 sw=4:
-# $OpenBSD: Ustar.pm,v 1.60 2010/07/04 19:34:47 espie Exp $
+# $OpenBSD: Ustar.pm,v 1.61 2010/07/28 12:19:54 espie Exp $
#
# Copyright (c) 2002-2007 Marc Espie <espie@openbsd.org>
#
sub new
{
- my ($class, $fh, $destdir) = @_;
+ my ($class, $fh, $state, $destdir) = @_;
$destdir = '' unless defined $destdir;
return bless {
fh => $fh,
swallow => 0,
+ state => $state,
key => {},
destdir => $destdir} , $class;
}
+sub fatal
+{
+ my ($self, $msg, @args) = $_;
+ $self->{state}->fatal("Ustar: $msg", @args);
+}
sub new_object
{
}
my $actual = read($self->{fh}, $temp, $toread);
if (!defined $actual) {
- die "Error while skipping archive: $!";
+ $self->fatal("Error while skipping archive: #1", $!);
}
if ($actual == 0) {
- die "Premature end of archive in header: $!";
+ $self->fatal("Premature end of archive in header: #1", $!);
}
$self->{swallow} -= $actual;
}
my $header;
my $n = read $self->{fh}, $header, 512;
return if (defined $n) and $n == 0;
- die "Error while reading header"
+ $self->fatal("Error while reading header")
unless defined $n and $n == 512;
if ($header eq "\0"x512) {
return $self->next;
$linkname, $magic, $version, $uname, $gname, $major, $minor,
$prefix, $pad) = unpack(USTAR_HEADER, $header);
if ($magic ne "ustar\0" || $version ne '00') {
- die "Not an ustar archive header";
+ $self->fatal("Not an ustar archive header");
}
# verify checksum
my $value = $header;
substr($value, 148, 8) = " "x8;
my $ck2 = unpack("%C*", $value);
if ($ck2 != oct($chksum)) {
- die "Bad archive checksum";
+ $self->fatal("Bad archive checksum");
}
$name =~ s/\0*$//o;
$mode = oct($mode) & 0xfff;
if (defined $types->{$type}) {
$types->{$type}->new($result);
} else {
- die "Unsupported type $type";
+ $self->fatal("Unsupported type #1", $type);
}
# adjust swallow
$self->{swallow} = $size;
$linkname = '';
}
if (length $prefix > MAXPREFIX) {
- die "Prefix too long $prefix";
+ $archive->fatal("Prefix too long #1", $prefix);
}
if (length $name > MAXFILENAME) {
- die "Name too long $name";
+ $archive->fatal("Name too long #1", $name);
}
if (length $linkname > MAXLINKNAME) {
- die "Linkname too long $linkname";
+ $archive->fatal("Linkname too long #1", $linkname);
}
if (length $uname > MAXUSERNAME) {
- die "Username too long $uname";
+ $archive->fatal("Username too long #1", $uname);
}
if (length $gname > MAXGROUPNAME) {
- die "Groupname too long $gname";
+ $archive->fatal("Groupname too long #1", $gname);
}
my $header;
my $cksum = ' 'x8;
sub pad
{
- my $fh = $_[0]->{fh};
- print $fh "\0"x1024 or die "Error writing to archive: $!";
+ my $self = shift;
+ my $fh = $self->{fh};
+ print $fh "\0"x1024 or $self->fatal("Error writing to archive: #1", $!);
}
sub close
{
my ($class, $object) = @_;
+ bless $object, $class;
if ($object->{size} != 0) {
- die "Bad archive: non null size for arbitrary entry";
+ $object->fatal("Bad archive: non null size for #1",
+ $class );
}
- bless $object, $class;
+ return $object;
}
+sub fatal
+{
+ my ($self, @args) = @_;
+ $self->{archive}->fatal(@args);
+}
+
+sub errsay
+{
+ my ($self, @args) = @_;
+ $self->{archive}->{state}->errsay(@args);
+}
sub todo
{
my ($self, $toread) = @_;
$arc->{padout} = 1;
my $header = $arc->mkheader($self, $self->type);
- print $out $header or die "Error writing to archive: $!";
+ print $out $header or $self->fatal("Error writing to archive: #1", $!);
$self->write_contents($arc);
my $k = $self->{key};
if (!defined $arc->{key}->{$k}) {
$self->resolve_links($wrarc);
$wrarc->{padout} = 1;
my $header = $wrarc->mkheader($self, $self->type);
- print $out $header or die "Error writing to archive: $!";
+ print $out $header or $self->fatal("Error writing to archive: #1", $!);
$self->copy_contents($wrarc);
}
$linkname=$self->{cwd}.'/'.$linkname;
}
link $self->{destdir}.$linkname, $self->{destdir}.$self->name or
- die "Can't link $self->{destdir}$linkname to $self->{destdir}",
- $self->name, ": $!";
+ $self->fatal("Can't link #1#2 to #1#3: #4",
+ $self->{destdir}, $linkname, $self->name, $!);
}
sub resolve_links
$self->{linkname} = $arc->{key}->{$k};
} else {
print join("\n", keys(%{$arc->{key}})), "\n";
- die "Can't copy link over: original for $k NOT available";
+ $self->fatal("Can't copy link over: original for #1 NOT available", $k);
}
}
my $self = shift;
$self->make_basedir($self->name);
symlink $self->{linkname}, $self->{destdir}.$self->name or
- die "Can't symlink $self->{linkname} to $self->{destdir}",
- $self->name, ": $!";
+ $self->fatal("Can't symlink #1 to #2#3: #4",
+ $self->{linkname}, $self->{destdir}, $self->name, $!);
}
sub isLink() { 1 }
$self->make_basedir($self->name);
require POSIX;
POSIX::mkfifo($self->{destdir}.$self->name, $self->{mode}) or
- die "Can't create fifo ", $self->name,": $!";
+ $self->fatal("Can't create fifo #1: #2", $self->name, $!);
$self->set_modes;
}
my $buffer;
my $out = OpenBSD::CompactWriter->new($self->{destdir}.$self->name);
if (!defined $out) {
- die "Can't write to $self->{destdir}", $self->name, ": $!";
+ $self->fatal("Can't write to #1#2: #3", $self->{destdir},
+ $self->name, $!);
}
my $toread = $self->{size};
while ($toread > 0) {
$maxread = $toread if $maxread > $toread;
my $actual = read($self->{archive}->{fh}, $buffer, $maxread);
if (!defined $actual) {
- die "Error reading from archive: $!";
+ $self->fatal("Error reading from archive: #1", $!);
}
if ($actual == 0) {
- die "Premature end of archive";
+ $self->fatal("Premature end of archive");
}
$self->{archive}->{swallow} -= $actual;
unless ($out->write($buffer)) {
- die "Error writing to $self->{destdir}", $self->name,
- ": $!";
+ $self->fatal("Error writing to #1#2: #3",
+ $self->{destdir}, $self->name, $!);
}
$toread -= $actual;
$self->todo($toread);
}
- $out->close or die "Error closing $self->{destdir}", $self->name,
- ": $!";
+ $out->close or $self->fatal("Error closing #1#2: #3",
+ $self->{destdir}, $self->name, $!);
$self->set_modes;
}
my $actual = read($self->{archive}->{fh}, $buffer, $toread);
if (!defined $actual) {
- die "Error reading from archive: $!";
+ $self->fatal("Error reading from archive: #1", $!);
}
if ($actual != $toread) {
- die "Error: short read from archive";
+ $self->fatal("Error: short read from archive");
}
$self->{archive}->{swallow} -= $actual;
return $buffer;
my $filename = $self->{realname};
my $size = $self->{size};
my $out = $arc->{fh};
- open my $fh, "<", $filename or die "Can't read file $filename: $!";
+ open my $fh, "<", $filename or $self->fatal("Can't read file #1: #2",
+ $filename, $!);
my $buffer;
my $toread = $size;
$maxread = $toread if $maxread > $toread;
my $actual = read($fh, $buffer, $maxread);
if (!defined $actual) {
- die "Error reading from file: $!";
+ $self->fatal("Error reading from file: #1", $!);
}
if ($actual == 0) {
- die "Premature end of file";
+ $self->fatal("Premature end of file");
}
unless (print $out $buffer) {
- die "Error writing to archive: $!";
+ $self->fatal("Error writing to archive: #1", $!);
}
$toread -= $actual;
}
if ($size % 512) {
print $out "\0" x (512 - $size % 512) or
- die "Error writing to archive: $!";
+ $self->fatal("Error writing to archive: #1", $!);
}
}
$maxread = $toread if $maxread > $toread;
my $actual = read($self->{archive}->{fh}, $buffer, $maxread);
if (!defined $actual) {
- die "Error reading from archive: $!";
+ $self->fatal("Error reading from archive: #1", $!);
}
if ($actual == 0) {
- die "Premature end of archive";
+ $self->fatal("Premature end of archive");
}
$self->{archive}->{swallow} -= $actual;
unless (print $out $buffer) {
- die "Error writing to archive $!";
+ $self->fatal("Error writing to archive #1", $!);
}
$toread -= $actual;
}
if ($size % 512) {
print $out "\0" x (512 - $size % 512) or
- die "Error writing to archive: $!";
+ $self->fatal("Error writing to archive: #1", $!);
}
$self->alias($arc, $self->name);
}
#! /usr/bin/perl
# Copyright (c) 2005-2007 Marc Espie <espie@openbsd.org>
-# $OpenBSD: pkg_merge,v 1.20 2010/07/04 19:34:06 espie Exp $
+# $OpenBSD: pkg_merge,v 1.21 2010/07/28 12:19:54 espie Exp $
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
my $allprefix = '';
open(my $outfh, "|-", OpenBSD::Paths->gzip, "-o", $out);
-my $wrarc = OpenBSD::Ustar->new($outfh, ".");
+my $wrarc = OpenBSD::Ustar->new($outfh, $ui, ".");
for my $pkgname (@ARGV) {
my $true_package = $ui->repo->find($pkgname);
$ui->fatal("No such package #1", $pkgname) unless $true_package;
#! /usr/bin/perl
# Copyright (c) 2005-2010 Marc Espie <espie@openbsd.org>
-# $OpenBSD: pkg_mklocatedb,v 1.28 2010/06/30 11:33:57 espie Exp $
+# $OpenBSD: pkg_mklocatedb,v 1.29 2010/07/28 12:19:54 espie Exp $
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
use OpenBSD::AddCreateDelete;
use File::Path;
+package OpenBSD::Pkgmklocatedb::State;
+our @ISA = qw(OpenBSD::AddCreateDelete::State);
+
+sub handle_options
+{
+ my $state = shift;
+ $state->{no_exports} = 1;
+ $state->SUPER::handle_options('ad:nqs:x:r:p:P',
+ '[-anPq] [-d repository] [-p portsdir] [-r release] [-s src] ',
+ '[-x X11src] [pkg-name [...]]');
+ $state->{srcdir} = $state->opt('s');
+ $state->{xdir} = $state->opt('x');
+ $state->{releasedir} = $state->opt('r');
+ $state->{portsdir} = $state->opt('p');
+ $state->{pkgdir} = $state->opt('d');
+ $state->{quiet} = $state->opt('q');
+ $state->{pkgpath} = $state->opt('P');
+ $state->{allinfo} = $state->opt('a');
+ $state->{nopipe} = $state->opt('n');
+}
+
+
package OpenBSD::PackingElement;
sub print_name {}
-package OpenBSD::PackingElement::FileObject;
+package OpenBSD::PackingElement::Name;
sub print_name
{
- my ($self, $fh, $pkgname) = @_;
- print $fh $pkgname, ":", $self->fullname, "\n";
+ my ($self, $state) = @_;
+ $state->{currentheader} = $self->{name}.':';
}
-package main;
-
-our ($opt_a, $opt_n, $opt_q, $opt_s, $opt_x, $opt_r, $opt_p, $opt_P, $opt_d);
-
-sub info
+package OpenBSD::PackingElement::ExtraInfo;
+sub print_name
{
- my $plist = shift;
- my $r;
- if ($opt_a) {
- $r = $plist->fullpkgpath.":".$plist->pkgname;
- } elsif ($opt_P) {
- $r = $plist->fullpkgpath;
- } else {
- $r = $plist->pkgname;
+ my ($self, $state) = @_;
+ if ($state->{allinfo}) {
+ $state->{currentheader} .= $self->{subdir}.':';
+ } elsif ($state->{pkgpath}) {
+ $state->{currentheader} = $self->{subdir}.':';
}
- print STDERR "$r\n" unless $opt_q;
- return $r;
+ $state->errsay($state->{currentheader}) unless $state->{quiet};
}
+package OpenBSD::PackingElement::FileObject;
+sub print_name
+{
+ my ($self, $state) = @_;
+ print {$state->{out}} $state->{currentheader}, $self->fullname, "\n";
+}
+
+package main;
+
sub tag
{
- my ($dir, $set, $rev) = @_;
+ my ($state, $dir, $set, $rev) = @_;
my $r;
- if ($opt_a) {
+ if ($state->{allinfo}) {
$r = "$dir/$set:$set$rev";
- } elsif ($opt_P) {
+ } elsif ($state->{pkgpath}) {
$r = "$dir/$set";
} else {
$r = "$set$rev";
}
- print STDERR "$r\n" unless $opt_q;
+ $state->errsay($r) unless $state->{quiet};
return $r;
}
-my $state = OpenBSD::AddCreateDelete::State->new("pkg_mklocatedb");
-$state->handle_options('ad:nqs:x:r:p:P',
- '[-anPq] [-d repository] [-p portsdir] [-r release] [-s src] ',
- '[-x X11src] [pkg-name [...]]');
-
-my $fh;
-my $MKLOCATEDB = OpenBSD::Paths->mklocatedb;
-
-if ($opt_n or -t STDOUT) {
- $fh = \*STDOUT;
-} else {
- open $fh, "|-", $MKLOCATEDB, $MKLOCATEDB or
- $state->fatal("couldn't open pipe: #1", $!);
-}
-if ($opt_s || $opt_x) {
+my ($rev, $arch);
+sub findos
+{
my $cmd = OpenBSD::Paths->uname." -mr";
- my ($rev, $arch) = split(/\s+/o, `$cmd`);
+ ($rev, $arch) = split(/\s+/o, `$cmd`);
chomp $arch;
$rev =~ s/\.//;
- if ($opt_s) {
- my $dir = "$opt_s/distrib/sets/lists";
- for my $set (qw(base comp etc game man misc)) {
- my $tag = tag('src', $set, $rev);
- for my $f ("$dir/$set/mi", "$dir/$set/md.$arch") {
- open my $l, '<', $f or next;
- while (my $e = <$l>) {
- chomp $e;
- $e =~ s/^\.//;
- print $fh "$tag:$e\n";
- }
- }
- }
+}
+
+sub open_output
+{
+ my $state = shift;
+
+
+ if ($state->{nopipe} or -t STDOUT) {
+ $state->{out} = \*STDOUT;
+ } else {
+ my $MKLOCATEDB = OpenBSD::Paths->mklocatedb;
+
+ open $state->{out}, "|-", $MKLOCATEDB, $MKLOCATEDB or
+ $state->fatal("couldn't open pipe to mklocatedb: #1", $!);
}
- if ($opt_x) {
- my $dir = "$opt_x/distrib/sets/lists";
- for my $set (qw(xbase xetc xfont xserv xshare)) {
- my $tag = tag('XF4', $set, $rev);
- for my $f ("$dir/$set/mi", "$dir/$set/md.$arch") {
- open my $l, '<', $f or next;
- while (my $e = <$l>) {
- chomp $e;
- $e =~ s/^\.//;
- print $fh "$tag:$e\n";
- }
+}
+
+sub do_src
+{
+ my ($state, $src, $tag, @sets) = @_;
+ findos() if !defined $arch;
+ my $dir = "$src/distrib/sets/lists";
+ for my $set (@sets) {
+ my $tag = tag($state, $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/^\.//;
+ print {$state->{out}} "$tag:$e\n";
+ $output = 1;
}
}
+ if (!$output) {
+ $state->fatal("Couldn't find set #1", $set);
+ }
}
}
-if ($opt_r) {
+sub do_release
+{
+ my $state = shift;
+
require OpenBSD::Ustar;
- opendir(my $dir, $opt_r) or next;
+ opendir(my $dir, $state->{releasedir}) or return;
while (my $e = readdir $dir) {
if ($e =~ m/^(\w+\d\d)\.tgz$/o) {
my $set = $1;
- open my $arc, '-|', OpenBSD::Paths->gzip, '-c', '-d', "--", "$opt_r/$e";
- my $u = OpenBSD::Ustar->new($arc, '/');
+ open my $arc, '-|', OpenBSD::Paths->gzip, '-c', '-d',
+ "--", $state->{releasedir}."/".$e or
+ $state->fatal("couldn't open pipe from gzip: #1", $!);
+
+ my $u = OpenBSD::Ustar->new($arc, $state, '/');
while (my $f = $u->next) {
my $name = $f->{name};
$name =~ s/^\.//o;
- print $fh "$set:$name\n";
+ print {$state->{out}} "$set:$name\n";
}
close $arc;
}
closedir($dir);
}
-if ($opt_p) {
+sub do_portsdir
+{
+ my $state = shift;
my $make = $ENV{MAKE} || 'make';
- open my $in, "cd $opt_p && $make print-plist-all |";
+ open my $in, "cd $state->{portsdir} && $make print-plist-all |";
my $done = 0;
while (!$done) {
my $plist = OpenBSD::PackingList->read($in,
$done = 1;
});
if (defined $plist && defined $plist->pkgname) {
- $plist->print_name($fh, info($plist));
+ $plist->print_name($state);
}
}
close($in);
}
-elsif ($opt_d) {
+sub do_pkgdir
+{
+ my $state = shift;
+
require File::Find;
no warnings qw(once);
- $state->fatal("Bad argument: #1 is not a directory", $opt_d)
- unless -d $opt_d;
+ $state->fatal("Bad argument: #1 is not a directory", $state->{pkgdir})
+ unless -d $state->{pkgdir};
File::Find::find(
- sub {
- return unless -f $_;
- my $plist = $state->repo->grabPlist($File::Find::name);
- return unless defined $plist;
- $plist->print_name($fh, info($plist));
- }, $opt_d);
+ sub {
+ return unless -f $_;
+ my $plist = $state->repo->grabPlist($File::Find::name);
+ return unless defined $plist;
+ $plist->print_name($state);
+ }, $state->{pkgdir});
+}
+
+my $state = OpenBSD::Pkgmklocatedb::State->new("pkg_mklocatedb");
+$state->handle_options;
+
+open_output($state);
+
+if ($state->{srcdir}) {
+ do_source($state, $state->{srcdir}, 'src',
+ qw(base comp etc game misc));
+}
+if ($state->{xdir}) {
+ do_source($state, $state->{xdir}, 'xenocara',
+ qw(xbase xetc xfont xserv xshare));
+}
+if ($state->{releasedir}) {
+ do_release($state);
+}
+
+if ($state->{portsdir}) {
+ do_portsdir($state);
+} elsif ($state->{pkgdir}) {
+ do_pkgdir($state);
} elsif (@ARGV == 0) {
$state->progress->for_list("Scanning installation",
[installed_packages()], sub {
my $pkgname = shift;
my $plist = OpenBSD::PackingList->from_installation($pkgname);
return unless defined $plist;
- $plist->print_name($fh, info($plist));
+ $plist->print_name($state);
});
} else {
$state->progress->for_list("Scanning packages", \@ARGV,
my $pkgname = shift;
my $plist = $state->repo->grabPlist($pkgname);
next unless $plist;
- $plist->print_name($fh, info($plist));
+ $plist->print_name($state);
});
}
-$OpenBSD: OpenBSD::Ustar.pod,v 1.14 2010/06/30 10:51:04 espie Exp $
+$OpenBSD: OpenBSD::Ustar.pod,v 1.15 2010/07/28 12:19:54 espie Exp $
=head1 NAME
# for reading
open(my $in, "<", $arcnameforreading) or die;
- $rdarc = OpenBSD::Ustar->new($in, $destdir);
+ $rdarc = OpenBSD::Ustar->new($in, $state, $destdir);
while (my $o = $rdarc->next) {
# decide whether we want to extract it, change object attributes
$o->create;
# for writing
open(my $out, ">", $arcnameforwriting) or die;
- $wrarc = OpenBSD::Ustar->new($fh, $destdir);
+ $wrarc = OpenBSD::Ustar->new($fh, $state, $destdir);
# loop
my $o = $wrarc->prepare($filename);
# tweak some entry parameters
# for copying
open(my $in, "<", $arcnameforreading) or die;
- $rdarc = OpenBSD::Ustar->new($in, $destdir);
+ $rdarc = OpenBSD::Ustar->new($in, $state, $destdir);
open(my $out, ">", $arcnameforwriting) or die;
- $wrarc = OpenBSD::Ustar->new($fh, $destdir);
+ $wrarc = OpenBSD::Ustar->new($fh, $state, $destdir);
while (my $o = $rdarc->next) {
$o->copy($wrarc);
}
to be usable on pipe outputs. For archive writing, the filehandle should
support C<print>.
+Error messages and fatal errors will be handled through the C<$state> object,
+which should conform to C<OpenBSD::State(3p)> (uses C<errsay> and C<fatal>).
+
Note that read and write support are mutually exclusive, though there is
no need to specify the mode used at creation time; it is implicitly
provided by the underlying filehandle.