Subject: Re: help with bootstrap-pkgsrc on Debian Linux 3.0?
To: None <tech-pkg@netbsd.org>
From: Jeremy C. Reed <reed@reedmedia.net>
List: tech-pkg
Date: 10/30/2002 01:25:48
I am now building pkgsrc packages under Debian Linux 3.0  :)

See all my comments (and diffs) for bootstrap-pkgsrc below.

On Tue, 29 Oct 2002, Jeremy C. Reed wrote:

> Here are the problems:

Due to typo, I had different prefix and localbase. I made them the same.

Here are some of my fixes and work arounds.

I have a diff at end also.

> gcc *.o lst.lib/*.o -o bmake.boot
> lst.lib/lstAppend.o: In function `Lst_Append':
> lst.lib/lstAppend.o(.text+0x0): multiple definition of `Lst_Append'

I see these lst*.o files are located in two places. I manually removed
bmake/lst.o (each time) and did bootstrap again. This needs to be fixed
still.

> install   -c -s   -o root -g wheel -m 555 bmake
> /home/jeremy/usr/pkg/bin/bmake
> install: invalid group `wheel'

In bootstrap, if Linux then exported BINGRP=root.

> pen.c:271: redefinition of `struct statfs'
> pen.c: In function `vfs2fs':
> pen.c:361: structure has no member named `val'
> pen.c:364: structure has no member named `f_basetype'

I changed to pen.c
#ifndef HAVE_STATVFS

Also received:

make[1]: Entering directory
`/home/jeremy/netbsd/othersrc/bootstrap-pkgsrc/pkg_install/lib
...
gcc -DHAVE_CONFIG_H -I. -I.  -g -O2 -c unsetenv.c -o unsetenv.o
unsetenv.c:47: conflicting types for `unsetenv'
/usr/include/stdlib.h:607: previous declaration of `unsetenv'

I see it has:
#ifndef HAVE_UNSETENV

but this HAVE_UNSETENV is never set!

So I added
AC_CHECK_FUNCS(unsetenv)
to bootstrap-pkgsrc/pkg_install/configure.in

And I added

/* Define if you have the unsetenv function.  */
#undef HAVE_UNSETENV

to bootstrap-pkgsrc/pkg_install/lib/config.h.in

(I didn't run autoconf, I also manually patched.)

And added

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

to that unsetenv.c.

These should be fixed in original pkg_install source.

> /home/jeremy/usr/pkg/sbin

"sbin" is really binary mtree (not a directory).
I made bootstrap mkdir the sbin directory too (but I guess this should be
done in the install target for the mtree). (Unrelated: but I have had
similar situations with install(1) where it created files instead of
placing in directories that needed to be created.)

And another problem:

===> Installing for digest-20010807
/bin/sh: /usr/pkg/sbin/pkg_info: No such file or directory
/bin/sh: /usr/pkg/sbin/mtree: No such file or directory

Now I see that because it uses Linux, then ZOULARISBASE should have been
set to. So I modified bootstrap to do that.

Then the next error was group wheel again. So I modified bootstrap to set
ROOT_GROUP too.

Then more group wheel problems.

The best fix would to have all these in bmake/mk/bsd.own.mk and
usr/pkg/share/mk/bsd.own.mk set to
 ${BINGRP}
like
LIBGRP?=        ${BINGRP}
already does.

So I patched bsd.own.mk.

I also want all these set in my mk.conf. And I want MAKECONF to be in my
prefix. This should be done so pkgsrc can be automatically ready to use.

So I patched bootstrap some more so it could generate a mk.conf.

So I set my MAKECONF to that generated mk.conf. It looks like
BINGRP=root
ROOT_GROUP=root
ZOULARISBASE=/home/jeremy/netbsd/usr/pkg
PKG_DBDIR=/home/jeremy/netbsd/var/db/pkg
LOCALBASE=/home/jeremy/netbsd/usr/pkg
FETCH_CMD=/home/jeremy/netbsd/usr/pkg/bin/ftp

So I exported MAKECONF to my new mk.conf and I could build and install
some packages :)

# PKG_DBDIR=/home/jeremy/netbsd/var/db/pkg pkg_info
digest-20010807     Message digest wrapper utility
gethost-0.03        hostname and IP resolver for testing /etc/hosts and nsswitch
vim-share-6.1.0     Data files for the vim editor (vi clone)
vim-6.1.0           Vim editor (vi clone) without gui

(pkgsrc/audio/libao won't build. I'll look at this later.)

By the way, at least these packages need to be registered after doing this
bootstrap: bmake, mtree and pkg_install.

Please consider some of these ideas and a diff is below.

   Jeremy C. Reed
   http://www.reedmedia.net/

p.s. here is the diffs ...

--- ./bmake/mk/bsd.own.mk.orig	2002-10-30 00:27:45.000000000 -0800
+++ ./bmake/mk/bsd.own.mk	2002-10-30 01:08:26.000000000 -0800
@@ -26,13 +26,13 @@
 #MANZ=		1

 MANDIR?=	/usr/share/man
-MANGRP?=	wheel
+MANGRP?=	${BINGRP}
 MANOWN?=	root
 MANMODE?=	${NONBINMODE}
 MANINSTALL?=	maninstall catinstall

 INFODIR?=	/usr/share/info
-INFOGRP?=	wheel
+INFOGRP?=	${BINGRP}
 INFOOWN?=	root
 INFOMODE?=	${NONBINMODE}

@@ -44,22 +44,22 @@

 DOCDIR?=	/usr/share/doc
 HTMLDOCDIR?=	/usr/share/doc/html
-DOCGRP?=	wheel
+DOCGRP?=	${BINGRP}
 DOCOWN?=	root
 DOCMODE?=	${NONBINMODE}

 NLSDIR?=	/usr/share/nls
-NLSGRP?=	wheel
+NLSGRP?=	${BINGRP}
 NLSOWN?=	root
 NLSMODE?=	${NONBINMODE}

 KMODDIR?=	/usr/lkm
-KMODGRP?=	wheel
+KMODGRP?=	${BINGRP}
 KMODOWN?=	root
 KMODMODE?=	${NONBINMODE}

 LOCALEDIR?=	/usr/share/locale
-LOCALEGRP?=	wheel
+LOCALEGRP?=	${BINGRP}
 LOCALEOWN?=	root
 LOCALEMODE?=	${NONBINMODE}

--- ./pkg_install/lib/pen.c.orig	2002-10-30 01:02:42.000000000 -0800
+++ ./pkg_install/lib/pen.c	2002-10-30 01:02:59.000000000 -0800
@@ -221,7 +221,7 @@
 	signal(SIGINT, oldsig);
 }

-#ifdef HAVE_STATVFS
+#ifndef HAVE_STATVFS
 /*	$NetBSD: pen.c,v 1.3 2002/10/28 14:42:18 bouyer Exp $	*/

 /*-
--- ./pkg_install/lib/unsetenv.c.orig	2002-10-30 01:04:13.000000000 -0800
+++ ./pkg_install/lib/unsetenv.c	2002-10-30 01:04:22.000000000 -0800
@@ -39,6 +39,10 @@
 #include <string.h>
 #include <stdlib.h>

+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 extern char **environ;

 #ifndef HAVE_UNSETENV
--- ./pkg_install/lib/config.h.in.orig	2002-10-30 01:04:52.000000000 -0800
+++ ./pkg_install/lib/config.h.in	2002-10-30 01:04:57.000000000 -0800
@@ -36,6 +36,9 @@
 /* Define if you have the setenv function.  */
 #undef HAVE_SETENV

+/* Define if you have the unsetenv function.  */
+#undef HAVE_UNSETENV
+
 /* Define if you have the setprogname function.  */
 #undef HAVE_SETPROGNAME

--- ./pkg_install/configure.in.orig	2002-10-30 01:04:34.000000000 -0800
+++ ./pkg_install/configure.in	2002-10-30 01:04:39.000000000 -0800
@@ -39,6 +39,7 @@
 AC_CHECK_FUNCS(getprogname)
 AC_CHECK_FUNCS(mkdtemp)
 AC_CHECK_FUNCS(setenv)
+AC_CHECK_FUNCS(unsetenv)
 AC_CHECK_FUNCS(setprogname)
 AC_CHECK_FUNCS(statvfs)
 AC_CHECK_FUNCS(strsep)
--- ./bootstrap.orig	2002-10-30 01:03:32.000000000 -0800
+++ ./bootstrap	2002-10-30 01:03:39.000000000 -0800
@@ -45,6 +45,9 @@
 # versions of tar files used here
 digestversion=digest-20020726

+# make a mk.conf with some settings this figures out
+: > mk.conf.temp
+
 opsys=`uname -s`

 case "$opsys" in
@@ -66,6 +69,12 @@
 	rmdirprog=/bin/rmdir
 	sedprog=/bin/sed
 	need_mtree=yes
+	BINGRP=root export BINGRP
+        echo "BINGRP=root" >> mk.conf.temp
+	ROOT_GROUP=${BINGRP} export ROOT_GROUP
+	echo "ROOT_GROUP=${BINGRP}" >> mk.conf.temp
+	ZOULARISBASE=${LOCALBASE} export ZOULARISBASE
+	echo "ZOULARISBASE=${LOCALBASE}" >> mk.conf.temp
 	;;
 NetBSD)
 	cpprog=/bin/cp
@@ -137,10 +146,12 @@
 	PATH=/usr/ccs/bin:$PATH; export PATH
 fi
 PKG_DBDIR=$pkgdbdir; export PKG_DBDIR
+echo "PKG_DBDIR=$pkgdbdir" >> mk.conf.temp
 LOCALBASE=$prefix; export LOCALBASE
+echo "LOCALBASE=$prefix" >> mk.conf.temp

 # create directories
-$mkdirprog -p $prefix $pkgdbdir
+$mkdirprog -p $prefix $pkgdbdir $prefix/sbin

 # bootstrap make and *.mk files
 $mkdirprog -p $prefix/share/mk $prefix/lib
@@ -163,7 +174,11 @@
 NetBSD)	$cpprog mods/bmake/Makefile.in bmake/Makefile.in
 	;;
 esac
-(cd bmake; ./configure --prefix=$prefix --with-default-sys-path=$prefix/share/mk; make -f makefile.boot bootstrap; env BINDIR=$prefix/bin ./bmake -f Makefile install)
+(cd bmake; ./configure --prefix=$prefix --with-default-sys-path=$prefix/share/mk&& make -f makefile.boot bootstrap && env BINDIR=$prefix/bin ./bmake -f Makefile install)
+
+if [ $? -ne 0 ] ; then
+  die "install of bmake failed."
+fi

 # bootstrap lukemftp
 case "$DEBIAN" in
@@ -171,26 +186,40 @@
 	LIBS="-lncurses"
 	;;
 esac
-(cd lukemftp; ./configure --disable-ipv6 --prefix=$prefix && make)
-(cd lukemftp/src; make install)
+(cd lukemftp; ./configure --disable-ipv6 --prefix=$prefix && make &&
+(cd lukemftp/src; make install))
+
+if [ ! -x "$prefix/bin/ftp" ] ; then
+  die "install of lukemftp ($prefix/bin/ftp) failed."
+  exit 1
+fi

 FETCH_CMD=$prefix/bin/ftp
 export FETCH_CMD
+echo "FETCH_CMD=$prefix/bin/ftp" >> mk.conf.temp

 # bootstrap digest
-(cd digest; ./configure --prefix=$prefix && make)
-(cd digest; make install)
+(cd digest; ./configure --prefix=$prefix && make &&
+(cd digest; make install))
+
+if [ $? -ne 0 ] ; then
+  die "install of digest failed."
+fi

 # create the digest package's meta files
 env DIGESTPROG=$prefix/bin/digest PKG_DIGEST=md5 PKG_DBDIR=$pkgdbdir ./pkg.sh create -d $pkgsrcdir/pkgtools/digest/DESCR -O -c '-Message digest wrapper utility' -l -p $prefix -f digest-PLIST $digestversion

 # bootstrap pkg_install
-(cd pkg_install; ./configure --prefix=$prefix && make)
-(cd pkg_install; make install)
+(cd pkg_install; ./configure --prefix=$prefix && make &&
+(cd pkg_install; make install))
+
+if [ $? -ne 0 ] ; then
+  die "install of pkg_install failed."
+fi

 # bootstrap mtree if necessary
 case "$need_mtree" in
-yes)	(cd mtree; ./configure --prefix=$prefix && make && make install)
+yes)	(cd mtree; ./configure --prefix=$prefix && make && make install || die "install of mtree failed.")
 	;;
 esac

@@ -203,8 +232,16 @@
 rm -rf $pkgdbdir/digest-* $pkgdbdir/pkgdb.byfile.db
 (cd $pkgsrcdir/pkgtools/digest; $prefix/bin/bmake clean && $prefix/bin/bmake && $prefix/bin/bmake install)

+if [ $? -ne 0 ] ; then
+  die "install of digest package via pkgsrc failed."
+fi
+
 echo "Please remember to add $prefix/bin to your PATH environment variable"
 echo "Please remember to set FETCH_CMD in /etc/mk.conf to $prefix/bin/ftp"
+#echo ""
+#echo "A mk.conf was also created to $prefix/mk.conf"
+#echo "Set MAKECONF to $prefix/mk.conf to use it."
+#echo "Or please remember to set FETCH_CMD in /etc/mk.conf to $prefix/bin/ftp"
 echo ""
 echo "Hopefully everything is now complete"