summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2019-05-28 19:31:43 +0000
committerMarc Espie <espie@cvs.openbsd.org>2019-05-28 19:31:43 +0000
commit5837f76c6c1e13d30d267690afbde081a914afd4 (patch)
tree70cabc6230c5e322f91f509270aa7b3a5b00f094 /usr.sbin/pkg_add
parent24750fbcd58562a9c1696a0679f19054dc30bcef (diff)
make PERMIT_CDROM info optional
as discussed with sthen@, code slightly adjusted
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackingElement.pm28
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PkgCreate.pm4
2 files changed, 19 insertions, 13 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm
index 257496a29be..93dac235ee8 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: PackingElement.pm,v 1.269 2018/09/17 12:39:46 espie Exp $
+# $OpenBSD: PackingElement.pm,v 1.270 2019/05/28 19:31:42 espie Exp $
#
# Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org>
#
@@ -725,6 +725,8 @@ sub add
return OpenBSD::PackingElement::CVSTag->add($plist, $args);
} elsif ($args =~ m/^(?:subdir|pkgpath)\=(.*?)\s+cdrom\=(.*?)\s+ftp\=(.*?)\s*$/o) {
return OpenBSD::PackingElement::ExtraInfo->add($plist, $1, $2, $3);
+ } elsif ($args =~ m/^(?:subdir|pkgpath)\=(.*?)\s+ftp\=(.*?)\s*$/o) {
+ return OpenBSD::PackingElement::ExtraInfo->add($plist, $1, undef, $2);
} elsif ($args eq 'no checksum') {
$plist->{state}->{nochecksum} = 1;
return;
@@ -907,14 +909,17 @@ sub new
{
my ($class, $subdir, $cdrom, $ftp) = @_;
- $cdrom =~ s/^\"(.*)\"$/$1/;
- $cdrom =~ s/^\'(.*)\'$/$1/;
$ftp =~ s/^\"(.*)\"$/$1/;
$ftp =~ s/^\'(.*)\'$/$1/;
- bless { subdir => $subdir,
- path => OpenBSD::PkgPath->new($subdir),
- cdrom => $cdrom,
+ my $o = bless { subdir => $subdir,
+ path => OpenBSD::PkgPath->new($subdir),
ftp => $ftp}, $class;
+ if (defined $cdrom) {
+ $cdrom =~ s/^\"(.*)\"$/$1/;
+ $cdrom =~ s/^\'(.*)\'$/$1/;
+ $o->{cdrom} = $cdrom;
+ }
+ return $o;
}
sub subdir
@@ -935,10 +940,13 @@ sub may_quote
sub stringize
{
my $self = shift;
- return join(' ',
- "pkgpath=".$self->{subdir},
- "cdrom=".may_quote($self->{cdrom}),
- "ftp=".may_quote($self->{ftp}));
+ my @l = (
+ "pkgpath=".$self->{subdir});
+ if (defined $self->{cdrom}) {
+ push @l, "cdrom=".may_quote($self->{cdrom});
+ }
+ push(@l, "ftp=".may_quote($self->{ftp}));
+ return join(' ', @l);
}
package OpenBSD::PackingElement::Name;
diff --git a/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm b/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm
index 9cef44b4290..a34ffc3be77 100644
--- a/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm
@@ -1,6 +1,6 @@
#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: PkgCreate.pm,v 1.153 2018/08/03 06:49:26 espie Exp $
+# $OpenBSD: PkgCreate.pm,v 1.154 2019/05/28 19:31:42 espie Exp $
#
# Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org>
#
@@ -1297,9 +1297,7 @@ sub add_extra_info
$subst->value('FTP');
if (defined $fullpkgpath || defined $cdrom || defined $ftp) {
$fullpkgpath //= '';
- $cdrom //= 'no';
$ftp //= 'no';
- $cdrom = 'yes' if $cdrom =~ m/^yes$/io;
$ftp = 'yes' if $ftp =~ m/^yes$/io;
OpenBSD::PackingElement::ExtraInfo->add($plist,