summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2004-01-28 22:12:02 +0000
committerMarc Espie <espie@cvs.openbsd.org>2004-01-28 22:12:02 +0000
commit2c3f95311188b79ec24f89f08968815795b872fd (patch)
tree18d1b3bfbc018212b4c33361e02a51140f755a3b /usr.sbin/pkg_add
parent13e9cdb0b0a1a090e1360ad436946084529d942e (diff)
Add -L to record/enforce localbase.
Okay sturm@
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackingElement.pm12
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackingList.pm11
-rw-r--r--usr.sbin/pkg_add/pkg_add16
-rw-r--r--usr.sbin/pkg_add/pkg_add.123
-rw-r--r--usr.sbin/pkg_add/pkg_create.117
-rw-r--r--usr.sbin/pkg_add/pkg_delete10
6 files changed, 71 insertions, 18 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm
index 1a03b005afb..0607ebc4817 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm
@@ -1,4 +1,4 @@
-# $OpenBSD: PackingElement.pm,v 1.6 2004/01/22 21:11:43 espie Exp $
+# $OpenBSD: PackingElement.pm,v 1.7 2004/01/28 22:12:01 espie Exp $
#
# Copyright (c) 2003 Marc Espie.
#
@@ -402,6 +402,13 @@ __PACKAGE__->setKeyword('name');
sub keyword() { "name" }
sub category() { "name" }
+package OpenBSD::PackingElement::LocalBase;
+our @ISA=qw(OpenBSD::PackingElement::Unique OpenBSD::PackingElement);
+
+__PACKAGE__->setKeyword('localbase');
+sub keyword() { "localbase" }
+sub category() { "localbase" }
+
package OpenBSD::PackingElement::Cwd;
use File::Spec;
our @ISA=qw(OpenBSD::PackingElement);
@@ -414,9 +421,6 @@ sub destate
{
my ($self, $state) = @_;
$state->{cwd} = $self->{name};
- if (!defined $state->{prefix}) {
- $state->{prefix} = $state->{cwd};
- }
}
package OpenBSD::PackingElement::Owner;
diff --git a/usr.sbin/pkg_add/OpenBSD/PackingList.pm b/usr.sbin/pkg_add/OpenBSD/PackingList.pm
index 24c6b9cdbab..5f9d41c6bd1 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackingList.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackingList.pm
@@ -1,4 +1,4 @@
-# $OpenBSD: PackingList.pm,v 1.4 2003/12/26 16:44:31 espie Exp $
+# $OpenBSD: PackingList.pm,v 1.5 2004/01/28 22:12:01 espie Exp $
#
# Copyright (c) 2003 Marc Espie.
#
@@ -148,10 +148,15 @@ sub pkgname($)
return $self->{name}->{name};
}
-sub prefix($)
+sub pkgbase($)
{
my $self = shift;
- return $self->{state}->{prefix};
+
+ if (defined $self->{localbase}) {
+ return $self->{localbase}->{name};
+ } else {
+ return '/usr/local';
+ }
}
# allows the autoloader to work correctly
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add
index 8770715c4e9..acb30e0d48a 100644
--- a/usr.sbin/pkg_add/pkg_add
+++ b/usr.sbin/pkg_add/pkg_add
@@ -1,7 +1,7 @@
#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: pkg_add,v 1.25 2004/01/27 17:47:45 sturm Exp $
+# $OpenBSD: pkg_add,v 1.26 2004/01/28 22:12:01 espie Exp $
#
# Copyright (c) 2003 Marc Espie.
#
@@ -120,11 +120,12 @@ package main;
my $errors = 0;
-our ($opt_v, $opt_n, $opt_I, $opt_f);
-getopts('vnIf:');
+our ($opt_v, $opt_n, $opt_I, $opt_f, $opt_L);
+getopts('vnIL:f:');
if ($opt_f) {
%forced = map {($_, 1)} split(/,/, $opt_f);
}
+$opt_L = '/usr/local' unless defined $opt_L;
if ($< && !$forced{nonroot}) {
die "$0 must be run as root";
@@ -188,6 +189,11 @@ sub pre_add($$)
$errors++;
return undef;
}
+ if ($plist->pkgbase() ne $opt_L) {
+ print "Localbase mismatch: package has: ", $plist->pkgbase(), " , user wants: $opt_L\n";
+ $errors++;
+ return undef;
+ }
my $pkgname = OpenBSD::PackageName->new($plist->pkgname());
if (defined $pkgname1) {
if ($pkgname->{pkgname} ne $pkgname1->{pkgname}) {
@@ -350,7 +356,7 @@ sub really_add($)
my $plist = $handle->{plist};
my $dir = $handle->info();
my $pkgname = $plist->pkgname();
- $ENV{'PKG_PREFIX'} = '/usr/local';
+ $ENV{'PKG_PREFIX'} = $plist->pkgbase();
# check for collisions with existing stuff
my $problems = 0;
for my $item (@{$plist->{items}}) {
@@ -484,7 +490,7 @@ while (my $pkg = shift @todo) {
for my $dep (@{$plist->{libdepend}}) {
# can't check libspecs yet
next if $dep->{name} ne $plist->pkgname();
- if (!check_lib_specs('/usr/local', $dep->{libspec})) {
+ if (!check_lib_specs($plist->pkgbase(), $dep->{libspec})) {
print "Can't install $pkg: incorrect libspec: ",
$dep->{libspec}, "\n";
next MAINLOOP unless $forced{libdepends};
diff --git a/usr.sbin/pkg_add/pkg_add.1 b/usr.sbin/pkg_add/pkg_add.1
index 79a8e051be3..93b81faf99a 100644
--- a/usr.sbin/pkg_add/pkg_add.1
+++ b/usr.sbin/pkg_add/pkg_add.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: pkg_add.1,v 1.10 2004/01/27 14:50:52 espie Exp $
+.\" $OpenBSD: pkg_add.1,v 1.11 2004/01/28 22:12:01 espie Exp $
.\"
.\" FreeBSD install - a package for the installation and maintenance
.\" of non-core utilities.
@@ -27,6 +27,7 @@
.Nm pkg_add
.Op Fl Inv
.Op Fl f Ar keys
+.Op Fl L Ar localbase
.Ar pkg-name Op Ar ...
.Sh DESCRIPTION
The
@@ -139,6 +140,26 @@ install even if not running as root.
.It Ar scripts
install scripts may fail.
.El
+.It Fl L Ar localbase
+Install a package under
+.Ar localbase .
+By default,
+.Ar localbase
+equals
+.Pa /usr/local ,
+and specifying it is not necessary.
+However, packages can be created using a different
+.Ar localbase
+.Po
+see
+.Xr pkg_create 1
+.Pc ,
+and those packages can only be installed by using the same
+.Ar localbase .
+See
+.Xr bsd.port.mk 5
+for a description of
+.Ev LOCALBASE .
.El
.Pp
By default, when adding packages via FTP, the
diff --git a/usr.sbin/pkg_add/pkg_create.1 b/usr.sbin/pkg_add/pkg_create.1
index de16a581c31..9c739c063e2 100644
--- a/usr.sbin/pkg_add/pkg_create.1
+++ b/usr.sbin/pkg_add/pkg_create.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: pkg_create.1,v 1.3 2004/01/22 21:11:43 espie Exp $
+.\" $OpenBSD: pkg_create.1,v 1.4 2004/01/28 22:12:01 espie Exp $
.\"
.\" FreeBSD install - a package for the installation and maintenance
.\" of non-core utilities.
@@ -43,6 +43,7 @@
.Op Fl r Ar rscript
.Op Fl S Ar fake-base
.Op Fl D Ar displayfile
+.Op Fl L Ar localbase
.Fl c Ar comment
.Fl d Ar description
.Fl f Ar packlist
@@ -130,6 +131,16 @@ the package, and to record as the base for installing the package.
Set
.Ar fake-base
as the prefix to prepend to any file to select for the package.
+.It Fl L Ar localbase
+Record
+.Ar localbase
+as the localbase used in the package.
+By default,
+.Pa /usr/local .
+Packages built with another localbase can only be installed by using
+the same localbase in
+.Xr pkg_add 1 ,
+to prevent errors.
.It Fl k Ar dscript
Set
.Ar dscript
@@ -268,6 +279,10 @@ may trip someone up later.
.It Cm @ignore
Used internally to tell extraction to ignore the next file (don't
copy it anywhere), as it's used for some special purpose.
+.It Cm @localbase
+Used internally to record the settings of
+.Fl L
+option.
.It Cm @name Ar name
Set the name of the package.
This is mandatory and is usually put at the top.
diff --git a/usr.sbin/pkg_add/pkg_delete b/usr.sbin/pkg_add/pkg_delete
index cd68e221319..20a0bd2147b 100644
--- a/usr.sbin/pkg_add/pkg_delete
+++ b/usr.sbin/pkg_add/pkg_delete
@@ -1,6 +1,6 @@
#!/usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: pkg_delete,v 1.21 2004/01/27 15:34:31 espie Exp $
+# $OpenBSD: pkg_delete,v 1.22 2004/01/28 22:12:01 espie Exp $
#
# Copyright (c) 2003 Marc Espie.
#
@@ -248,7 +248,7 @@ sub delete
package main;
-our ($opt_v, $opt_D, $opt_d, $opt_n, $opt_f, $opt_q, $opt_p, $opt_c);
+our ($opt_v, $opt_D, $opt_d, $opt_n, $opt_f, $opt_q, $opt_p, $opt_c, $opt_L);
sub remove_packing_info
{
@@ -288,7 +288,7 @@ sub delete_package
}
die if $problems;
- $ENV{'PKG_PREFIX'} = '/usr/local';
+ $ENV{'PKG_PREFIX'} = $plist->pkgbase();
if ($plist->has(REQUIRE)) {
$plist->get(REQUIRE)->delete($state);
}
@@ -314,7 +314,9 @@ sub delete_package
remove_packing_info($dir) unless $opt_n;
}
-getopts('vcDdnf:qpS:');
+getopts('vcDdnf:qpS:L:');
+
+$opt_L = '/usr/local' unless defined $opt_L;
if (defined $opt_p) {
die "Option p is obsolete";