bryanburke
Dabbler
- Joined
- Nov 11, 2011
- Messages
- 11
THIS HOW-TO IS NOW OUTDATED. PLEASE USE THE 8.0.3 VERSION
IMPORTANT: Please read the guide completely to avoid confusion and prevent errors!
Good day, everyone! I've been poking around with the FreeNAS 8.0.2 source trying to upgrade nut for use with my newer model UPS. Along the way, I found out 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.2 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.2 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.2 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.2 sources, skip to step 2.
We use svn just like we would for trunk, except we are pulling the 8.0.2 branch instead:
The new folder created on your local machine (or virtual machine) is called "8.0.2" 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 the FreeNAS build script:
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, important ports like nut 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 only the few ports that have custom patches for FreeNAS back to their July 17, 2011 snapshots.
3) Apply a couple precautionary measures taken from the build script in trunk.
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) 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 benchmarks/iperf".
Now simply use the same syntax to add additional ports 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.
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.
IMPORTANT: Please read the guide completely to avoid confusion and prevent errors!
Good day, everyone! I've been poking around with the FreeNAS 8.0.2 source trying to upgrade nut for use with my newer model UPS. Along the way, I found out 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.2 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.2 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.2 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.2 sources, skip to step 2.
We use svn just like we would for trunk, except we are pulling the 8.0.2 branch instead:
Code:
svn co https://freenas.svn.sourceforge.net/svnroot/freenas/branches/8.0.2
The new folder created on your local machine (or virtual machine) is called "8.0.2" 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 the FreeNAS build script:
Code:
--- build/do_build.sh 2011-11-10 12:55:31.000000000 -0600 +++ build/do_build.sh 2011-11-11 17:47:53.000000000 -0600 @@ -26,6 +26,8 @@ exit 1 fi echo "Checking out tree from ${FREEBSD_CVSUP_HOST}..." + +# Fetch CURRENT ports tree here cat <<EOF > FreeBSD/supfile *default host=${FREEBSD_CVSUP_HOST} *default base=${root}/FreeBSD/sup @@ -34,7 +36,7 @@ *default delete use-rel-suffix src-all tag=RELENG_8_2 -ports-all date=2011.07.17.00.00.00 +ports-all date=. EOF csup -L 1 ${root}/FreeBSD/supfile # cvsup fixes any changes we make, it seems. Repatch @@ -42,6 +44,42 @@ rm -f ${root}/FreeBSD/ports-patches fi +# Added from trunk build script to prevent build errors + # Nuke the newly created files to avoid build errors, as + # patch(1) will automatically append to the previously + # non-existent file. + for file in $(find ${root}/FreeBSD/ -name '*.orig' -size 0); do + rm -f "$(echo "$file" | sed -e 's/.orig//')" + done + +# 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 + +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) + cat <<EOF > ${root}/ports.topatch +sysutils/ataidle +dns/inadyn +net/istgt +net/netatalk +www/py-django +www/py-dojango +net/samba35 +EOF + +# Now backport the ports listed above +for port in $(cd ${root} && cat ports.topatch); do + csup -L 1 -i "ports/$port" ${root}/FreeBSD/supfile_backports +done + # Make sure that all the patches are applied touch ${root}/FreeBSD/src-patches for i in $(cd ${root}/patches && echo freebsd-*.patch); do @@ -64,6 +102,18 @@ exit fi +# Added from trunk build script to prevent build errors +# Probably not even necessary, just a precaution +# +# HACK: chmod +x the script because: +# 1. It's not in FreeBSD proper, so it will always be touched. +# 2. The mode is 0644 by default, and using a pattern like ${SHELL} +# in the Makefile snippet won't work with csh users because the +# script uses /bin/sh constructs. +if [ -f "${root}/FreeBSD/src/include/mk-osreldate.sh.orig" ]; then + chmod +x ${root}/FreeBSD/src/include/mk-osreldate.sh +fi + # OK, now we can build cd FreeBSD/src args="-c ../../nanobsd/freenas-common"
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, important ports like nut 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 only the few ports that have custom patches for FreeNAS back to their July 17, 2011 snapshots.
3) Apply a couple precautionary measures taken from the build script in trunk.
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) 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 benchmarks/iperf".
Now simply use the same syntax to add additional ports 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.
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.