Changes

Jump to: navigation, search

XELK-AN-003: Package Management with Yocto

7,967 bytes added, 10:36, 5 April 2019
Installing packages on target
{{AppliesToAxelEsatta}}
{{AppliesToAxelLite}}
{{Applies To Yocto}}
{{InfoBoxBottom}}
{{WarningMessage|text=This application note was validated against specific versions of the kit only. It may not work with other versions. Supported versions are listed in the ''History'' section.}}
==History==
|First release
|-
|1.0.1
|November 2016
|[[Axel_Embedded_Linux_Kit_(XELK)#XELK_software_components|2.2.0]]
|Add SMART commands examples
|-
|3.0.1
|November 2017
|[[Axel_Embedded_Linux_Kit_(XELK)#XELK_software_components|3.0.1]]
|Add SMART commands output
|}
This application note details:
* how to use a package manager 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 XELK packaging system is RPM <ref name="RPM-Wikipedia">https://en.wikipedia.org/wiki/RPM_Package_Manager</ref>, which can be uses used with SMART <ref name="smart-project">https://labix.org/smart</ref><ref name="smart-yocto">https://www.yoctoproject.org/blogs/khem/2013/get-smart-smart-package-manager</ref><ref name="man-smart">https://linux.die.net/man/8/smart</ref> to install a package, with all its dependencies, from a remote repository.
To use smart, you need to be sure that the image is build with runtime package management support:
<pre>
IMAGE_FEATURES += "package-management"
</pre>
The files to deploy on server are inside <code>$BUILD_DIR/tmp/deploy/rpm</code>
User can also build ''all'' the recipe inside the configured layer project layers with:
<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 Ubuntu 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>
* 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/rpm /* user@myyocto.example.com:/var/www/yocto
</pre>
<pre>
smart channel --add xelk-2.2.0-cortexa9hf cortexa9hf_vfp_neon type=rpm-md baseurl=http://myyocto.example.com/xelk-2.2.0/cortexa9hf_vfp_neon
</pre>
Where:
* <code>xelk-2.2.0-cortexa9hfcortexa9hf_vfp_neon</code> is the name of the channel* <code>http://myyocto.example.com/xelk-2.2.0/cortexa9hf_vfp_neon</code> is the URL of the webserver We assume that network interface has been already configured for Internet access. In any case, a simple network configuration can be done directly on serial console with the following commands: <pre class="board-terminal">root@imx6qxelk:~# ifconfig eth0 192.168.0.94root@imx6qxelk:~# route add default gw 192.168.0.254root@imx6qxelk:~# echo "nameserver 8.8.8.8" > /etc/resolv.conf</pre> For example:'''<pre class="board-terminal">root@imx6qxelk:~# smart channel --add cortexa9hf_neon type=rpm-md baseurl=http://yocto.dave.eu/xelk-3.0.0/cortexa9hf_neon/ Alias: cortexa9hf_neonType: rpm-mdBase URL: http://yocto.dave.eu/xelk-3.0.0/cortexa9hf_neon/ Include this channel? (y/N): y</pre>
You can also add a ''local'' directory, for example mounted via NFS directly on target, with the following command:
After you configure the channel and/or update packages feed on server, you need to update smart database:
 
<pre class="board-terminal">
root@imx6qxelk:~# smart update
Loading cache...
Updating cache... ############################################################ [100%]
 
Fetching information for 'cortexa9hf_neon'...
-> http://yocto.dave.eu/xelk-3.0.0/cortexa9hf_neon/repodata/repomd.xml
repomd.xml ############################################################ [ 50%]
-> http://yocto.dave.eu/xelk-3.0.0/cortexa9hf_neon/repodata/primary.xml.gz
-> http://yocto.dave.eu/xelk-3.0.0/cortexa9hf_neon/repodata/filelists.xml.gz
filelists.xml.gz ############################################################ [ 75%]
primary.xml.gz ############################################################ [100%]
 
Updating cache... ############################################################ [100%]
 
Channels have 17495 new packages.
Saving cache...
 
root@imx6qxelk:~#
</pre>
 
Finally you can install the packages on the target with the following command:
<pre>
smart updateinstall PACKAGE_NAME
</pre>
Finally you can For example:<pre class="board-terminal">root@imx6qxelk:~# smart install the vim Loading cache...Updating cache... ############################################################ [100%] Computing transaction... Installing packages (and all its 6): vim-7.4.769-r0@cortexa9hf_neon vim-syntax-7.4.769-r0@cortexa9hf_neon vim-common-7.4.769-r0@cortexa9hf_neon vim-tutor-7.4.769-r0@cortexa9hf_neon vim-help-7.4.769-r0@cortexa9hf_neon vim-vimrc-7.4.769-r0@cortexa9hf_neon  9.4MB of package files are needed. 26.9MB will be used. Confirm changes? (Y/n):  Fetching packages... -> http://yocto.dave.eu/xelk-3.0.0/cortexa9hf_neon/vim-vimrc-7.4.769-r0.cortexa9hf_neon.rpm vim-vimrc-7.4.769-r0.cortexa9hf_neon.rpm ############################################################ [ 16%]-> http://yocto.dave.eu/xelk-3.0.0/cortexa9hf_neon/vim-syntax-7.4.769-r0.cortexa9hf_neon.rpm -> http://yocto.dave.eu/xelk-3.0.0/cortexa9hf_neon/vim-tutor-7.4.769-r0.cortexa9hf_neon.rpm vim-tutor-7.4.769-r0.cortexa9hf_neon.rpm ############################################################ [ 33%]-> http://yocto.dave.eu/xelk-3.0.0/cortexa9hf_neon/vim-7.4.769-r0.cortexa9hf_neon.rpm vim-7.4.769-r0.cortexa9hf_neon.rpm ############################################################ [ 50%]vim-syntax-7.4.769-r0.cortexa9hf_neon.rpm ############################################################ [ 66%]-> http://yocto.dave.eu/xelk-3.0.0/cortexa9hf_neon/vim-common-7.4.769-r0.cortexa9hf_neon.rpm -> http://yocto.dave.eu/xelk-3.0.0/cortexa9hf_neon/vim-help-7.4.769-r0.cortexa9hf_neon.rpm vim-help-7.4.769-r0.cortexa9hf_neon.rpm ############################################################ [ 83%]vim-common-7.4.769-r0.cortexa9hf_neon.rpm ############################################################ [100%]  Committing transaction...Preparing... ############################################################ [ 0%] 1:Installing vim-vimrc ############################################################ [ 16%] 2:Installing vim-help ############################################################ [ 33%] 3:Installing vim-tutor ############################################################ [ 50%] 4:Installing vim ############################################################ [ 66%]Output from vim-7.4.769-r0@cortexa9hf_neon: update-alternatives: Linking /bin/vi to /usr/bin/vim.vim update-alternatives: Linking /usr/bin/vim to /usr/bin/vim.vim 5:Installing vim-common ############################################################ [ 83%] 6:Installing vim-syntax ############################################################ [100%]</pre> The package dependencies) will be resolved automatically. == Other useful SMART commands == A brief guide to SMART command line interface is [http://labix.org/smart/user-guide/Command%20Line%20Interface here]. In the next section we'll show some example of SMART usage. === Gathering statistics === To view some information on repositories use <code>smart stats</code> <pre>root@axel:~# smart statsLoading cache...Updating cache... ######################################## [100%] Installed Packages: 331Total Packages: 11757Total Provides: 27765Total Requires: 4798Total Upgrades: 11704Total Conflicts: 73</pre> === List installed packages === User can see the target list of installed packages with the following command:<code>smart query --installed</code>
<pre>
root@axel:~# smart install PACKAGE_NAMEquery --installedLoading cache...Updating cache... ######################################## [100%] alsa-conf-1.0.28-r0@cortexa9hf_vfp_neonalsa-conf-base-1.0.28-r0@cortexa9hf_vfp_neonalsa-state-0.2.0-r5@cortexa9hf_vfp_neonalsa-states-0.2.0-r5@cortexa9hf_vfp_neonalsa-utils-alsactl-1.0.28-r1@cortexa9hf_vfp_neonalsa-utils-alsamixer-1.0.28-r1@cortexa9hf_vfp_neonapm-3.2.2+14-r2@cortexa9hf_vfp_neonapmd-3.2.2+14-r2@cortexa9hf_vfp_neonavahi-daemon-0.6.31-r11.1@cortexa9hf_vfp_neon[...]
</pre>
E=== List available packages === To list the available packages into the current configured channels use <code>smart query</code> Please note that this will show all package, it's usually more useful to give it a pattern, e.g.:
<pre>
root@axel:~# smart install emacsquery '*httpd*'Loading cache...Updating cache... ######################################## [100%] libmicrohttpd-bin-0.9.34-r0@cortexa9hf_vfp_neonlibmicrohttpd-dbg-0.9.34-r0@cortexa9hf_vfp_neonlibmicrohttpd-dev-0.9.34-r0@cortexa9hf_vfp_neonlibmicrohttpd-doc-0.9.34-r0@cortexa9hf_vfp_neonlibmicrohttpd10-0.9.34-r0@cortexa9hf_vfp_neonlighttpd-1.4.35-r1@cortexa9hf_vfp_neonlighttpd-1.4.35-r1@cortexa9hf_vfp_neonlighttpd-dbg-1.4.35-r1@cortexa9hf_vfp_neonlighttpd-dev-1.4.35-r1@cortexa9hf_vfp_neonlighttpd-doc-1.4.35-r1@cortexa9hf_vfp_neonlighttpd-module-access-1.4.35-r1@cortexa9hf_vfp_neon[...]
</pre>
8,154
edits

Navigation menu