Mon Feb 27 22:42:27 2012 UTC ()
Update to 1.36:

- Allow specifying packages by their basename, without a category.  This
  affects the arguments to the 'build' command as well as the list of
  packages provided to AUTO_PACKAGES and BUILD_PACKAGES.


(jmmv)
diff -r1.47 -r1.48 pkgsrc/pkgtools/pkg_comp/Makefile
diff -r1.35 -r1.36 pkgsrc/pkgtools/pkg_comp/files/pkg_comp.8
diff -r1.39 -r1.40 pkgsrc/pkgtools/pkg_comp/files/pkg_comp.sh

cvs diff -r1.47 -r1.48 pkgsrc/pkgtools/pkg_comp/Makefile (expand / switch to context diff)
--- pkgsrc/pkgtools/pkg_comp/Makefile 2010/11/13 16:23:22 1.47
+++ pkgsrc/pkgtools/pkg_comp/Makefile 2012/02/27 22:42:26 1.48
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.47 2010/11/13 16:23:22 jmmv Exp $
+# $NetBSD: Makefile,v 1.48 2012/02/27 22:42:26 jmmv Exp $
 
-DISTNAME=	pkg_comp-1.35
+DISTNAME=	pkg_comp-1.36
 CATEGORIES=	pkgtools
 MASTER_SITES=	# empty
 DISTFILES=	# empty

cvs diff -r1.35 -r1.36 pkgsrc/pkgtools/pkg_comp/files/Attic/pkg_comp.8 (expand / switch to context diff)
--- pkgsrc/pkgtools/pkg_comp/files/Attic/pkg_comp.8 2010/04/15 09:42:45 1.35
+++ pkgsrc/pkgtools/pkg_comp/files/Attic/pkg_comp.8 2012/02/27 22:42:27 1.36
@@ -1,4 +1,4 @@
-.\" $NetBSD: pkg_comp.8,v 1.35 2010/04/15 09:42:45 jmmv Exp $
+.\" $NetBSD: pkg_comp.8,v 1.36 2012/02/27 22:42:27 jmmv Exp $
 .\"
 .\" pkg_comp - Build packages inside a clean chroot environment
 .\" Copyright (c) 2002, 2003, 2004, 2005 Julio M. Merino Vidal <jmmv@NetBSD.org>
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd April 15, 2010
+.Dd February 27, 2012
 .Dt PKG_COMP 8
 .Os
 .Sh NAME
@@ -155,7 +155,12 @@
 A list of packages to automatically build during the
 .Sy auto
 target.
-A package is in the form section/name, like misc/colorls.
+A package is in the form
+.Sq section/name ,
+like
+.Sq misc/colorls ,
+or a plain name like
+.Sq colorls .
 Defaults to nothing.
 .It AUTO_TARGET
 The pkgsrc target to use when building packages in an automated fashion
@@ -173,7 +178,12 @@
 A list of packages to automatically build after the
 .Sy makeroot
 target.
-A package is in the form section/name, like misc/colorls.
+A package is in the form
+.Sq section/name ,
+like
+.Sq misc/colorls ,
+or a plain name like
+.Sq colorls .
 Defaults to nothing.
 .It BUILD_TARGET
 The pkgsrc target to use when building packages.
@@ -475,8 +485,8 @@
 This step is required before trying any other, except maketemplate.
 .It build
 Builds the specified packages inside the chroot.
-You need to pass their names as relative paths inside pkgsrc, like
-.Pa pkgtools/pkg_comp .
+You can pass the package names as a relative path within pkgsrc or as the
+basename of the package directory (i.e. omitting the directory name).
 .It install
 Install the specified binary packages into the chroot.
 Package names can contain globs.

cvs diff -r1.39 -r1.40 pkgsrc/pkgtools/pkg_comp/files/Attic/pkg_comp.sh (expand / switch to context diff)
--- pkgsrc/pkgtools/pkg_comp/files/Attic/pkg_comp.sh 2010/11/13 16:23:22 1.39
+++ pkgsrc/pkgtools/pkg_comp/files/Attic/pkg_comp.sh 2012/02/27 22:42:27 1.40
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: pkg_comp.sh,v 1.39 2010/11/13 16:23:22 jmmv Exp $
+# $NetBSD: pkg_comp.sh,v 1.40 2012/02/27 22:42:27 jmmv Exp $
 #
 # pkg_comp - Build packages inside a clean chroot environment
 # Copyright (c) 2002, 2003, 2004, 2005 Julio M. Merino Vidal <jmmv@NetBSD.org>
@@ -701,13 +701,14 @@
 {
     local failed invalid p pkgs script statfile
 
-    pkgs="$*"
-
-    # Check if all packages exist
-    invalid=""
-    for p in $pkgs; do
-        if [ ! -d $REAL_PKGSRC/$p ]; then
-            invalid="$invalid $p"
+    pkgs=
+    invalid=
+    for pkg in "${@}"; do
+        local match="$(find_pkg "${pkg}")"
+        if [ -z "${match}" ]; then
+            invalid="${invalid} ${pkg}"
+        else
+            pkgs="${pkgs} ${match}"
         fi
     done
     if [ -n "$invalid" ]; then
@@ -752,6 +753,32 @@
             echo "    $p"
         done
     fi
+}
+
+# find_pkg name
+#
+#   Checks if the given package exists and outputs its path within pkgsrc.
+#   Outputs nothing if the package is not found.
+find_pkg()
+{
+    local name="${1}"
+
+    case "${name}" in
+    */*)
+        if [ -d "${REAL_PKGSRC}/${name}" ]; then
+            echo "${name}"
+        else
+            :  # Not found; output nothing.
+        fi
+        ;;
+    *)
+        local match="$(cd "${REAL_PKGSRC}" && echo */"${name}")"
+        if [ -d "${REAL_PKGSRC}/${match}" ]; then
+            echo "${match}"
+        else
+            :  # Not found; output nothing.
+        fi
+    esac
 }
 
 # build_and_install pkg