Local builder installation
In this section there are commands to follow.
During development, it can be useful to have a short build cycle where you can build your package after modifying files. That is the goal of the redpesk “local builder”. We will use it to speed up our own developments.
Local builder
In this part, we will install and use the local builder to develop our custom binding. If you would like further information about the local builder, please follow this link.
Installation
You have to have either incus
or docker
installed on your host.
Firstly, we need to create some directories on your computer, depending if you already have installed rp-cli
, these directories may already exist.
mkdir -p $HOME/my_rp_builder_dir/gitsources
mkdir -p $HOME/my_rp_builder_dir/gitpkgs
Docker
- For Debian/Ubuntu:
docker run --detach \
--init \
--cap-add=SYS_ADMIN \
--security-opt apparmor:unconfined \
--user $(id -u):$(id -g) \
--publish 8080:8080 \
--volume ~/my_rp_builder_dir:/home/devel/rp-build:z \
--name redpesk-localbuilder \
registry.redpesk.bzh/redpesk-ci/redpesk-localbuilder:latest
- For Almalinux/Fedora:
docker run --detach \
--init \
--cap-add=SYS_ADMIN \
--security-opt label:disable \
--user $(id -u):$(id -g) \
--publish 8080:8080 \
--volume ~/my_rp_builder_dir:/home/devel/rp-build:z \
--name redpesk-localbuilder \
registry.redpesk.bzh/redpesk-ci/redpesk-localbuilder:latest
Incus
# Get the latest redpesk localbuilder container
wget https://download.redpesk.bzh/redpesk-ci/redpesk-builder/lxc/redpesk-localbuilder_latest.tar.gz
wget https://download.redpesk.bzh/redpesk-ci/redpesk-builder/lxc/redpesk-localbuilder_latest.md5
# Check the image integrity
md5sum --check redpesk-localbuilder_latest.md5
# Import the image in incus
incus image import ./redpesk-localbuilder.tar.gz --alias redpesk-localbuilder-image
# Create the container using the image previously downloaded
incus launch redpesk-localbuilder-image redpesk-localbuilder --config security.privileged=true --config security.nesting=true
# Add the loop-control device
incus config device add redpesk-localbuilder loop-control unix-char path=/dev/loop-control
# Import your ssh key
incus config device add redpesk-localbuilder my_ssh disk source=~/.ssh path=/home/devel/.ssh
# Mapping host directories in the container
incus config device add redpesk-localbuilder my_rp_build disk source=$HOME/my_rp_builder_dir path=/home/devel/rp-build
# Restart the local-builder
incus restart redpesk-localbuilder
Local builder connection with rp-cli
rp-cli
is the redpesk command line interface. You can find further information about rp-cli
in the chapter Concepts.
If you did not install rp-cli
yet, please use the following line:
wget https://raw.githubusercontent.com/redpesk-devtools/redpesk-sdk-tools/master/install-redpesk-sdk.sh
bash install-redpesk-sdk.sh --rp-cli
Then, configure rp-cli
by using the following command:
$ rp-cli onboard
Do you want to configure the redpesk backend connection? (Y/n)
> n
Do you want to configure the redpesk local-builder connection? (Y/n)
> Y
-- Local builder link configuration requested by user --
Current available connections: [NONE]
Please enter the IP of the local builder you want to interact with (ex: 10.231.232.2), then press enter:
> 10.231.232.187
Modification of the local builder file...[OK]
The default mounted directory (/home/armand/my_rp_builder_dir/gitsources) exists on the host, should it be used as 'gitsources' directory? (Y/n)
> Y
The default mounted directory (/home/armand/my_rp_builder_dir/gitpkgs) exists on the host, should it be used as 'gitpkgs' directory? (Y/n)
> Y
Note that
rp-cli onboard
is an helper for otherrp-cli
commands. You can also achieve similar results withrp-cli connections
to manage connections to redpesk factory andrp-cli local connections
to manage connections to your local builder.
rp-cli
requests the IP of the local builder. Enter the IP of the corresponding container running on your host and press enter. To get this IP, two methods are available, depending if you are using incus
or docker
.
- With
incus
> incus ls redpesk-localbuilder
+----------------------+---------+---------------------+------+-----------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+----------------------+---------+---------------------+------+-----------+-----------+
| redpesk-localbuilder | RUNNING | 10.171.7.234 (eth0) | | CONTAINER | 0 |
+----------------------+---------+---------------------+------+-----------+-----------+
- With
docker
> docker inspect -f json redpesk-localbuilder |jq .[].NetworkSettings.IPAddress
"172.17.0.3"
Then, rp-cli
checks if the default mounted directories exist on the system. These directories are the one created by default at the local-builder installation.
So, if during local builder installation you follow what we give in this documentation, you can answer ‘yes’ to the questions asked like in the example above.
If rp-cli
does not detect these directories in your system, he asks for the directories to use and creates them if they do not exist.
Now that rp-cli
knows where the sources are, use the following command to clone them in the right path.
The flag
--branch
is here to precise which branch of the project we want to use.
rp-cli local package init anemometer-industrial-demo --project industrial-demo-project --branch "master"
You can now work on your sources natively in the path ~/my_rp_builder_dir/gitsources/industrial-demo-project/anemometer-industrial-demo/
.