package_rpm: Add custom extension support for spec generation.

Add hooks to allow customisation of the rpm spec files. Since python functions
aren't visible in the data store, one variable is used to trigger the call to
a separately named function. A dummy function is not provided since this then
triggers various class ordering complexities which are best avoided.

Ultimately this will be replaced by a refactor of the code to generate the
spec file using a python class.

This allows the tizen layer to add hooks for the security manifests for
example.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
package_rpm: Add builddir macro to define source directory

This allows its usage in other RPM macros so files in ${S} can be found.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
package_manager: Add rpm v4 support

Currently the package manager code only supports rpm v5. To be useful outside
of OE or with OE layers using v4, it makes sense to add in rpm v4 support. This
takes a patch from "Bartosh, Eduard" <eduard.bartosh@intel.com> and enhances
it to also include versions of the workarounds from poky-eurogiciel to
allow rpm v4 usage with the class for image construction.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/create-recipe: minor fixes

Fixed:
- Remove PR. We don't need the "PR = r0" in the bb file.
- Function length can't get the array's size correctly.
  Should use function scalar.

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
pango / ptest: clean CFLAGS for host binary

The binary gen-all-unicode needs to be compiled for the host
architecture, the CFLAGS passed to target system could cause
build issues for it.

Signed-off-by: Wenzong Fan <wenzong.fan@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
perf.bb: fix multilib build

Fixed:
$ bitbake perf lib32-perf
ERROR: QA Issue: lib32-perf: Files/directories were installed but not shipped
  /usr/lib64
  /usr/lib64/traceevent
  /usr/lib64/traceevent/plugins
  /usr/lib64/traceevent/plugins/plugin_function.so
  /usr/lib64/traceevent/plugins/plugin_scsi.so
  /usr/lib64/traceevent/plugins/plugin_hrtimer.so
  /usr/lib64/traceevent/plugins/plugin_kmem.so
  /usr/lib64/traceevent/plugins/plugin_jbd2.so
  /usr/lib64/traceevent/plugins/plugin_xen.so
  /usr/lib64/traceevent/plugins/plugin_mac80211.so
  /usr/lib64/traceevent/plugins/plugin_cfg80211.so
  /usr/lib64/traceevent/plugins/plugin_sched_switch.so
  /usr/lib64/traceevent/plugins/plugin_kvm.so [installed-vs-shipped]

The perf.do_configure edits kernel's
${STAGING_KERNEL_DIR}/tools/perf/config/Makefile, there would be
problems since kernel doesn't have multilib, and the build result is
undetermined.

Previously, the sed command changed libdir to /usr/lib64 (or 32) in the
Makefile, so the build result was different if we build perf (64) first
or lib32-perf first.

Use the weak assignment "libdir ?=" to instead of "libdir =" will fix
the problem since the multilib builds are in different processes, and
they won't affect each other any more.

The sed command will match both $(prefix)/$(lib) and $(prefix)/lib since
the Makefile may has been modified before this patch.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
classes/compress_doc.bbclass: compress man/info pages

A distribution compression policy should be established, and used by all
packages. It compressed man pages in ${mandir} and info pages in ${infodir}

1. The doc will be compressed to gz format by default, which is configured
in ${DOC_COMPRESS}

2. It will automatically correct the compressed doc which is not
in ${DOC_COMPRESS} but in ${DOC_COMPRESS_LIST} to the format
of ${DOC_COMPRESS} policy

3. It is easy to add a new type compression by editing
local.conf, such as:
...
DOC_COMPRESS_LIST_append = ' abc'
DOC_COMPRESS = 'abc'
DOC_COMPRESS_CMD[abc] = 'abc compress cmd ***'
DOC_DECOMPRESS_CMD[abc] = 'abc decompress cmd ***'
...

[YOCTO #1238]

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
package_rpm: Add optional improved directory handling

During spec generation, ideally directories should not be auto
packaged under the %file section of rpm packages but take ownership of
specific directories.

* packages only empty directories or explict directory.
   See:
       - http://www.rpm.org/max-rpm/s1-rpm-inside-files-list-directives.html
       - "The %dir Directive"

* This will prevent the overlapping of security permission.
   For example, in Tizen the directory /etc have smack label 'System::Shared'
   So Only one package should own and set the label of /etc to prevent
   the overwriting of the smack label.

Existing behaviour is maintained if DIRFILES is not set. If it is set,
the modified behaviour is used. If can be set to an empty value by
core recipes to trigger the modified behaviour.

[RP: Modified to allow optional usage of DIRFILES]
Signed-off-by: Ronan Le Martret <ronan@fridu.net>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
rpcbind: Make user's home directory /

Signed-off-by: Dan McGregor <dan.mcgregor@usask.ca>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
xserver-nodm-init: Only start in runlevel 5

Runlevel 3 is often multi-user without X, so don't start the X
server in runlevel 3. This allows one to start up a machine without
X running from the bootloader.

Signed-off-by: Dan McGregor <dan.mcgregor@usask.ca>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/contrib/build-perf-test: Update eglibc -> glibc

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
systemd: upgrade to 216

Upgrade systemd from 213 to 216.

systemd-older-kernel.patch is removed as it's fixed in 216.

0001-uClibc-doesn-t-implement-pwritev-preadv.patch is removed because
the file it patches has been removed from the project.

0001-util-Including-missing.h-to-get-MAX_HANDLE_SZ.patch is removed because
it has been merged.

0001-missing.h-add-fake-__NR_memfd_create-for-MIPS.patch is backported
to fix compilation error for mips.

Below are the required kernel versions for systemd 216.
        Linux kernel >= 3.0
        Linux kernel >= 3.3 for loop device partition support features with nspawn
        Linux kernel >= 3.8 for Smack support

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
systemd: add PACKAGECONFIG for curl

Add PACKAGECONFIG for curl and disable it by default.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
systemd: make runlevel work in non-runlevel targets

Previously, after booting into the targets like multi-user.target or
graphical.target, the output of `runlevel' command is 'unknown'.

This is confusing for users. Normally, we would expect mutli-user.target
would have a `runlevel' output of 'N 3'.
This is the behaviour of Fedora20.

This patch installs symlinks for systemd-update-utmp-runlevel.service
in do_install task to fix the above problem.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
update-rc.d: fix logic in populate_packages_updatercd

The 'and' logic for the check is wrong. To make things clear, please
see the example below.

Say that we have a recipe A, which has a sysv-init style init script named
initA and no corresponding service file. The recipe inherits update-rc.d,
but it doesn't inherit systemd.bbclass. The DISTRO_FEATURES has 'systemd'
inside it, but it doesn't have 'sysvinit'. Now if we build an image, with
the 'and' logic in the check, the symlinks for initA would not be installed
into /etc/rc?.d directory.
This is incorrect. Because there's no corresponding service. The symlinks
in /etc/rc?.d/ should be created so that the service would be correctly
started at boot time.

The logic should really be 'or' in the check. This is actually what the code
was when it was originally written.

Several different situations are listed below to prove the correctness of the
'or' logic.

If 'sysvinit' is in DISTRO_FEATURES, the initA script would always be installed
with corresponding preisnt/postinst generated and added.

If 'sysvinit' is not in DISTRO_FEATURES, we have three situations.
1) A has initA and A.service.
   In such situation, systemd.bbclass would set INHIBIT_UPDATERCD_BBCLASS,
   so no preinst/postinst about update-rc.d would be added and the symlinks
   for initA would not be created.

2) A has initA, and the functionality of initA is not implemented internally
   in systemd.
   In such situation, symlinks for initA would be installed.

3) A has initA, and the functionality of initA is implemented internally in
   systemd or in some other recipe.
   Examples for such situation are alsa-state and keymaps in OE.
   In such situation, we need to set INHIBIT_UPDATERCD_BBCLASS in the recipe
   so that there would be no preinst/postinst scripts about update-rc.d added.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
alsa-state: fix pkg_postinst and set INHIBIT_UPDATERCD_BBCLASS

As alsa-state inherits update-rc.d, the update-rc.d part inpostinst script
has already been handled in update-rc.d.bbclass.

Besides, we need to set INHIBIT_UPDATERCD_BBCLASS to "1" if 'sysvinit'
is not in DISTRO_FEATURES. This is because the init script is not installed
in such situation, adding update-rc.d part in the preinst/postinst scripts
just makes no sense.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
keymaps: fix for systemd

Only install 'keymap.sh' script if 'sysvinit' is in DISTRO_FEATURES.
This is because systemd internally provides a mechanism to implement
the functionality this script tries to implement. Please see
systemd-vconsole-setup.service for more details.

Also we set 'INHIBIT_UPDATERCD_BBCLASS' to "1" if 'sysvinit' is not
in DISTRO_FEATURES.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
systemd: add kbd-keymaps to RRECOMMENDS of systemd-vconsole-setup

systemd-vconsole-setup.service not only configures font but also
keymaps.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
v86d: set INHIBIT_UPDATERCD_BBCLASS if 'sysvinit' not in DISTRO_FEATURES

Set INHIBIT_UPDATERCD_BBCLASS to "1" if 'sysvinit' is not in DISTRO_FEATURES.

The functionality of the init script 'fbsetup' is implemented internally in
systemd. So fbsetup is not installed if 'sysvinit' is in DISTRO_FEATURES.

That's why we need to set INHIBIT_UPDATERCD_BBCLASS to "1" to avoid
generation of update-rc.d related preinst/postinst scripts.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
systemd: add support for executing scripts under /etc/rcS.d

This patch adds support for systemd to execute scripts under /etc/rcS.d.

To be compitable, all services translated from /etc/rcS.d/ scripts would
run before services translated from /etc/rcN.d scripts.

[YOCTO #5159]

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>