From 624a06e4e79fbd1f38e1a2343a94565b7e5c0727 Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Wed, 20 May 2026 22:11:10 +0800
Subject: [PATCH] Update openwrt build script

---
 build.sh |  184 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 184 insertions(+), 0 deletions(-)

diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..d5a52db
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,184 @@
+#!/bin/bash
+
+# board
+BOARD=igkboard-rk3576
+
+# openwrt branch
+BRANCH=openwrt-25.12
+
+#openwrt url
+GITURL=https://github.com/openwrt/openwrt.git
+
+# this project absolute path
+PRJ_PATH=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
+
+# binaries build prefix install path
+PRFX_PATH=$PRJ_PATH/install
+
+# binaries finally install path if needed
+#INST_PATH=/tftp
+
+# config file path
+CONF_FILE=$PRJ_PATH/config.json
+
+# shell script will exit once get command error
+set -e
+
+#+-------------------------+
+#| Shell script functions  |
+#+-------------------------+
+
+function pr_error() {
+    echo -e "\033[40;31m $1 \033[0m"
+}
+
+function pr_warn() {
+    echo -e "\033[40;33m $1 \033[0m"
+}
+
+function pr_info() {
+    echo -e "\033[40;32m $1 \033[0m"
+}
+
+# decompress a packet to destination path
+function do_unpack()
+{
+    tarball=$1
+    dstpath=`pwd`
+
+    if [[ $# == 2 ]] ; then
+        dstpath=$2
+    fi
+
+    pr_info "decompress $tarball => $dstpath"
+
+    mkdir -p $dstpath
+    case $tarball in
+        *.tar.gz)
+            tar -xzf $tarball -C $dstpath
+            ;;
+
+        *.tar.bz2)
+            tar -xjf $tarball -C $dstpath
+            ;;
+
+        *.tar.xz)
+            tar -xJf $tarball -C $dstpath
+            ;;
+
+        *.tar.zst)
+            tar -I zstd -xf $tarball -C $dstpath
+            ;;
+
+        *.tar)
+            tar -xf $tarball -C $dstpath
+            ;;
+
+        *.zip)
+            unzip -qo $tarball -d $dstpath
+            ;;
+
+        *)
+            pr_error "decompress Unsupport packet: $tarball"
+            return 1;
+            ;;
+    esac
+}
+
+# parser configure file and export environment variable
+function do_export()
+{
+    export SDK=$BRANCH
+}
+
+function do_fetch()
+{
+    cd $PRJ_PATH
+
+    if [ -f $SDK/Makefile ] ; then
+        pr_info "$SDK source code fetched already"
+        return 0;
+    fi
+
+    pr_info "start fetch source code"
+    git clone $GITURL -b $BRANCH $SDK --depth=1
+
+    cd $SDK && pwd
+
+    sed -i 's#https://git.openwrt.org/feed/#https://github.com/openwrt/#g' feeds.conf.default
+    sed -i 's#https://git.openwrt.org/project/#https://github.com/openwrt/#g' feeds.conf.default
+    sed -i 's#https://git.openwrt.org/#https://github.com/openwrt/#g' feeds.conf.default
+
+    pr_info "start feeds update and install "
+    ./scripts/feeds update -a
+    ./scripts/feeds install -a
+
+}
+
+function do_patch()
+{
+    PATCH_FILE=$PRJ_PATH/patch/${BRANCH}-${BOARD}.patch
+
+    cd $PRJ_PATH/$SDK
+
+    if [ ! -f patched.tag ] ; then
+        pr_info "do patch $(basename $PATCH_FILE)"
+        patch -p1 < $PATCH_FILE
+    fi
+}
+
+function do_config()
+{
+    DEF_CONFIG=.${BOARD}.defconfig
+
+    cd $PRJ_PATH/$SDK
+
+    pr_info "make defconfig: $DEF_CONFIG"
+    cp $DEF_CONFIG .config
+    make defconfig
+}
+
+function do_build()
+{
+    IMAGE_PATH=bin/targets/*/*/
+
+    echo ""
+    pr_warn "startu build..."
+    make V=s -j$(nproc)
+    #make -j1
+
+    echo ""
+    pr_warn "output images path: $IMAGE_PATH"
+    ls $IMAGE_PATH
+    echo ""
+}
+
+function do_clean()
+{
+    cd $WKSP/SDK && pwd
+
+    pr_warn "start clean"
+    make clean
+}
+
+#+-------------------------+
+#| Shell script body entry |
+#+-------------------------+
+
+do_export
+
+if [[ $# == 1 && $1 == -c ]] ;then
+    do_clean
+    exit;
+fi
+
+pr_warn "start build $SDK SDK for ${BOARD}"
+
+do_fetch
+
+do_patch
+
+do_config
+
+do_build
+

--
Gitblit v1.10.0