I have used a set of build scripts to build my community builds for WNDR3700 and later also for R7800. I thought to document the scripts here in case somebody finds them useful. I have polished these scripts for some five years, and they make a regular build process pretty easy.
The key characteristics for the script set is that it documents all personal changes during the build process and creates not only the binary firmware but also the set of patches that can be applied to a clean master. It also contains a self-creation script that clones a clean new repo and patches it with the made changes.
Benefits of the script set:
- It enables me to publish diff/patch files with each release of the community release making the exact contents of my build wholly transparent. Anybody can easily rebuild the same firmware from scratch with the scripts.
- This enables me to e.g. transfer my whole build environment to a new clean Ubuntu buildhost in a few minutes
- Having extensive diff about all personal changes in main source and all feeds (and in .config, diffconfig etc.) enables also an easy comparison of unexpected changes between builds. I use a visual diff tool (WinMerge, Meld, etc.) to compare diffconfig and the patches to the previous builds' same files.
I placed an example of a firmware build and the related files in "x Example build release" directory in Dropbox.
- personal changes are not committed to git, but just left added by "git add". That enables "git diff" usage. (The same could likely be achieved via git commits and "git format-patch", but I have selected to use uncommitted changes)
- Use a ".config seed" to set the package/config menuconfig selections. I use a file .config.init that I always copy to be the new .config before a new build. "make defconfig" then expands it to a full .config during the build. Using such file is not quite mandatory, but enables better control of package selections in light of possibly changing defaults.
- scripts expect that they are located in "hnscripts" directory in buildroot
Scripts and their short explanations:
- updateNmake - Update source code and make the build (via parallelcompile). Update git sources, timestamp the build, build it, and finally create the patches and re-creation script into the bin directory
- newBuildroot - Creates Openwrt/LEDE build environment with the current directory as the root. Installs prerequisite packages into Ubuntu x64. An updated version of the script is created into the bin directory along the firmware at each build
- mountNcopy - Mount the Virtualbox shared folder and copy files to PC. Just for transferring files, nothing really special
- parallelcompile - Compile using a multiple threads
- singlecompile - Compile using a single thread. Useful for debugging
- kernelcompile - Clean & compile kernel using a single thread. Useful for debugging
Called from singlecompile & parallelcompile:
- timestampVersion - Collect source version info and insert it into firmware before compilation. Embedd exact version info of all sources and feeds in the build.
- createbuildinfo - Create info on current config and source code changes. Run at the end of the build process. Creates the patch files, the re-creation script, diffconfig etc.
The creation script runs pretty automatically. The needed few steps are:
- Create the base directory (I use /OwrtLEDE) and make it writable by your normal user account (non-root)
- Download from my newest firmware the newBuildroot.sh file and the four *.patch files to /OwrtLEDE
- Run newBuildroot.sh. It creates the complete build environment and applies the patches
- Build firmware with hnscripts/updateNmake.sh
Detailed explanation of the steps in the build environment creation process can be found in my WNDR3700 build thread:
Steps in the actual firmware build process:
- Copy .config.init as the new .config to initialize the build profile: cp .config.init .config
("make defconfig" will expand the recipe to a full .config . You can run that command also manually.)
- Do the actual make: hnscripts/updateNmake.sh
- Transfer files from bin/targets/... to wherever you need them. I use the script hnscripts/mountNcopy.sh