How To Create and Use RFS Customization Script
Table of Contents
Summary
This HOWTO covers the process for creating an RFS customization script to modify the Factory generated target RFS.
NOTE: This HOWTO assumes that the Desktop Factory has been configured and built prior to the use of the RFS customization script. If these Factory configuration and build steps have not been completed yet, please do so before continuing with this HOWTO.
Making systematic modifications to the Factory-generated RFS during the BSP/SDK build process with the use of an RFS customization script can be broken up into two distinct tasks, each of which is covered within this HOWTO:
RFS Customization Script Introduction
There are instances where certain modifications need to be made to the Factory-generated RFS beyond simply adding or overwriting files within the RFS (as can be accomplished with the use of an RFS Overlay Archive). Some examples are:
- dynamically adding, moving, or removing files
- modifying file contents
- modifying file permissions
- any conditional operations
The RFS customization script is run immediately prior to the RFS images creation during the BSP/SDK build.
Create RFS Customization Script
Write RFS Customization Script
One of the most important aspects of using the RFS customization script facility within Factory is the script itself. The script can be created anywhere on the development host with your favorite text editor, but for purposes of this HOWTO, it will be created within the user-created src/local/ directory within Factory's top-level.
vim src/local/myRFSscript.sh
From here, the contents of the RFS customization script are left largely to the requirements of the tasks at hand. The RFS customization script is run from the top-level Factory directory and is passed the RFS working directory (build_[arch]-timesys-linux-[libc]/rfs/) as the only parameter. The example RFS customization script here is commented to explain what each section does and is intended for reference purposes. Note Copy and pasting this code from your web browser may not maintain proper formatting.
#!/bin/bash # change directory to the RFS working directory or # stop execution if unable to do so RFSDIR=$1 cd $RFSDIR || exit 1 # backup etc/network/interfaces file if [ -f etc/network/interfaces] ; then mv etc/network/interfaces etc/network/interfaces.bck fi # create new interfaces file and # setup eth0 dhcp configuration cat >> etc/network/interfaces <<EOF auto eth0 iface eth0 inet dhcp EOF # prevent openssh from automatically starting # by removing initscript if [ -f etc/init.d/S50-openssh ] ; then rm etc/init.d/S50-openssh rm etc/init.d/K50-openssh fi # add tty0 console cat >> etc/inittab <<EOF ds:2345:respawn:/sbin/mingetty --noclear tty0 EOF # mount hdb on /work mkdir work cat >> etc/fstab <<EOF /dev/hdb /work ext2 defaults 0 0 EOF # create /etc/init.d/rc.local to start our apps mkdir -p etc/init.d cat > etc/init.d/rc.local <<EOF #!/bin/sh # put app init stuff here case "\$1" in start) echo "starting custom app" ;; stop) echo "stopping custom app" ;; esac EOF
Once the script is created, it will also need to be marked as executable before proceeding.
chmod +x src/local/myRFSscript.sh
Verify RFS Customization Script
You can verify the RFS Customization script acts as expected by simply executing it from the within the top-level Factory directory and inspecting the results in the RFS working directory (build_[arch]-timesys-linux-[libc]/rfs/). Once the results of the script are satisfactory, integration with the BSP/SDK build process is the next step.
Integrate RFS Customization Script with Factory
Copy RFS Customization Script to an Accessible Location
If the RFS customization script has been not been created from the steps listed above, ensure it is copied to a location accessible to the Desktop Factory (where elevated privileges are not needed).
cp /PATH/TO/myRFSscript.sh /PATH/TO/factory/src/local/
Enable RFS Customization Script in Workorder
The RFS Customization Script is enabled by listing the script file with a fully qualified path in the Factory workorder. This can be done via the menuconfig
interface.
- Run
make menuconfig
from the top-level Factory directory - Navigate to Target Configuration > Build RFS > RFS Customization script
- Enter script file and location - in our example,
file://$(TSWO_SRC_LOCAL_LOCATION)/myRFSscript.sh
- Exit menuconfig and save workorder
Note the $(TSWO_SRC_LOCAL_LOCATION)
into the workorder in step 3 above evaluates to src/local in the top-level Factory directory.
Clean and Rebuild RFS and Installer
In order to rebuild the RFS images, the rfs build state in Factory needs to be reset. This is accomplished with the rfs-distclean
make target, run from the top level Factory directory.
make rfs-distclean
With the RFS reset and ready to be rebuilt, the following can be run from the top-level Factory directory to regenerate the RFS images and SDK Installer:
make rfs && installers
or simply running "make
" will automatically rebuild both the RFS images and the SDK installer to reflect the modifications to the RFS based on the newly applied RFS customization script.