Table of content
Upgrading FreeBSD installation and packages from source.
Only the upgrading process from sources will be detailed here. For a
binary upgrade, the tools to use are freebsd-update
for the base
system and pkg upgrade
for the packages.
- Updating from SVN is deprecated (SVN repository has been closed in April 2021).
Accelerated compilation
It is possible to accelerate the compilation stage by introducing one or more of the following strategies:
- using a filesystem in memory
- caching files generated by the preprocessor
- distributing compilation accros computers
Memory filesystem
If you have enough RAM, it is possible to reduce the updating time by choosing a filesystem in memory rather than on disk for the various compilation stages. The amount of memory to allocate depends of course on the available resources and what will need to be updated (system, ports).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
Use of ccache and distcc
- Man pages: ccache (1), distcc (1)
Since FreeBSD 11.0, packages and distribution can be build using
ccache
by simply adding WITH_CCACHE_BUILD=yes
respectively in /etc/make.conf
and /etc/src.conf
.
The compilation and installation is performed through:
- For
ccache
: - For
distcc
-
For computers which participate in the distributed compilation, the
distccd
daemon must be enabled, this step is not necessary for the computer starting the compilation as it will be referred to with the special keyword localhost. Configuration is realised in the/etc/rc.conf
file:
Here are the possible invocations for the ccache
and
distcc
programs and their combination when using the
cc
compiler:
Program | Type of use | ||
---|---|---|---|
ccache | distcc | command line | path modification |
✓ | ccache cc |
/usr/local/libexec/ccache |
|
✓ | distcc cc |
/usr/local/libexec/distcc |
|
✓ | ✓ | env CCACHE_PREFIX=distcc ccache cc |
not possible |
In the case of the path modification, the path above must appear first
in the PATH
environment variable so that the corresponding wrappers
are called. This PATH
modification allows to avoid making
modifications to scripts. However, for that, the compilers must be
called without a specified path, and a joint use of ccache and distcc
is not possible.
It is then possible to start the compilation by enabling the various
accelerations using the variables USE_CCACHE
and USE_DISTCC
; either by
placing them in the /etc/make.conf
file or by setting them as
parameter in make:
1 2 |
|
The DISTCC_HOSTS
must be an environment variable. However, it is
possible to use the $DISTCC_DIR/hosts
file instead, but beware of the
$DISTCC_DIR
value, especially if it has been redefined.
The main parameters and options defining the computer contact list used to distribute the compilation are described below:
Parameter | Description |
---|---|
–randomize | Use the listed computer in a random order |
Computer | Description |
---|---|
localhost | Keyword allowing to directly use this local computer |
ip | IP address to connect to |
hostname | Computer to connect to after name resolution |
Option | Description |
---|---|
,lzo | Set up compression, particularly useful if the network is slow |
/limit | Limit the number of simultaneous connections to avoid overload |
:port | Port number to use if it is not the standard one |
Base distribution
- Man pages: src.conf (5)
1 2 3 4 5 6 |
|
The /etc/src.conf
file can control what will be included or
excluded from the base distribution. This will be used to remove tools
or hardware support for obsolete or not commonly used items, enable
extra features such as NAND and DTrace support.
Use of ccache
can be enabled to decrease build time,
useful only if the base system is compiled regularly:
Add support for debugging with DTrace:
Build extra components, like nand memory support:
Use retpoline to protect against CVE-2017-5715: Speculative execution vulnerabilities
Remove i386 support, as it’s not needed anymore on modern system:
Remove support for obsolete hardware or unused components:
Don’t include test infrastructure:
If building a server we don’t need support for wireless communication:
Now that the build options have been configured in /etc/rc.conf
,
we will describe the standard build process,
but don’t forget to take a look at /usr/src/UPDATING
for detailed instructions:
1 2 3 4 5 6 7 8 9 10 |
|
If you are using sendmail
it is necessary to update
it’s configuration by running:
1 |
|
To ensure that applications are using the last API, one could wish to rebuild all the packages
Ports and packages
- Man pages: make.conf (5)
First, you need to retrieve the necessary sources according to your
release of FreeBSD. This is done with the git
command:
1 2 3 4 5 6 |
|
1 2 |
|
To upgrade the packages, you will need to update the ports, build the index, fetch all the applications sources (this step is not necessary but will avoid problems if a source is missing in the middle of an upgrade), read the upgrade notice, create a snapshot (to have the possibility to rollback if something goes wrong) and finally upgrade:
1 2 3 4 5 6 7 |
|
If for some reason, the upgrade broke things, you can rollback to the
previous stable state. Nevertheless, be careful because some
applications once runned may have updated their data in an
incompatible format with previous versions (ex: mysql_upgrade
):
1 |
|
- Clean up
-
After several upgrades, it is possible that little bugs in ports definition lead to residual files, without forgetting that shared libraries are not deleted but moved to
/usr/local/lib/compat/pkg/
byportupgrade
.Be wise in removing files, you need to be sure that they are not needed, don’t blindly remove files returned by:
1 2 3 4 5
# Unused libraries libchk # installed from: /usr/ports/sysutils/libchk # Orphaned files find /usr/local/ -type f \ -exec sh -c ' pkg which -q "$0" > /dev/null || echo "$0" ' {} \;