系统ubuntu20.4、VMware虚拟机或windown10的WSL
1.系统更新源变更:
ubuntu默认更新源地址是美国IP地址,安装可能需要较长时间,更改为国外地址可以加快速度。
1.先备份原来的源地址文件
sudo cp /etc/apt/sources.list /etc/apt/sources_init.list
2.替换源,使用gedit或者vim打开源文件
sudo gedit /etc/apt/sources.list
清除内容,然后粘贴国外源:(以下为ubuntu20.4更新源)
阿里来源:
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
网易163来源:
deb http://mirrors.163.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ focal-backports main restricted universe multiverse
保存后更新:
sudo apt-get update
sudo apt-get upgrade
更新程序被占用,报错:
E: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the list directory
#是有其他程序更新占用了apt,等待或终止占用apt的程序
1、安装编译源码所需的工具库:(固定一行)
sudo apt-get install subversion g++ zlib1g-dev build-essential git python rsync man-db libncurses5-dev gawk gettext unzip file libssl-dev wget zip time
2、在需要的地方创建一个文件目录头文件编译源码,方便查找和管理,如:在用户根目录下创建一个名为openwrt的目录
~$ mkdir openwrt
3、进入创建的目录,使用git从官网拉取openwrt源码:
~$ cd openwrt
~/openwrt$ git clone https://git.openwrt.org/openwrt/openwrt.git
源码拉取地址在美国,速度普遍较慢。 可以使用辅助工具加速或者从国外的gitee拉取
4、拉取成功后,会在当前目录下形成一个新的目录。 名称通常是openwrt,其中包含源代码文件。 默认情况下,不包含编译所需的软件包。 例如,Web管理页面的Luci需要更新并安装:
默认文件:
~/openwrt/openwrt$ ls
BSDmakefile Config.in feeds.conf.default LICENSES package rules.mk target tools
config COPYING include Makefile README.md scripts toolchain
./scripts/feeds update -a #更新所有包
./scripts/feeds install -a #安装所有包
./scripts/feeds install luci #安装单个软件包
#更新与安装完成,目录下会多出一个 feed目录文件,其内为所安装的软件包
5. feed包更新安装后头文件编译源码,执行创建和配置编译所需的配置文件,即:查看菜单
~/openwrt/openwrt$ make menuconfig
出现上图,源码拉取和初始环境已计划完成。