Commit 509b82f3 authored by Josua Mayer's avatar Josua Mayer

miscellaneous additions to build container

- can work with podman
- added required packages
- allow using an apt proxy
Signed-off-by: default avatarJosua Mayer <josua@solid-run.com>
parent 3275231e
...@@ -16,12 +16,19 @@ A docker image providing a consistent build environment can be used as below: ...@@ -16,12 +16,19 @@ A docker image providing a consistent build environment can be used as below:
1. build container image (first time only) 1. build container image (first time only)
``` ```
docker build -t lx2160a_build docker docker build -t lx2160a_build docker
# optional with an apt proxy, e.g. apt-cacher-ng
# docker build --build-arg APTPROXY=http://127.0.0.1:3142 -t lx2160a_build docker
``` ```
2. invoke build script in working directory 2. invoke build script in working directory
``` ```
docker run -i -t -v "$PWD":/work lx2160a_build $(id -u) $(id -g) docker run -i -t -v "$PWD":/work lx2160a_build -u $(id -u) -g $(id -g)
``` ```
### rootless Podman
Due to the way podman performs user-id mapping, the root user inside the container (uid=0, gid=0) will be mapped to the user running podman (e.g. 1000:100).
Therefore in order for the build directory to be owned by current user, `-u 0 -g 0` have to be passed to *docker run*.
## Build with host tools ## Build with host tools
Simply running ./runme.sh will check for required tools, clone and build images and place results in images/ directory. Simply running ./runme.sh will check for required tools, clone and build images and place results in images/ directory.
...@@ -41,7 +48,7 @@ Selecting boot loader - *BOOT_LOADER=u-boot,uefi* ...@@ -41,7 +48,7 @@ Selecting boot loader - *BOOT_LOADER=u-boot,uefi*
### Examples: ### Examples:
- `./runme.sh` **or** - `./runme.sh` **or**
- `docker run -i -t -v "$PWD":/work lx2160a_build $(id -u) $(id -g)` - `docker run -i -t -v "$PWD":/work lx2160a_build -u $(id -u) -g $(id -g)`
generates *images/lx2160acex7_2000_700_3200_8_5_2.img* which is an image ready to be deployed on micro SD card and *images/lx2160acex7_xspi_2000_700_3200_8_5_2.img* which is an image ready to be deployed on the COM SPI flash. generates *images/lx2160acex7_2000_700_3200_8_5_2.img* which is an image ready to be deployed on micro SD card and *images/lx2160acex7_xspi_2000_700_3200_8_5_2.img* which is an image ready to be deployed on the COM SPI flash.
......
# use debian base # use debian base
FROM debian:buster-slim FROM debian:buster-slim
# apt proxy (optional)
ARG APTPROXY=
RUN test -n "$APTPROXY" && printf 'Acquire::http { Proxy "%s"; }\n' $APTPROXY | tee -a /etc/apt/apt.conf.d/proxy
# update # update
RUN set -e; \ RUN set -e; \
apt-get update; \ apt-get update; \
apt-get -y upgrade; \ apt-get -y upgrade; \
: :
RUN apt-get update ; apt-get -y install wget make tar p7zip-full squashfs-tools vim \ RUN apt-get update ; apt-get -y install build-essential wget make p7zip p7zip-full \
e2fsprogs parted dosfstools acpica-tools mtools \ device-tree-compiler acpica-tools xz-utils sudo gcc libssl-dev python2 \
device-tree-compiler xz-utils sudo gcc libssl-dev python2 python3 \ bison flex u-boot-tools git bc fuseext2 e2tools multistrap \
bison flex u-boot-tools git bc fuseext2 e2tools multistrap \ qemu-system-arm g++ cpio python unzip rsync dosfstools tar pandoc \
qemu-system-arm g++ cpio python unzip rsync python3 meson ninja-build squashfs-tools parted mtools
# build environment # build environment
WORKDIR /work WORKDIR /work
COPY shflags /
COPY entry.sh / COPY entry.sh /
ENTRYPOINT ["/bin/sh", "/entry.sh"] ENTRYPOINT ["/bin/sh", "/entry.sh"]
...@@ -8,27 +8,30 @@ ...@@ -8,27 +8,30 @@
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# #
if [ $# -ne 2 ]; then # include shFlags library
echo "Error: Missing arguments uid and gid!" . /shflags
echo "Maybe you forgot to pass <uid> <gid> to docker run?"
exit 1
fi
_UID=$1 # declare flags
_GID=$2 DEFINE_integer 'uid' 1000 'User ID to run as' 'u'
DEFINE_integer 'gid' 100 'Group ID to run as' 'g'
# create build user (and group if it does not exist) # parse flags
groupadd -g $_GID build 2>/dev/null || true FLAGS "$@" || exit 1
useradd -s /bin/bash -m -u $_UID -g $_GID build eval set -- "${FLAGS_ARGV}"
# passwordless sudo for build user # create build-user and group if not root
adduser build sudo user=root
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers if [ "x${FLAGS_uid}" != "x0" ]; then
groupadd -g ${FLAGS_gid} build 2>/dev/null || true
useradd -s /bin/bash -u ${FLAGS_uid} -g ${FLAGS_gid} -m -G sudo build
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
user=build
fi
# preconfigure git identity # preconfigure git identity
sudo -u build git config --global user.name "LX2160A Toolchain Container" sudo -u $user git config --global user.name "LX2160A Toolchain Container"
sudo -u build git config --global user.email "support@solid-run.com" sudo -u $user git config --global user.email "support@solid-run.com"
cd /work cd /work
# now run the build script as the build user # now run the build script as the build user
sudo -u build ./runme.sh sudo -u $user ./runme.sh
This diff is collapsed.
...@@ -12,14 +12,14 @@ BUILDROOT_VERSION=2020.02.1 ...@@ -12,14 +12,14 @@ BUILDROOT_VERSION=2020.02.1
############################################################################### ###############################################################################
# Misc # Misc
############################################################################### ###############################################################################
RELEASE=${RELEASE:-LSDK-21.08} : ${RELEASE:=LSDK-21.08}
DDR_SPEED=${DDR_SPEED:-3200} : ${DDR_SPEED:=2600}
SERDES=${SERDES:-8_5_2} : ${SERDES:=8_5_2}
UEFI_RELEASE=${UEFI_RELEASE:-RELEASE} : ${UEFI_RELEASE:=RELEASE}
SHALLOW=${SHALLOW:false} : ${SHALLOW:=false}
SECURE=${SECURE:false} : ${SECURE:=false}
ATF_DEBUG=${ATF_DEBUG:false} : ${ATF_DEBUG:=false}
DISTRO=${DISTRO:ubuntu} : ${DISTRO:=ubuntu}
if [ "x$SHALLOW" == "xtrue" ]; then if [ "x$SHALLOW" == "xtrue" ]; then
SHALLOW_FLAG="--depth 1" SHALLOW_FLAG="--depth 1"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment