搭建Docker开发环境_Linux

环境搭建

文章目录

  • 环境搭建
    • @[toc]
    • Docker
      • Docker运行权限
      • Docker加速
      • Docker容器创建
    • Python版本切换
    • 版本工具
      • Repo
      • Git
    • 开发
      • SDK代码拉取
        • 在线
        • 离线(推荐)
    • Debian
      • 安装软件包
      • 编译
      • 打包
    • 问题
      • 技巧

Docker

sudo apt  install docker.io

Docker运行权限

#添加docker group
sudo groupadd docker# 将当前用户添加到docker组
sudo gpasswd -a ${USER} docker# 重启docker服务:
sudo service docker restart
​
# 查看用户组及成员:
cat /etc/group | grep docker

Docker加速

# 编辑 Docker 配置文件
$ sudo vim /etc/docker/daemon.json
​
# 加入以下配置项
{
    "registry-mirrors": [
        "https://dockerproxy.com",
        "https://hub-mirror.c.163.com",
        "https://mirror.baidubce.com",
        "https://ccr.ccs.tencentyun.com"
    ]
}# 重启docker
$ sudo service docker restart

Docker容器创建

# 推荐:Ubuntu 18.04 版本  
# 拉取Ubuntu镜像
docker pull ubuntu:18.04

# 进入关联源码目录挂载使用绝对路径,启动Docker
cd ~
docker run -it -v ${PWD}:${PWD} --privileged --name Ubuntu18_Lubancat2 ubuntu:18.04

# 环境依赖
apt-get update

# Docker 补充
apt install -y bc time rsync curl vim sudo

# 安装 SDK 构建所需要的软件包
apt install -y git ssh make gcc libssl-dev liblz4-tool u-boot-tools curl \
expect g++ patchelf chrpath gawk texinfo chrpath diffstat binfmt-support \
qemu-user-static live-build bison flex fakeroot cmake gcc-multilib g++-multilib \
unzip device-tree-compiler python-pip libncurses5-dev python3-pyelftools \
dpkg-dev

# 添加用户
adduser gaoyang3513

# 为用户username添加sudo权限
sudo usermod -a -G sudo gaoyang3513

# sudo 免密,在sudoer.d目录新建docker-nopasswd
#    添加内容:gaoyang3513 ALL=(ALL) NOPASSWD: ALL
sudo visudo /etc/sudoers.d/docker-nopassswd

# 切换用户
su gaoyang3513

Python版本切换

# 添加,优先python3
update-alternatives --install /usr/bin/python python /usr/bin/python2 100
update-alternatives --install /usr/bin/python python /usr/bin/python3 150# 切换
update-alternatives --config python

版本工具

Repo

# 环境配置
mkdir -p ~/.local/bin/
export PATH=~/.local/bin/:$PATH

# 下载
curl https://storage.googleapis.com/git-repo-downloads/repo > .local/bin/repo

# 权限
chmod a+x .local/bin/repo

# 生效
source .profile

Git

git config --global user.name "gaoyang3513"
git config --global user.email "[email protected]"

git config --global core.editor vim

开发

SDK代码拉取

在线
#github地址
repo --trace init --depth=1 --repo-url https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -u https://github.com/LubanCat/manifests.git -b linux -m rk356x_linux_release.xml 

# 同步源码
repo --trace sync -c -j4
离线(推荐)
# 离线SDK,解压
cd SDK_RK3568_Linux_New 
7z x ../../01-Resource/01-鲁班猫/8-SDK源码压缩包/LubanCat_rk356x_Linux_SDK_20230711.7z

repo init --depth=1 -u https://github.com/LubanCat/manifests.git -b linux -m rk356x_linux_release.xml

# 检出.repo 目录下的 git 仓库并同步
repo sync -l -j10
# 不推荐同步
# repo sync -c -j10

Debian

安装软件包

sudo apt install binfmt-support qemu-user-static

# 安装 debian 根文件系统构建依赖的软件包,无视过程报错
sudo dpkg -i debian/ubuntu-build-service/packages/*
sudo apt-get install -f

编译

# 选择目标
#     10. BoardConfig-LubanCat-RK3568-debian-xfce.mk
./build.sh lunch

打包

# 一键编译 u-Boot, kernel, Rootfs, Recovery, 并打包为 update.img 镜像
./build.sh

问题

  • 错误1../build.sh: line 717: /usr/bin/time: No such file or directory
atp instal -y time
  • 错误2. 2023-09-08T01:18:53 You must install 'rsync' on your build machine

    apt install -y rsync
    
  • 错误3. fatal: Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle

    # vi ~/bin/repo
    ​
    - REPO_URL = 'https://gerrit.googlesource.com/git-repo'
    + REPO_URL = 'https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'
    

    或repo init时参数--repo-url指定,如:--repo-url https://mirrors.tuna.tsinghua.edu.cn/git/git-repo

  • 错误.Failed to run livebuild, please check your network connection.

    if [ -f binary-tar.tar.gz ]; then \
            tar -jcf linaro-buster-alip-`date +%Y%m%d`-1.config.tar.bz2 auto/ config/ configure; \
            sudo mv binary.contents linaro-buster-alip-`date +%Y%m%d`-1.contents; \
            sudo mv chroot.packages.live linaro-buster-alip-`date +%Y%m%d`-1.packages; \
            sudo mv binary-tar.tar.gz linaro-buster-alip-`date +%Y%m%d`-1.tar.gz; \
            md5sum linaro-buster-alip-`date +%Y%m%d`-1.build-log.txt linaro-buster-alip-`date +%Y%m%d`-1.config.tar.bz2 linaro-buster-alip-`date +%Y%m%d`-1.contents linaro-buster-alip-`date +%Y%m%d`-1.packages linaro-buster-alip-`date +%Y%m%d`-1.tar.gz > linaro-buster-alip-`date +%Y%m%d`-1.md5sums.txt; \
            sha1sum linaro-buster-alip-`date +%Y%m%d`-1.build-log.txt linaro-buster-alip-`date +%Y%m%d`-1.config.tar.bz2 linaro-buster-alip-`date +%Y%m%d`-1.contents linaro-buster-alip-`date +%Y%m%d`-1.packages linaro-buster-alip-`date +%Y%m%d`-1.tar.gz > linaro-buster-alip-`date +%Y%m%d`-1.sha1sums.txt; \
    fi
     Failed to run livebuild, please check your network connection. 
    VERSION=none TARGET=xfce SOC=rk356x ./mk-buster-rootfs.sh
    

    直接原因为binary-tar.tar.gz文件未生成,根本原因为qemu中挂载/proc目录失败,解决方案:参考1.docker 中使用mount命令报错:mount: permission denied

技巧

# 新开
docker exec -it Ubuntu20_RK3568 /bin/bash
  • Github加速

    参考1.

  • 百度网盘加速

    参考1.

  • sudoer修改

    参考1. 批量修改ubuntu用户sudo免密码

你可能感兴趣的:(平台开发---RK3568,linux,lunbancat2,RK3568,Docker,Debian)