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
# Creates the build environment with the current directory as the root
# To avoid problems with long paths, something like /Openwrt is preferable
# Script creates subdir for trunk or the release branch, and dl for downloads
# Creates main source repository and luci, packages & routing feeds
### Target definitions
## Current version
### Prerequisites for buildroot
sudo apt-get install build-essential subversion libncurses5-dev zlib1g-dev
sudo apt-get install gawk gcc-multilib flex git-core gettext libssl-dev
### Prerequisite for 18.06 and 19.07 on Ubuntu 17.10+ as it has python3 by default
# sudo apt-get install python
### Prerequisite for master on Ubuntu as master needs python3 libs
sudo apt-get install python3-distutils
### Prerequisites for being able to send patches to openwrt-devel
sudo apt-get install git-email
### Newly patched Ubuntu may not yet have the correct kernel headers.
# sudo apt-get install linux-headers-$(uname -r)
### set the preferred umask (allowed: 0000-0022)
### download directory (outside main directory to protect from make distclean)
mkdir -p dl
### main directory
mkdir -p $TARGET
### checkout/clone and change to directory
git clone $GITREPO $TARGET
### create symlink to dl (after git clone)
ln -s ../dl dl
### patch main source first to set feeds correctly
### update the feeds, apply patches to feeds
### re-create index to find new packages, finally install
patch -p1 -i ../$FILESTAMP-main.patch
scripts/feeds update -a
(cd feeds/luci; patch -p1 -i ../../../$FILESTAMP-luci.patch)
(cd feeds/packages; patch -p1 -i ../../../$FILESTAMP-packages.patch)
#(cd feeds/routing; patch -p1 -i ../../../$FILESTAMP-routing.patch)
scripts/feeds update -i
scripts/feeds install -a
### chmod known script files executable
chmod -f 755 files/etc/*.sh
chmod -f 755 files/etc/rc.button/*
### chmod buildscripts executable
chmod -f 755 hnscripts/*.sh
### add created/modified files in main repo to version control
git add -f files
git add -A
### add created/modified files in feeds to version control
(cd feeds/luci; git add -A)
(cd feeds/packages; git add -A)
#(cd feeds/routing; git add -A)
### initialise .config
cp .config.init .config
Updated in Nov 2019 with the current versions.