Target commands are executed within the root filesystem which we are just building. This concept is similar to the one of Docker.
The key benefit of using those commands is, that it is very natural. You can automate virtually every command, which you would use to configure the system manually in your terminal.
When you build a system for a foreign architecture, Wharfie uses Qemu to.be able to execute the commands on your x86 host.
Run gets exactly one argument. This is the command, which should be executed on the targets root filesystem. This command can be multiline.
For example:
RUN apt-get install -y psutils \
openssh-server ...
The Backslash () at the end of the line indicates, that the command continues in the next line.
If you want to install a new software on your target image, you most likely want to use apt. To avoid apt and dpkg from requesting inputs from the user, you can pass "-y" to apt-get.
For example:
RUN apt-get install -y tzdata
In case you want to deviate from the default, you might want to use dpkg-reconfigure after the installation.
RUN echo Antarctica/Mawson > /etc/timezone && dpkg-reconfigure -f noninteractive tzdata
An easy, non-interactive way to add a user and set his password is to use the tools "useradd" and "chpasswd".
This example adds the user "wharfie" with the password "secret":
RUN useradd -ms /bin/bash wharfie; echo "wharfie:secret" | chpasswd;
This command comes from Docker. There it defines the one and only entry point of the docker container. In Wharfie it defines a command that is executed from a systems service unit. So there can be multiple commands, and they are all executed at the end of the boot process.
For example:
CMD ['/run.sh']
This command is creating an archive with all the license texts of all installed packages. Note, that packages which are installed from 3rd party sources are not included in this archive.
For example:
LICENSE all-licenses.tar
This command is creating an archive with all debian source packages, which are currently installed in the system. Like for the license archive, this archive doesn't contain 3rd party packages.
SOURCES all-sources.tar
This command exports a crosstoolchain, containing the full root filesystem of the target, as well as a cross compiler for an x86 host.
It can be simply exported as a tar archive.
For example:
TOOLCHAIN cross-toolchain.tar
If you need more host tools then just the gcc compiler, you can define those packages in an environment variable.
ENV ADDITIONAL_TOOLCHAIN_PACKAGES libstdc++4.9-dev ...