├── Dockerfile ├── Makefile ├── README.md ├── entrypoint.sh ├── ubuntu-14.04 ├── Dockerfile ├── Makefile └── entrypoint.sh ├── ubuntu-16.04 ├── Dockerfile ├── Makefile └── entrypoint.sh ├── ubuntu-18.04 ├── Dockerfile ├── Makefile └── entrypoint.sh ├── ubuntu-20.04 ├── Dockerfile ├── Makefile └── entrypoint.sh ├── ubuntu-22.04 ├── Dockerfile ├── Makefile └── entrypoint.sh ├── ubuntu-24.04 ├── Dockerfile ├── Makefile └── entrypoint.sh └── yocto-build.sh /Dockerfile: -------------------------------------------------------------------------------- 1 | # This dockerfile uses the ubuntu image 2 | # VERSION 0 - EDITION 1 3 | # Author: Yen-Chin, Lee 4 | # Command format: Instruction [arguments / command] .. 5 | 6 | FROM ubuntu:16.04 7 | MAINTAINER Yen-Chin, Lee, coldnew.tw@gmail.com 8 | 9 | # Add 32bit package in package list 10 | RUN dpkg --add-architecture i386 11 | 12 | # Update package infos first 13 | RUN apt-get update -y 14 | 15 | ## Install requred packages: 16 | # http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html 17 | 18 | # Essentials 19 | RUN apt-get install -y gawk wget git-core diffstat unzip texinfo gcc-multilib \ 20 | build-essential chrpath socat cpio python python3 python3-pip python3-pexpect \ 21 | xz-utils debianutils iputils-ping vim bc g++-multilib bash realpath 22 | 23 | # Graphical and Eclipse Plug-In Extras 24 | RUN apt-get install -y libsdl1.2-dev xterm 25 | 26 | # Documentation 27 | RUN apt-get install -y make xsltproc docbook-utils fop dblatex xmlto 28 | 29 | # OpenEmbedded Self-Test 30 | RUN apt-get install -y python-git 31 | 32 | # Extra package for build with NXP's images 33 | RUN apt-get install -y \ 34 | sed cvs subversion coreutils texi2html \ 35 | python-pysqlite2 help2man gcc g++ \ 36 | desktop-file-utils libgl1-mesa-dev libglu1-mesa-dev mercurial \ 37 | autoconf automake groff curl lzop asciidoc u-boot-tools busybox 38 | 39 | # Extra package for Xilinx PetaLinux 40 | RUN apt-get install -y xvfb libtool libncurses5-dev libssl-dev zlib1g-dev:i386 tftpd 41 | 42 | # Install repo tool for some bsp case, like NXP's yocto 43 | RUN curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > /usr/bin/repo 44 | RUN chmod a+x /usr/bin/repo 45 | 46 | # Install Java 47 | #RUN \ 48 | # echo oracle-java11-installer shared/accepted-oracle-license-v1-2 select true | debconf-set-selections && \ 49 | # apt-get install -y software-properties-common && \ 50 | # add-apt-repository -y ppa:linuxuprising/java && \ 51 | # apt-get update && \ 52 | # apt-get install -y oracle-java11-installer-local && \ 53 | # rm -rf /var/lib/apt/lists/* && \ 54 | # rm -rf /var/cache/oracle-jdk11-installer-local 55 | 56 | # Set the locale, else yocto will complain 57 | RUN apt-get install locales -y 58 | RUN locale-gen en_US.UTF-8 && \ 59 | DEBIAN_FRONTEND=noninteractive dpkg-reconfigure locales 60 | ENV LANG en_US.UTF-8 61 | ENV LANGUAGE en_US:en 62 | ENV LC_ALL en_US.UTF-8 63 | 64 | # make /bin/sh symlink to bash instead of dash 65 | # Xilinx's petalinux need this 66 | RUN echo "dash dash/sh boolean false" | debconf-set-selections 67 | RUN DEBIAN_FRONTEND=noninteractive dpkg-reconfigure dash 68 | 69 | # default workdir is /yocto 70 | WORKDIR /yocto 71 | 72 | # Add entry point, we use entrypoint.sh to mapping host user to 73 | # container 74 | COPY entrypoint.sh /entrypoint.sh 75 | RUN chmod +x /entrypoint.sh 76 | ENTRYPOINT ["/entrypoint.sh"] 77 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: build 2 | 3 | build: 4 | docker build -t coldnew/yocto-build . 5 | 6 | run: 7 | docker run -it coldnew/yocto-build 8 | 9 | deploy: 10 | docker push coldnew/yocto-build 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | docker-yocto 2 | ================= 3 | 4 | ## About 5 | 6 | This repo contains docker image I use for building the yocto images. 7 | 8 | I use the script [yocto-build.sh](https://raw.githubusercontent.com/coldnew/docker-yocto/master/yocto-build.sh) to switch yocto building environment so I can use docker to build the [Yocto project](https://www.yoctoproject.org) instad of install a ubuntu as VM. 9 | 10 | ## Setting up 11 | 12 | First download the [yocto-build.sh](https://raw.githubusercontent.com/coldnew/docker-yocto/master/yocto-build.sh) as `~/bin/yocto-build` 13 | 14 | ```sh 15 | mkdir -p ~/bin 16 | curl https://raw.githubusercontent.com/coldnew/docker-yocto/master/yocto-build.sh > ~/bin/yocto-build 17 | chmod +x ~/bin/yocto-build 18 | ``` 19 | 20 | Add following line to the `~/.bashrc` file to ensure that the `~/bin` folder is in you PATH variable. 21 | 22 | ```sh 23 | export PATH=~/bin:$PATH 24 | ``` 25 | 26 | ## Basic Usage 27 | 28 | First time to use the `yocto-build` command, you need to tell it where is the workdir we build the yocto image. 29 | 30 | For example, if I want to build yocto at `/home/coldnew/poky` then: 31 | 32 | ```sh 33 | yocto-build --workdir /home/coldnew/poky 34 | ``` 35 | 36 | After this command, we'll create a container named `yocto-build`, which is the environment we used to build the yocto image. 37 | Now you'll find your current shell is switch to the container and the `/home/coldnew/poky` is mounted to `/yocto`. 38 | 39 | ## Spawn a new shell 40 | 41 | If you want to spawn a new shell in another terminal, you can use 42 | 43 | ```sh 44 | yocto-build --shell 45 | ``` 46 | 47 | This will spawn a new shell if you already specify a workdir. 48 | 49 | ## Remove the container 50 | 51 | This script only support *ONLY ONE CONTAINER*, so If you want to change the workdir, you should remove it first, remove a container is easy, just use following command: 52 | 53 | ```sh 54 | yocto-build --rm 55 | ``` 56 | 57 | Then you can setup a new workdir you want. 58 | 59 | ## Upgrade script 60 | 61 | Upgrade this script is easy, just type 62 | 63 | ```sh 64 | yocto-build --upgrade 65 | ``` 66 | 67 | ## Pull new docker container 68 | 69 | To pull new docker image, just type 70 | 71 | ```sh 72 | yocto-build --pull 73 | ``` -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # -*- mode: shell-script; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- 3 | # 4 | # Copyright (C) 2019 coldnew 5 | # Authored-by: Yen-Chin, Lee 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License version 2 as 9 | # published by the Free Software Foundation. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License along 17 | # with this program; if not, write to the Free Software Foundation, Inc., 18 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | 20 | # first check if environment variable be set or not 21 | if [ -z "${USER}" ]; then 22 | echo "ERROR: We need USER to be set!"; exit 100 23 | fi 24 | 25 | if [ -z "${HOST_UID}" ]; then 26 | echo "ERROR: We need HOST_UID be set" ; exit 100 27 | fi 28 | 29 | if [ -z "${HOST_GID}" ]; then 30 | echo "ERROR: We need HOST_GID be set" ; exit 100 31 | fi 32 | 33 | # reset user_?id to either new id or if empty old (still one of above 34 | # might not be set) 35 | USER_UID=${HOST_UID:=$UID} 36 | USER_GID=${HOST_GID:=$GID} 37 | 38 | # Create Group 39 | groupadd ${USER} --gid ${USER_GID} > /dev/null 2>&1 40 | 41 | # Create user 42 | useradd ${USER} --shell /bin/bash --create-home \ 43 | --uid ${USER_UID} --gid ${USER_GID} > /dev/null 2>&1 44 | 45 | echo 'ALL ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers 46 | 47 | chown -R ${USER_UID}:${USER_GID} /home/${USER} > /dev/null 2>&1 48 | 49 | # switch to current user 50 | su "${USER}" 51 | 52 | # enter to shell 53 | exec /bin/bash 54 | -------------------------------------------------------------------------------- /ubuntu-14.04/Dockerfile: -------------------------------------------------------------------------------- 1 | # This dockerfile uses the ubuntu image 2 | # VERSION 0 - EDITION 1 3 | # Author: Yen-Chin, Lee 4 | # Command format: Instruction [arguments / command] .. 5 | 6 | FROM ubuntu:14.04 7 | MAINTAINER Yen-Chin, Lee, coldnew.tw@gmail.com 8 | 9 | # Add 32bit package in package list 10 | RUN dpkg --add-architecture i386 11 | 12 | # Update package infos first 13 | RUN apt-get update -y 14 | 15 | ## Install requred packages: 16 | # http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html 17 | 18 | # Essentials 19 | RUN apt-get install -y gawk wget git-core diffstat unzip texinfo gcc-multilib \ 20 | build-essential chrpath socat cpio python python3 python3-pip python3-pexpect \ 21 | xz-utils debianutils iputils-ping vim bc g++-multilib bash realpath 22 | 23 | # Graphical and Eclipse Plug-In Extras 24 | RUN apt-get install -y libsdl1.2-dev xterm 25 | 26 | # Documentation 27 | RUN apt-get install -y make xsltproc docbook-utils fop dblatex xmlto 28 | 29 | # OpenEmbedded Self-Test 30 | RUN apt-get install -y python-git 31 | 32 | # Extra package for build with NXP's images 33 | RUN apt-get install -y \ 34 | sed cvs subversion coreutils texi2html \ 35 | python-pysqlite2 help2man gcc g++ \ 36 | desktop-file-utils libgl1-mesa-dev libglu1-mesa-dev mercurial \ 37 | autoconf automake groff curl lzop asciidoc u-boot-tools busybox 38 | 39 | # Extra package for Xilinx PetaLinux 40 | RUN apt-get install -y xvfb libtool libncurses5-dev libssl-dev zlib1g-dev:i386 tftpd net-tools 41 | 42 | # Install repo tool for some bsp case, like NXP's yocto 43 | RUN curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > /usr/bin/repo 44 | RUN chmod a+x /usr/bin/repo 45 | 46 | # Install Java 47 | #RUN \ 48 | # echo oracle-java11-installer shared/accepted-oracle-license-v1-2 select true | debconf-set-selections && \ 49 | # apt-get install -y software-properties-common && \ 50 | # add-apt-repository -y ppa:linuxuprising/java && \ 51 | # apt-get update && \ 52 | # apt-get install -y oracle-java11-installer-local && \ 53 | # rm -rf /var/lib/apt/lists/* && \ 54 | # rm -rf /var/cache/oracle-jdk11-installer-local 55 | 56 | # Set the locale, else yocto will complain 57 | RUN locale-gen en_US.UTF-8 58 | ENV LANG en_US.UTF-8 59 | ENV LANGUAGE en_US:en 60 | ENV LC_ALL en_US.UTF-8 61 | 62 | # make /bin/sh symlink to bash instead of dash 63 | # Xilinx's petalinux need this 64 | RUN echo "dash dash/sh boolean false" | debconf-set-selections 65 | RUN DEBIAN_FRONTEND=noninteractive dpkg-reconfigure dash 66 | 67 | # default workdir is /yocto 68 | WORKDIR /yocto 69 | 70 | # Add entry point, we use entrypoint.sh to mapping host user to 71 | # container 72 | COPY entrypoint.sh /entrypoint.sh 73 | RUN chmod +x /entrypoint.sh 74 | ENTRYPOINT ["/entrypoint.sh"] 75 | -------------------------------------------------------------------------------- /ubuntu-14.04/Makefile: -------------------------------------------------------------------------------- 1 | all: build 2 | 3 | build: 4 | docker build -t coldnew/yocto-build:ubuntu-14.04 . 5 | 6 | run: 7 | docker run -it coldnew/yocto-build:ubuntu-14.04 8 | 9 | deploy: 10 | docker push coldnew/yocto-build:ubuntu-14.04 11 | -------------------------------------------------------------------------------- /ubuntu-14.04/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # -*- mode: shell-script; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- 3 | # 4 | # Copyright (C) 2019 coldnew 5 | # Authored-by: Yen-Chin, Lee 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License version 2 as 9 | # published by the Free Software Foundation. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License along 17 | # with this program; if not, write to the Free Software Foundation, Inc., 18 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | 20 | # first check if environment variable be set or not 21 | if [ -z "${USER}" ]; then 22 | echo "ERROR: We need USER to be set!"; exit 100 23 | fi 24 | 25 | if [ -z "${HOST_UID}" ]; then 26 | echo "ERROR: We need HOST_UID be set" ; exit 100 27 | fi 28 | 29 | if [ -z "${HOST_GID}" ]; then 30 | echo "ERROR: We need HOST_GID be set" ; exit 100 31 | fi 32 | 33 | # reset user_?id to either new id or if empty old (still one of above 34 | # might not be set) 35 | USER_UID=${HOST_UID:=$UID} 36 | USER_GID=${HOST_GID:=$GID} 37 | 38 | # Create Group 39 | groupadd ${USER} --gid ${USER_GID} > /dev/null 2>&1 40 | 41 | # Create user 42 | useradd ${USER} --shell /bin/bash --create-home \ 43 | --uid ${USER_UID} --gid ${USER_GID} > /dev/null 2>&1 44 | 45 | echo 'ALL ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers 46 | 47 | chown -R ${USER_UID}:${USER_GID} /home/${USER} > /dev/null 2>&1 48 | 49 | # switch to current user 50 | su "${USER}" 51 | 52 | # enter to shell 53 | exec /bin/bash 54 | -------------------------------------------------------------------------------- /ubuntu-16.04/Dockerfile: -------------------------------------------------------------------------------- 1 | # This dockerfile uses the ubuntu image 2 | # VERSION 0 - EDITION 1 3 | # Author: Yen-Chin, Lee 4 | # Command format: Instruction [arguments / command] .. 5 | 6 | FROM ubuntu:16.04 7 | MAINTAINER Yen-Chin, Lee, coldnew.tw@gmail.com 8 | 9 | # Add 32bit package in package list 10 | RUN dpkg --add-architecture i386 11 | 12 | # Update package infos first 13 | RUN apt-get update -y 14 | 15 | ## Install requred packages: 16 | # http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html 17 | 18 | # Essentials 19 | RUN apt-get install -y gawk wget git-core diffstat unzip texinfo gcc-multilib \ 20 | build-essential chrpath socat cpio python python3 python3-pip python3-pexpect \ 21 | xz-utils debianutils iputils-ping vim bc g++-multilib bash realpath 22 | 23 | # Graphical and Eclipse Plug-In Extras 24 | RUN apt-get install -y libsdl1.2-dev xterm 25 | 26 | # Documentation 27 | RUN apt-get install -y make xsltproc docbook-utils fop dblatex xmlto 28 | 29 | # OpenEmbedded Self-Test 30 | RUN apt-get install -y python-git 31 | 32 | # Extra package for build with NXP's images 33 | RUN apt-get install -y \ 34 | sed cvs subversion coreutils texi2html \ 35 | python-pysqlite2 help2man gcc g++ \ 36 | desktop-file-utils libgl1-mesa-dev libglu1-mesa-dev mercurial \ 37 | autoconf automake groff curl lzop asciidoc u-boot-tools busybox 38 | 39 | # Extra package for Xilinx PetaLinux 40 | RUN apt-get install -y xvfb libtool libncurses5-dev libssl-dev zlib1g-dev:i386 tftpd net-tools 41 | 42 | # Install gcc9 to build chromium and gn-native 43 | RUN apt-get upgrade -y && \ 44 | apt-get install build-essential software-properties-common -y && \ 45 | add-apt-repository ppa:ubuntu-toolchain-r/test -y && \ 46 | apt-get update -y && \ 47 | apt-get install gcc-9 g++-9 -y && \ 48 | update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-9 && \ 49 | update-alternatives --config gcc 50 | 51 | # Install repo tool for some bsp case, like NXP's yocto 52 | RUN curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > /usr/bin/repo 53 | RUN chmod a+x /usr/bin/repo 54 | 55 | # Install Java 56 | #RUN \ 57 | # echo oracle-java11-installer shared/accepted-oracle-license-v1-2 select true | debconf-set-selections && \ 58 | # apt-get install -y software-properties-common && \ 59 | # add-apt-repository -y ppa:linuxuprising/java && \ 60 | # apt-get update && \ 61 | # apt-get install -y oracle-java11-installer-local && \ 62 | # rm -rf /var/lib/apt/lists/* && \ 63 | # rm -rf /var/cache/oracle-jdk11-installer-local 64 | 65 | # Set the locale, else yocto will complain 66 | RUN apt-get install locales -y 67 | RUN locale-gen en_US.UTF-8 && \ 68 | DEBIAN_FRONTEND=noninteractive dpkg-reconfigure locales 69 | ENV LANG en_US.UTF-8 70 | ENV LANGUAGE en_US:en 71 | ENV LC_ALL en_US.UTF-8 72 | 73 | # make /bin/sh symlink to bash instead of dash 74 | # Xilinx's petalinux need this 75 | RUN echo "dash dash/sh boolean false" | debconf-set-selections 76 | RUN DEBIAN_FRONTEND=noninteractive dpkg-reconfigure dash 77 | 78 | # default workdir is /yocto 79 | WORKDIR /yocto 80 | 81 | # Add entry point, we use entrypoint.sh to mapping host user to 82 | # container 83 | COPY entrypoint.sh /entrypoint.sh 84 | RUN chmod +x /entrypoint.sh 85 | ENTRYPOINT ["/entrypoint.sh"] 86 | -------------------------------------------------------------------------------- /ubuntu-16.04/Makefile: -------------------------------------------------------------------------------- 1 | all: build 2 | 3 | build: 4 | docker build -t coldnew/yocto-build:ubuntu-16.04 . 5 | 6 | rebuild: 7 | docker build --no-cache -t coldnew/yocto-build:ubuntu-16.04 . 8 | run: 9 | docker run -it coldnew/yocto-build:ubuntu-16.04 10 | 11 | deploy: 12 | docker push coldnew/yocto-build:ubuntu-16.04 13 | -------------------------------------------------------------------------------- /ubuntu-16.04/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # -*- mode: shell-script; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- 3 | # 4 | # Copyright (C) 2019 coldnew 5 | # Authored-by: Yen-Chin, Lee 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License version 2 as 9 | # published by the Free Software Foundation. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License along 17 | # with this program; if not, write to the Free Software Foundation, Inc., 18 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | 20 | # first check if environment variable be set or not 21 | if [ -z "${USER}" ]; then 22 | echo "ERROR: We need USER to be set!"; exit 100 23 | fi 24 | 25 | if [ -z "${HOST_UID}" ]; then 26 | echo "ERROR: We need HOST_UID be set" ; exit 100 27 | fi 28 | 29 | if [ -z "${HOST_GID}" ]; then 30 | echo "ERROR: We need HOST_GID be set" ; exit 100 31 | fi 32 | 33 | # reset user_?id to either new id or if empty old (still one of above 34 | # might not be set) 35 | USER_UID=${HOST_UID:=$UID} 36 | USER_GID=${HOST_GID:=$GID} 37 | 38 | # Create Group 39 | groupadd ${USER} --gid ${USER_GID} > /dev/null 2>&1 40 | 41 | # Create user 42 | useradd ${USER} --shell /bin/bash --create-home \ 43 | --uid ${USER_UID} --gid ${USER_GID} > /dev/null 2>&1 44 | 45 | echo 'ALL ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers 46 | 47 | chown -R ${USER_UID}:${USER_GID} /home/${USER} > /dev/null 2>&1 48 | 49 | # switch to current user 50 | su "${USER}" 51 | 52 | # enter to shell 53 | exec /bin/bash 54 | -------------------------------------------------------------------------------- /ubuntu-18.04/Dockerfile: -------------------------------------------------------------------------------- 1 | # This dockerfile uses the ubuntu image 2 | # VERSION 0 - EDITION 1 3 | # Author: Yen-Chin, Lee 4 | # Command format: Instruction [arguments / command] .. 5 | 6 | FROM ubuntu:18.04 7 | MAINTAINER Yen-Chin, Lee, coldnew.tw@gmail.com 8 | 9 | # Disable interactive functions 10 | ENV DEBIAN_FRONTEND noninteractive 11 | 12 | # Add 32bit package in package list 13 | RUN dpkg --add-architecture i386 14 | RUN sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list 15 | 16 | # Update package infos first 17 | RUN apt-get update -y && apt-get upgrade -y 18 | 19 | ## Install requred packages: 20 | # http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html 21 | RUN apt-get -y build-dep qemu && \ 22 | apt-get -y remove oss4-dev 23 | 24 | # Essentials 25 | RUN apt-get install -y gawk wget git-core diffstat unzip texinfo gcc-multilib \ 26 | build-essential chrpath socat tar python python3 python3-pip python3-pexpect \ 27 | debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev \ 28 | pylint3 xterm cpio 29 | 30 | # Graphical and Eclipse Plug-In Extras 31 | RUN apt-get install -y libsdl1.2-dev xterm 32 | 33 | # Documentation 34 | RUN apt-get install -y make xsltproc docbook-utils fop dblatex xmlto 35 | 36 | # OpenEmbedded Self-Test 37 | RUN apt-get install -y python-git 38 | 39 | # Extra package for build with NXP's images 40 | RUN apt-get install -y \ 41 | sed cvs subversion coreutils texi2html \ 42 | python-pysqlite2 help2man gcc g++ \ 43 | desktop-file-utils libgl1-mesa-dev libglu1-mesa-dev mercurial \ 44 | autoconf automake groff curl lzop asciidoc u-boot-tools busybox 45 | 46 | # Extra package for Xilinx PetaLinux 47 | RUN apt-get install -y xvfb libtool libncurses5-dev libssl-dev zlib1g-dev:i386 tftpd net-tools 48 | 49 | # Install gcc10 for build chromium and gn-native 50 | RUN apt-get install build-essential software-properties-common -y && \ 51 | add-apt-repository ppa:ubuntu-toolchain-r/test -y && \ 52 | apt-get update -y && \ 53 | apt-get install gcc-10 g++-10 -y && \ 54 | update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 60 --slave /usr/bin/g++ g++ /usr/bin/g++-10 && \ 55 | update-alternatives --config gcc 56 | 57 | # Install repo tool for some bsp case, like NXP's yocto 58 | RUN curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > /usr/bin/repo 59 | RUN chmod a+x /usr/bin/repo 60 | 61 | # Install nfs-utils 62 | RUN apt-get install nfs-common -y 63 | 64 | # Install Java 65 | #RUN \ 66 | # echo oracle-java11-installer shared/accepted-oracle-license-v1-2 select true | debconf-set-selections && \ 67 | # apt-get install -y software-properties-common && \ 68 | # add-apt-repository -y ppa:linuxuprising/java && \ 69 | # apt-get update && \ 70 | # apt-get install -y oracle-java11-installer-local && \ 71 | # rm -rf /var/lib/apt/lists/* && \ 72 | # rm -rf /var/cache/oracle-jdk11-installer-local 73 | 74 | # Set the locale, else yocto will complain 75 | RUN apt-get install locales -y 76 | RUN locale-gen en_US.UTF-8 && \ 77 | DEBIAN_FRONTEND=noninteractive dpkg-reconfigure locales 78 | ENV LANG en_US.UTF-8 79 | ENV LANGUAGE en_US:en 80 | ENV LC_ALL en_US.UTF-8 81 | 82 | # make /bin/sh symlink to bash instead of dash 83 | # Xilinx's petalinux need this 84 | RUN echo "dash dash/sh boolean false" | debconf-set-selections 85 | RUN DEBIAN_FRONTEND=noninteractive dpkg-reconfigure dash 86 | 87 | # Extra packages I want 88 | RUN apt-get install -y rsync fakeroot fakechroot libpython2.7 python-setuptools 89 | 90 | # update to glibc 2.31 by use ubuntu 20.04 source 91 | # update glibc to 2.31 by use ubuntu 20.04 92 | RUN echo 'deb http://archive.ubuntu.com/ubuntu/ focal main' >> /etc/apt/sources.list.d/focal.list && \ 93 | echo 'deb-src http://archive.ubuntu.com/ubuntu/ focal main' >> /etc/apt/sources.list.d/focal.list && \ 94 | apt update -y && \ 95 | apt install -y libc6 libc6-dev && \ 96 | rm -rf /etc/apt/sources.list.d/focal.list 97 | 98 | # default workdir is /yocto 99 | WORKDIR /yocto 100 | 101 | # Add entry point, we use entrypoint.sh to mapping host user to 102 | # container 103 | COPY entrypoint.sh /entrypoint.sh 104 | RUN chmod +x /entrypoint.sh 105 | ENTRYPOINT ["/entrypoint.sh"] 106 | -------------------------------------------------------------------------------- /ubuntu-18.04/Makefile: -------------------------------------------------------------------------------- 1 | all: build 2 | 3 | build: 4 | docker build -t coldnew/yocto-build:ubuntu-18.04 . 5 | rebuild: 6 | docker build --no-cache -t coldnew/yocto-build:ubuntu-18.04 . 7 | 8 | run: 9 | docker run -it coldnew/yocto-build:ubuntu-18.04 10 | 11 | deploy: 12 | docker push coldnew/yocto-build:ubuntu-18.04 13 | -------------------------------------------------------------------------------- /ubuntu-18.04/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # -*- mode: shell-script; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- 3 | # 4 | # Copyright (C) 2019 coldnew 5 | # Authored-by: Yen-Chin, Lee 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License version 2 as 9 | # published by the Free Software Foundation. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License along 17 | # with this program; if not, write to the Free Software Foundation, Inc., 18 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | 20 | # first check if environment variable be set or not 21 | if [ -z "${USER}" ]; then 22 | echo "ERROR: We need USER to be set!"; exit 100 23 | fi 24 | 25 | if [ -z "${HOST_UID}" ]; then 26 | echo "ERROR: We need HOST_UID be set" ; exit 100 27 | fi 28 | 29 | if [ -z "${HOST_GID}" ]; then 30 | echo "ERROR: We need HOST_GID be set" ; exit 100 31 | fi 32 | 33 | # reset user_?id to either new id or if empty old (still one of above 34 | # might not be set) 35 | USER_UID=${HOST_UID:=$UID} 36 | USER_GID=${HOST_GID:=$GID} 37 | 38 | # Create Group 39 | groupadd ${USER} --gid ${USER_GID} > /dev/null 2>&1 40 | 41 | # Create user 42 | useradd ${USER} --shell /bin/bash --create-home \ 43 | --uid ${USER_UID} --gid ${USER_GID} > /dev/null 2>&1 44 | 45 | echo 'ALL ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers 46 | 47 | chown -R ${USER_UID}:${USER_GID} /home/${USER} > /dev/null 2>&1 48 | 49 | # switch to current user 50 | su "${USER}" 51 | 52 | # enter to shell 53 | exec /bin/bash 54 | -------------------------------------------------------------------------------- /ubuntu-20.04/Dockerfile: -------------------------------------------------------------------------------- 1 | # This dockerfile uses the ubuntu image 2 | # VERSION 0 - EDITION 1 3 | # Author: Yen-Chin, Lee 4 | # Command format: Instruction [arguments / command] .. 5 | 6 | FROM ubuntu:20.04 7 | MAINTAINER Yen-Chin, Lee, coldnew.tw@gmail.com 8 | 9 | # Disable interactive functions 10 | ENV DEBIAN_FRONTEND noninteractive 11 | 12 | # Add 32bit package in package list 13 | RUN dpkg --add-architecture i386 14 | RUN sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list 15 | 16 | # Update package infos first 17 | RUN apt-get update -y 18 | 19 | ## Install requred packages: 20 | # http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html 21 | RUN apt-get -y build-dep qemu && \ 22 | apt-get -y remove oss4-dev 23 | 24 | # Essentials 25 | RUN apt-get install -y gawk wget git-core diffstat unzip texinfo gcc-multilib \ 26 | build-essential chrpath socat tar python python3 python3-pip python3-pexpect \ 27 | debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev \ 28 | pylint3 xterm cpio 29 | 30 | # Graphical and Eclipse Plug-In Extras 31 | RUN apt-get install -y libsdl1.2-dev xterm 32 | 33 | # Documentation 34 | RUN apt-get install -y make xsltproc docbook-utils fop dblatex xmlto 35 | 36 | # OpenEmbedded Self-Test 37 | #RUN apt-get install -y python-git 38 | 39 | # Extra package for build with NXP's images 40 | RUN apt-get install -y \ 41 | sed cvs subversion coreutils texi2html \ 42 | python-pysqlite2 help2man gcc g++ \ 43 | desktop-file-utils libgl1-mesa-dev libglu1-mesa-dev mercurial \ 44 | autoconf automake groff curl lzop asciidoc u-boot-tools busybox 45 | 46 | # Extra package for Xilinx PetaLinux 47 | # RUN apt-get install -y xvfb libtool libncurses5-dev libssl-dev zlib1g-dev:i386 tftpd 48 | 49 | # Install repo tool for some bsp case, like NXP's yocto 50 | RUN curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > /usr/bin/repo 51 | RUN chmod a+x /usr/bin/repo 52 | 53 | # Install Java 54 | #RUN \ 55 | # echo oracle-java11-installer shared/accepted-oracle-license-v1-2 select true | debconf-set-selections && \ 56 | # apt-get install -y software-properties-common && \ 57 | # add-apt-repository -y ppa:linuxuprising/java && \ 58 | # apt-get update && \ 59 | # apt-get install -y oracle-java11-installer-local && \ 60 | # rm -rf /var/lib/apt/lists/* && \ 61 | # rm -rf /var/cache/oracle-jdk11-installer-local 62 | 63 | # Set the locale, else yocto will complain 64 | RUN apt-get install locales -y 65 | RUN locale-gen en_US.UTF-8 && \ 66 | DEBIAN_FRONTEND=noninteractive dpkg-reconfigure locales 67 | ENV LANG en_US.UTF-8 68 | ENV LANGUAGE en_US:en 69 | ENV LC_ALL en_US.UTF-8 70 | 71 | # make /bin/sh symlink to bash instead of dash 72 | # Xilinx's petalinux need this 73 | RUN echo "dash dash/sh boolean false" | debconf-set-selections 74 | RUN DEBIAN_FRONTEND=noninteractive dpkg-reconfigure dash 75 | 76 | # default workdir is /yocto 77 | WORKDIR /yocto 78 | 79 | # Add entry point, we use entrypoint.sh to mapping host user to 80 | # container 81 | COPY entrypoint.sh /entrypoint.sh 82 | RUN chmod +x /entrypoint.sh 83 | ENTRYPOINT ["/entrypoint.sh"] 84 | -------------------------------------------------------------------------------- /ubuntu-20.04/Makefile: -------------------------------------------------------------------------------- 1 | all: build 2 | 3 | build: 4 | docker build -t coldnew/yocto-build:ubuntu-20.04 . 5 | 6 | run: 7 | docker run -it coldnew/yocto-build:ubuntu-20.04 8 | 9 | deploy: 10 | docker push coldnew/yocto-build:ubuntu-20.04 11 | -------------------------------------------------------------------------------- /ubuntu-20.04/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # -*- mode: shell-script; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- 3 | # 4 | # Copyright (C) 2019 coldnew 5 | # Authored-by: Yen-Chin, Lee 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License version 2 as 9 | # published by the Free Software Foundation. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License along 17 | # with this program; if not, write to the Free Software Foundation, Inc., 18 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | 20 | # first check if environment variable be set or not 21 | if [ -z "${USER}" ]; then 22 | echo "ERROR: We need USER to be set!"; exit 100 23 | fi 24 | 25 | if [ -z "${HOST_UID}" ]; then 26 | echo "ERROR: We need HOST_UID be set" ; exit 100 27 | fi 28 | 29 | if [ -z "${HOST_GID}" ]; then 30 | echo "ERROR: We need HOST_GID be set" ; exit 100 31 | fi 32 | 33 | # reset user_?id to either new id or if empty old (still one of above 34 | # might not be set) 35 | USER_UID=${HOST_UID:=$UID} 36 | USER_GID=${HOST_GID:=$GID} 37 | 38 | # Create Group 39 | groupadd ${USER} --gid ${USER_GID} > /dev/null 2>&1 40 | 41 | # Create user 42 | useradd ${USER} --shell /bin/bash --create-home \ 43 | --uid ${USER_UID} --gid ${USER_GID} > /dev/null 2>&1 44 | 45 | echo 'ALL ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers 46 | 47 | chown -R ${USER_UID}:${USER_GID} /home/${USER} > /dev/null 2>&1 48 | 49 | # switch to current user 50 | su "${USER}" 51 | 52 | # enter to shell 53 | exec /bin/bash 54 | -------------------------------------------------------------------------------- /ubuntu-22.04/Dockerfile: -------------------------------------------------------------------------------- 1 | # This dockerfile uses the ubuntu image 2 | # VERSION 0 - EDITION 1 3 | # Author: Yen-Chin, Lee 4 | # Command format: Instruction [arguments / command] .. 5 | 6 | FROM ubuntu:22.04 7 | MAINTAINER Yen-Chin, Lee, coldnew.tw@gmail.com 8 | 9 | # Disable interactive functions 10 | ENV DEBIAN_FRONTEND noninteractive 11 | 12 | # Add 32bit package in package list 13 | RUN dpkg --add-architecture i386 14 | RUN sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list 15 | 16 | # Update package infos first 17 | RUN apt-get update -y 18 | 19 | ## Install requred packages: 20 | # http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html 21 | RUN apt-get -y build-dep qemu && \ 22 | apt-get -y remove oss4-dev 23 | 24 | # Essentials 25 | RUN apt-get install -y gawk wget git-core diffstat unzip texinfo gcc-multilib \ 26 | build-essential chrpath socat tar python3 python3-pip python3-pexpect \ 27 | debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev \ 28 | xterm cpio vim 29 | 30 | # Graphical and Eclipse Plug-In Extras 31 | RUN apt-get install -y libsdl1.2-dev xterm 32 | 33 | # Documentation 34 | RUN apt-get install -y make xsltproc docbook-utils fop dblatex xmlto 35 | 36 | # OpenEmbedded Self-Test 37 | #RUN apt-get install -y python-git 38 | 39 | # Extra package for build with NXP's images 40 | RUN apt-get install -y \ 41 | sed cvs subversion coreutils texi2html \ 42 | help2man gcc g++ \ 43 | desktop-file-utils libgl1-mesa-dev libglu1-mesa-dev mercurial \ 44 | autoconf automake groff curl lzop asciidoc u-boot-tools busybox 45 | 46 | # Extra package for Xilinx PetaLinux 47 | # RUN apt-get install -y xvfb libtool libncurses5-dev libssl-dev zlib1g-dev:i386 tftpd 48 | 49 | # Install repo tool for some bsp case, like NXP's yocto 50 | RUN curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > /usr/bin/repo 51 | RUN chmod a+x /usr/bin/repo 52 | 53 | # Install Java 54 | #RUN \ 55 | # echo oracle-java11-installer shared/accepted-oracle-license-v1-2 select true | debconf-set-selections && \ 56 | # apt-get install -y software-properties-common && \ 57 | # add-apt-repository -y ppa:linuxuprising/java && \ 58 | # apt-get update && \ 59 | # apt-get install -y oracle-java11-installer-local && \ 60 | # rm -rf /var/lib/apt/lists/* && \ 61 | # rm -rf /var/cache/oracle-jdk11-installer-local 62 | 63 | # Set the locale, else yocto will complain 64 | RUN apt-get install locales -y 65 | RUN locale-gen en_US.UTF-8 && \ 66 | DEBIAN_FRONTEND=noninteractive dpkg-reconfigure locales 67 | ENV LANG en_US.UTF-8 68 | ENV LANGUAGE en_US:en 69 | ENV LC_ALL en_US.UTF-8 70 | 71 | # make /bin/sh symlink to bash instead of dash 72 | # Xilinx's petalinux need this 73 | RUN echo "dash dash/sh boolean false" | debconf-set-selections 74 | RUN DEBIAN_FRONTEND=noninteractive dpkg-reconfigure dash 75 | 76 | # default workdir is /yocto 77 | WORKDIR /yocto 78 | 79 | # Add entry point, we use entrypoint.sh to mapping host user to 80 | # container 81 | COPY entrypoint.sh /entrypoint.sh 82 | RUN chmod +x /entrypoint.sh 83 | ENTRYPOINT ["/entrypoint.sh"] 84 | -------------------------------------------------------------------------------- /ubuntu-22.04/Makefile: -------------------------------------------------------------------------------- 1 | all: build 2 | 3 | build: 4 | docker build -t coldnew/yocto-build:ubuntu-22.04 . 5 | 6 | run: 7 | docker run -it coldnew/yocto-build:ubuntu-22.04 8 | 9 | deploy: 10 | docker push coldnew/yocto-build:ubuntu-22.04 11 | -------------------------------------------------------------------------------- /ubuntu-22.04/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # -*- mode: shell-script; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- 3 | # 4 | # Copyright (C) 2019 coldnew 5 | # Authored-by: Yen-Chin, Lee 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License version 2 as 9 | # published by the Free Software Foundation. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License along 17 | # with this program; if not, write to the Free Software Foundation, Inc., 18 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | 20 | # first check if environment variable be set or not 21 | if [ -z "${USER}" ]; then 22 | echo "ERROR: We need USER to be set!"; exit 100 23 | fi 24 | 25 | if [ -z "${HOST_UID}" ]; then 26 | echo "ERROR: We need HOST_UID be set" ; exit 100 27 | fi 28 | 29 | if [ -z "${HOST_GID}" ]; then 30 | echo "ERROR: We need HOST_GID be set" ; exit 100 31 | fi 32 | 33 | # reset user_?id to either new id or if empty old (still one of above 34 | # might not be set) 35 | USER_UID=${HOST_UID:=$UID} 36 | USER_GID=${HOST_GID:=$GID} 37 | 38 | # Create Group 39 | groupadd ${USER} --gid ${USER_GID} > /dev/null 2>&1 40 | 41 | # Create user 42 | useradd ${USER} --shell /bin/bash --create-home \ 43 | --uid ${USER_UID} --gid ${USER_GID} > /dev/null 2>&1 44 | 45 | echo 'ALL ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers 46 | 47 | chown -R ${USER_UID}:${USER_GID} /home/${USER} > /dev/null 2>&1 48 | 49 | # switch to current user 50 | su "${USER}" 51 | 52 | # enter to shell 53 | exec /bin/bash 54 | -------------------------------------------------------------------------------- /ubuntu-24.04/Dockerfile: -------------------------------------------------------------------------------- 1 | # This dockerfile uses the ubuntu image 2 | # VERSION 0 - EDITION 1 3 | # Author: Yen-Chin, Lee 4 | # Command format: Instruction [arguments / command] .. 5 | 6 | FROM ubuntu:24.04 7 | MAINTAINER Yen-Chin, Lee, coldnew.tw@gmail.com 8 | 9 | # Disable interactive functions 10 | ENV DEBIAN_FRONTEND noninteractive 11 | 12 | # https://askubuntu.com/questions/1513927/ubuntu-24-04-docker-images-now-includes-user-ubuntu-with-uid-gid-1000 13 | # remove default uid 1000 user 14 | RUN userdel -r ubuntu 15 | 16 | # Add 32bit package in package list 17 | RUN dpkg --add-architecture i386 18 | RUN sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list && \ 19 | sed -i 's/^Types: deb$/Types: deb deb-src/' /etc/apt/sources.list.d/ubuntu.sources 20 | 21 | ## Install requred packages: 22 | # http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html 23 | RUN apt-get update -y && \ 24 | apt-get -y build-dep qemu 25 | 26 | # Essentials 27 | RUN apt-get install -y gawk wget git-core diffstat unzip texinfo gcc-multilib \ 28 | build-essential chrpath socat tar python3 python3-pip python3-pexpect \ 29 | debianutils iputils-ping python3-git python3-jinja2 libsdl1.2-dev \ 30 | xterm cpio 31 | 32 | # Graphical and Eclipse Plug-In Extras 33 | RUN apt-get install -y libsdl1.2-dev xterm 34 | 35 | # Documentation 36 | RUN apt-get install -y make xsltproc docbook-utils fop dblatex xmlto 37 | 38 | # OpenEmbedded Self-Test 39 | #RUN apt-get install -y python-git 40 | 41 | # Extra package for build with NXP's images 42 | RUN apt-get install -y \ 43 | sed cvs subversion coreutils texi2html \ 44 | help2man gcc g++ \ 45 | desktop-file-utils mercurial \ 46 | autoconf automake groff curl lzop asciidoc u-boot-tools busybox vim 47 | 48 | # Extra package for Xilinx PetaLinux 49 | # RUN apt-get install -y xvfb libtool libncurses5-dev libssl-dev zlib1g-dev:i386 tftpd 50 | 51 | # Install repo tool for some bsp case, like NXP's yocto 52 | RUN curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > /usr/bin/repo 53 | RUN chmod a+x /usr/bin/repo 54 | 55 | # Install Java 56 | #RUN \ 57 | # echo oracle-java11-installer shared/accepted-oracle-license-v1-2 select true | debconf-set-selections && \ 58 | # apt-get install -y software-properties-common && \ 59 | # add-apt-repository -y ppa:linuxuprising/java && \ 60 | # apt-get update && \ 61 | # apt-get install -y oracle-java11-installer-local && \ 62 | # rm -rf /var/lib/apt/lists/* && \ 63 | # rm -rf /var/cache/oracle-jdk11-installer-local 64 | 65 | # Set the locale, else yocto will complain 66 | RUN apt-get install locales -y 67 | RUN locale-gen en_US.UTF-8 && \ 68 | DEBIAN_FRONTEND=noninteractive dpkg-reconfigure locales 69 | ENV LANG en_US.UTF-8 70 | ENV LANGUAGE en_US:en 71 | ENV LC_ALL en_US.UTF-8 72 | 73 | # make /bin/sh symlink to bash instead of dash 74 | # Xilinx's petalinux need this 75 | RUN echo "dash dash/sh boolean false" | debconf-set-selections 76 | RUN DEBIAN_FRONTEND=noninteractive dpkg-reconfigure dash 77 | 78 | # default workdir is /yocto 79 | WORKDIR /yocto 80 | 81 | # Add entry point, we use entrypoint.sh to mapping host user to 82 | # container 83 | COPY entrypoint.sh /entrypoint.sh 84 | RUN chmod +x /entrypoint.sh 85 | ENTRYPOINT ["/entrypoint.sh"] 86 | -------------------------------------------------------------------------------- /ubuntu-24.04/Makefile: -------------------------------------------------------------------------------- 1 | all: build 2 | 3 | build: 4 | docker build -t coldnew/yocto-build:ubuntu-24.04 . 5 | 6 | run: 7 | docker run -it coldnew/yocto-build:ubuntu-24.04 8 | 9 | deploy: 10 | docker push coldnew/yocto-build:ubuntu-24.04 11 | -------------------------------------------------------------------------------- /ubuntu-24.04/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # -*- mode: shell-script; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- 3 | # 4 | # Copyright (C) 2019 coldnew 5 | # Authored-by: Yen-Chin, Lee 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License version 2 as 9 | # published by the Free Software Foundation. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License along 17 | # with this program; if not, write to the Free Software Foundation, Inc., 18 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | 20 | # first check if environment variable be set or not 21 | if [ -z "${USER}" ]; then 22 | echo "ERROR: We need USER to be set!"; exit 100 23 | fi 24 | 25 | if [ -z "${HOST_UID}" ]; then 26 | echo "ERROR: We need HOST_UID be set" ; exit 100 27 | fi 28 | 29 | if [ -z "${HOST_GID}" ]; then 30 | echo "ERROR: We need HOST_GID be set" ; exit 100 31 | fi 32 | 33 | # reset user_?id to either new id or if empty old (still one of above 34 | # might not be set) 35 | USER_UID=${HOST_UID:=$UID} 36 | USER_GID=${HOST_GID:=$GID} 37 | 38 | # Create Group 39 | groupadd ${USER} --gid ${USER_GID} > /dev/null 2>&1 40 | 41 | # Create user 42 | useradd ${USER} --shell /bin/bash --create-home \ 43 | --uid ${USER_UID} --gid ${USER_GID} > /dev/null 2>&1 44 | 45 | echo 'ALL ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers 46 | 47 | chown -R ${USER_UID}:${USER_GID} /home/${USER} > /dev/null 2>&1 48 | 49 | # switch to current user 50 | su "${USER}" 51 | 52 | # enter to shell 53 | exec /bin/bash 54 | -------------------------------------------------------------------------------- /yocto-build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # -*- mode: shell-script; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- 3 | # 4 | # Copyright (C) 2019 coldnew 5 | # Authored-by: Yen-Chin, Lee 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License version 2 as 9 | # published by the Free Software Foundation. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License along 17 | # with this program; if not, write to the Free Software Foundation, Inc., 18 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | 20 | 21 | # We should not have any trouble on running this script 22 | # set -x 23 | 24 | # SDIR store this script path 25 | SDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 26 | # SNAME store the script name 27 | SNAME="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")" 28 | 29 | # check for directory architecture 30 | YOCTODIR="${SDIR}" 31 | IMAGE="coldnew/yocto-build" 32 | CONTAINER="yocto-build" 33 | DOCKER_ARGS="" 34 | 35 | ############################################################ 36 | #### Library for common usage functions 37 | 38 | function INFO { 39 | : << FUNCDOC 40 | This function print the MSG with "INFO:" as prefix, and add newline after MSG 41 | 42 | parameter 1: MSG -> message for info 43 | 44 | FUNCDOC 45 | echo -e "\x1b[92m\x1b[1mINFO\x1b[0m:" 46 | echo -e "\e[92m\e[1mINFO\e[0m: ${1}\n" 47 | } 48 | 49 | function ERROR { 50 | : << FUNCDOC 51 | This function print the MSG with "ERROR:" as prefix, and add newline after MSG 52 | 53 | parameter 1: MSG -> message for info 54 | 55 | FUNCDOC 56 | 57 | echo -e "\e[31m\e[1mERROR\e[0m: ${1}\n" 58 | } 59 | 60 | ############################################################ 61 | 62 | function read_config { 63 | : << FUNCDOC 64 | 65 | This function source the ~/.yocto-build.sh to modify some variable of this script. 66 | 67 | The variables supported are: 68 | 69 | IMAGE 70 | 71 | The docker image you want to use, default: coldnew/yocto-build 72 | 73 | example: 74 | 75 | IMAGE="coldnew/yocto-build" 76 | 77 | 78 | CONTAINER 79 | 80 | The docker container name you use, default: yocto-build 81 | 82 | example: 83 | 84 | CONTAINER="yocto-build" 85 | 86 | DOCKER_ARGS 87 | 88 | Extra docker args you want to pass to it when create container 89 | 90 | example: 91 | 92 | DOCKER_ARGS=' --volume="${HOME}:${HOME}" --volume="/tmp:/tmp" ' 93 | 94 | FUNCDOC 95 | 96 | if [ -e "${HOME}/.yocto-build.sh" ]; then 97 | INFO "Read config from: ${HOME}/.yocto-build.sh" 98 | source "${HOME}/.yocto-build.sh" 99 | 100 | if [ "$IMAGE" != "coldnew/yocto-build" ]; then 101 | INFO "CONTAINER: $CONTAINER" 102 | fi 103 | 104 | if [ "$CONTAINER" != "yocto-build" ]; then 105 | INFO "CONTAINER: $CONTAINER" 106 | fi 107 | 108 | if [ "$DOCKER_ARGS" != "" ]; then 109 | INFO "DOCKER_ARGS: $DOCKER_ARGS" 110 | fi 111 | 112 | else 113 | INFO "No config file ${HOME}/.yocto-build.sh to read!" 114 | fi 115 | } 116 | 117 | function usage { 118 | cat < 121 | 122 | Arguments: 123 | 124 | -a, --attach : attach to current runing container 125 | -s, --shell : spawn a new shell to current container 126 | -w, --workdir : yocto workspace to shared with docker container 127 | -r, --rm : remove current working container 128 | -u, --upgrade : upgrade this script 129 | -p, --pull : pull new docker container image 130 | -h, --help : show this help info 131 | 132 | Description: 133 | 134 | The first time you run this script, you should specify yor 135 | yocto project directory like following: 136 | 137 | $0 --workdir /home/coldnew/poky 138 | 139 | This script will help you to pull the docker image and mount 140 | the /home/coldnew/poky to container's /yocto directory, and 141 | you can build you yocto in this container. 142 | 143 | If you want to attach current running shell, you can use: 144 | 145 | $0 --attach 146 | 147 | If you want to create a new shell, use: 148 | 149 | $0 --shell 150 | 151 | After all build done, you can remove current container by using: 152 | 153 | $0 --rm 154 | 155 | To upgrade this script, type: 156 | 157 | $0 --upgrade 158 | 159 | To pull the new docker container image, type: 160 | 161 | $0 --pull 162 | 163 | EOF 164 | } 165 | 166 | # NOTE: This requires GNU getopt. On Mac OS X and FreeBSD, you have 167 | # to install this separately 168 | TEMP=`getopt -o uasw:rph --long upgrade,attach,shell,workdir:,rm,pull,help -- "$@"` 169 | 170 | if [ $? != 0 ] ; then 171 | usage 172 | exit 1 173 | fi 174 | 175 | # if no argument 176 | if [ -z "$1" ] ;then 177 | usage 178 | exit 1 179 | fi 180 | 181 | # parsing arguments 182 | while true 183 | do 184 | case "$1" in 185 | -u | --upgrade) 186 | INFO "Upgrade script $NAME" 187 | curl https://raw.githubusercontent.com/coldnew/docker-yocto/master/yocto-build.sh > /tmp/$SNAME 188 | mv /tmp/$SNAME $SDIR/$SNAME 189 | chmod +x $SDIR/$SNAME 190 | exit $? 191 | ;; 192 | -p | --pull) 193 | INFO "Pull new image: $IMAGE" 194 | docker pull $IMAGE 195 | exit $? 196 | ;; 197 | -h | --help) 198 | usage; exit 0 199 | ;; 200 | -r | --rm) 201 | if docker inspect $CONTAINER > /dev/null 2>&1 ; then 202 | INFO "Remove container: $CONTAINER" 203 | docker rm $CONTAINER 204 | else 205 | INFO "container: $CONTAINER not exist, no need to remove" 206 | fi 207 | exit $? 208 | ;; 209 | -s | --shell) 210 | if docker inspect $CONTAINER > /dev/null 2>&1 ; then 211 | INFO "Spawn /bin/bash for container: $CONTAINER" 212 | docker exec -it $CONTAINER /entrypoint.sh 213 | else 214 | ERROR "container: $CONTAINER not exist, please use '$0 --workdir ' first" 215 | exit -1 216 | fi 217 | exit $? 218 | ;; 219 | -a | --attach) 220 | if docker inspect $CONTAINER > /dev/null 2>&1 ; then 221 | INFO "Atttach to running container: $CONTAINER" 222 | docker attach $CONTAINER 223 | else 224 | ERROR "container: $CONTAINER not exist, please use '$0 --workdir ' first" 225 | exit -1 226 | fi 227 | exit $? 228 | ;; 229 | -w | --workdir) 230 | # Try to start an existing/stopped container with thie give name $CONTAINER 231 | # otherwise, run a new one. 232 | YOCTODIR=$(readlink -m "$2") 233 | if docker inspect $CONTAINER > /dev/null 2>&1 ; then 234 | INFO "Reattaching to running container $CONTAINER" 235 | docker start -i ${CONTAINER} 236 | else 237 | INFO "Creating container $CONTAINER" 238 | USER=$(whoami) 239 | read_config 240 | docker run -it \ 241 | --volume="$YOCTODIR:/yocto" \ 242 | --volume="${HOME}/.ssh:/home/${USER}/.ssh" \ 243 | --volume="${HOME}/.gitconfig:/home/${USER}/.gitconfig" \ 244 | --volume="/etc/localtime:/etc/localtime:ro" \ 245 | --env="DISPLAY" \ 246 | --env="QT_X11_NO_MITSHM=1" \ 247 | --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ 248 | --env=HOST_UID=$(id -u) \ 249 | --env=HOST_GID=$(id -g) \ 250 | --env=USER=${USER} \ 251 | $(eval echo ${DOCKER_ARGS}) \ 252 | --name=$CONTAINER \ 253 | $IMAGE 254 | fi 255 | exit $? 256 | ;; 257 | *) 258 | usage 259 | exit $? 260 | ;; 261 | esac 262 | done 263 | 264 | # bye 265 | exit $? 266 | --------------------------------------------------------------------------------