aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorneonloop2021-03-07 14:47:57 +0000
committerneonloop2021-03-07 14:47:57 +0000
commit9ab73f47aedebd94eb4d353262a582d9fd3a8cec (patch)
treee73509334e64bd337d9524cf03f1d910c90ca521
parent4ad5efd6071cefe6cc813d5d6b38869b54a44eaf (diff)
downloadtrimui-toolchain-9ab73f47aedebd94eb4d353262a582d9fd3a8cec.tar.gz
trimui-toolchain-9ab73f47aedebd94eb4d353262a582d9fd3a8cec.tar.bz2
trimui-toolchain-9ab73f47aedebd94eb4d353262a582d9fd3a8cec.zip
Clear buildroot source after building
This saves an enormous amount of disk space in the image. Since fewer packages are installed, there is a method for installing extra packages. This also adds a helper script for setting up common cross-compiling variables.
-rw-r--r--.gitignore2
-rw-r--r--Dockerfile34
-rw-r--r--Makefile2
-rw-r--r--README.md7
-rwxr-xr-xbuild_toolchain.sh19
-rwxr-xr-xenv-setup.sh5
-rw-r--r--extra_packages.txt1
7 files changed, 41 insertions, 29 deletions
diff --git a/.gitignore b/.gitignore
index d713d0f..36e8ac9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,3 @@
.build
workspace/*
-extras/* \ No newline at end of file
+extras/*
diff --git a/Dockerfile b/Dockerfile
index 7fb7e1e..a4a96b7 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -3,19 +3,14 @@ FROM ubuntu:16.04
RUN apt-get -y update \
&& apt-get -y install \
bc \
- bison \
build-essential \
bzip2 \
- clang \
cpio \
curl \
g++ \
git \
- libboost-dev \
libncurses5-dev \
- libz-dev \
locales \
- libtool \
make \
patch \
perl \
@@ -23,51 +18,38 @@ RUN apt-get -y update \
unzip \
rsync \
wget \
- zip \
&& rm -rf /var/lib/apt/lists/*
-
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \
locale-gen
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
+ENV BUILDROOT_VERSION 2016.05
ENV BUILDROOT_HOST_DIR /var/lib/trimui-toolchain
ENV BUILDROOT_SYSROOT ${BUILDROOT_HOST_DIR}/usr/arm-buildroot-linux-gnueabi/sysroot/
-ENV BR_VER 2016.05
-ENV BR_DIR buildroot-${BR_VER}
-ENV BR_TAR ${BR_DIR}.tar.bz2
-ENV BR_URL https://buildroot.org/downloads/${BR_TAR}
-
-
RUN useradd -d /home/trimui -m -s /bin/bash -U trimui
RUN mkdir -p ${BUILDROOT_HOST_DIR} && \
chown -R trimui:trimui ${BUILDROOT_HOST_DIR} && \
ln -s ${BUILDROOT_HOST_DIR}/usr /opt/trimui-toolchain
-
USER trimui
WORKDIR /home/trimui
COPY trimui_config trimui_config
+COPY build_toolchain.sh *.patch ./
+RUN ./build_toolchain.sh
-RUN echo ${BR_DIR} && wget ${BR_URL} && ls -l && tar xf ${BR_TAR} && rm -f ${BR_TAR}
-RUN ln -s ${BR_DIR} buildroot
-
-WORKDIR /home/trimui/buildroot
-RUN make trimui_defconfig BR2_EXTERNAL=../trimui_config && make toolchain
+COPY env-setup.sh .
-COPY *.patch .
-RUN for patch in *.patch; do patch -p0 < $patch; done
-RUN make
-
-
-WORKDIR /home/trimui
+COPY extra_packages.txt .
+USER root
+RUN apt-get -y update && apt-get -y install $(cat extra_packages.txt) && rm -rf /var/lib/apt/lists/*
+USER trimui
COPY extras extras
-
RUN rsync -av extras/* $BUILDROOT_SYSROOT/usr/
VOLUME /home/trimui/workspace
diff --git a/Makefile b/Makefile
index c15fc2b..fb073f4 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ shell: .build
docker run -it --rm -v $(WORKSPACE_DIR):/home/trimui/workspace trimui-toolchain /bin/bash
.PHONY: shell
-.build: Dockerfile *.patch $(CONFIG_FILES) $(EXTRA_FILES)
+.build: Dockerfile *.patch build_toolchain.sh env-setup.sh extra_packages.txt $(CONFIG_FILES) $(EXTRA_FILES)
docker build -t trimui-toolchain .
touch .build
diff --git a/README.md b/README.md
index cf180ae..69f3c85 100644
--- a/README.md
+++ b/README.md
@@ -10,8 +10,13 @@ After building the first time, unless a dependency of the image has changed, `ma
- On your host machine, clone repositories into `./workspace` and make changes as usual.
- In the container shell, find the repository in `~/workspace` and build as usual.
+ - Optionally, `source ~/env-setup.sh` in the shell to set common cross-compiling and path variables.
-### Adding additional files to the toolchain sysroot
+### Installing extra packages
+
+To install extra packages into your container, add the ubuntu package names to `./extra_packages.txt`, one per line. They will be installed the next time you start a new shell. To keep git from tracking your changes to this file, run `git update-index --skip-worktree ./extra_packages.txt`.
+
+### Adding libraries to the toolchain sysroot
Put files that you want included in the sysroot (libs and headers, you've built, etc.) in `./extras`. They will be copied to `$SYSROOT/usr` as the container is built.
diff --git a/build_toolchain.sh b/build_toolchain.sh
new file mode 100755
index 0000000..7562c57
--- /dev/null
+++ b/build_toolchain.sh
@@ -0,0 +1,19 @@
+#! /bin/bash
+
+set -xe
+
+BR_DIR=buildroot-${BUILDROOT_VERSION:-"2016.05"}
+BR_TAR=${BR_DIR}.tar.bz2
+BR_URL=https://buildroot.org/downloads/${BR_TAR}
+
+echo ${BR_DIR} && wget ${BR_URL} && ls -l && tar xf ${BR_TAR} && rm -f ${BR_TAR}
+
+pushd ${BR_DIR}
+make trimui_defconfig BR2_EXTERNAL=../trimui_config
+make toolchain
+
+for patch in ../*.patch; do patch -p0 < $patch; done
+make
+
+popd
+rm -r ${BR_DIR}
diff --git a/env-setup.sh b/env-setup.sh
new file mode 100755
index 0000000..e3d0dc3
--- /dev/null
+++ b/env-setup.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+export CHAINPREFIX=/opt/trimui-toolchain
+export PATH=$PATH:$CHAINPREFIX/bin
+export CROSS_COMPILE=$CHAINPREFIX/bin/arm-buildroot-linux-gnueabi-
diff --git a/extra_packages.txt b/extra_packages.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/extra_packages.txt
@@ -0,0 +1 @@
+