Subject: Re: Dependent, but not available packages
To: Mike M. Volokhov <mishka@terabyte.com.ua>
From: Mike M. Volokhov <mishka@terabyte.com.ua>
List: tech-pkg
Date: 09/10/2003 18:49:04
On Tue, 09 Sep 2003 20:09:13 +0300
"Mike M. Volokhov" <mishka@terabyte.com.ua> wrote:

> Greetings!
> 
> For example, I need dependency on some package, and include it within
> 
> DEPENDS+=	foo:../../category/foo
> 
> Next, it might be occurs, when that "foo" package have the following
> line in its own Makefile:
> 
> NOT_FOR_PLATFORM=	MyPlaftorm-*-*
> 
> and my platform is listed there. In such case it shows me message
> about unavailabilty, and then... continues build process. Sometimes
> this not so critical, but often a package will not work without
> that dependent one.
> 
> Is it possible to handle the build process of my own packages
> and have the choice of stopping or continuing make in this situation?
> Or there is existent some other way?

I've investigate the "install-depends" target and found it calls
make(1) on each depend package, having set PKGNAME_REQD variable
to name of "parent" package. The "grep -rl PKGNAME_REQD pkgsrc/mk"
command shows me that bsd.pkg.mk file only is uses this variable.
So as PKGNAME_REQD is defined only when "install-depends" invoked,
it is possible to relatively safe determine, when make(1) should
stops, and when it should just show a warning and did a normal
exit (as in case of manual installation).

The following patch provides this functionality:

===================================================================
RCS file: /cvsroot/pkgsrc/mk/bsd.pkg.mk,v
retrieving revision 1.1268
diff -u -r1.1268 bsd.pkg.mk
--- bsd.pkg.mk	2003/09/10 02:20:50	1.1268
+++ bsd.pkg.mk	2003/09/10 11:36:40
@@ -1384,7 +1384,12 @@
 .    endif	# MACHINE_PLATFORM
 .  endfor	# __tmp__
 .  if !defined(__PLATFORM_OK)
+.    if defined(PKGNAME_REQD)
+PKG_FAIL_REASON+= "${PKGNAME} is not available for ${MACHINE_PLATFORM}" \
+	"    and can not be installed by dependency. Aborting."
+.    else
 PKG_SKIP_REASON+= "${PKGNAME} is not available for ${MACHINE_PLATFORM}"
+.    endif
 .  endif	# !__PLATFORM_OK
 
 #
===================================================================

However, this patch assume high claims to values of *_FOR_PLATFORM
variables, so as all packages (like noted by Michal Pasternak
mail/qmail-users) will fails on install.

We may use yet another variable called, for example, PKG_INVPLATFORM_FAIL.
Thus, the following lines

	PKG_INVPLATFORM_FAIL?=	YES
	.if defined(PKGNAME_REQD) && PKG_INVPLATFORM_FAIL == 'YES'

lets control make(1), when dependent package is mandatory, and when
it just recommended, and if it's so, don't fail build process.

--
BR, Mishka.