Lampros - Weird Bricks

Building a package from a port

28 December, 2014 | MongoDB

These instructions have been tested on a 4GB RAM, 2 vCPUs VPS - nope I don't work for them, but I'm quickly becoming a huge fan

1. Update pkg:

env ASSUME_ALWAYS_YES=YES pkg upgrade

2. Get the ports tree

time portsnap fetch extract

Took about 5 minutes:

110.871u 165.742s 5:03.28 91.2% 62+167k 7361+5099io 32pf+0w

3. Make sure SSL and SASL are added

We want to install Mongo and make sure it compiles with both SSL and SASL enabled - let's check what the default port options are , shall we?

cd /usr/ports/databases/mongodb
make showconfig


===> The following configuration options are available for mongodb-2.6.6:
     SASL=off: SASL authentication support
     SSL=on: SSL protocol support
     TEST=off: Add support for running regression test
===> Use 'make config' to modify these settings

4. How do we enable SASL so we don't get the prompts?

grep OPTIONS_ Makefile

^ That's how - we add 'SASL' next to 'SSL' in 'OPTIONS_DEFAULT'

5. Use AWK to modify the file in a single command:

awk '{ gsub("OPTIONS_DEFAULT=SSL","OPTIONS_DEFAULT=SSL SASL" ) ; print }' Makefile > Makefile2

Backup the original Makefile

mv Makefile Makefile.backup

Rename Makefile2 to Makefile

mv Makefile2 Makefile

6. Check that it worked:

make showconfig
===> The following configuration options are available for mongodb-2.6.6:
     SASL=on: SASL authentication support
     SSL=on: SSL protocol support
     TEST=off: Add support for running regression test
===> Use 'make config' to modify these settings

Looks like it worked.

7. Now prefetch all source files for Mongo and all dependencies:

time make fetch-recursive

8. Get a list of ports that Mongo depends on

We'll install some of the port dependencies using packages to make things faster (in this case we won't get any benefit from installing perl/python from ports!)

make all-depends-list



9. Let's try installing some of those with pkg:

env ASSUME_ALWAYS_YES=YES pkg install scons pcre snappy v8 python27 m4 gmake perl5 gettext-tools libffi

10. Now to compile with no prompts/interruptions:

setenv BATCH yes; time make install clean

We got no prompts and the following output (took 29 minutes and 31 seconds to compile)

===>  Cleaning for cyrus-sasl-2.1.26_9
===>  Cleaning for mongodb-2.6.6
2466.164u 257.914s 29:31.00 153.8%      25917+543k 3527+394210io 1246pf+28w

11. Now create a pkg out of the port:

pkg create mongodb-2.6.6


Creating package for mongodb-2.6.6

12. And here's our package:

ls -alh mongodb-2.6.6.txz
-rw-r--r--  1 root  wheel    46M Dec 28 03:24 mongodb-2.6.6.txz

13. Now let's copy the mongodb-2.6.6.txz package to a brand new system that has nothing installed:

scp mongodb-2.6.6.txz root@
The authenticity of host ' (' can't be established.
ECDSA key fingerprint is 48:8f:84:f1:78:e3:ab:c3:3d:e0:17:b0:86:4c:a1:4b.
No matching host key fingerprint found in DNS.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '' (ECDSA) to the list of known hosts.
Password for root@mongotest2:
mongodb-2.6.6.txz                                                                         100%   46MB  15.5MB/s   00:03

14. Install the package on the brand new system:

env ASSUME_ALWAYS_YES=YES pkg install mongodb-2.6.6.txz

The output is too long to copy paste here, so instead let's take a look at the installed packages:

pkg info
cyrus-sasl-2.1.26_9            RFC 2222 SASL (Simple Authentication and Security Layer)
gettext-runtime-0.19.3         GNU gettext runtime libraries and programs
indexinfo-0.2                  Utility to regenerate the GNU info page index
libffi-3.0.13_3                Foreign Function Interface
mongodb-2.6.6                  NOSQL distributed document-oriented database
pcre-8.35_2                    Perl Compatible Regular Expressions library
pkg-1.4.1                      Package manager
python2-2_3                    The "meta-port" for version 2 of the Python interpreter
python27-2.7.9                 Interpreted object-oriented programming language
snappy-1.1.1_1                 Fast compressor/decompressor library
v8-3.18.5                      Open source JavaScript engine by Google

As you can see pkg installed the mongo package we built plus all of it's dependencies - over 25 minutes saved in compiling time :)


Unattended port installation and FreeBSD setup"

StackExchange - How can I avoid the prompts when installing a FreeBSD port?