Wednesday, 28 March 2012

FreeBSD Port Install info

Here's an overview of what happens when you go to a port's directory and type make install.

The process starts with make fetch. If the source code isn't in /usr/ports/distfiles, your system goes to the MASTER_SITE specified in the Makefile and gets it.

Then, make checksum confirms that the distfile's hashed signature matches the one that the port has on file. This is meant as a security measure; if the source code contains a Trojan horse loaded by an attacker, this process will detect it and stop the build with a warning about a checksum mismatch.

Of course, make checksum also stops compilation if the distfile has been deliberately changed. Software authors might make a minor change in their code, but give the source file the same name when they make it available for download. The FreeBSD port might or might not work after this change. If you're sure that the distfile has not been compromised and want to try it anyway, you can override this with make NO_CHECKSUM=YES.

The make depends stage checks to see if the port requires any other software to install. For example, an X window manager requires an X server. Recursing through the various dependencies, make depends builds them as needed.

To create a work directory and uncompress the distfile, use make extract.

A port contains patches, if necessary, to allow the software to build under FreeBSD; make patch applies them.

Any configure script in the source code is run by make configure.

The make build stage compiles the checked, extracted, and patched software.

Finally, make install installs the software and records its presence under /var/db/pkg.

Whenever you use a make target, all previous stages are run. For example, a make extract runs through make fetch, make checksum, and make extract.

Build Port with Debugs

Try this:

make WITH_DEBUG=yes install clean

WITH_DEBUG adds -g to the CFLAGS and prevents the binary from being
stripped during installation.

Modify a Port

1) Go in to the port directory
2) Type make clean to remove any work directories
4) Type make patch to apply any patches that the port maintainer has included
5) Enter the directory where the problem source file is - usually work/portname-version/some subdir
6) Copy it to filename.c.orig (If the port maintainer has already patched filename.c, 'make patch' will already have created filename.c.orig) so you will need to move the current orig to a new name and then create you one.
7) Edit filename.c to include your changes
8) Diff the two files and put the resulting patch file in portdir/files

I.e., if filename.c is in work/foo-x.y/bar/ you should cd to
work/foo-x.y/ and then run

diff -u bar/filename.c.orig bar/filename.c > ../../files/patch-filename.c

10) Return to the portdir and type make clean
11) Type make extract and then make patch - if it works, you should be able to do the install - if it doesn't work, post the errors here
and we'll figure it out


Use this package to downgrade a select port

1) install
cd /usr/port/port-mgmt/portdowngrade
make install clean

setenv CVSROOT
portdowngrade png

Then select the version you want to downgrade too. After this go into the port and make install (or make deinstall / make reinstall)

No comments:

Post a Comment