We will use lighttpd for this example, as it is lightweight and easy to configure. Follow these steps:
- Install the web server:
$ sudo apt-get install lighttpd
- By default, the document root specified in the /etc/lighttpd/lighttpd.conf configuration file is /var/www/html, so we only need a symlink to our package feed:
$ sudo ln -s /opt/yocto/fsl-community-bsp/wandboard/tmp/deploy/rpm /var/www/html/rpm
- Next, reload the configuration as follows:
$ sudo service lighttpd reload
For development, you can also launch a Python HTTP server from the feeds directory as follows:
$ cd /opt/yocto/fsl-community-bsp/wandboard/tmp/deploy/rpm
$ sudo python -m SimpleHTTPServer 80
- Refresh the package index. This needs to be done manually to update the package feed after every build:
$ bitbake package-index
- If you want to serve the packages from a different directory instead of directly from your build directory:
- You will need to copy the packages:
$ rsync -r -u /opt/yocto/fsl-community-bsp/wandboard/tmp/deploy/rpm/* <new_dir>/
-
- Then add the corresponding metadata to the repositories. For that, you will need to install the createrepo tool:
$ sudo apt-get install createrepo
-
- And direct it to the new feed directory:
$ createrepo <new_dir>
The createrepo tool will create XML-based metadata from the RPM packages:
You can also build and use the createrepo-c utility from your Yocto build system, a C implementation of createrepo, as follows:
$ bitbake createrepo-c-native -c addto_recipe_sysroot
$ oe-run-native createrepo-c-native createrepo_c <new_dir>
Then we need to configure our target filesystem with the new package feeds:
- Log in to the target and create a new directory to contain the repository configuration:
$ mkdir -p /etc/yum.repos.d
The repository configuration files will have the following format:
[<repo name>]
name=<Repository description>
baseurl=<url://path/to/repo>
enabled=<0 (disable) or 1 (enabled)>
gpgcheck=<0 (disable signature check) or 1 (enabled)>
gpgkey=<url://path/to/gpg-file if gpgcheck is enabled>
The previously mentioned baseurl is the complete URL for the repositories, with a http://, https://, ftp://, or file:// prefix.
An example repository configuration file is as follows:
$ vi /etc/yum.repos.d/yocto.repo
[yocto-rpm]
name=Yocto 2.4: rpm
baseurl=http://<server-ip>/rpm/
- Once the setup is ready, we will be able to query and update packages from the target's root filesystem with the following:
# dnf --nogpgcheck makecache
# dnf --nogpgcheck search <package_name>
# dnf --nogpgcheck install <package_name>
By default, dnf is built to use sign package feeds so we need to either configure the preceding repository with:
gpgcheck=0
Or use the --nogpgcheck command line argument as shown previously.
- To make this change persistent in the target's root filesystem, we can configure the package feeds at compilation time by using the PACKAGE_FEED_* variables in conf/local.conf, as follows:
PACKAGE_FEED_URIS = "http://<server_ip>/"
PACKAGE_FEED_BASE_PATHS = "rpm"
The package feed's base URL is composed as shown next:
${PACKAGE_FEED_URIS}/${PACKAGE_FEED_BASE_PATHS}/${PACKAGE_FEED_ARCHS}.
By default, the package feed is prepared as a single repository so there is no need to use the PACKAGE_FEED_ARCHS variable.
The variables shown previously will configure the filesystem for any of the supported package formats.