Add build code for Docker development environment

This simplifies the tedious task of building all the Rockbox
toolchains manually by providing a build code for a Docker container
image. It's useful for quickly spinning up a build client with just a
couple commands and no waiting to compile (though downloading takes a
little while).

I've built an image as built1n/rbclient on Docker Hub.

All toolchains (even the weird ones) are included, except android16.

Change-Id: I6b863628ffb397604f59ec6def2f8bb8c8c7185f
diff --git a/tools/docker_rbclient/Dockerfile b/tools/docker_rbclient/Dockerfile
new file mode 100644
index 0000000..4c31ded
--- /dev/null
+++ b/tools/docker_rbclient/Dockerfile
@@ -0,0 +1,66 @@
+FROM debian:9
+
+WORKDIR /home/rb
+
+ENV HOME /home/rb
+ENV MAKEFLAGS -j12
+
+RUN apt-get update && \
+    DEBIAN_FRONTEND=noninteractive apt-get install -y \
+    build-essential \
+    git \
+    perl \
+    curl \
+    texinfo \
+    flex \
+    bison \
+    bzip2 \
+    gzip \
+    zip \
+    patch \
+    automake \
+    libtool \
+    libtool-bin \
+    autoconf \
+    libmpc-dev \
+    gawk \
+    python \
+    python-lzo \
+    python-setuptools \
+    mtd-utils \
+    xorriso \
+    wget \
+    subversion \
+    libncurses5-dev \
+    texlive-latex-base \
+    texlive-binaries \
+    texlive-latex-extra \
+    tex4ht \
+    texlive-fonts-recommended \
+    lmodern \
+    latex-xcolor \
+    texlive-base \
+    libsdl1.2-dev \
+    libsdl1.2debian
+
+RUN cd /home/rb && git clone git://git.rockbox.org/rockbox
+
+RUN cd /home/rb/rockbox && ./tools/rockboxdev.sh --target="s"
+RUN cd /home/rb/rockbox && ./tools/rockboxdev.sh --target="m"
+RUN cd /home/rb/rockbox && ./tools/rockboxdev.sh --target="a"
+RUN cd /home/rb/rockbox && ./tools/rockboxdev.sh --target="i"
+RUN cd /home/rb/rockbox && ./tools/rockboxdev.sh --target="x"
+RUN cd /home/rb/rockbox && ./tools/rockboxdev.sh --target="y"
+
+# compile sometimes fails; place this last to avoid duplicate work
+RUN cd /home/rb/rockbox && ./tools/rockboxdev.sh --target="r"
+
+RUN cd /home/rb/rockbox && \
+    wget "http://git.rockbox.org/?p=www.git;a=blob_plain;f=buildserver/rbclient.pl;hb=HEAD" -O rbclient.pl && \
+    chmod +x rbclient.pl
+
+COPY runclient_modified.sh /home/rb/rockbox/runclient.sh
+
+RUN cd /home/rb/rockbox && chmod +x runclient.sh
+
+ENTRYPOINT cd /home/rb/rockbox && ./runclient.sh $USER $PASS $NAME
diff --git a/tools/docker_rbclient/README b/tools/docker_rbclient/README
new file mode 100644
index 0000000..a514e75
--- /dev/null
+++ b/tools/docker_rbclient/README
@@ -0,0 +1,35 @@
+This directory builds a Docker container image for a rockbox build
+client with all toolchains except android.
+
+There is a pre-built client available as built1n/rbclient on Docker
+Hub if you would like to avoid having to build all the toolchains. See
+the Docker documentation on how to pull and run it.
+
+To build from scratch:
+
+1. Make sure you have Docker installed and running.
+
+2. Run:
+
+  docker build . -t myclient
+
+  This will build the image and tag it as `myclient.'
+
+3. To run your client:
+
+  docker run -e USER=your username -e PASS=anything -e NAME=clientname \
+             myclient
+
+  You can also run a bash shell interactively by issuing:
+
+  docker run -it myclient bash
+
+  This will drop you into a fully-equiped rockbox development
+  environment.
+
+It is also possible to pull straight from Docker Hub. Run:
+
+  docker pull built1n/rbclient
+  
+Then you can use all the commands above, with `myclient' replaced with
+`built1n/rbclient'.
\ No newline at end of file
diff --git a/tools/docker_rbclient/runclient_modified.sh b/tools/docker_rbclient/runclient_modified.sh
new file mode 100644
index 0000000..7688291
--- /dev/null
+++ b/tools/docker_rbclient/runclient_modified.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+trap "exit" INT
+
+USER=$1
+PASS=$2
+NAME=$3
+ARCHLIST=arm-eabi-gcc444,arm-rb-gcc494,sh,m68k-gcc452,mipsel-gcc494,mipsel-rb-gcc494,sdl,latex
+
+while true
+do
+    if [ -f "rbclient.pl.new" ]; then
+        mv "rbclient.pl.new" "rbclient.pl"
+    fi
+    # Possible values for archlist are:
+
+    # arm-eabi-gcc444 : needed for ARM-based traditional targets
+    # arm-rb-gcc494   : linux based sony players, Samsung YP-R0 YP-R1
+    # sh : SH-based players, i.e. the Archoses
+    # m68k-gcc452 : coldfire-based players
+    # mipsel-gcc494 : MIPS-based players
+    # mipsel-rb-gcc494: linux based MIPS players i.e Agptek Rocker (Benjie T6)
+    # sdl : Non-crosscompiled targets. Simulators, application, checkwps, database tool, ...
+    # android16 : Android port
+    # latex : manuual
+
+    perl -s rbclient.pl -username=$USER -password=$PASS -clientname=$NAME -archlist=$ARCHLIST -buildmaster=buildmaster.rockbox.org -port=19999
+    res=$?
+    if test "$res" -eq 22; then
+      echo "Address the above issue(s), then restart!"
+      exit
+    fi
+    sleep 30
+done