summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2010-04-24 14:33:13 +0000
committerMarc Espie <espie@cvs.openbsd.org>2010-04-24 14:33:13 +0000
commitbc4ce90b88329f6a46e3724a616e7192b594e80f (patch)
treeb2e177326807490b28db0c17c5d5585bdec6b1c7
parentabbb6547776afe984e6708422d24279b74820091 (diff)
pieces required for resolve-lib (reuse code for consistency)
-rw-r--r--usr.sbin/pkg_add/Makefile6
-rw-r--r--usr.sbin/pkg_add/OpenBSD/LibSpec/Build.pm111
2 files changed, 115 insertions, 2 deletions
diff --git a/usr.sbin/pkg_add/Makefile b/usr.sbin/pkg_add/Makefile
index dfea9d4673d..c392998bddd 100644
--- a/usr.sbin/pkg_add/Makefile
+++ b/usr.sbin/pkg_add/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.60 2010/03/22 20:38:44 espie Exp $
+# $OpenBSD: Makefile,v 1.61 2010/04/24 14:33:12 espie Exp $
.include <bsd.own.mk>
@@ -24,6 +24,7 @@ PACKAGES= \
OpenBSD/IdCache.pm \
OpenBSD/Interactive.pm \
OpenBSD/LibSpec.pm \
+ OpenBSD/LibSpec/Build.pm \
OpenBSD/Mtree.pm \
OpenBSD/OldLibs.pm \
OpenBSD/PackageInfo.pm \
@@ -59,7 +60,8 @@ PACKAGES= \
OpenBSD/md5.pm \
OpenBSD/x509.pm
-PACKAGEDIRS=OpenBSD OpenBSD/PackageRepository OpenBSD/ProgressMeter
+PACKAGEDIRS=OpenBSD OpenBSD/PackageRepository OpenBSD/ProgressMeter \
+ OpenBSD/LibSpec
SCRIPTS= \
pkg_add \
diff --git a/usr.sbin/pkg_add/OpenBSD/LibSpec/Build.pm b/usr.sbin/pkg_add/OpenBSD/LibSpec/Build.pm
new file mode 100644
index 00000000000..ad8a97936ca
--- /dev/null
+++ b/usr.sbin/pkg_add/OpenBSD/LibSpec/Build.pm
@@ -0,0 +1,111 @@
+# ex:ts=8 sw=4:
+# $OpenBSD: Build.pm,v 1.1 2010/04/24 14:33:12 espie Exp $
+#
+# Copyright (c) 2010 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;
+
+# the specs used during build are slightly different from the specs at
+# runtime.
+package OpenBSD::Library::Static;
+our @ISA = qw(OpenBSD::Library);
+sub new
+{
+ my ($class, $dir, $stem) = @_;
+ bless {dir => $dir, stem => $stem}, $class;
+}
+
+sub no_match_dispatch
+{
+ my ($library, $spec, $base) = @_;
+ return $spec->no_match_static($library, $base);
+}
+
+sub to_string
+{
+ my $self = shift;
+ return "$self->{dir}/lib$self->{stem}.a";
+}
+
+sub version { ".a" }
+
+sub is_static { 1 }
+
+sub is_better { 0 }
+
+package OpenBSD::Library::Build;
+our @ISA = qw(OpenBSD::Library);
+
+sub static
+{ 'OpenBSD::Library::Static'; }
+
+sub from_string
+{
+ my ($class, $filename) = @_;
+ if (my ($dir, $stem) = $filename =~ m/^(.*)\/lib([^\/]+)\.a$/o) {
+ return $class->static->new($dir, $stem);
+ } else {
+ return $class->SUPER::from_string($filename);
+ }
+}
+
+package OpenBSD::LibSpec;
+sub no_match_static
+{
+ &OpenBSD::LibSpec::no_match_name;
+}
+
+package OpenBSD::LibSpec::GT;
+our @ISA = qw(OpenBSD::LibSpec);
+sub no_match_major
+{
+ my ($spec, $library) = @_;
+ return $spec->major > $library->major;
+}
+
+sub to_string
+{
+ my $self = shift;
+ return join('.', $self->key, ">=".$self->major, $self->minor);
+
+}
+
+
+package OpenBSD::LibSpec::Build;
+our @ISA = qw(OpenBSD::LibSpec);
+
+sub new_from_string
+{
+ my ($class, $string) = @_;
+
+ $string =~ s/\.$//;
+ if (my ($stem, $strict, $major, $minor) = $string =~ m/^(.*)\.(\>?)\=(\d+)\.(\d+)$/o) {
+ return $class->new_object($stem, $strict, $major, $minor);
+ } elsif (($stem, $strict, $major) = $string =~ m/^(.*)\.(\>?)\=(\d+)$/o) {
+ return $class->new_object($stem, $strict, $major, 0);
+ } else {
+ return $class->new_object($string, '>', 0, 0);
+ }
+}
+
+sub new_object
+{
+ my ($class, $stem, $strict, $major, $minor) = @_;
+ my $n = $strict eq '' ? "OpenBSD::LibSpec" : "OpenBSD::LibSpec::GT";
+ return $n->new_with_stem($stem, $major, $minor);
+}
+
+1;