Last active
May 8, 2019 14:06
-
-
Save Pheoxy/114a3a45729058048f0b8d126a4cbdd7 to your computer and use it in GitHub Desktop.
Openwrt Build Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Build openwrt in docker container | |
# Enviroment | |
GIT_BRANCH='openwrt-18.06' | |
CORES='-j6' | |
DEBUG='false' | |
# Stop on error | |
set -e | |
## Setup ccache | |
# Update symlinks | |
sudo /usr/sbin/update-ccache-symlinks | |
# Prepend ccache into the PATH | |
# if [[ -z "${/usr/lib/ccache:$PATH}" ]]; | |
# then | |
# MY_SCRIPT_VARIABLE="Some default value because DEPLOY_ENV is undefined" | |
# else | |
# MY_SCRIPT_VARIABLE="${DEPLOY_ENV}" | |
# fi | |
# echo "printenv PATH" | find /C /I ";</usr/lib/ccache:$PATH>;" | |
echo 'export PATH="/usr/lib/ccache:$PATH"' | tee -a ~/.bashrc | |
# Source bashrc to test the new PATH | |
source ~/.bashrc | |
# Git clone openwrt openwrt | |
if [ ! -d openwrt/ ] | |
then | |
git clone https://git.openwrt.org/openwrt/openwrt.git -b $GIT_BRANCH | |
cd openwrt | |
./scripts/feeds update -a | |
./scripts/feeds install -a | |
else | |
echo "Found openwrt/ directory from previous git clone" | |
echo "Skipping..." | |
echo "Pulling updates from git and cleaning openwrt/" | |
cd openwrt | |
rm -rf feeds/* | |
rm -rf package/* | |
git fetch origin | |
git reset --hard origin/$GIT_BRANCH | |
git clean -f -d | |
git pull | |
make distclean | |
./scripts/feeds update -a | |
./scripts/feeds install -a | |
fi | |
# Setup .config from config.seed and update seed for new changes | |
# cp ../config.seed ../openwrt/.config | |
# ./scripts/diffconfig.sh > diffconfig | |
# # Write changes to .config | |
# cp diffconfig .config | |
#make defconfig;make oldconfig | |
make menuconfig | |
# Compile | |
make download | |
# Make output folders | |
mkdir -p ../output | |
if [ $DEBUG=true ] | |
then | |
time make V=s $CORES 2>&1 | tee ../output/make.log | grep -i error | |
else | |
time make $CORES | |
fi | |
# Cleaning up for git | |
mkdir -p ../output/$(date +%Y%m%d%H%M) | |
if [ -f ../output/make.log ] | |
then | |
mv ../output/make.log ../output/$(date +%Y%m%d%H%M)/make.log | |
fi | |
cp .config ../output/$(date +%Y%m%d%H%M)/config.seed.new | |
cp -R bin/targets/* ../output/$(date +%Y%m%d%H%M)/ | |
echo "Build Success!" | |
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# rebuild and start docker container | |
cd ~/Projects/docker-openwrt-builder && \ | |
sudo docker build -t openwrt-builder . && \ | |
sudo docker run \ | |
-itd \ | |
--name=openwrt-builder \ | |
-e PUID=1000 -e PGID=1000 \ | |
-v /etc/localtime:/etc/localtime:ro \ | |
-v /home/dhancock/Projects/docker-openwrt-builder/openwrt:/home/openwrt \ | |
openwrt-builder && \ | |
sudo docker ps -a && \ | |
sudo docker exec -it openwrt-builder /bin/bash | |
# Remove, rebuild and start docker container | |
cd ~/Projects/docker-openwrt-builder && \ | |
sudo docker ps -a && \ | |
sudo docker stop openwrt-builder && \ | |
sudo docker rm openwrt-builder && \ | |
sudo docker system prune && \ | |
sudo docker build -t openwrt-builder . && \ | |
sudo docker run \ | |
-itd \ | |
--name=openwrt-builder \ | |
-e PUID=1000 -e PGID=1000 \ | |
-v /etc/localtime:/etc/localtime:ro \ | |
-v /home/dhancock/Projects/docker-openwrt-builder/openwrt:/home/openwrt \ | |
openwrt-builder && \ | |
sudo docker ps -a && \ | |
sudo docker exec -it openwrt-builder /bin/bash | |
# Then run build.sh script | |
./build.sh | |
# Move built files to output folder | |
mkdir -p ../output/$(date +%Y%m%d%H%M) && \ | |
cp .config ../output/$(date +%Y%m%d%H%M)/config.seed.new && \ | |
cp -R bin/targets/* ../output/$(date +%Y%m%d%H%M)/ | |
# Remove docker container | |
sudo docker ps -a && \ | |
sudo docker stop openwrt-builder && \ | |
sudo docker rm openwrt-builder && \ | |
sudo docker system prune | |
## Used services and settings to run as built-in otherwise they are not included | |
# Global build settings | |
luci-ssl-openssl | |
luci-app-adblock | |
luci-app-ddns | |
luci-app-upnp | |
luci-app-openvpn | |
openvpn-openssl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment