Skip to content

Commit

Permalink
Introduce PKGGNUDIR as a way to control gnu prefix.
Browse files Browse the repository at this point in the history
By default pkgsrc uses LOCABASE/gnu as a prefix for packages to install
native versions of GNU tools, which are them symbolically linked back to
the 'g' versions of the files in LOCALBASE, and users can then add
LOCALBASE/gnu/bin to PATH to pick up those tools.

On systems where the GNU environment is desired, PKGGNUDIR now allows
users to install the non-'g' files directly into LOCALBASE, making them
the default without having to alter PATH, whilst retaining the 'g' files
in order to ensure dependencies and tool paths remain the same.
  • Loading branch information
jperkin committed Dec 6, 2012
1 parent 6cc403a commit bfb94be
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 9 deletions.
3 changes: 2 additions & 1 deletion mk/bsd.pkg.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $NetBSD: bsd.pkg.mk,v 1.1982 2012/07/18 12:29:12 obache Exp $
# $NetBSD: bsd.pkg.mk,v 1.1983 2012/12/06 11:36:30 jperkin Exp $
#
# This file is in the public domain.
#
Expand Down Expand Up @@ -194,6 +194,7 @@ BSD_MAKE_ENV+= MKHTML=no
_BUILD_DEFS= ${BUILD_DEFS}
_BUILD_DEFS+= LOCALBASE
_BUILD_DEFS+= PKGGNUDIR
_BUILD_DEFS+= PKGINFODIR
_BUILD_DEFS+= PKGMANDIR
_BUILD_DEFS+= _USE_DESTDIR
Expand Down
3 changes: 2 additions & 1 deletion mk/build/bsd.build-vars.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $NetBSD: bsd.build-vars.mk,v 1.7 2011/09/08 20:17:15 abs Exp $
# $NetBSD: bsd.build-vars.mk,v 1.8 2012/12/06 11:36:31 jperkin Exp $
#
# Package-settable variables:
#
Expand Down Expand Up @@ -40,6 +40,7 @@ MAKE_ENV+= X11BASE=${X11BASE:Q}
MAKE_ENV+= X11PREFIX=${X11PREFIX:Q}
MAKE_ENV+= PKGMANDIR=${PKGMANDIR:Q}
MAKE_ENV+= PKGINFODIR=${PKGINFODIR:Q}
MAKE_ENV+= PKGGNUDIR=${PKGGNUDIR:Q}

# Provide a consistent environment for packages using (Net)BSD-style
# Makefiles.
Expand Down
10 changes: 9 additions & 1 deletion mk/defaults/mk.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $NetBSD: mk.conf,v 1.217 2012/11/10 17:13:37 ryoon Exp $
# $NetBSD: mk.conf,v 1.218 2012/12/06 11:36:31 jperkin Exp $
#

# This file provides default values for variables that may be overridden
Expand Down Expand Up @@ -307,6 +307,14 @@ PKGMANDIR?= man
#
# See also: PKGINFODIR

PKGGNUDIR?= gnu/
# The subdirectory of PREFIX that holds gnu programs and manual pages.
# Making this value empty can be useful when trying to build a fully
# GNU environment.
#
# Possible: Any sane pathname including a trailing slash, or empty to
# install into LOCALBASE

BSDSRCDIR?= /usr/src
# Where the NetBSD src module source tree is located
# used in the emulators/plex86, emulators/vmware-module{,3}, net/arla,
Expand Down
10 changes: 6 additions & 4 deletions mk/install/install.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $NetBSD: install.mk,v 1.64 2012/07/28 21:33:48 reed Exp $
# $NetBSD: install.mk,v 1.65 2012/12/06 11:36:31 jperkin Exp $
#
# This file provides the code for the "install" phase.
#
Expand Down Expand Up @@ -39,8 +39,9 @@
# INSTALLATION_DIRS
# A list of directories that should be created at the very
# beginning of the install phase. These directories are relative
# to ${PREFIX}. As a convenience, a leading man/ is transformed
# to ${PKGMANDIR}, to save package authors from typing too much.
# to ${PREFIX}. As a convenience, a leading gnu/ is transformed
# to ${PKGGNUDIR} and a leading man/ is transformed to
# ${PKGMANDIR}, to save package authors from typing too much.
#
# AUTO_MKDIRS
# INSTALLATION_DIRS_FROM_PLIST
Expand Down Expand Up @@ -268,7 +269,7 @@ install-makedirs:
.if defined(INSTALLATION_DIRS) && !empty(INSTALLATION_DIRS)
@${STEP_MSG} "Creating installation directories"
${RUN} \
for dir in ${INSTALLATION_DIRS:C,^man/,${PKGMANDIR}/,}; do \
for dir in ${INSTALLATION_DIRS:C,^gnu/,${PKGGNUDIR},:C,^man/,${PKGMANDIR}/,}; do \
case "$$dir" in \
${PREFIX}/*) \
dir=`${ECHO} "$$dir" | ${SED} "s|^${PREFIX}/||"` ;; \
Expand All @@ -292,6 +293,7 @@ install-dirs-from-PLIST:
${CAT} ${PLIST_SRC} \
| sed -n \
-e 's,\\,\\\\,' \
-e 's,^gnu/,${PKGGNUDIR},' \
-e 's,^man/,${PKGMANDIR}/,' \
-e 's,^info/,${PKGINFODIR}/,' \
-e 's,^share/locale/,${PKGLOCALEDIR}/locale/,' \
Expand Down
50 changes: 50 additions & 0 deletions mk/plist/plist-gnu.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# $NetBSD: plist-gnu.awk,v 1.1 2012/12/06 11:36:31 jperkin Exp $
#
# Copyright (c) 2012 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Jonathan Perkin
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

### This awk script handles gnu entries in PLISTs. This script
### requires the following scripts to be included:
###
### plist-functions.awk (print_entry)
###
### Certain environment variables must be set prior to running this script:
###
### PKGGNUDIR is the ${PREFIX}-relative path to the installed GNU files.
###
BEGIN {
# PKGGNUDIR is allowed to be empty so we do not provide a default.
PKGGNUDIR = ENVIRON["PKGGNUDIR"]
}

###
### Convert gnu/ to ${PKGGNUDIR} for all GNU file entries.
###
/^[^@]/ && \
/^gnu\// {
sub("^gnu/", PKGGNUDIR)
}
5 changes: 4 additions & 1 deletion mk/plist/plist.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $NetBSD: plist.mk,v 1.43 2012/05/27 14:32:28 cheusov Exp $
# $NetBSD: plist.mk,v 1.44 2012/12/06 11:36:31 jperkin Exp $
#
# This Makefile fragment handles the creation of PLISTs for use by
# pkg_create(8).
Expand Down Expand Up @@ -136,6 +136,7 @@ _PLIST_AWK_ENV+= LIBTOOL_EXPAND=${_LIBTOOL_EXPAND:Q}
_PLIST_AWK_ENV+= LS=${TOOLS_LS:Q}
_PLIST_AWK_ENV+= MANINSTALL=${_PLIST_MANINSTALL:Q}
_PLIST_AWK_ENV+= MANZ=${_MANZ:Q}
_PLIST_AWK_ENV+= PKGGNUDIR=${PKGGNUDIR:Q}
_PLIST_AWK_ENV+= PKGMANDIR=${PKGMANDIR:Q}
_PLIST_AWK_ENV+= PREFIX=${DESTDIR:Q}${PREFIX:Q}
_PLIST_AWK_ENV+= TEST=${TOOLS_TEST:Q}
Expand Down Expand Up @@ -169,6 +170,7 @@ PLIST_SUBST+= OPSYS=${OPSYS:Q} \
RMDIR=${RMDIR:Q} \
RM=${RM:Q} \
TRUE=${TRUE:Q} \
PKGGNUDIR=${PKGGNUDIR:Q} \
PKGMANDIR=${PKGMANDIR:Q}

.for _var_ in ${PLIST_VARS}
Expand All @@ -187,6 +189,7 @@ _PLIST_1_AWK+= -f ${PKGSRCDIR}/mk/plist/plist-macros.awk

_PLIST_AWK+= -f ${.CURDIR}/../../mk/plist/plist-functions.awk
_PLIST_AWK+= -f ${.CURDIR}/../../mk/plist/plist-locale.awk
_PLIST_AWK+= -f ${.CURDIR}/../../mk/plist/plist-gnu.awk
_PLIST_AWK+= -f ${.CURDIR}/../../mk/plist/plist-info.awk
_PLIST_AWK+= -f ${.CURDIR}/../../mk/plist/plist-man.awk
_PLIST_AWK+= -f ${.CURDIR}/../../mk/plist/plist-libtool.awk
Expand Down
4 changes: 3 additions & 1 deletion mk/plist/print-plist.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $NetBSD: print-plist.mk,v 1.20 2012/03/08 23:12:16 wiz Exp $
# $NetBSD: print-plist.mk,v 1.21 2012/12/06 11:36:31 jperkin Exp $

###
### Automatic PLIST generation
Expand Down Expand Up @@ -28,6 +28,7 @@ _PRINT_PLIST_AWK_SUBST+= \
gsub(/${PKGNAME_NOREV}/, "$${PKGNAME}"); \
gsub(/${PKGVERSION:S/./\./g:C/nb[0-9]*$$//}/, "$${PKGVERSION}");\
gsub(/^${PKGLOCALEDIR}\/locale/, "share/locale"); \
gsub("^${PKGGNUDIR}", "gnu/"); \
gsub("^${PKGINFODIR}/", "info/"); \
gsub("^${PKGMANDIR}/", "man/");
_PRINT_PLIST_AWK_SUBST+=}
Expand Down Expand Up @@ -176,6 +177,7 @@ print-PLIST:
/${DESTDIR:S|/|\\/|g:S/+/\\\\+/g}${PREFIX:S|/|\\/|g}\/\.$$/ { next; } \
/${PKG_DBDIR:S|/|\\/|g}\// { next; } \
{ sub("${DESTDIR:S/+/\\\\\\+/g}${PREFIX}/\\\\./", ""); } \
{ sub("^${PKGGNUDIR}", "gnu/"); } \
{ sub("^${PKGINFODIR}/", "info/"); } \
{ sub("^${PKGMANDIR}/", "man/"); } \
/^${PKG_DBDIR:S|^${PREFIX}/||:S|/|\\/|g}(\/|$$)/ { next; } \
Expand Down

0 comments on commit bfb94be

Please sign in to comment.