mirror of
https://github.com/outbackdingo/openwrt-builder.git
synced 2026-01-27 10:19:59 +00:00
fcc6fd29887e31dbdd3d99bcba720534b86867e2
Openwrt
Build OpenWRT system image
How to
Container image to build Openwrt image based on https://openwrt.org/docs/guide-developer/toolchain/install-buildsystem To build own container image:
sudo yum install -y git podman
git clone https://github.com/danpawlik/openwrt-builder
cd openwrt-builder
podman build -t openwrt-builder -f Dockerfile
Example config
How to use:
mkdir -p openwrt-builder && chmod 0777 openwrt-builder
podman run --name openwrt -it -u user -v $(pwd)/openwrt-builder:/home/user/openwrt-builder:z,rw quay.io/dpawlik/openwrt:f40 bash
Then inside the container (from https://openwrt.org/docs/guide-developer/toolchain/use-buildsystem):
git clone https://git.openwrt.org/openwrt/openwrt.git ~/openwrt-builder/openwrt && cd ~/openwrt-builder/openwrt
Optionally add MediaTek feed (onlt for 21.02):
cat << EOF >> feeds.conf.default
src-git mtksdk https://git01.mediatek.com/openwrt/feeds/mtk-openwrt-feeds
EOF
git add feeds.conf.default ; git commit -m 'Add MediaTek feed'
Update the feeds:
./scripts/feeds update -a && ./scripts/feeds install -a
Use device config:
# BPI-R4
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/mediatek/mt7988a/bpi-r4 > ~/openwrt-builder/openwrt/.config
# AX3200
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/mediatek/mt7622/ax3200 > ~/openwrt-builder/openwrt/.config
# AX3600
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/qualcommax/ax3600 > ~/openwrt-builder/openwrt/.config
# Xiaomi 4A Giga Edition
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/ramips/mt7621/4a-giga > ~/openwrt-builder/openwrt/.config
# Ubiquiti U6 Lite
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/ramips/mt7621/u6-lite > ~/openwrt-builder/openwrt/.config
# Ubuquti UAP-AC-LR
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/ath79/generic/uap-ac-lr > ~/openwrt-builder/openwrt/.config
# Mikrotik hAP AC
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/ath79/mikrotik/962uigs-5hact2hnt > ~/openwrt-builder/openwrt/.config
NOTE: If device got additional hardware installed, for example: Banana Pi R4 got wireless card, it is also included in the config file.
then add the required packages that I use for the router/AP function:
- Main router:
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/common/main-router >> ~/openwrt-builder/openwrt/.config
- Dumb AP:
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/common/dumb_ap >> ~/openwrt-builder/openwrt/.config
- Basic config
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/common/basic >> ~/openwrt-builder/openwrt/.config
Example:
# Banana Pi R4 as main router
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/mediatek/mt7988a/bpi-r4 > ~/openwrt-builder/openwrt/.config
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/common/main-router >> ~/openwrt-builder/openwrt/.config
# optional configs
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/common/optimize >> ~/openwrt-builder/openwrt/.config
for m in $(grep "=m" ~/openwrt-builder/openwrt/.config | grep -v 'CONFIG_PACKAGE_libustream-mbedtls=m'); do module=$(echo $m| cut -f1 -d'='); sed -i "s/$m/\# $module is not set/g" ~/openwrt-builder/openwrt/.config; done
# AX3200 as dumb AP
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/mediatek/mt7622/ax3200 > ~/openwrt-builder/openwrt/.config
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/common/dumb_ap >> ~/openwrt-builder/openwrt/.config
# optional configs
curl -SL https://raw.githubusercontent.com/danpawlik/openwrt-builder/master/configs/common/optimize >> ~/openwrt-builder/openwrt/.config
# etc.
Build
Configure the firmware image and the kernel:
make menuconfig
Optional: comment modules:
for m in $(grep "=m" .config | grep -v 'CONFIG_PACKAGE_libustream-mbedtls=m'); do module=$(echo $m| cut -f1 -d'='); sed -i "s/$m/\# $module is not set/g" .config; done
Then:
make -j$(nproc) kernel_menuconfig
Build the firmware image:
make -j $(nproc) defconfig download clean world
To get more verbosity:
make -j1 V=s defconfig download clean world
With Ansible - WIP (Work In Progress)
- Install Ansible:
sudo dnf install -y ansible-core git
- Clone builder project
git clone https://github.com/danpawlik/openwrt-builder && cd openwrt-builder
- Run Ansible playbook
ansible-playbook -i ansible/inventory.yaml ansible/openwrt-build.yaml
Description
Languages
Shell
47.7%
Makefile
44.5%
Dockerfile
7.8%