# Building and Installing Ports via a Meta-Port Fails



## mhugelmann (Dec 10, 2015)

Hello all,

Over the summer I built a FAMP server. To save myself time in the future, I read-up on how to create a meta-port to install all the software I needed in one go. My two main informational sources were: http://www.freebsddiary.org/meta-ports.php and https://forums.freebsd.org/threads/howto-creating-metaports.9137/

After creating the meta-port, I tested it on another machine with a vanilla FreeBSD 10.1 network installation. Everything worked as it should.

However, the hard drive in my server died recently, and I had no choice but to reinstall FreeBSD. I installed 10.1 again via the network installer. Once the install was done, I went to use the meta-port. Things seemed to go okay at first, but after trying to install the first port, it failed with an exit code of 1.

I was hoping someone could shed some light as to why this is, what I'm doing wrong, or maybe something that has changed. I've included below the Makefile for the meta-port, the command I issued to start the install process and the eventual output where the process fails.

Any insight or help is greatly appreciated.

Makefile:

```
# New ports collection makefile for: FreeBSD
# Date created:           2015.05.18
# Whom:                   ech0wav3 <ech0wav3@.com>
# $FreeBSD:$
#

PORTNAME= ech0wav3-server-famp
PORTVERSION=      1.0
CATEGORIES=       www
MASTER_SITES=
DISTFILES=

MAINTAINER=       ech0wav3@.com
COMMENT=  The meta-port for the famp ech0wav3 server

NO_BUILD= YES
NO_INSTALL=       YES
NO_WRKSUBDIR=   YES
USE_CDRTOOLS=     YES

BUILD_DEPENDS+= apache24:${PORTSDIR}/www/apache24
BUILD_DEPENDS+= mysql56-server:${PORTSDIR}/databases/mysql56-server
BUILD_DEPENDS+= php56:${PORTSDIR}/lang/php56
BUILD_DEPENDS+= php56-mysql:${PORTSDIR}/databases/php56-mysql
BUILD_DEPENDS+= php56-mysqli:${PORTSDIR}/databases/php56-mysqli
BUILD_DEPENDS+= mod_php56:${PORTSDIR}/www/mod_php56
BUILD_DEPENDS+= php56-xml:${PORTSDIR}/textproc/php56-xml
BUILD_DEPENDS+= php56-hash:${PORTSDIR}/security/php56-hash
BUILD_DEPENDS+= php56-curl:${PORTSDIR}/ftp/php56-curl
BUILD_DEPENDS+= php56-tokenizer:${PORTSDIR}/devel/php56-tokenizer
BUILD_DEPENDS+= php56-zlib:${PORTSDIR}/archivers/php56-zlib
BUILD_DEPENDS+= php56-zip:${PORTSDIR}/archivers/php56-zip

.include <bsd.port.mk>
```

The command issued once in the meta-port's directory: `make config-recursive install clean`

And finally, here's the output before failing (This is after trying a few different times, so users and groups were already made from before, but the exit code and error is the same as it was from the first time I ran it):

```
===> Setting user-specified options for ech0wav3-server-famp-1.0 and dependencies
===>  Staging for ech0wav3-server-famp-1.0
===>   ech0wav3-server-famp-1.0 depends on executable: apache24 - not found
===>  Installing for apache24-2.4.17
===>   apache24-2.4.17 depends on package: perl5>=5.20<5.21 - found
===>   apache24-2.4.17 depends on shared library: libexpat.so - found (/usr/local/lib/libexpat.so)
===>   apache24-2.4.17 depends on shared library: libapr-1.so - found (/usr/local/lib/libapr-1.so)
===>   apache24-2.4.17 depends on shared library: libpcre.so - found (/usr/local/lib/libpcre.so)
===>  Checking if apache24 already installed
===>   Registering installation for apache24-2.4.17 as automatic
Installing apache24-2.4.17...
===> Creating users and/or groups.
Using existing group 'www'.
Using existing user 'www'.
To run apache www server from startup, add apache24_enable="yes"
in your /etc/rc.conf. Extra options can be found in startup script.

Your hostname must be resolvable using at least 1 mechanism in
/etc/nsswitch.conf typically DNS or /etc/hosts or apache might
have issues starting depending on the modules you are using.

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

- apache24 default build changed from static MPM to modular MPM
- more modules are now enabled per default in the port
- icons and error pages moved from WWWDIR to DATADIR

   If build with modular MPM and no MPM is activated in
   httpd.conf, then mpm_prefork will be activated as default
   MPM in etc/apache24/modules.d to keep compatibility with
   existing php/perl/python modules!

Please compare the existing httpd.conf with httpd.conf.sample
and merge missing modules/instructions into httpd.conf!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

===> SECURITY REPORT:
      This port has installed the following files which may act as network
      servers and may therefore pose a remote security risk to the system.
/usr/local/libexec/apache24/mod_cgid.so

      This port has installed the following startup scripts which may cause
      these network services to be started at boot time.
/usr/local/etc/rc.d/apache24
/usr/local/etc/rc.d/htcacheclean

      If there are vulnerabilities in these programs there may be a security
      risk to the system. FreeBSD makes no guarantee about the security of
      ports included in the Ports Collection. Please type 'make deinstall'
      to deinstall the port if this is a concern.

      For more information, and contact details about the security
      status of this software, see the following webpage:
http://httpd.apache.org/
===>   ech0wav3-server-famp-1.0 depends on executable: apache24 - not found
*** Error code 1

Stop.
make: stopped in /root/metaports/ech0wav3-server-famp
```


----------



## tobik@ (Dec 10, 2015)

Here's an updated port:

```
# New ports collection makefile for: FreeBSD
# Date created:           2015.05.18
# Whom:                   ech0wav3 <ech0wav3@.com>
# $FreeBSD:$
#

PORTNAME=	ech0wav3-server-famp
PORTVERSION=	1.0
PORTREVISION=	1
CATEGORIES=	www

MAINTAINER=	ech0wav3@.com
COMMENT=	Meta-port for the famp ech0wav3 server

# Versions should be set in /etc/make.conf (but the defaults reflect
# your versions so there is no point in doing this right now)

USES=	metaport
USE_PHP=	mysql mysqli xml hash curl tokenizer zlib zip
# Pulls in Apache as well
WANT_PHP_MOD=	yes
USE_MYSQL=	server

.include <bsd.port.mk>
```
A couple of things:

I've not tested this port
Declare run dependencies in the metaport if you want pkg-autoremove(8) to work correctly
USE_CDRTOOLS does nothing so I removed it
There special support for PHP extensions
Same for MySQL
The Apache PHP module declares a dependency on an Apache server itself so you don't need to
AFAICT the PHP, MySQL and Apache versions should be declared in /etc/make.conf if you're not ok with the defaults
There is special metaport support (get it with USES=metaport) in the ports tree that removes the need to declare NO_{INSTALL,BUILD} and empty distfiles yourself etc.


----------



## mhugelmann (Dec 11, 2015)

Wow! Thanks for your response tobik!

It seems like a lot has changed with the ports system since those pages I referenced were written.

I have a follow-up/further question now: What about more generic or basic ports? If I wanted to install something like misc/figlet, how would I go about defining that in a meta-port? What about something like sysutils/screen? It has a dependency of devel/gmake, but nothing related to a valid USE_* variable.

Again, thank you for taking the time to respond with such a clear answer and thorough explanation. It is very greatly appreciated.


----------



## tobik@ (Dec 11, 2015)

mhugelmann said:


> What about more generic or basic ports? If I wanted to install something like misc/figlet, how would I go about defining that in a meta-port? What about something like sysutils/screen? It has a dependency of devel/gmake, but nothing related to a valid USE_* variable.


You add a run dependency. See the Porter's Handbook: https://www.freebsd.org/doc/en_US.I...ook/makefile-depend.html#makefile-run_depends


----------

