Changes

Jump to: navigation, search

DIVELK-AN-001: Package Management with Yocto

6,194 bytes added, 21:57, 19 July 2017
Created page with "{{InfoBoxTop}} {{Applies To Diva}} {{Applies To Yocto}} {{InfoBoxBottom}} ==History== {| class="wikitable" border="1" !Version !Date !DIVELK version !Notes |- |1.0.0 |July 2..."
{{InfoBoxTop}}
{{Applies To Diva}}
{{Applies To Yocto}}
{{InfoBoxBottom}}

==History==

{| class="wikitable" border="1"
!Version
!Date
!DIVELK version
!Notes
|-
|1.0.0
|July 2017
|[[Diva_Embedded_Linux_Kit_(DIVELK)#DIVELK_software_components|3.0.0]]
|First release
|-
|}

== Introduction ==

This application note details:
* how to build packages and packages feeds with Yocto
* how to deploy your own package manager server
* how to use a package manager with a Yocto based root file system

== Yocto Package Manager ==

The default DIVELK packaging system is Open PacKaGe management, OPKG <ref name="OPKG-Wikipedia">https://en.wikipedia.org/wiki/opkg</ref>, which can be used with <code>opkg</code> command line utility to install a package, with all its dependencies, from a remote repository.

To use <code>opkg</code>, you need to be sure that the image is build with runtime package management support:

<pre>
IMAGE_FEATURES += " package-management"
</pre>

This is already enabled in default DIVELK images.

== Building packages and feeds ==

After bootstrapping the [[Yocto BSP (DIVELK)|DIVELK Yocto environment]] and build the packages you want to publish, you can create the package feeds with:

<pre>
bitbake package-index
</pre>

The files to deploy on server are inside <code>$BUILD_DIR/tmp/deploy/ipk</code>

User can also build ''all'' the recipe inside the project layers with:

<pre>
bitbake -k world
</pre>

Please note that, due the fact that some packages may fail to build, the ''-k'' switch is needed to tell bitbake continue even in case of failure.

It also require a lot of disk space (~60-80 GiB including work dir and intermediate files) and a long build time (both to download and compile the various packages)

== Configuring the webserver ==

Here we give an example in how to configure the Apache webserver on a Ubuntu 14.04 LTS distribution to serve Yocto packages. We assume that you already configure the networking properly (e.g. setup public or local DNS) and that you already install Apache with its dependencies.

* Create a new virtualhost by entering the following text inside, for example, <code>/etc/apache2/sites-available/myyocto</code>

<pre>
<VirtualHost *:80>
ServerName myyocto.example.com
ServerAdmin admin@example.com

DocumentRoot /var/www/yocto
<Directory /var/www/yocto>
Options FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
Options +Indexes
</Directory>

ErrorLog ${APACHE_LOG_DIR}/yocto-error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/yocto-access.log combined
</VirtualHost>
</pre>

* enable the virtualhost

<pre>
sudo a2ensite yocto
</pre>

* apply the changes to Apache

<pre>
sudo service apache2 restart
</pre>

* copy the feeds and packages from your build environment into the webserver directory, e.g. via ftp or scp

<pre>
scp -r $BUILD_DIR/tmp/deploy/ipk/* user@myyocto.example.com:/var/www/yocto
</pre>

== Installing packages on target ==

To use <code>opkg</code> at runtime first of all you need configure it with the address of your server and the kind of packages it provides.

Usually a standard Yocto build provide three kind of packages:
* architecture dependent packages (''all'')
* CPU architecture dependent packages (''cortexa8hf-vfp-neon'', for DIVELK)
* board dependent packages (e.g. the one that depends on the specific kernel, those packages are named ''diva'' for DIVELK)

<code>opkg</code> configuration reside in <code>/etc/opkg</code>. User can run the following commands to configure all the three packages type above:

<pre>
URL=http://yocto.example.com
FEEDS="all cortexa8hf-vfp-neon diva"

rm -f /etc/opkg/divelk-feeds.conf
for feed in $FEEDS; do
echo "feed:$feed"
echo "src/gz $feed $URL/$feed" >> /etc/opkg/divelk-feeds.conf

done
</pre>

Where <code>http://yocto.example.com</code> is the URL of the webserver.

{{ImportantMessage|text=DAVE already provides pre-build packages (from ''world'' build) for DIVELK. The URL of the server is https://yocto.dave.eu/divelk-x.y.z, where x.y.z is the DIVELK release. The latest release is always available at https://yocto.dave.eu/divelk-latest}}

After you change one of the <code>opkg</code> configuration files and/or update packages feed on server, you need to update opkg database with:

<pre>
opkg update
</pre>

Finally you can install the packages on the target with the following command:

<pre>
opkg install PACKAGE_NAME
</pre>

E.g. <code>opkg install emacs</code>


The package dependencies will be resolved automatically.

== Other useful OPKG commands ==

Apart from Yocto Project, OPKG is used on OpenWRT<ref name="OpenWRTSite">https://openwrt.org/</ref> project too, thus documentation about its usage can be found into [https://wiki.openwrt.org/doc/techref/opkg their documentation pages]

In the next section we'll show some example of OPKG usage.

=== List installed packages ===

User can see the list of installed packages with <code>opkg list-installed</code>

=== List available packages ===

To list the available packages into the current configured channels use <code>opkg list</code>

<pre>
root@diva:~# opkg list
a52dec - 0.7.4-r4 - ATSC A/52 surround sound stream decoder ATSC A/52 surround sound stream
decoder.
a52dec-doc - 0.7.4-r4 - ATSC A/52 surround sound stream decoder ATSC A/52 surround sound stream
decoder.
accel-ppp - 1.7.3+git-r1 - ACCEL-PPP is a high performance VPN server application for linux ACCEL-
PPP is a high performance VPN server application for linux.
accel-ppp-dbg - 1.7.3+git-r1 - ACCEL-PPP is a high performance VPN server application for linux -
Debugging files ACCEL-PPP is a high performance VPN server application
for linux. This package contains ELF symbols and related sources for
[...]
</pre>

Please note that ''Description'' field may contains line break and thus this may break grepping into its output.

=== Search for files ===

Files belonging to a package can be found with <code>opkg files <pkg></code>, e.g.:

Packages providing a given file can be found with <code>opkg search <file></code>, e.g.:

== References ==

{{reflist}}
743
edits

Navigation menu