diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2006-03-06 10:40:33 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2006-03-06 10:40:33 +0000 |
commit | 2ed6f211b263d0c8d42d7a5cfbc07b1a51937cc2 (patch) | |
tree | bcb438a3eec22d07650a83a4faf21cfcddc916b5 | |
parent | 4b26c07c41fd53d5f0036fc4eb39faa1339f8541 (diff) |
take some infrequently used code completely out of the way.
-rw-r--r-- | usr.sbin/pkg_add/Makefile | 5 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageRepository.pm | 57 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm | 72 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageRepository/Source.pm | 56 |
4 files changed, 136 insertions, 54 deletions
diff --git a/usr.sbin/pkg_add/Makefile b/usr.sbin/pkg_add/Makefile index 784174f0905..0a98ff109e1 100644 --- a/usr.sbin/pkg_add/Makefile +++ b/usr.sbin/pkg_add/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.35 2006/03/04 13:13:05 espie Exp $ +# $OpenBSD: Makefile,v 1.36 2006/03/06 10:40:31 espie Exp $ .include <bsd.own.mk> @@ -25,6 +25,7 @@ PACKAGES= \ OpenBSD/PackageLocator.pm \ OpenBSD/PackageName.pm \ OpenBSD/PackageRepository.pm \ + OpenBSD/PackageRepository/SCP.pm \ OpenBSD/PackageRepositoryList.pm \ OpenBSD/PackingElement.pm \ OpenBSD/PackingList.pm \ @@ -42,7 +43,7 @@ PACKAGES= \ OpenBSD/Vstat.pm \ OpenBSD/md5.pm \ -PACKAGEDIRS=OpenBSD +PACKAGEDIRS=OpenBSD OpenBSD/PackageRepository SCRIPTS= \ pkg_add \ diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm index a76f6172fbb..765dec954a4 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageRepository.pm,v 1.1 2006/03/04 13:13:05 espie Exp $ +# $OpenBSD: PackageRepository.pm,v 1.2 2006/03/06 10:40:31 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -35,8 +35,12 @@ sub new } elsif ($baseurl =~ m/^http\:/i) { return OpenBSD::PackageRepository::HTTP->_new($baseurl); } elsif ($baseurl =~ m/^scp\:/i) { + require OpenBSD::PackageRepositorySCP; + return OpenBSD::PackageRepository::SCP->_new($baseurl); } elsif ($baseurl =~ m/src\:/i) { + require OpenBSD::PackageRepository::Source; + return OpenBSD::PackageRepository::Source->_new($baseurl); } else { return OpenBSD::PackageRepository::Local->_new($baseurl); @@ -507,57 +511,6 @@ sub finish_and_close $self->SUPER::finish_and_close($object); } -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}; -} - package OpenBSD::PackageRepository::HTTPorFTP; our @ISA=qw(OpenBSD::PackageRepository::Distant); 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; diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepository/Source.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepository/Source.pm new file mode 100644 index 00000000000..9f87f707573 --- /dev/null +++ b/usr.sbin/pkg_add/OpenBSD/PackageRepository/Source.pm @@ -0,0 +1,56 @@ +# ex:ts=8 sw=4: +# $OpenBSD: Source.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 PackageRepository::Source; + +sub find +{ + my ($repository, $name, $arch, $srcpath) = @_; + my $dir; + my $make; + if (defined $ENV{'MAKE'}) { + $make = $ENV{'MAKE'}; + } else { + $make = '/usr/bin/make'; + } + if (defined $repository->{baseurl} && $repository->{baseurl} ne '') { + $dir = $repository->{baseurl} + } elsif (defined $ENV{PORTSDIR}) { + $dir = $ENV{PORTSDIR}; + } else { + $dir = '/usr/ports'; + } + # figure out the repository name and the pkgname + my $pkgfile = `cd $dir && SUBDIR=$srcpath ECHO_MSG=: $make show=PKGFILE`; + chomp $pkgfile; + if (! -f $pkgfile) { + system "cd $dir && SUBDIR=$srcpath $make package BULK=Yes"; + } + if (! -f $pkgfile) { + return undef; + } + $pkgfile =~ m|(.*/)([^/]*)|; + my ($base, $fname) = ($1, $2); + + my $repo = OpenBSD::PackageRepository::Local->_new($base); + return $repo->find($fname); +} + +1; |