• 搭建Docker开发环境_Linux


    环境搭建

    Docker

    sudo apt  install docker.io
    
    • 1

    Docker运行权限

    #添加docker group
    sudo groupadd docker# 将当前用户添加到docker组
    sudo gpasswd -a ${USER} docker# 重启docker服务:
    sudo service docker restart
    ​
    # 查看用户组及成员:
    cat /etc/group | grep docker
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15

    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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33

    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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    版本工具

    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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    Git

    git config --global user.name "gaoyang3513"
    git config --global user.email "gaoyang3513@163.com"
    
    git config --global core.editor vim
    
    • 1
    • 2
    • 3
    • 4

    开发

    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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    离线(推荐)
    # 离线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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    Debian

    安装软件包

    sudo apt install binfmt-support qemu-user-static
    
    # 安装 debian 根文件系统构建依赖的软件包,无视过程报错
    sudo dpkg -i debian/ubuntu-build-service/packages/*
    sudo apt-get install -f
    
    • 1
    • 2
    • 3
    • 4
    • 5

    编译

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

    打包

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

    问题

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

      apt install -y rsync
      
      • 1
    • 错误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/'
      
      • 1
      • 2
      • 3
      • 4

      或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
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10

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

    技巧

    # 新开
    docker exec -it Ubuntu20_RK3568 /bin/bash
    
    • 1
    • 2
  • 相关阅读:
    【OpenDDS开发指南V3.20】第四章:条件和监听
    C#中通过LINQtoXML加载、创建、保存、遍历XML和修改XML树
    862. 和至少为 K 的最短子数组 二分+栈思想/双端队列+滑窗
    uniapp实现App弹窗更新升级(完整版)热更新
    面试题-React(十一):性能优化之PureComponent和memo
    法线贴图的视线原理
    Kotlin的协程与生命周期
    Elasticsearch如何保证数据不丢失?
    DSPE-PEG-DBCO 磷脂-聚乙二醇-二苯并环辛炔 一种线性杂双官能聚乙二醇化试剂
    do end用法的妙处
  • 原文地址:https://blog.csdn.net/gaoyang3513/article/details/133051947