summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2006-03-06 10:40:33 +0000
committerMarc Espie <espie@cvs.openbsd.org>2006-03-06 10:40:33 +0000
commit2ed6f211b263d0c8d42d7a5cfbc07b1a51937cc2 (patch)
treebcb438a3eec22d07650a83a4faf21cfcddc916b5 /usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm
parent4b26c07c41fd53d5f0036fc4eb39faa1339f8541 (diff)
take some infrequently used code completely out of the way.
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm72
1 files changed, 72 insertions, 0 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm
new file mode 100644
index 00000000000..fffd1d4191e
--- /dev/null
+++ b/usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm
@@ -0,0 +1,72 @@
+# ex:ts=8 sw=4:
+# $OpenBSD: SCP.pm,v 1.1 2006/03/06 10:40:32 espie Exp $
+#
+# Copyright (c) 2003-2004 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.
+
+use strict;
+use warnings;
+
+package OpenBSD::PackageRepository::SCP;
+our @ISA=qw(OpenBSD::PackageRepository::Distant);
+
+
+sub grab_object
+{
+ my ($self, $object) = @_;
+
+ exec {"/usr/bin/scp"}
+ "scp",
+ $self->{host}.":".$self->{path}.$object->{name},
+ "/dev/stdout"
+ or die "can't run scp";
+}
+
+our %distant = ();
+
+sub maxcount
+{
+ return 2;
+}
+
+sub opened
+{
+ my $self = $_[0];
+ my $k = $self->{key};
+ if (!defined $distant{$k}) {
+ $distant{$k} = [];
+ }
+ return $distant{$k};
+}
+
+sub _new
+{
+ my ($class, $baseurl) = @_;
+ $baseurl =~ s/scp\:\/\///i;
+ $baseurl =~ m/\//;
+ bless { host => $`, key => $`, path => "/$'" }, $class;
+}
+
+sub list
+{
+ my ($self) = @_;
+ if (!defined $self->{list}) {
+ my $host = $self->{host};
+ my $path = $self->{path};
+ $self->{list} = $self->_list("ssh $host ls -l $path");
+ }
+ return $self->{list};
+}
+
+1;