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:
1. build container image (first time only)
```
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
```
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
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*
### Examples:
- `./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.
......
# use debian base
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
RUN set -e; \
apt-get update; \
apt-get -y upgrade; \
:
RUN apt-get update ; apt-get -y install wget make tar p7zip-full squashfs-tools vim \
e2fsprogs parted dosfstools acpica-tools mtools \
device-tree-compiler xz-utils sudo gcc libssl-dev python2 python3 \
RUN apt-get update ; apt-get -y install build-essential wget make p7zip p7zip-full \
device-tree-compiler acpica-tools xz-utils sudo gcc libssl-dev python2 \
bison flex u-boot-tools git bc fuseext2 e2tools multistrap \
qemu-system-arm g++ cpio python unzip rsync
qemu-system-arm g++ cpio python unzip rsync dosfstools tar pandoc \
python3 meson ninja-build squashfs-tools parted mtools
# build environment
WORKDIR /work
COPY shflags /
COPY entry.sh /
ENTRYPOINT ["/bin/sh", "/entry.sh"]
......@@ -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.
#
if [ $# -ne 2 ]; then
echo "Error: Missing arguments uid and gid!"
echo "Maybe you forgot to pass <uid> <gid> to docker run?"
exit 1
fi
# include shFlags library
. /shflags
_UID=$1
_GID=$2
# declare flags
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)
groupadd -g $_GID build 2>/dev/null || true
useradd -s /bin/bash -m -u $_UID -g $_GID build
# parse flags
FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}"
# passwordless sudo for build user
adduser build sudo
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
# create build-user and group if not root
user=root
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
sudo -u build 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.name "LX2160A Toolchain Container"
sudo -u $user git config --global user.email "support@solid-run.com"
cd /work
# 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
###############################################################################
# Misc
###############################################################################
RELEASE=${RELEASE:-LSDK-21.08}
DDR_SPEED=${DDR_SPEED:-3200}
SERDES=${SERDES:-8_5_2}
UEFI_RELEASE=${UEFI_RELEASE:-RELEASE}
SHALLOW=${SHALLOW:false}
SECURE=${SECURE:false}
ATF_DEBUG=${ATF_DEBUG:false}
DISTRO=${DISTRO:ubuntu}
: ${RELEASE:=LSDK-21.08}
: ${DDR_SPEED:=2600}
: ${SERDES:=8_5_2}
: ${UEFI_RELEASE:=RELEASE}
: ${SHALLOW:=false}
: ${SECURE:=false}
: ${ATF_DEBUG:=false}
: ${DISTRO:=ubuntu}
if [ "x$SHALLOW" == "xtrue" ]; then
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