use a simple perl script to compute initial pkgpaths... Cwd can replace
pwd -P, and we select the longest prefix from PORTSDIR_PATH. This lets mystuff-like dirs get stripped from PKGPATH correctly, as long as PORTSDIR_PATH is set correctly.
This commit is contained in:
parent
e545312d3c
commit
8b31dd60d8
42
infrastructure/mk/getpkgpath
Normal file
42
infrastructure/mk/getpkgpath
Normal file
@ -0,0 +1,42 @@
|
||||
#! /usr/bin/perl
|
||||
|
||||
# $OpenBSD: getpkgpath,v 1.1 2006/12/26 15:00:24 espie Exp $
|
||||
#
|
||||
# Copyright (c) 2006 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 Cwd qw(abs_path);
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my $dir = shift;
|
||||
my $path = $ENV{PORTSDIR_PATH} or exit 1;
|
||||
|
||||
my $pkgpath;
|
||||
my $real_dir = abs_path($dir);
|
||||
for my $d (split ':', $path) {
|
||||
my $real_d = abs_path($d);
|
||||
if ($real_dir =~ m/^\Q$real_d\E\//) {
|
||||
my $newpath = $';
|
||||
if (!defined $pkgpath or length $newpath < length $pkgpath) {
|
||||
$pkgpath = $newpath;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (defined $pkgpath) {
|
||||
print $pkgpath, "\n";
|
||||
exit 0;
|
||||
} else {
|
||||
exit 1;
|
||||
}
|
@ -1,14 +1,18 @@
|
||||
# $OpenBSD: pkgpath.mk,v 1.11 2006/12/02 11:27:46 espie Exp $
|
||||
# $OpenBSD: pkgpath.mk,v 1.12 2006/12/26 15:00:24 espie Exp $
|
||||
# ex:ts=4 sw=4 filetype=make:
|
||||
# pkgpath.mk - 2003 Marc Espie
|
||||
# This file is in the public domain.
|
||||
|
||||
# definitions common to bsd.port.mk and bsd.port.subdir.mk
|
||||
|
||||
PORTSDIR_PATH ?= ${PORTSDIR}:${PORTSDIR}/mystuff
|
||||
TMPDIR ?= /tmp
|
||||
READMES_TOP ?= ${PORTSDIR}
|
||||
|
||||
|
||||
.if !defined(PKGPATH)
|
||||
_PORTSDIR != cd ${PORTSDIR} && pwd -P
|
||||
_CURDIR != cd ${.CURDIR} && pwd -P
|
||||
PKGPATH = ${_CURDIR:S,${_PORTSDIR}/,,}
|
||||
PKGPATH != PORTSDIR_PATH=${PORTSDIR_PATH} \
|
||||
perl ${PORTSDIR}/infrastructure/mk/getpkgpath ${.CURDIR}
|
||||
.endif
|
||||
.if empty(PKGPATH)
|
||||
PKGDEPTH =
|
||||
@ -16,10 +20,6 @@ PKGDEPTH =
|
||||
PKGDEPTH = ${PKGPATH:C|[^./][^/]*|..|g}/
|
||||
.endif
|
||||
|
||||
PORTSDIR_PATH ?= ${PORTSDIR}:${PORTSDIR}/mystuff
|
||||
TMPDIR ?= /tmp
|
||||
READMES_TOP ?= ${PORTSDIR}
|
||||
|
||||
# Code to invoke to split dir,-multi,flavor
|
||||
|
||||
_flavor_fragment = \
|
||||
|
Loading…
Reference in New Issue
Block a user