# ex:ts=8 sw=4:
-# $OpenBSD: Add.pm,v 1.141 2014/01/11 11:51:01 espie Exp $
+# $OpenBSD: Add.pm,v 1.142 2014/01/11 11:54:43 espie Exp $
#
# Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org>
#
{
my ($handle, $state) = @_;
- $state->{archive} = $handle->{location};
- $handle->{partial} //= {};
- $state->{partial} = $handle->{partial};
$state->progress->visit_with_size($handle->{plist}, 'install', $state);
$handle->{location}->finish_and_close;
}
+sub perform_extraction
+{
+ my ($handle, $state) = @_;
+
+ $handle->{partial} = {};
+ $state->{partial} = $handle->{partial};
+ $state->{archive} = $handle->{location};
+ $state->progress->visit_with_size($handle->{plist}, 'extract', $state);
+}
+
my $user_tagged = {};
sub extract_pkgname
{
}
-sub install
+sub extract
{
my ($self, $state) = @_;
+ $state->{partial}->{$self} = 1;
if ($state->{interrupted}) {
die "Interrupted";
}
+}
+
+sub install
+{
+ my ($self, $state) = @_;
$state->{partial}->{$self} = 1;
+ if ($state->{interrupted}) {
+ die "Interrupted";
+ }
}
sub copy_info
use OpenBSD::Error;
use File::Basename;
use File::Path;
+use OpenBSD::Temp;
sub prepare_for_addition
{
}
}
-sub install
-{
- my ($self, $state) = @_;
- $self->SUPER::install($state);
- my $fullname = $self->fullname;
- my $destdir = $state->{destdir};
- if ($fullname =~ m,^$state->{localbase}/share/doc/pkg-readmes/,) {
- $state->{readmes}++;
- }
-
- if ($state->{extracted_first}) {
- if ($state->{not}) {
- $state->say("moving tempfile -> #1",
- $destdir.$fullname) if $state->verbose >= 5;
- return;
- }
- File::Path::mkpath(dirname($destdir.$fullname));
- if (defined $self->{link}) {
- link($destdir.$self->{link}, $destdir.$fullname);
- } elsif (defined $self->{symlink}) {
- symlink($self->{symlink}, $destdir.$fullname);
- } else {
- rename($self->{tempname}, $destdir.$fullname) or
- $state->fatal("can't move #1 to #2: #3",
- $self->{tempname}, $fullname, $!);
- $state->say("moving #1 -> #2",
- $self->{tempname}, $destdir.$fullname)
- if $state->verbose >= 5;
- undef $self->{tempname};
- }
- } else {
- my $file = $self->prepare_to_extract($state);
- $state->say("extracting #1", $destdir.$fullname)
- if $state->verbose >= 5;
- if ($state->{not}) {
- $state->{archive}->skip;
- return;
- } else {
- $file->create;
- $self->may_check_digest($file, $state);
-
- }
- }
- $self->set_modes($state, $destdir.$fullname);
-}
-
sub prepare_to_extract
{
my ($self, $state) = @_;
return $file;
}
+sub extract
+{
+ my ($self, $state) = @_;
+
+ my $file = $self->prepare_to_extract($state);
+
+ if (defined $self->{link} || defined $self->{symlink}) {
+ $state->{archive}->skip;
+ return;
+ }
+
+ $self->SUPER::extract($state);
+
+ # figure out a safe directory where to put the temp file
+ my $d = dirname($file->{destdir}.$file->name);
+ # we go back up until we find an existing directory.
+ # hopefully this will be on the same file system.
+ while (!-d $d && -e _ || defined $state->{noshadow}->{$d}) {
+ $d = dirname($d);
+ }
+ if ($state->{not}) {
+ $state->say("extracting tempfile under #1", $d)
+ if $state->verbose >= 3;
+ $state->{archive}->skip;
+ } else {
+ if (!-e _) {
+ File::Path::mkpath($d);
+ }
+ my ($fh, $tempname) = OpenBSD::Temp::permanent_file($d, "pkg");
+ $self->{tempname} = $tempname;
+
+ # XXX don't apply destdir twice
+ $file->{destdir} = '';
+ $file->set_name($tempname);
+
+ if ($self->{tieto}) {
+ my $src = $self->{tieto}->realname($state);
+ unlink($tempname);
+ $state->say("linking #1 to #2", $src, $tempname)
+ if $state->verbose >= 3;
+ if (link($src, $tempname) ||
+ $state->copy_file($src, $tempname)) {
+ # we still need to adjust properties
+ $file->set_modes;
+ $state->{archive}->skip;
+ return;
+ }
+ # okay, it didn't work. recreate tempname.
+ open $fh, ">", $tempname;
+ }
+
+ $state->say("extracting #1", $tempname) if $state->verbose >= 3;
+
+ if (!$file->isFile) {
+ $state->fatal("can't extract #1, it's not a file",
+ $self->stringize);
+ }
+ $file->create;
+ $self->may_check_digest($file, $state);
+ }
+}
+
+sub install
+{
+ my ($self, $state) = @_;
+ $self->SUPER::install($state);
+ my $fullname = $self->fullname;
+ my $destdir = $state->{destdir};
+ if ($fullname =~ m,^$state->{localbase}/share/doc/pkg-readmes/,) {
+ $state->{readmes}++;
+ }
+
+ if ($state->{not}) {
+ $state->say("moving tempfile -> #1",
+ $destdir.$fullname) if $state->verbose >= 5;
+ return;
+ }
+ File::Path::mkpath(dirname($destdir.$fullname));
+ if (defined $self->{link}) {
+ link($destdir.$self->{link}, $destdir.$fullname);
+ } elsif (defined $self->{symlink}) {
+ symlink($self->{symlink}, $destdir.$fullname);
+ } else {
+ rename($self->{tempname}, $destdir.$fullname) or
+ $state->fatal("can't move #1 to #2: #3",
+ $self->{tempname}, $fullname, $!);
+ $state->say("moving #1 -> #2",
+ $self->{tempname}, $destdir.$fullname)
+ if $state->verbose >= 5;
+ undef $self->{tempname};
+ }
+ $self->set_modes($state, $destdir.$fullname);
+}
+
package OpenBSD::PackingElement::RcScript;
sub install
{
}
}
+sub extract
+{
+}
+
sub install
{
my ($self, $state) = @_;
}
package OpenBSD::PackingElement::Sampledir;
+sub extract
+{
+}
sub install
{
}
package OpenBSD::PackingElement::Dir;
+sub extract
+{
+ my ($self, $state) = @_;
+ my $fullname = $self->fullname;
+ my $destdir = $state->{destdir};
+
+ return if -e $destdir.$fullname;
+ $self->SUPER::extract($state);
+ $state->say("new directory #1", $destdir.$fullname)
+ if $state->verbose >= 3;
+ return if $state->{not};
+ File::Path::mkpath($destdir.$fullname);
+}
+
sub install
{
my ($self, $state) = @_;
my $fullname = $self->fullname;
my $destdir = $state->{destdir};
- $state->say("new directory #1", $destdir.$fullname) if $state->verbose >= 5;
+ $state->say("new directory #1", $destdir.$fullname)
+ if $state->verbose >= 5;
return if $state->{not};
File::Path::mkpath($destdir.$fullname);
$self->set_modes($state, $destdir.$fullname);
$self->fullname, $dest, $!);
}
-sub install
+sub extract
{
my ($self, $state) = @_;
- if (!$state->{extracted_first}) {
- $self->may_verify_digest($state);
- }
+ $self->may_verify_digest($state);
}
package OpenBSD::PackingElement::FCONTENTS;
#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: PkgAdd.pm,v 1.44 2014/01/09 20:20:01 espie Exp $
+# $OpenBSD: PkgAdd.pm,v 1.45 2014/01/11 11:54:43 espie Exp $
#
# Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org>
#
OpenBSD::OldLibs->save($set, $state);
}
- if ($replacing && !$state->{delete_first}) {
- $state->{extracted_first} = 1;
- for my $handle ($set->newer) {
- next if $state->{size_only};
- $set->setup_header($state, $handle, "extracting");
+ if ($state->{delete_first}) {
+ delete_old_packages($set, $state);
+ }
- try {
- OpenBSD::Replace::perform_extraction($handle,
- $state);
- } catchall {
- unless ($state->{interrupted}) {
- $state->errsay($_);
- $errors++;
- }
- };
- if ($state->{interrupted} || $errors) {
- $state->fatal(partial_install("Installation of ".
- $handle->pkgname." failed", $set, $state));
+ for my $handle ($set->newer) {
+ next if $state->{size_only};
+ $set->setup_header($state, $handle, "extracting");
+
+ try {
+ OpenBSD::Add::perform_extraction($handle,
+ $state);
+ } catchall {
+ unless ($state->{interrupted}) {
+ $state->errsay($_);
+ $errors++;
}
+ };
+ if ($state->{interrupted} || $errors) {
+ $state->fatal(partial_install("Installation of ".
+ $handle->pkgname." failed", $set, $state));
}
- } else {
- $state->{extracted_first} = 0;
}
-
- if ($replacing) {
+ if (!$state->{delete_first}) {
delete_old_packages($set, $state);
}
iterate($set->newer, sub {
return if $state->{size_only};
my $handle = shift;
-
my $pkgname = $handle->pkgname;
my $plist = $handle->plist;
- $set->setup_header($state, $handle,
- $replacing ? "installing" : undef);
+
+ $set->setup_header($state, $handle, "installing");
$state->set_name_from_handle($handle, '+');
try {
# ex:ts=8 sw=4:
-# $OpenBSD: Replace.pm,v 1.86 2014/01/09 20:20:01 espie Exp $
+# $OpenBSD: Replace.pm,v 1.87 2014/01/11 11:54:43 espie Exp $
#
# Copyright (c) 2004-2014 Marc Espie <espie@openbsd.org>
#
sub update_issue { undef }
-sub extract
-{
- my ($self, $state) = @_;
- $state->{partial}->{$self} = 1;
- if ($state->{interrupted}) {
- die "Interrupted";
- }
-}
-
-package OpenBSD::PackingElement::FileBase;
-use OpenBSD::Temp;
-
-sub extract
-{
- my ($self, $state) = @_;
-
- my $file = $self->prepare_to_extract($state);
-
- if (defined $self->{link} || defined $self->{symlink}) {
- $state->{archive}->skip;
- return;
- }
-
- $self->SUPER::extract($state);
-
- # figure out a safe directory where to put the temp file
- my $d = dirname($file->{destdir}.$file->name);
- # we go back up until we find an existing directory.
- # hopefully this will be on the same file system.
- while (!-d $d && -e _ || defined $state->{noshadow}->{$d}) {
- $d = dirname($d);
- }
- if ($state->{not}) {
- $state->say("extracting tempfile under #1", $d)
- if $state->verbose >= 3;
- $state->{archive}->skip;
- } else {
- if (!-e _) {
- File::Path::mkpath($d);
- }
- my ($fh, $tempname) = OpenBSD::Temp::permanent_file($d, "pkg");
- $self->{tempname} = $tempname;
-
- # XXX don't apply destdir twice
- $file->{destdir} = '';
- $file->set_name($tempname);
-
- if ($self->{tieto}) {
- my $src = $self->{tieto}->realname($state);
- unlink($tempname);
- $state->say("linking #1 to #2", $src, $tempname)
- if $state->verbose >= 3;
- if (link($src, $tempname) ||
- $state->copy_file($src, $tempname)) {
- # we still need to adjust properties
- $file->set_modes;
- $state->{archive}->skip;
- return;
- }
- # okay, it didn't work. recreate tempname.
- open $fh, ">", $tempname;
- }
-
- $state->say("extracting #1", $tempname) if $state->verbose >= 3;
-
- $file->create;
- $self->may_check_digest($file, $state);
- }
-}
-
-package OpenBSD::PackingElement::Dir;
-sub extract
-{
- my ($self, $state) = @_;
- my $fullname = $self->fullname;
- my $destdir = $state->{destdir};
-
- return if -e $destdir.$fullname;
- $self->SUPER::extract($state);
- $state->say("new directory #1", $destdir.$fullname)
- if $state->verbose >= 3;
- return if $state->{not};
- File::Path::mkpath($destdir.$fullname);
-}
-
-
-package OpenBSD::PackingElement::Sample;
-sub extract
-{
-}
-
-package OpenBSD::PackingElement::Sampledir;
-sub extract
-{
-}
-
-package OpenBSD::PackingElement::SpecialFile;
-sub extract
-{
- my ($self, $state) = @_;
- $self->may_verify_digest($state);
-}
-
package OpenBSD::PackingElement::Exec;
sub update_issue
{
package OpenBSD::Replace;
-sub perform_extraction
-{
- my ($handle, $state) = @_;
-
- $handle->{partial} = {};
- $state->{partial} = $handle->{partial};
- $state->{archive} = $handle->{location};
- $state->progress->visit_with_size($handle->{plist}, 'extract', $state);
-}
-
sub check_plist_exec
{
my ($plist, $state, $new) = @_;