Subject: Re: pkg/20477: defs.Linux.mk assumes sed is in /bin, isn't on
To: None <tech-pkg@netbsd.org>
From: Julio Merino <jmmv@menta.net>
List: tech-pkg
Date: 02/24/2003 18:15:19
Hmm... I notice now that I didn't send the patch to this list. So here it
goes (note that this only affects the bootstrap script, but we may use it
to automatically generate a defs.Linux.mk file or something...)

Index: bootstrap
===================================================================
RCS file: /cvsroot/othersrc/bootstrap-pkgsrc/bootstrap,v
retrieving revision 1.52
diff -u -u -r1.52 bootstrap
--- bootstrap	2003/02/21 11:31:41	1.52
+++ bootstrap	2003/02/24 17:07:31
@@ -53,44 +53,63 @@
 
 opsys=`uname -s`
 
+die()
+{
+	echo >&2 "$@"
+	exit 1
+}
+
+echo_msg()
+{
+	echo "===> $@"
+}
+
+check_prog() {
+	_var="$1"; _name="$2"
+
+	eval _tmp=\"\$$_var\"
+	if [ "x$_tmp" != "x" ]; then
+		# Variable is already set (by the user, for example)
+		echo "$_name is $_tmp"
+		return 0
+	fi
+
+	for _d in `echo $PATH | tr ':' ' '`; do
+		if [ -x "$_d/$_name" ]; then
+			# Program found
+			eval $_var=\""$_d/$_name"\"
+			echo "$_name is $_d/$_name"
+			return 1
+		fi
+	done
+
+	die "$_name not found."
+}
+
+overpath=""
 case "$opsys" in
 Darwin)
-	awkprog=/usr/bin/awk
-	cpprog=/bin/cp
-	idprog=/usr/bin/id
-	lsprog=/bin/ls
-	mkdirprog=/bin/mkdir
-	rmdirprog=/bin/rmdir
 	root_group=wheel
-	sedprog=/usr/bin/sed
 	need_pax=yes
 	need_mtree=no
 	need_bsd_install=no
 	set_opsys=no
 	;;
 FreeBSD)
-	awkprog=/usr/bin/awk
-	cpprog=/bin/cp
-	idprog=/usr/bin/id
-	lsprog=/bin/ls
-	mkdirprog=/bin/mkdir
-	rmdirprog=/bin/rmdir
 	root_group=wheel
-	sedprog=/usr/bin/sed
 	need_pax=yes
 	need_mtree=yes
 	need_bsd_install=no
 	set_opsys=no
 	;;
 IRIX*)
-	awkprog=/bin/awk
-	cpprog=/bin/cp
-	idprog=/bin/id
-	lsprog=/bin/ls
-	mkdirprog=/bin/mkdir
-	rmdirprog=/bin/rmdir
+	if [ -d "/usr/freeware/bin" ]; then
+		overpath="/usr/freeware/bin:$overpath"
+	fi
+	if [ -d "/usr/bsd/bin" ]; then
+		overpath="/usr/bsd/bin:$overpath"
+	fi
 	root_group=sys
-	sedprog=/bin/sed
 	need_mtree=yes
 	need_bsd_install=yes
 	need_pax=yes
@@ -102,56 +121,31 @@
 	if [ -f /etc/debian_version ]; then
 		DEBIAN=yes
 	fi
-	awkprog=/usr/bin/awk
-	cpprog=/bin/cp
-	idprog=/usr/bin/id
-	lsprog=/bin/ls
-	mkdirprog=/bin/mkdir
-	rmdirprog=/bin/rmdir
 	root_group=root
-	sedprog=/bin/sed
 	need_pax=yes
 	need_mtree=yes
 	need_bsd_install=no
 	set_opsys=no
 	;;
 NetBSD)
-	awkprog=/usr/bin/awk
-	cpprog=/bin/cp
-	idprog=/usr/bin/id
-	lsprog=/bin/ls
-	mkdirprog=/bin/mkdir
-	rmdirprog=/bin/rmdir
 	root_group=wheel
-	sedprog=/usr/bin/sed
 	need_pax=no
 	need_mtree=no
 	need_bsd_install=no
 	set_opsys=no
 	;;
 OpenBSD)
-	awkprog=/usr/bin/awk
-	cpprog=/bin/cp
-	idprog=/usr/bin/id
-	lsprog=/bin/ls
-	mkdirprog=/bin/mkdir
-	rmdirprog=/bin/rmdir
 	root_group=wheel
-	sedprog=/usr/bin/sed
 	need_pax=yes
 	need_mtree=no
 	need_bsd_install=no
 	set_opsys=no
 	;;
 SunOS)
-	awkprog=/usr/bin/nawk
-	cpprog=/usr/bin/cp
-	idprog=/usr/xpg4/bin/id
-	lsprog=/usr/bin/ls
-	mkdirprog=/bin/mkdir
-	rmdirprog=/bin/rmdir
+	if [ -d "/usr/xpg4/bin" ]; then
+		overpath="/usr/xpg4/bin:$overpath"
+	fi
 	root_group=root
-	sedprog=/usr/xpg4/bin/sed
 	need_pax=yes
 	need_mtree=yes
 	need_bsd_install=no
@@ -159,14 +153,7 @@
 	;;
 *)
 	echo "This platform ($opsys) is untried - good luck, and thanks for using pkgsrc"
-	awkprog=awk
-	cpprog=cp
-	idprog=id
-	lsprog=ls
-	mkdirprog=mkdir
-	rmdirprog=rmdir
 	root_group=wheel
-	sedprog=sed
 	need_pax=yes
 	need_mtree=yes
 	need_bsd_install=yes
@@ -174,16 +161,18 @@
 	;;
 esac
 
-die()
-{
-	echo >&2 "$@"
-	exit 1
-}
+if [ "x${PRESERVE_PATH:=yes}" != "xyes" ]; then
+	PATH="$overpath:$PATH"
+fi
 
-echo_msg()
-{
-	echo "===> $@"
-}
+echo_msg "Checking for basic tools"
+check_prog awkprog awk
+check_prog cpprog cp
+check_prog idprog id
+check_prog lsprog ls
+check_prog mkdirprog mkdir
+check_prog rmdirprog rmdir
+check_prog sedprog sed
 
 if [ `$idprog -u` != 0 ]; then
 	die "You must be root to set up pkgsrc for $opsys"




On Mon, 24 Feb 2003 11:58:56 -0500
Jan Schaumann <jschauma@netmeister.org> wrote:

> "Jeremy C. Reed" <reed@reedmedia.net> wrote:
> > On Mon, 24 Feb 2003 nb-pr@gendalia.org wrote:
> > 
> > > pkgsrc/mk/defs.Linux.mk:SED?=            /bin/sed
> > > but it's in /usr/bin/sed
> > 
> > On my Linux box, I added to my mk.conf:
> > 
> > EGREP=          /usr/bin/egrep
> > FGREP=          /usr/bin/fgrep
> > GREP=           /usr/bin/grep
> > BASENAME=       /usr/bin/basename
> > 
> > (These are not under /bin according to the Filesystem Hierarchy Standard;
> > sed is under /bin. Linux is not Linux.)
> 
> I wonder if maybe we should make a decision regarding this Linux-mess.
> I'd say we follow a 'best reasonable effort' during bootstrap-process
> (similar to what Julio suggested), but note if we deviate from FHS or
> LSB standards.  If so, we warn the user and set some extra stuff in
> /etc/mk.conf similar to what Jeremy does here.
> 
> How does that sound?
> 
> > For the fix in defs.Linux.mk, they should probably just be set to
> > command name (no path), just like CMP is set.
> 
> Hmm, I don't think that's a wise idea.  The whole point of using a full
> path is to avoid the problems resulting in different people having
> different versions in different orders in their PATH variable.  We
> shouldn't rely on that.
> 
> -Jan
> 
> -- 
> Of course it runs NetBSD!		http://www.netbsd.org


-- 
Julio M. Merino Vidal <jmmv@menta.net>
The NetBSD Project - http://www.NetBSD.org/