基于docker构建香橙派zero系统构建环境

最近接触了很多板子,用的Soc都不一样,自己的开发设备中的环境已经混乱的不行。所以想到使用docker来管理这些开发环境,方便又省心~

构建过程

下载docker镜像

docker pull ubuntu:18.04

新建并启动docker容器

docker run -it \
--privileged=true --cap-add=ALL \
--name opizero_env \
-p 40022:22 \
-v /home/luo/dataHDD1/OPI_SDK/OPIzero:/work \
-v /lib/modules:/lib/modules \
-v /dev:/dev \
ubuntu:18.04 /bin/bash

重新进入docker容器的交互模式

docker exec -it opizero_env /bin/bash 

进入容器后

apt update
apt install vim -y

修改软件源(阿里源)(可以不改)

vim /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

# deb https://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

下载SDK源码

git clone https://github.com/orangepi-xunlong/orangepi-build.git

安装依赖工具

apt install whiptail dialog psmisc acl uuid uuid-runtime curl gnupg gawk git
apt-get install binfmt-support qemu qemu-user-static debootstrap

执行

./build.sh

期间需要用户自己选择写参数,使用方向键选择,回车键确认就好了。

遇到的问题

问题一:系统版本过高

root@2dbd083e0bf7:/work/orangepi-build# ./build.sh
[ o.k. ] Using config file [ /work/orangepi-build/userpatches/config-example.conf ]
[ .... ] Installing package [ lsb-release ]
Hit:1 https://mirrors.ustc.edu.cn/ubuntu jammy InRelease
Hit:2 https://mirrors.ustc.edu.cn/ubuntu jammy-updates InRelease
Hit:3 https://mirrors.ustc.edu.cn/ubuntu jammy-backports InRelease
Hit:4 https://mirrors.ustc.edu.cn/ubuntu jammy-security InRelease
Hit:5 https://mirrors.ustc.edu.cn/ubuntu jammy-proposed InRelease
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
  distro-info-data libpython3-stdlib python3 python3-minimal python3.10 python3.10-minimal
Suggested packages:
  python3-doc python3-tk python3-venv python3.10-venv python3.10-doc binutils binfmt-support
The following NEW packages will be installed:
  distro-info-data libpython3-stdlib lsb-release python3 python3-minimal python3.10 python3.10-minimal
0 upgraded, 7 newly installed, 0 to remove and 6 not upgraded.
Need to get 2818 kB of archives.
After this operation, 7031 kB of additional disk space will be used.
Get:1 https://mirrors.ustc.edu.cn/ubuntu jammy-updates/main amd64 python3.10-minimal amd64 3.10.6-1~22.04.2 [2251 kB]
Get:2 https://mirrors.ustc.edu.cn/ubuntu jammy-updates/main amd64 python3-minimal amd64 3.10.6-1~22.04 [24.3 kB]
Get:3 https://mirrors.ustc.edu.cn/ubuntu jammy-updates/main amd64 python3.10 amd64 3.10.6-1~22.04.2 [497 kB]
Get:4 https://mirrors.ustc.edu.cn/ubuntu jammy-updates/main amd64 libpython3-stdlib amd64 3.10.6-1~22.04 [6910 B]
Get:5 https://mirrors.ustc.edu.cn/ubuntu jammy-updates/main amd64 python3 amd64 3.10.6-1~22.04 [22.8 kB]
Get:6 https://mirrors.ustc.edu.cn/ubuntu jammy-updates/main amd64 distro-info-data all 0.52ubuntu0.2 [5160 B]
Get:7 https://mirrors.ustc.edu.cn/ubuntu jammy/main amd64 lsb-release all 11.1.0ubuntu4 [10.8 kB]
Fetched 2818 kB in 1s (4303 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package python3.10-minimal.
(Reading database ... 11776 files and directories currently installed.)
Preparing to unpack .../python3.10-minimal_3.10.6-1~22.04.2_amd64.deb ...
Unpacking python3.10-minimal (3.10.6-1~22.04.2) ...
Setting up python3.10-minimal (3.10.6-1~22.04.2) ...
Selecting previously unselected package python3-minimal.
(Reading database ... 11785 files and directories currently installed.)
Preparing to unpack .../python3-minimal_3.10.6-1~22.04_amd64.deb ...
Unpacking python3-minimal (3.10.6-1~22.04) ...
Selecting previously unselected package python3.10.
Preparing to unpack .../python3.10_3.10.6-1~22.04.2_amd64.deb ...
Unpacking python3.10 (3.10.6-1~22.04.2) ...
Selecting previously unselected package libpython3-stdlib:amd64.
Preparing to unpack .../libpython3-stdlib_3.10.6-1~22.04_amd64.deb ...
Unpacking libpython3-stdlib:amd64 (3.10.6-1~22.04) ...
Setting up python3-minimal (3.10.6-1~22.04) ...
Selecting previously unselected package python3.
(Reading database ... 11830 files and directories currently installed.)
Preparing to unpack .../python3_3.10.6-1~22.04_amd64.deb ...
Unpacking python3 (3.10.6-1~22.04) ...
Selecting previously unselected package distro-info-data.
Preparing to unpack .../distro-info-data_0.52ubuntu0.2_all.deb ...
Unpacking distro-info-data (0.52ubuntu0.2) ...
Selecting previously unselected package lsb-release.
Preparing to unpack .../lsb-release_11.1.0ubuntu4_all.deb ...
Unpacking lsb-release (11.1.0ubuntu4) ...
Setting up python3.10 (3.10.6-1~22.04.2) ...
Setting up distro-info-data (0.52ubuntu0.2) ...
Setting up libpython3-stdlib:amd64 (3.10.6-1~22.04) ...
Setting up python3 (3.10.6-1~22.04) ...
running python rtupdate hooks for python3.10...
running python post-rtupdate hooks for python3.10...
Setting up lsb-release (11.1.0ubuntu4) ...
cat: /etc/timezone: No such file or directory
/work/orangepi-build/scripts/configuration.sh: line 321: systemd-detect-virt: command not found
[ o.k. ] Preparing [ host ]
/work/orangepi-build/scripts/general.sh: line 664: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8): No such file or directory
[ o.k. ] Build host OS release [ jammy ]
[ error ] ERROR in function prepare_host [ general.sh:700 ]
[ error ] It seems you ignore documentation and run an unsupported build system: jammy
[ o.k. ] Process terminated
系统版本过高……修改docker环境版本即可

问题二:编译停止

Running in chroot, ignoring request.
invoke-rc.d: policy-rc.d denied execution of start.
Setting up libdigest-sha-perl (6.02-1build2) ...
Setting up gcc (4:9.3.0-1ubuntu2) ...
Setting up dpkg-dev (1.19.7ubuntu3.2) ...
Setting up liberror-perl (0.17029-1) ...
Setting up python3-requests-unixsocket (0.2.0-2) ...
Setting up python3-software-properties (0.99.9.11) ...
Setting up git (1:2.25.1-1ubuntu3.10) ...
Setting up g++-9 (9.4.0-1ubuntu1~20.04.1) ...
Setting up g++ (4:9.3.0-1ubuntu2) ...
update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode
Setting up build-essential (12.8ubuntu1.1) ...
Setting up bind9-dnsutils (1:9.16.1-0ubuntu2.12) ...
Setting up glib-networking:armhf (2.64.2-1ubuntu0.1) ...
Setting up libsoup2.4-1:armhf (2.70.0-1) ...
Setting up dnsutils (1:9.16.1-0ubuntu2.12) ...
Setting up libappstream4:armhf (0.12.10-2) ...
Setting up packagekit (1.1.13-2ubuntu1.1) ...
Running in chroot, ignoring request.
invoke-rc.d: policy-rc.d denied execution of force-reload.
Failed to open connection to "system" message bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
Created symlink /etc/systemd/user/sockets.target.wants/pk-debconf-helper.socket -> /usr/lib/systemd/user/pk-debconf-helper.socket.
Setting up software-properties-common (0.99.9.11) ...
Processing triggers for initramfs-tools (0.136ubuntu6.7) ...
Processing triggers for libc-bin (2.31-0ubuntu9.9) ...
Processing triggers for systemd (245.4-4ubuntu3.20) ...
Processing triggers for dbus (1.12.16-2ubuntu2.3) ...
Processing triggers for resolvconf (1.82) ...
[ o.k. ] Ending debootstrap process and preparing cache [ focal ]
[ o.k. ] Unmounting [ /work/orangepi-build/.tmp/rootfs-current-orangepizero-focal-no-no ]
focal-cli-armhf.539...60f.tar.lz4:  745MiB [ 242MiB/s] [=================================================================] 107%
[ o.k. ] Applying distribution specific tweaks for [ focal ]
[ o.k. ] Applying common tweaks
[ .... ] Updating [ package lists ]
[ .... ] Installing [ linux-u-boot-current-orangepizero_2.2.2_armhf.deb ]
/work/orangepi-build/scripts/image-helpers.sh: line 125: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
[ .... ] Installing [ linux-image-current-sunxi_2.2.2_armhf.deb ]
/work/orangepi-build/scripts/image-helpers.sh: line 125: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
[ .... ] Installing [ linux-dtb-current-sunxi_2.2.2_armhf.deb ]
/work/orangepi-build/scripts/image-helpers.sh: line 125: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
[ .... ] Installing [ linux-focal-root-current-orangepizero_2.2.2_armhf.deb ]
/work/orangepi-build/scripts/image-helpers.sh: line 125: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
[ .... ] Installing [ orangepi-firmware_2.2.2_all.deb ]
/work/orangepi-build/scripts/image-helpers.sh: line 125: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
[ .... ] Installing [ orangepi-config_2.2.2_all.deb ]
/work/orangepi-build/scripts/image-helpers.sh: line 125: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
[ o.k. ] Enabling serial console [ ttyS0 ]
[ o.k. ] Enabling serial console [ ttyGS0 ]
[ .... ] Installing additional packages [  hostapd htop mmc-utils sunxi-tools ]
/work/orangepi-build/scripts/chroot-buildpackages.sh: line 333: kill: (428772) - No such process
[ o.k. ] Calling image customization script [ customize-image.sh ]
[ o.k. ] Unmounting [ /work/orangepi-build/.tmp/rootfs-current-orangepizero-focal-no-no ]
[ o.k. ] Preparing image file for rootfs [ orangepizero focal ]
[ o.k. ] Current rootfs size [ 895 MiB ]
[ o.k. ] Creating blank image for rootfs [ 1124 MiB ]
[ .... ] dd: 1.10GiB [ 138MiB/s] [======================================================================================>] 100%
[ o.k. ] Creating partitions [ root: ext4 ]
[ error ] ERROR in function check_loop_device [ image-helpers.sh:82 ][ error ] Device node /dev/loop11p1 does not exist
[ o.k. ] Process terminated
[ o.k. ] Unmounting [ /work/orangepi-build/.tmp/rootfs-current-orangepizero-focal-no-no/ ]
[ error ] ERROR in function unmount_on_exit [ image-helpers.sh:69 ][ error ] debootstrap-ng was interrupted
[ o.k. ] Process terminated
docker挂载ISO/分区时报failed to setup loop device: No such file or directory - 不方便说的个人空间 - OSCHINA - 中文开源技
确定是没有内核模块需要在创建容器的时候添加-v /lib/modules:/lib/modules

问题三:检查不到系统版本

root@bde5cc8d9cb9:/work/orangepi-build# ./build.sh
[ o.k. ] Using config file [ /work/orangepi-build/userpatches/config-example.conf ]
[ .... ] Installing package [ lsb-release ]
Hit:1 http://mirrors.aliyun.com/ubuntu bionic InRelease
Hit:2 http://mirrors.aliyun.com/ubuntu bionic-security InRelease
Hit:3 http://mirrors.aliyun.com/ubuntu bionic-updates InRelease
Hit:4 http://mirrors.aliyun.com/ubuntu bionic-backports InRelease
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 lsb-release : Depends: python3:any (>= 3.4~)
E: Unable to correct problems, you have held broken packages.
cat: /etc/timezone: No such file or directory
/work/orangepi-build/scripts/configuration.sh: line 321: lsb_release: command not found
/work/orangepi-build/scripts/configuration.sh: line 321: systemd-detect-virt: command not found
[ o.k. ] Preparing [ host ]
/work/orangepi-build/scripts/general.sh: line 664: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8): No such file or directory
/work/orangepi-build/scripts/general.sh: line 676: lsb_release: command not found
[ o.k. ] Build host OS release [ (unknown) ]
[ error ] ERROR in function prepare_host [ general.sh:700 ]
[ error ] It seems you ignore documentation and run an unsupported build system: (unknown)
[ o.k. ] Process terminated
镜像破损

问题四:Package manager is running in the background.

root@fdcdb5f876b6:/work/orangepi-build# ./build.sh
./build.sh: line 86: sudo: command not found
./build.sh: line 87: sudo: command not found
./build.sh: line 90: sudo: command not found
./build.sh: line 91: sudo: command not found
[ o.k. ] Create example config file using template [ config-default.conf ]
[ o.k. ] Using config file [ /work/orangepi-build/userpatches/config-example.conf ]
[ warn ] Package manager is running in the background. [ Please wait! Retrying in 30 sec ]
[ warn ] Package manager is running in the background. [ Please wait! Retrying in 30 sec ]
[ warn ] Package manager is running in the background. [ Please wait! Retrying in 30 sec ]
[ warn ] Package manager is running in the background. [ Please wait! Retrying in 30 sec ]
[ warn ] Package manager is running in the background. [ Please wait! Retrying in 30 sec ]
[ warn ] Package manager is running in the background. [ Please wait! Retrying in 30 sec ]
一直在运行这个……

没有成功安装依赖环境!!!

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值