openwrt 单独编译 ipk

发布于 2023-12-01  31 次阅读


准备环境

可以参考 这里 进行环境准备!

使用 ubuntu ,更新系统:

sudo apt update && sudo apt upgrade -y

安装依赖:

sudo apt -y install ack antlr3 asciidoc autoconf automake autopoint binutils bison build-essential bzip2 ccache cmake cpio curl device-tree-compiler fastjar flex gawk gettext gcc-multilib g++-multilib git gperf haveged help2man intltool libc6-dev-i386 libelf-dev libglib2.0-dev libgmp3-dev libltdl-dev libmpc-dev libmpfr-dev libncurses5-dev libncursesw5-dev libreadline-dev libssl-dev libtool lrzsz mkisofs msmtp nano ninja-build p7zip p7zip-full patch pkgconf python2.7 python3 python3-pyelftools libpython3-dev qemu-utils rsync scons squashfs-tools subversion swig texinfo uglifyjs upx-ucl unzip vim wget xmlto xxd zlib1g-dev python3-setuptools

拉取 openwrt 官方源:

git clone -b v23.05.2 https://github.com/openwrt/openwrt.git

拉取需要编译的源

cd openwrt/package/
git clone https://github.com/xxx # xxx 改为你需要手动编译的 ipk 地址和名字

更新 feeds

cd ../
./scripts/feeds update -a && ./scripts/feeds install -a

选择 ipk

make menuconfig

再打开的菜单中,找到对应选项并配置成 M 即可(按空格)!

注意:记得选择 Target System 设置输出的目标为你的机型!

获取交叉编译链

make tools/install V=s -j$(grep processor /proc/cpuinfo | wc -l)
make toolchain/install V=s -j$(grep processor /proc/cpuinfo | wc -l)

编译 ipk

make package/xxx/compile V=s -j$(grep processor /proc/cpuinfo | wc -l)

编译完成后,ipk 文件会生成在 ./bin/packages/<Target System>/base 目录下,直接拷贝出来就可以安装了!注意对应 openwrt 的版本号哦~