# How to install packages in Yocto Project

**URL:** <https://hub.mender.io/t/how-to-install-packages-in-yocto-project/1004>\
**Category:** Yocto Project\
**Created:** [September 11, 2019, 2:28pm UTC](https://hub.mender.io/t/how-to-install-packages-in-yocto-project/1004 "2019-09-11T14:28:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)\
**Post date:** [September 11, 2019, 2:28pm UTC](https://hub.mender.io/t/how-to-install-packages-in-yocto-project/1004/1 "2019-09-11T14:28:45Z")

</div>

## Introduction

This is a high-level tutorial and the intention is not to cover the Yocto Project in depth. If you are interested in detailed information, we recommend that you read the [Yocto Project Mega-Manual](https://www.yoctoproject.org/docs/latest/mega-manual/mega-manual.html).

This tutorial will cover how to add packages to any given image utilizing `local.conf`.

 ![LF_17_02_Yocto-Badge-Update_Participant_Final](https://canada1.discourse-cdn.com/flex036/uploads/mender/original/1X/758c60e0e8309c4dc2519392b78668e7396c15bd.png)

## Prerequisites

To follow this tutorial, you will need:

- **A configured Yocto environment**. Please take a look at one of the following if you do not have this prepared:
  - [Preparing the Yocto Project environment from scratch](https://hub.mender.io/t/preparing-the-yocto-project-environment-from-scratch/801)
  - [Preparing the Yocto Project environment based on Mender demo environment](https://hub.mender.io/t/preparing-the-yocto-project-environment-based-on-mender-demo-environment)

- **Enough Free Memory:** Your development host should have at least 50 GBytes of free disk space for building images.

### Scope

For the sake of this tutorial lets set a couple of requirements that we want to accomplish on our target device.

We would like our image to contain the following:

- inotify-tools

> inotify-tools is a C library and a set of command-line programs for Linux providing a simple interface to inotify. These programs can be used to monitor and act upon filesystem events

Additionally we would like the following packages that are suitable for development:

- SSH server running on the device
- gdb, gdbserver and strace installed on the device
- evtest, i2c-tools, ethtool, fbset, memtester
  - these are all applications useful during testing debugging various parts of the device

### Building a package

Bitbake supports building individual packages. In the following example I will compile and package `inotify-tools`:

```auto
bitbake inotify-tools

```

This will not include `inotify-tools` in any image and it will only create a `inotify-tools` package, one can actually inspect and see that it created several packages:

```auto
ls -1 tmp/deploy/rpm/*/inotify-tools-*
tmp/deploy/rpm/cortexa7t2hf_neon_vfpv4/inotify-tools-3.14+git0+1df9af4d6c-r0.cortexa7t2hf_neon_vfpv4.rpm
tmp/deploy/rpm/cortexa7t2hf_neon_vfpv4/inotify-tools-dbg-3.14+git0+1df9af4d6c-r0.cortexa7t2hf_neon_vfpv4.rpm
tmp/deploy/rpm/cortexa7t2hf_neon_vfpv4/inotify-tools-dev-3.14+git0+1df9af4d6c-r0.cortexa7t2hf_neon_vfpv4.rpm
tmp/deploy/rpm/cortexa7t2hf_neon_vfpv4/inotify-tools-doc-3.14+git0+1df9af4d6c-r0.cortexa7t2hf_neon_vfpv4.rpm
tmp/deploy/rpm/cortexa7t2hf_neon_vfpv4/inotify-tools-src-3.14+git0+1df9af4d6c-r0.cortexa7t2hf_neon_vfpv4.rpm

```

**NOTE!** The `cortexa7t2hf_neon_vfpv4` architecture string might be different in your environment depending on what device you are targeting.

I will not cover in detail how these where created but if you are interested there is a very detailed explanation in the [Yocto Project Mega Manual](https://www.yoctoproject.org/docs/latest/mega-manual/mega-manual.html#bitbake-dev-environment) that explains all the steps executed when we ran `bitbake dropbear`.

### How to figure out what packages are available?

Before we move on, I wanted to quickly cover some tricks on how to look up what packages actually are available within Yocto as this is not not always to figure out, especially since you might not have that specific layer in your environment that provides a recipe for the desired package.

The best tool for looking up recipes/packages is the [OpenEmbedded Layer Index](https://layers.openembedded.org/layerindex/branch/master/recipes/) which keeps an index of all provided packages of the layers that are registered at the site (most are).

If you are interested in getting a list of available packages in your current environment you can run:

```auto
bitbake-layers show-recipes

```

The output of above command can of course be filtering using some simple shell tricks, e.g to find provided `python3` modules you can run:

```auto
bitbake-layers show-recipes | grep python3-*

```

### Customizing images using `local.conf`

The simplest way of adding a package to an image target is with small modification to `local.conf`.

A simple way of ensuring that `inotify-tools` is installed to any give image is by adding the following to `local.conf`:

```auto
echo 'IMAGE_INSTALL_append = " inotify-tools"' >> conf/local.conf

```

- **IMAGE\_INSTALL** - Image recipes set [IMAGE\_INSTALL](https://www.yoctoproject.org/docs/latest/mega-manual/mega-manual.html#var-IMAGE_INSTALL) to specify the packages to install into an image.

- **\_append** - This is an override that will append the specific string to a variable. The space at the beginning is important!

And if we now build `core-image-base` it will have included the `inotify-tools`:

```auto
bitbake core-image-base

```

We can add one more entry to add the packages that we want for our development image:

```auto
echo 'IMAGE_INSTALL_append = " dropbear gdb gdbserver strace evtest i2c-tools ethtool fbset memtester"' >> conf/local.conf

```

With these changes we are ensuring that regardless what image you build the above defined packages will be included.

**NOTE!** `local.conf` is considered a “local file” and any changes made to this file are not preserved should you reset your build environment. It is also encouraged not to try to use this file for any other purpose then temporary local modifications. Have a look at the [How to create custom images using Yocto Project](https://hub.mender.io/t/how-to-create-custom-images-using-yocto-project/902) tutorial which covers how do accomplish a similar result as defined here in a more sustainable way.

## Conclusion

In this tutorial we have covered the basics of how install packages utilizing `local.conf` in the Yocto Project, in the hopes that it will help you get started quickly without need of digging to deep in Yocto Project internals.

For further reading visit:

- [Yocto Mega Manual - 4.3. OpenEmbedded Build System Concepts](https://www.yoctoproject.org/docs/latest/mega-manual/mega-manual.html#openembedded-build-system-build-concepts)

* * *

_If this tutorial was useful to you, please press like, or leave a thank you note to the contributor who put valuable time into this and made it available to you. It will be much appreciated!_
