diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..2d56f2b --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,52 @@ +FROM ubuntu:18.04 + +ARG MENDER_ARTIFACT_VERSION=2.3.0 +ARG MENDER_CONVERT_VERSION=1.0.0 + +RUN apt-get update && apt-get install -y \ + kpartx \ + bison \ + flex \ + mtools \ + parted \ + mtd-utils \ + e2fsprogs \ + u-boot-tools \ + pigz \ + device-tree-compiler \ + autoconf \ + autotools-dev \ + libtool \ + pkg-config \ + python \ +# for mender-convert to run (mkfs.vfat is required for boot partition) + sudo \ + dosfstools \ +# to compile U-Boot + bc \ +# to download gcc toolchain and mender-artifact + wget \ +# to extract gcc toolchain + xz-utils \ +# to download mender-convert and U-Boot sources + git + +# Disable sanity checks made by mtools. These checks reject copy/paste operations on converted disk images. +RUN echo "mtools_skip_check=1" >> $HOME/.mtoolsrc + +# Needed while we use older U-Boot version for Raspberry Pi +# https://tracker.mender.io/browse/MEN-2198 +# Assumes $(pwd) is / +RUN wget -nc -q http://releases.linaro.org/components/toolchain/binaries/6.3-2017.05/arm-linux-gnueabihf/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf.tar.xz \ + && tar -xJf gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf.tar.xz \ + && rm gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf.tar.xz \ + && echo export PATH=$PATH:/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/bin >> /root/.bashrc + + +RUN wget -q -O /usr/bin/mender-artifact https://d1b0l86ne08fsf.cloudfront.net/mender-artifact/$MENDER_ARTIFACT_VERSION/mender-artifact \ + && chmod +x /usr/bin/mender-artifact + + +# TODO: support selecting tag of mender-convert with MENDER_CONVERT_VERSION +# TODO: consider lighter way to download to avoid git dependency +RUN git clone https://github.com/mendersoftware/mender-convert.git diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 0000000..bcb1583 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,78 @@ +Docker environment for mender-convert +===================================== + +In order to correctly set up partitions and bootloaders, mender-convert has many dependencies, +and their version and name vary between Linux distributions. + +To make using mender-convert easier, a reference setup using a Ubuntu 18.04 Docker container +is provided. + +You need to [install Docker Engine CE](https://docs.docker.com/install) to use this environment. + + +## Build the mender-convert container image + +To build a container based on Ubuntu 18.04 with all required dependencies for mender-convert, +copy this directory to your workstation and change the current directory to it. + +Then run + +```bash +./build.sh +``` + +This will create a container image you can use to run mender-convert. + + +## Use the mender-convert container image + +Create a directory `input` under the directory where you copied these files (`build.sh`, `run.sh`, etc.): + +```bash +mkdir input +``` + +Put your raw disk image into `input`, e.g. `input/2018-10-09-raspbian-stretch.img`. +Then put a Mender client binary compiled for your device into `input/mender-1.6.0-arm-linux-gnueabihf-gcc`. +See [the Mender documentation on how to cross-compile the Mender client for your device](https://docs.mender.io/development/client-configuration/cross-compiling). + +After you have built or pulled the mender-convert container image, +you can run it with + +```bash +./run.sh +``` + +This will drop you into a shell environment (interactive mode). +Change to the mender-convert directory: + +```bash +cd /mender-convert +``` + +You can now run mender-convert with your desired options, e.g. + +```bash +DEVICE_TYPE="raspberrypi3" +RAW_DISK_IMAGE="input/2018-10-09-raspbian-stretch.img" +MENDER_CLIENT="input/mender-1.6.0-arm-linux-gnueabihf-gcc" + +ARTIFACT_NAME="2018-10-09-raspbian-stretch" +MENDER_DISK_IMAGE="2018-10-09-raspbian-stretch.sdimg" +TENANT_TOKEN="" + +./mender-convert from-raw-disk-image \ + --raw-disk-image $RAW_DISK_IMAGE \ + --mender-disk-image $MENDER_DISK_IMAGE \ + --device-type $DEVICE_TYPE \ + --mender-client $MENDER_CLIENT \ + --artifact-name $ARTIFACT_NAME \ + --bootloader-toolchain arm-linux-gnueabihf \ + --server-url "https://hosted.mender.io" \ + --tenant-token $TENANT_TOKEN +``` + +Conversion will take 10-15 minutes, depending on your storage and resources available. +You can watch `output/build.log` for progress and diagnostics information. + +After it finishes, you can find your images in the `output` directory on your host machine! diff --git a/docker/build.sh b/docker/build.sh new file mode 100755 index 0000000..e0a0683 --- /dev/null +++ b/docker/build.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +set -e + +IMAGE_NAME=mender-convert + +docker build . -t $IMAGE_NAME diff --git a/docker/run.sh b/docker/run.sh new file mode 100755 index 0000000..a823dbc --- /dev/null +++ b/docker/run.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +set -e + +IMAGE_NAME=mender-convert + +INPUT_DIR="$(pwd)/input" +OUTPUT_DIR="$(pwd)/output" + +mkdir -p $OUTPUT_DIR + +docker run -it \ + --mount type=bind,source=$INPUT_DIR,target=/mender-convert/input,readonly \ + --mount type=bind,source=$OUTPUT_DIR,target=/mender-convert/output \ + --privileged=true \ + $IMAGE_NAME