summaryrefslogtreecommitdiff
path: root/mk/scripts
diff options
context:
space:
mode:
authorjlam <jlam>2006-01-18 18:21:56 +0000
committerjlam <jlam>2006-01-18 18:21:56 +0000
commit9a425279e3143fc7f9e49465a5efa72922d8c9f1 (patch)
tree1c4784c1ad83fe35474f11346d4093a0c1160694 /mk/scripts
parent89173453273fbe8142bc1629967d6e11e3cd9313 (diff)
downloadpkgsrc-9a425279e3143fc7f9e49465a5efa72922d8c9f1.tar.gz
Add a "-s pkgsrcdir" option that allows specifying the path to the pkgsrc
directory tree on the command line more easily.
Diffstat (limited to 'mk/scripts')
-rwxr-xr-xmk/scripts/pkg_path38
1 files changed, 32 insertions, 6 deletions
diff --git a/mk/scripts/pkg_path b/mk/scripts/pkg_path
index efe7d7475da..f9fb6e80335 100755
--- a/mk/scripts/pkg_path
+++ b/mk/scripts/pkg_path
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $NetBSD: pkg_path,v 1.1 2006/01/18 18:03:08 jlam Exp $
+# $NetBSD: pkg_path,v 1.2 2006/01/18 18:21:56 jlam Exp $
#
# Copyright (c) 2006 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -43,14 +43,22 @@
# pkg_path -- canonicalize directories into "package paths"
#
# SYNOPSIS
-# pkg_path dir ...
+# pkg_path [-s pkgsrcdir] dir ...
+#
+# OPTIONS
+# The following command line arguments are supported.
+#
+# -s pkgsrcdir Use the specified directory as the path to the
+# pkgsrc directory tree. By default, this is the
+# value stored in the PKGSRCDIR environment variable.
#
# DESCRIPTION
# pkg_path canonicalizes the specified directories into package
# paths are are relative to the pkgsrc directory tree, and prints
-# each of them to standard output on a new line. Directories
-# that are not valid package directories or are not found are
-# skipped during processing.
+# each of them to standard output on a new line. The specified
+# directories are taken to be relative to the current directory or
+# are otherwise absolute paths. Directories that are not valid
+# package directories or are not found are skipped during processing.
#
# ENVIRONMENT
# PKGSRCDIR This is the location of the pkgsrc directory tree,
@@ -65,10 +73,28 @@
self="${0##*/}"
+usage() {
+ ${ECHO} 1>&2 "usage: $self [-s pkgsrcdir] dir ..."
+}
+
+# Process optional arguments
+while ${TEST} $# -gt 0; do
+ case "$1" in
+ -s) PKGSRCDIR=$2; shift 2 ;;
+ --) shift; break ;;
+ -*) ${ECHO} 1>&2 "$self: unknown option -- ${1#-}"
+ usage
+ exit 1
+ ;;
+ *) break ;;
+ esac
+done
+
+# Process required arguments
startdir=`${PWD_CMD}`
while ${TEST} $# -gt 0; do
dir="$1"; shift
- case $dir in
+ case "$dir" in
${PKGSRCDIR}/*) ;;
/*) ${ECHO} 1>&2 "$self: \`\`$dir'' not a valid package directory"
continue