How to Set Up a Yocto Build Server as a Remote Package Repository

If you are using Yocto to create your embedded linux system, it can really useful to set your server up to act as a package repository.

Setting up

Assuming that you have set your local.conf to have

PACKAGE_CLASSES ?= "package_ipk"

then when you create a full system image, you will have all of the ipk files under your ${TMPDIR}/deploy/ipk

If ${TMPDIR} has not been defined in your local.conf, it will default to <BUILD DIR>/tmp

Mine looks like:

ming@gweinydd:~/wip/yocto/build/tmp/deploy/ipk$ ls -l
total 416
drwxr-xr-x 2 ming ming 4096 Jul 9 14:50 all
drwxr-xr-x 2 ming ming 397312 Jul 11 16:49 cortexa8hf-neon
drwxr-xr-x 2 ming ming 20480 Jul 12 19:35 my_hub

What you now need to do is set up a web server to serve files from that directory.

Python

The simplest option is to use the Python HTTP Server module

cd /home/ming/wip/yocto/build/tmp/deploy/ipk
python3 -m http.server

That will start a Web Server on port 8000, so you will need to add the following lines to the file /etc/opkg/opkg.conf

src/gz all http://build-server:8000/all
src/gz cortexa8hf-neon http://build-server:8000/cortexa8hf-neon
src/gz my_hub http://build-server:8000/my_hub

Change build-server to the IP address of your build server

Apache

For me, I have the standard Apache installation, so I just create a link from /var/www/html/project to the ipk directory.

ln -s /home/ming/wip/yocto/build/tmp/deploy/ipk /var/www/html/repo

Then restart the server

apachectl restart

To get Yocto to create a package manifest run the bitbake command:

bitbake package-index

The, over on your embedded system, edit the file /etc/opkg/opkg.conf and add the lines (editing the build-server and repo names):

src/gz all http://build-server/repo/all
src/gz cortexa8hf-neon http://build-server/repo/cortexa8hf-neon
src/gz my_hub http://build-server/repo/my_hub

Change build-server to the IP address of your build server

Update the list of Available Packages

Now you can run an opkg update to update the list of available packages.

Note: Updates may not be cached, so you may need to re-run that after a reboot.

Installing a package

To install a package that you have previously built, run opkg install <PACKAGE NAME>

If you add a new package or update an existing one (in which case you need to ensure you update the PR value in the recipe!), you will need to build the complete system image in order for bitbake to create the ipk file.

To get a full list of opkg commands, just run opkg without any arguments.