Skip to content

Commit

Permalink
Ninux Build OpenWRT
Browse files Browse the repository at this point in the history
  • Loading branch information
mikysal78 committed Jan 14, 2024
0 parents commit 1bc73e8
Show file tree
Hide file tree
Showing 33 changed files with 855 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM debian:bookworm

RUN apt-get update &&\
apt-get install -y \
sudo ccache time git-core subversion build-essential g++ bash make \
libssl-dev patch libncurses5 libncurses5-dev zlib1g-dev gawk flex \
gettext wget unzip xz-utils python3 python3-distutils-extra rsync curl \
gcc-multilib libsnmp-dev liblzma-dev libpam0g-dev cpio rsync \
clang python3-distutils file wget automake && \

apt-get clean && \
useradd -m user && \
echo 'user ALL=NOPASSWD: ALL' > /etc/sudoers.d/user

ADD https://github.com/github-release/github-release/releases/download/v0.9.0/linux-amd64-github-release.bz2 linux-amd64-github-release.bz2
RUN bzip2 -d linux-amd64-github-release.bz2 && \
cp linux-amd64-github-release /usr/local/bin/github-release && \
chmod +x /usr/local/bin/github-release

USER user
WORKDIR /home/user

# set dummy git config
RUN git config --global user.name "user" && git config --global user.email "[email protected]"


53 changes: 53 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env groovy

import org.apache.commons.io.FilenameUtils

Map ARCHIVES_PATH = [
"lamobo_R1": "openwrt/bin/targets/sunxi/cortexa7/openwrt-sunxi-cortexa7-lamobo_lamobo-r1-ext4-sdcard.img.gz",
"glinet_gl-mt300n-v2": "openwrt/bin/targets/ramips/mt76x8/openwrt-ramips-mt76x8-glinet_gl-mt300n-v2-squashfs-sysupgrade.bin",
"linksys_wrt3200acm": "openwrt/bin/targets/mvebu/cortexa9/openwrt-mvebu-cortexa9-linksys_wrt3200acm-squashfs-sysupgrade.bin",
"totolink_X5000R": "openwrt/bin/targets/ramips/mt7621/openwrt-ramips-mt7621-totolink_x5000r-squashfs-sysupgrade.bin",
"tplink_c2600": "openwrt/bin/targets/ipq806x/generic/openwrt-ipq806x-generic-tplink_c2600-squashfs-sysupgrade.bin",
"X86_64": "openwrt/bin/targets/x86/64/openwrt-x86-64-generic-ext4-combined-efi.img.gz",
"raspy_3": "openwrt/bin/target/bcm27xx/bcm2710/openwrt-bcm27xx-bcm2710-rpi-3-squashfs-sysupgrade.img.gz",
"raspy_4": "openwrt/bin/target/bcm27xx/bcm2711/openwrt-bcm27xx-bcm2711-rpi-4-squashfs-sysupgrade.img.gz"
]

String target_choices = (ARCHIVES_PATH.keySet() as String[]).join(',')

properties([
parameters([
booleanParam(name: 'CLEAN_BUILD', defaultValue: true, description: 'deletes contents of the directories /bin and /build_dir.'),
extendedChoice(defaultValue: "${target_choices}", description: 'Which target to build', multiSelectDelimiter: ',', name: 'TARGETS', quoteValue: false, saveJSONParameterToFile: false, type: 'PT_MULTI_SELECT', value: "${target_choices}", visibleItemCount: 6),
])
])

String[] TARGETS = params.TARGETS.split(',')

// parallel task map
Map tasks = [failFast: false]

TARGETS.each { target ->
tasks[target] = { ->
node {
def UPLOAD_FILE = ARCHIVES_PATH[target]
def ARCHIVE_NAME = FilenameUtils.getBaseName(UPLOAD_FILE)
ws("${WORKSPACE}/../ninux-build-openwrt") {
stage('Checkout') {
// Get some code from a GitHub repository
checkout scm
}
// Mark the code checkout 'stage'....
tools = load "jenkins.groovy"
tools.build(target)
tools.publishArtifact(UPLOAD_FILE)
tools.githubRelease(UPLOAD_FILE, ARCHIVE_NAME)
}
}
}
}


stage("Parallel builds") {
parallel(tasks)
}
94 changes: 94 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
===========================
Ninux NNXX - Openwrt Builds
===========================

.. image:: https://github.com/mikysal78/ninux-build-openwrt/blob/master/workflows/nnxx.png
:target: http://wiki.ninux.org/nnxx
:alt: Ninux NNXX

-----------

Build
-----
-

Build script:

.. code-block:: shell
./build.sh tplink_c2600
-

Build manually:

.. code-block:: shell
cd openwrt
make menuconfig
make defconfig
make V=s
-

Write your SD card:

.. code-block:: shell
gzip -k -d openwrt/bin/path_xxx/file_xxx.img.gz
dd if=openwrt/bin/path_xxx/file_xxx.img of=/dev/YOURSDCARD
-

-----------

Clean
-----
Cleaning Up (in openwrt directory):

.. code-block:: shell
make clean
deletes contents of the directories /bin and /build_dir. make clean does not remove the toolchain, it also avoids cleaning architectures/targets other than the one you have selected in your .config

-

Dirclean:

.. code-block:: shell
make dirclean
deletes contents of the directories /bin and /build_dir and additionally /staging_dir and /toolchain (=the cross-compile tools) and /logs. 'Dirclean' is your basic "Full clean" operation.


-

Distclean:

.. code-block:: shell
make distclean
nukes everything you have compiled or configured and also deletes all downloaded feeds contents and package sources.


*CAUTION* : In addition to all else, this will erase your build configuration (<buildroot_dir>/.config), your toolchain and all other sources. Use with care!

-----------

Jenkins
-------

.. image:: https://github.com/mikysal78/ninux-build-openwrt/blob/master/workflows/project.png
:alt: Jenkins project

.. image:: https://github.com/mikysal78/ninux-build-openwrt/blob/master/workflows/repo.png
:alt: Jenkins repository

.. image:: https://github.com/mikysal78/ninux-build-openwrt/blob/master/workflows/esegui.png
:alt: Jenkins build

75 changes: 75 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/bash
set -e
set -x

TARGET=$1
OPENWRT_VERSION="v23.05.2"

ROOT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
BUILD_DIR="/mnt/nfs-firmware/${OPENWRT_VERSION}/${TARGET}"

cd ${ROOT_DIR}

if [[ "${TARGET}" != "lamobo_R1" ]] || [[ "${TARGET}" != "tplink_c2600" ]]
then
# issue on lamobo_R1 or tplink_c2600
# ERROR: package/network/services/ppp failed to build (build variant: default)
export CONFIG_CCACHE=y
export CCACHE_DIR=/tmp/ccache
export CCACHE_MAXSIZE=10G
export CCACHE_COMPILERCHECK="%compiler% -dumpmachine; %compiler% -dumpversion"
[ -d $CCACHE_DIR ] || mkdir -m 777 $CCACHE_DIR
else
export CLEAN_BUILD=true
fi
# Install all necessary packages
#sudo apt-get install build-essential subversion libncurses5-dev zlib1g-dev gawk gcc-multilib flex git-core libssl-dev unzip python wget time

if [[ ! -d openwrt/.git ]]
then
rm -rf openwrt
git clone https://github.com/openwrt/openwrt.git openwrt
fi

cd ${ROOT_DIR}/openwrt
git fetch -a

git reset --hard HEAD^
git checkout -f ${OPENWRT_VERSION}

# Patch kernel config to enable nf_conntrack_events
#patch ${ROOT_DIR}/openwrt/target/linux/generic/config-5.10 < ${ROOT_DIR}/configs/kernel-config.patch

rm -rf ${ROOT_DIR}/openwrt/files
cp -r ${ROOT_DIR}/root_files ${ROOT_DIR}/openwrt/files

# configure feeds
echo "src-git chilli https://github.com/openwisp/coova-chilli-openwrt.git" > feeds.conf
echo "src-git openwisp_config https://github.com/openwisp/openwisp-config.git^1.0.1" >> feeds.conf
echo "src-git openwisp_monitoring https://github.com/openwisp/openwrt-openwisp-monitoring.git" >> feeds.conf
echo "src-git zerotier https://github.com/mwarning/zerotier-openwrt.git" >> feeds.conf
sed '/telephony/d' feeds.conf.default >> feeds.conf

./scripts/feeds update -a -f
./scripts/feeds install -a -f
rm -rf package/feeds/luci/luci-app-apinger
rm -rf ${ROOT_DIR}/openwrt/.config*
cp ${ROOT_DIR}/configs/${TARGET}.config ${ROOT_DIR}/openwrt/.config
cat ${ROOT_DIR}/configs/base-config >> ${ROOT_DIR}/openwrt/.config

make defconfig

if [[ "${CLEAN_BUILD}" == "true" || "${CONFIG_CCACHE}" == "y" ]]
then
make clean
fi

echo "Cleaning bin dir"
rm -rf ./bin/*

# If you try compiling OpenWrt on multiple cores and don't download all source files for all dependency packages
# it is very likely that your build will fail.
# https://openwrt.org/docs/guide-developer/toolchain/use-buildsystem#download_sources_and_multi_core_compile
make download

make -j$(nproc) || make V=s # Retry with full log if failed
40 changes: 40 additions & 0 deletions configs/X86_64.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Router
CONFIG_TARGET_x86=y
CONFIG_TARGET_x86_64=y
CONFIG_TARGET_x86_64_DEVICE_generic=y
CONFIG_TARGET_KERNEL_PARTSIZE=32
CONFIG_TARGET_ROOTFS_PARTSIZE=1024
CONFIG_GRUB_TITLE="Ninux"
CONFIG_PACKAGE_intel-microcode=y

CONFIG_PACKAGE_luci-app-openwisp=y
CONFIG_PACKAGE_luci-app-wireguard=y

CONFIG_PACKAGE_kmod-usb-storage=y
CONFIG_PACKAGE_kmod-usb-storage-extras=y
CONFIG_PACKAGE_kmod-usb-storage-uas=y

CONFIG_PACKAGE_kmod-fs-ext4=y
CONFIG_PACKAGE_kmod-fs-exfat=y
CONFIG_PACKAGE_kmod-fs-f2fs=y

CONFIG_PACKAGE_f2fs-tools=y
CONFIG_PACKAGE_usbutils=y
CONFIG_PACKAGE_block-mount=m

CONFIG_PACKAGE_rt2800-pci-firmware=y
CONFIG_PACKAGE_kmod-rt2800-pci=y
CONFIG_PACKAGE_rt2800-usb-firmware=y
CONFIG_PACKAGE_kmod-rt2800-usb=y

CONFIG_PACKAGE_pciutils=y
CONFIG_PACKAGE_htop=y
CONFIG_PACKAGE_nano=y

CONFIG_DRIVER_11AC_SUPPORT=y
CONFIG_DRIVER_11N_SUPPORT=y
CONFIG_PACKAGE_MAC80211_DEBUGFS=y
CONFIG_PACKAGE_MAC80211_MESH=y
CONFIG_PACKAGE_kmod-cfg80211=y
CONFIG_PACKAGE_kmod-mac80211=y
CONFIG_PACKAGE_kmod-vxlan=y
80 changes: 80 additions & 0 deletions configs/base-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@

# enable image builder
CONFIG_IB=y
CONFIG_IB_STANDALONE=y

# avoid broken feeds in /etc/opkg/distfeeds.conf
# CONFIG_FEED_chilli is not set
# CONFIG_FEED_openwisp_config is not set
# CONFIG_FEED_openwisp_monitoring is not set


# additional packages
CONFIG_PACKAGE_wget=y
CONFIG_PACKAGE_partx-utils=y
CONFIG_PACKAGE_bird2=y
CONFIG_PACKAGE_bird2c=y
CONFIG_PACKAGE_bird2cl=y
CONFIG_PACKAGE_librt=y
CONFIG_PACKAGE_luci=y
CONFIG_PACKAGE_luci-ssl=y
CONFIG_PACKAGE_iputils-ping=y
CONFIG_PACKAGE_ip-full=y
CONFIG_PACKAGE_iwinfo=y
CONFIG_PACKAGE_iperf3=y
CONFIG_PACKAGE_ipip=y
CONFIG_PACKAGE_kmod-ipip=y
CONFIG_PACKAGE_lua-cjson=y
CONFIG_PACKAGE_uhttpd-mod-ubus=y
CONFIG_PACKAGE_lua-cjson=y
CONFIG_PACKAGE_rpcd-mod-iwinfo=y

# openwisp2 related packages
CONFIG_PACKAGE_openwisp-config=y
CONFIG_PACKAGE_netjson-monitoring=y
CONFIG_PACKAGE_openwisp-monitoring=y

# other configurations
CONFIG_BUSYBOX_CUSTOM=y
CONFIG_BUSYBOX_CONFIG_FEATURE_EDITING_SAVEHISTORY=y
CONFIG_BUSYBOX_CONFIG_FEATURE_EDITING_SAVE_ON_EXIT=y
CONFIG_BUSYBOX_CONFIG_FEATURE_REVERSE_SEARCH=y
CONFIG_BUSYBOX_CONFIG_FEATURE_VI_UNDO=y
CONFIG_BUSYBOX_CONFIG_WATCH=y

# Chilli
CONFIG_PACKAGE_coova-chilli=y
CONFIG_COOVACHILLI_REDIR=y
CONFIG_COOVACHILLI_OPENSSL=y
CONFIG_COOVACHILLI_PROXY=y
CONFIG_COOVACHILLI_USERAGENT=y
CONFIG_COOVACHILLI_UAMDOMAINFILE=y
CONFIG_COOVACHILLI_JSONINTERFACE=y

#ZeroTier VPN
CONFIG_PACKAGE_zerotier=y

# allow to build curl with different ssl library
CONFIG_LIBCURL_MBEDTLS=y

# Mesh
CONFIG_PACKAGE_mesh11sd=m

# WirelessAPD
# CONFIG_PACKAGE_wpad-basic-wolfssl is not set
CONFIG_PACKAGE_wpad-wolfssl=y


# IP Addresses and Names
CONFIG_PACKAGE_avahi-autoipd=y
CONFIG_PACKAGE_luci-proto-autoip=y

# Wiregiard
CONFIG_PACKAGE_kmod-wireguard=y
CONFIG_PACKAGE_luci-proto-wireguard=y
CONFIG_PACKAGE_wireguard-tools=y
CONFIG_PACKAGE_luci-proto-vxlan=y

#WatchCat
CONFIG_PACKAGE_luci-app-watchcat=y
CONFIG_PACKAGE_watchcat=y
4 changes: 4 additions & 0 deletions configs/glinet_gl-mt300n-v2.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Router
CONFIG_TARGET_ramips=y
CONFIG_TARGET_ramips_mt76x8=y
CONFIG_TARGET_ramips_mt76x8_DEVICE_glinet_gl-mt300n-v2=y
13 changes: 13 additions & 0 deletions configs/kernel-config.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/target/linux/generic/config-5.10 b/target/linux/generic/config-5.10
index 4529f3888a..d51fc2e302 100644
--- a/target/linux/generic/config-5.10
+++ b/target/linux/generic/config-5.10
@@ -3398,7 +3398,7 @@ CONFIG_MII=y
# CONFIG_MIPS_ALCHEMY is not set
# CONFIG_MIPS_CDMM is not set
# CONFIG_MIPS_COBALT is not set
-# CONFIG_MIPS_FPU_EMULATOR is not set
+CONFIG_MIPS_FPU_EMULATOR=y
# CONFIG_MIPS_FP_SUPPORT is not set
# CONFIG_MIPS_GENERIC is not set
# CONFIG_MIPS_GENERIC_KERNEL is not set
6 changes: 6 additions & 0 deletions configs/lamobo_R1.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Router
CONFIG_TARGET_sunxi=y
CONFIG_TARGET_sunxi_cortexa7=y
CONFIG_TARGET_sunxi_cortexa7_DEVICE_lamobo_lamobo-r1=y
CONFIG_TARGET_ROOTFS_TARGZ=y

Loading

0 comments on commit 1bc73e8

Please sign in to comment.