These instructions are unsupported. Developers use the dev mailing list.


pfSense developer building bootstrapping - building a custom pfSense image


This document will go over the steps necessary in order to produce an environment where pfSense images can be built. Note that this used to include a "developer" ISO but that no longer works and is not officially supported. Following this guide will get you a bootable ISO and memstick image, and potentially NanoBSD images.

0. Install FreeBSD 8.1 ( http://www.freebsd.org/doc/en/books/handbook/install.html ) for pfSense 2.0.x images ... or FreeBSD 8.3 if you want to build pfSense 2.1.

1. Begin pfSense bootstrap by running these shell commands:

echo "WITHOUT_X11=yo" >> /etc/make.conf
echo "OPTIONS_UNSET=X11" >> /etc/make.conf
echo "BATCH=yo" >> /etc/make.conf
mkdir -p /home/pfsense/pfSenseGITREPO /usr/pfSensesrc

2. Grab ports and build GIT
portsnap fetch extract 
cd /usr/ports/textproc/expat2 && make depends install
cd /usr/ports/devel/git && make depends install
cd /usr/ports/sysutils/fastest_cvsup/ && make depends install
# tcsh requires reloading available binaries - if you run this command and it fails -- don't worry.
rehash   

3. Continue on with the GIT repo checkouts:
cd /home/pfsense && git clone git://github.com/pfsense/pfsense-tools.git tools
cd /home/pfsense && git clone https://github.com/pfsense/freesbie2.git freesbie2
cd /home/pfsense/tools/builder_scripts && chmod a+rx *.sh

4. Ensure FreeBSD sources are present
Some ports require sources in /usr/src to build correctly.
csup -h `fastest_cvsup -c tld -q` /usr/share/examples/cvsup/standard-supfile

5. Invoke our new menu system by running:
cd /home/pfsense/tools/builder_scripts 
./menu.sh

Note: You can use the following command if you do not wish to use the menu:
./set_version.sh

5.1. After invoking the menu system set the version you would like to build
Versions available are in the radio box or select custom and enter one of:
RELENG_1_2 pfSense RELENG_1_2 + FreeBSD RELENG_7_2
RELENG_2_0 pfSense HEAD (2.0) + FreeBSD RELENG_7_2
RELENG_7_2 pfSense RELENG_1_2 + FreeBSD RELENG_7_2
RELENG_8_0 pfSense HEAD + FreeBSD 8-CURRENT


5.2. Invoke the Apply patches option
This will fetch the version of FreeBSD required and apply our patches. You should not see any errors during this step.

To run this outside of the menu system, use:
./apply_kernel_patches.sh


5.2a Ensure BSDInstaller is sound
rm -rf /home/pfsense/installer
./get_bsdinstaller.sh ; ./rebuild_bsdinstaller.sh


5.3 Invoke the Build ISO option
pfSense will now build an iso. Sit back and wait while the operation proceeds.

To run this outside of the menu system, use:
./build_iso.sh


5.4 Plan for failure
It is expected that the first try to build the ports, and the first try to build an ISO will fail, but subsequent attempts work. This is because certain parts expect files or binaries to be present that get built on the first run but not fully used until the second. This may get fixed eventually, but because the workaround is easy (just run the build again), it's not a priority.

6. Testing
If all goes well you should have a pfSense.iso in /usr/obj.pfSense ... Test it.

7. Keeping in sync with pfSense Repo's
Invoke the Sync command to update tools and freesbie sources with rcs.pfsense.org.

8. Other images available for building
Once you have a working ISO you can build pretty much any pfSense image listed in the menu system.

9. Updating pfPorts
Occasionally when updating the tools repo you might find that there have been updates to ports included therein:
# find files in pfPorts modified in the last day
find /home/pfsense/tools/pfPorts/ -mtime 1
# List of files will be output, from there, find a port to update (if relevant), and then run:
./build_pfPorts.sh <portname>
For example, to update lighttpd, run:
./build_pfPorts.sh lighttpd

Troubleshooting
Should the ports become very far out of date, to the point where some fail to (re)build, run:
portsnap fetch extract
pkg_delete \*
And then do step 2 again to rebuild git and such, then
rm /tmp/pfSense_do_not_build_pfPorts
./build_pfPorts.sh
...
If for some reason the build goes wrong you can wipe out *ALL* of /usr/local/ and restore back to a after installation state and start over completely by invoking the Clean option of menu system.
...
If you need to update your repository URLs after they have moved, you can run
cd /home/pfsense/tools/ && git remote set-url origin git://github.com/pfsense/pfsense-tools.git && git fetch && git rebase origin && cd /home/pfsense/tools/builder_scripts && ./fixup_git_repo_urls.sh && ./update_git_repos.sh

If that fails, you may need to run:
cd /home/pfsense/tools/
git reset --hard origin
cd /home/pfsense/tools/builder_scripts/ && ./update_git_repos.sh && ./fixup_git_repo_urls.sh && ./update_git_repos.sh

Further Reading
Also see http://devwiki.pfsense.org/CreatingAnAppliance
Notes available on MIPS builds MIPSNotes

alias builder_scripts 'cd /home/pfsense/tools/builder_scripts'
alias builder_profiles 'cd /home/pfsense/tools/builder_scripts/builder_profiles'
alias build_iso.sh 'cd /home/pfsense/tools/builder_scripts && ./build_iso.sh'
alias update_git_repos.sh 'cd /home/pfsense/tools/builder_scripts && ./update_git_repos.sh'
alias clean_build.sh 'cd /home/pfsense/tools/builder_scripts && ./clean_build.sh'
alias build_nano.sh 'cd /home/pfsense/tools/builder_scripts && ./build_nano.sh'
alias apply_kernel_patches.sh 'cd /home/pfsense/tools/builder_scripts && ./apply_kernel_patches.sh'

Valid XHTML :: Valid CSS: :: Powered by WikkaWiki