bryanburke
Dabbler
- Joined
- Nov 11, 2011
- Messages
- 11
IMPORTANT: Please read the guide completely to avoid confusion and prevent errors!
Good day, everyone! I've updated the guide and the patch for FreeNAS 8.0.3. This guide will show you how to upgrade the ports tree (almost) as a whole and even add ports like transmission-daemon to the FreeNAS image. This guide requires the ability to build FreeNAS 8.0.3 from source using the FreeBSD command-line; if you have no idea how to do this, consult joeschmuck's excellent guide in this same forum.
Note: This modification to the FreeNAS 8.0.3 source is NOT sponsored or supported by the development team. Do NOT send them any questions about this guide!
Note: I am NOT responsible for any damage that may occur to your data as a result of this method. If you are concerned about the safety of the following instructions, MAKE A BACKUP FIRST!
Note: I can only certify that this method works with the 8.0.3 source. Don't bug me with questions about older versions or trunk!
Note: Read all notes...
Step 1: Get the Sources
If you already have the 8.0.3 sources, skip to step 2.
We use svn just like we would for trunk, except we are pulling the 8.0.3-RELEASE tag instead:
The new folder created on your local machine (or virtual machine) is called "8.0.3-RELEASE" and is the root directory during the FreeNAS build. From here on I will simply call it FREENAS_ROOT.
Step 2: Patch the Build Script
Here is my unified diff which you can use to patch "build/do_build.sh":
Copy that code and place it in a file called "do_build.sh.diff" in FREENAS_ROOT. Then run the patch command to apply it:
Note: The diff file MUST be in FREENAS_ROOT for the above command to work as it is.
So, what does this patch actually do? Well, the original build script downloads the ports tree as it existed on July 17, 2011. The development team froze FreeNAS 8's ports tree on that date to apply custom patches to several ports. On the downside, though, all unpatched ports are frozen at older versions. So, to update the ports tree while still allowing the FreeNAS patches to be applied, the above patch to the build script does the following:
1) Download a current, up-to-date ports tree initially.
2) Regress the few ports that have custom patches for FreeNAS back to their July 17, 2011 snapshots.
3) Backport emulators/open-vm-tools as well to prevent a packaging error in the most recent version.
That's really all there is to it!
Step 3: Customize FreeNAS with More Ports (Optional)
Use your favorite command-line text editor (I use nano in my below examples) and open up the file "freenas-common" under the "nanobsd" directory.
Scroll down until you see a bunch of lines that start with "add_port" and go to the bottom of the list, which ends in "add_port sysutils/ipmitool" (line 254).
Now simply use the same syntax to add additional ports below that line with the formula:
For example, to add transmission-daemon, the code would be like this:
Step 4: Build FreeNAS
If you have previously built FreeNAS, you might have the "FreeBSD" directory in FREENAS_ROOT. If you do, type the following commands:
Those commands will ensure that the patched build script updates everything.
Now from FREENAS_ROOT run the following commands (yes, dropping into sh first can prevent build errors):
You can, of course substitute any CVSUP host for the one above. For a list of cvsup mirrors and their statuses, see www.mavetju.org/unix/freebsd-mirrors/cvsup-stats-global.php
When the build finishes, you should have your custom images waiting for you in the "obj.***" directory, where the *** is either i386 or amd64.
If you don't know how to install the custom image, refer to the official FreeNAS documentation.
Step 5: Make Your Changes Persist Between Reboots (Optional)
Once your FreeNAS installation has booted and you have configured it to your liking (or restored your previous configuration), you can modify "/etc/rc.conf" to start ports you added in step 3 at boot (like transmission-daemon) and pass arguments to their RC scripts (such as configuration directories, etc.). To do this, use the following commands from the FreeNAS command-line (must be logged in as root):
Make your changes to the file as required. For example, I have the following inserted for transmission-daemon:
Refer to each port's documentation for applicable RC options.
Now reboot your FreeNAS installation and your changes will be made!
--------------------------------------------
Thanks for reading! Let me know if there are any mistakes or if anything is missing.
Please check the ADDENDUM below before asking any questions to make sure I have not already answered them.
Good day, everyone! I've updated the guide and the patch for FreeNAS 8.0.3. This guide will show you how to upgrade the ports tree (almost) as a whole and even add ports like transmission-daemon to the FreeNAS image. This guide requires the ability to build FreeNAS 8.0.3 from source using the FreeBSD command-line; if you have no idea how to do this, consult joeschmuck's excellent guide in this same forum.
Note: This modification to the FreeNAS 8.0.3 source is NOT sponsored or supported by the development team. Do NOT send them any questions about this guide!
Note: I am NOT responsible for any damage that may occur to your data as a result of this method. If you are concerned about the safety of the following instructions, MAKE A BACKUP FIRST!
Note: I can only certify that this method works with the 8.0.3 source. Don't bug me with questions about older versions or trunk!
Note: Read all notes...
Step 1: Get the Sources
If you already have the 8.0.3 sources, skip to step 2.
We use svn just like we would for trunk, except we are pulling the 8.0.3-RELEASE tag instead:
Code:
svn co https://freenas.svn.sourceforge.net/svnroot/freenas/tags/8.0.3-RELEASE
The new folder created on your local machine (or virtual machine) is called "8.0.3-RELEASE" and is the root directory during the FreeNAS build. From here on I will simply call it FREENAS_ROOT.
Step 2: Patch the Build Script
Here is my unified diff which you can use to patch "build/do_build.sh":
Code:
--- build/do_build.sh 2012-01-11 22:07:06.000000000 -0600 +++ build/do_build.sh 2012-01-13 14:18:47.000000000 -0600 @@ -34,7 +34,8 @@ echo "No sup host defined, please define FREEBSD_CVSUP_HOST and rerun" exit 1 fi - echo "Checking out tree from ${FREEBSD_CVSUP_HOST}..." + echo "Checking out up-to-date tree from ${FREEBSD_CVSUP_HOST}..." +# Fetch up-to-date ports tree with this file cat <<EOF > FreeBSD/supfile *default host=${FREEBSD_CVSUP_HOST} *default base=${root}/FreeBSD/sup @@ -44,8 +45,39 @@ *default compress src-all tag=RELENG_8_2 +ports-all date=. +EOF +# Create a new supfile to backport only the ports we need to patch + cat <<EOF > FreeBSD/supfile_backports +*default host=${FREEBSD_CVSUP_HOST} +*default base=${root}/FreeBSD/sup +*default prefix=${root}/FreeBSD +*default release=cvs +*default delete use-rel-suffix +*default compress + ports-all date=2011.07.17.00.00.00 EOF +# Create a file containing the categories and names of all +# ports that will be patched (and therefore must be backported) +# +# Also backport open-vm-tools to prevent a packaging error in the latest version + cat <<EOF > FreeBSD/ports.topatch +sysutils/ataidle +dns/inadyn +net/istgt +net-mgmt/net-snmp +net/netatalk +sysutils/nut +www/py-django +www/py-dojango +net/rsync +net/samba36 +databases/tdb +emulators/open-vm-tools +emulators/open-vm-tools-nox11 +EOF + # Nuke the newly created files to avoid build errors. # # patch(1) will automatically append to the previously non-existent @@ -61,6 +93,13 @@ # Force a repatch because csup pulls pristine sources. : > $FREENAS_ROOT/FreeBSD/src-patches : > $FREENAS_ROOT/FreeBSD/ports-patches + +# Now backport the ports that will be patched +for port in $(cat ${root}/FreeBSD/ports.topatch); do + echo "Backporting $port from ${FREEBSD_CVSUP_HOST}..." + csup -L 1 -i "ports/$port" ${root}/FreeBSD/supfile_backports +done + fi for patch in $(cd $FREENAS_ROOT/patches && ls freebsd-*.patch); do
Copy that code and place it in a file called "do_build.sh.diff" in FREENAS_ROOT. Then run the patch command to apply it:
Code:
patch < do_build.sh.diff
Note: The diff file MUST be in FREENAS_ROOT for the above command to work as it is.
So, what does this patch actually do? Well, the original build script downloads the ports tree as it existed on July 17, 2011. The development team froze FreeNAS 8's ports tree on that date to apply custom patches to several ports. On the downside, though, all unpatched ports are frozen at older versions. So, to update the ports tree while still allowing the FreeNAS patches to be applied, the above patch to the build script does the following:
1) Download a current, up-to-date ports tree initially.
2) Regress the few ports that have custom patches for FreeNAS back to their July 17, 2011 snapshots.
3) Backport emulators/open-vm-tools as well to prevent a packaging error in the most recent version.
That's really all there is to it!
Step 3: Customize FreeNAS with More Ports (Optional)
Use your favorite command-line text editor (I use nano in my below examples) and open up the file "freenas-common" under the "nanobsd" directory.
Scroll down until you see a bunch of lines that start with "add_port" and go to the bottom of the list, which ends in "add_port sysutils/ipmitool" (line 254).
Now simply use the same syntax to add additional ports below that line with the formula:
Code:
add_port <category>/<port_name>
For example, to add transmission-daemon, the code would be like this:
Code:
add_port net-p2p/transmission-daemon
Step 4: Build FreeNAS
If you have previously built FreeNAS, you might have the "FreeBSD" directory in FREENAS_ROOT. If you do, type the following commands:
Code:
cd FreeBSD/ rm -rf supfile sup/ src-patches ports-patches cd ../
Those commands will ensure that the patched build script updates everything.
Now from FREENAS_ROOT run the following commands (yes, dropping into sh first can prevent build errors):
Code:
sh export FREEBSD_CVSUP_HOST=cvsup10.freebsd.org build/do_build.sh
You can, of course substitute any CVSUP host for the one above. For a list of cvsup mirrors and their statuses, see www.mavetju.org/unix/freebsd-mirrors/cvsup-stats-global.php
When the build finishes, you should have your custom images waiting for you in the "obj.***" directory, where the *** is either i386 or amd64.
If you don't know how to install the custom image, refer to the official FreeNAS documentation.
Step 5: Make Your Changes Persist Between Reboots (Optional)
Once your FreeNAS installation has booted and you have configured it to your liking (or restored your previous configuration), you can modify "/etc/rc.conf" to start ports you added in step 3 at boot (like transmission-daemon) and pass arguments to their RC scripts (such as configuration directories, etc.). To do this, use the following commands from the FreeNAS command-line (must be logged in as root):
Code:
mount -uw / cd /conf/base/etc/ nano -w rc.conf
Make your changes to the file as required. For example, I have the following inserted for transmission-daemon:
Code:
transmission_enable="YES" transmission_conf_dir="/mnt/zfs_volume/config/transmission" transmission_user="root"
Refer to each port's documentation for applicable RC options.
Now reboot your FreeNAS installation and your changes will be made!
--------------------------------------------
Thanks for reading! Let me know if there are any mistakes or if anything is missing.
Please check the ADDENDUM below before asking any questions to make sure I have not already answered them.