Reverted c619010d3b5efa9dc0ebec7839b73cbcd59edcb2

Reverted wrong implementation of getting default architecture. It was
caused inconsitent determination of arch. Different arch was determined
for different orders of repos in .ks file. As a result of wrong
determination of architecture there are image creation failures for the
configurations, where arch was determined incorrectly.

Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
Show stdout and stderr log of post script using msger

 - Msger can't show and recode stdout and stderr log of post script
 because subprocess excuted post script with sys.stdout and sys.stderr.
 Then mic get the log using subprocess pipe and show log using msger.

Signed-off-by: Yeongil Jang <yg0577.jang@samsung.com>
kickstart: add the installerfw KS command

This command will be used in the KS file and it will specify the list legacy
MIC features which have to be disabled. Instead of these feature, the general
installer framework infrastructure mechanisms will be used.

The first option will be "extlinux" which will disable the legacy extlinux
installation feature. At some point, installerfw=all will be supported,
it will disable all the legacy features (for keyboard, fstab, users, etc).

Along with the option, introduce a helper function which checks if a the
installer framework has to be used for a feature. Usage example:

if use_installerfw(ks, "extlinux"):
    # do not execute MIC's built-in extlinux installation code
else:
    # the compatibility legacy mode

original written by Artem
Artem: added the use_installerfw() function.

Signed-off-by: Gui Chen <gui.chen@intel.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
raw: add an option to avoid installing extlinux

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
partitionedfs: preserve the KS partition number

The 'add_partition()' function takes partition from the KS file and processes
them. A commentary in 'add_partition()' says: "partitions have to be added in
the first-to-last order", so the order is important.

The order number is basically the partition entry number in the KS file.
Unfortunately, it is lost once the partition is added, and later on it is not
easy to match a partition from the KS file to the processed partition.

This patch teaches 'add_partition()' to preserve the KS file partition number
for later use. The new key 'ks_pnum' will be useful in the next patch, when we
export information about partitions and we want it to be in the KS file order.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
baseimager: export a number of helful environment variables

Make the MIC export a number of environment variables for the %post section of
the KickStart file.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
VfatDiskMount: do not initialize uuid

Do not try to be too smart and initialize UUID to a time-stamp. This UUID is
later on used form mounting in /etc/fstab (UUID=...), and of course this fails
for VFAT because VfatDiskMount provides a fake UUID.

Instead, make VfatDiskMount provide no UUID at all.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
ExtDiskMount: fix the UUID feature for extX

The current implementation of ExtDiskMount is strange. Instead of generating a
random UUID and then ask mkfs.extX to use that UUID, it run mkfs.extX without
-U, let's mkfs.extX generate a random UUID, and then uses e2fsdump and parses
its output.

This is not very logical, and this also does not work with the version of
mkfs that we use at the moment.

Change the logic and simply use mkfs.extX -U.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
fix rpm header not including 'VCS' tag

Signed-off-by: Gui Chen <gui.chen@intel.com>
baseimager: add a couple of more installer FW variables

Add two more installer framework variables:

INSTALLERFW_ROOT_PART_NUM and INSTALLERFW_BOOT_PART_NUM

which define the boot and root parition numbers.

Change-Id: I6b717d3051faa23edb58b44265b3eae3aab2a63e
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
Revert "baseimager: add a couple of more installer FW variables"

A better solution is invented.

This reverts commit be0a53342bec78025413dbbd0bf4de5d9c8b454f.
baseimager: move environment variable definitions

It is cleaner to have a single place where we define all the environement
variables. Move a couple of historical variables to the
'_get_post_scripts_env()' function.

Change-Id: I58e5d2dbe4477effccf254c48a1f74ccad484c8c
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
baseimager: export INSTALLERFW_MOUNT_PREFIX

The installer framework scripts sometimes need to know the real current path
where the partitions are mounted. In MIC environment, the real path is the same
as the mountpoint, except when we are not in chroot, in which case the real
path has a prefix. Export this information in the 'INSTALLERFW_MOUNT_PREFIX'
variable.

In other environments, like pc-installer, the current path may be different,
and pc-installer will export it in 'INSTALLERFW_MOUNT_PREFIX'.

This will allow us writing configuration scripts which will work in both MIC
and pc-installer environments.

Change-Id: Ia867685acb43836c7086b062e2f34908f378f355
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
Revert "VfatDiskMount: do not initialize uuid"

This reverts commit 83410bc120b1f214401517f00da86c53e9f3d1b2.

This patch is actually wrong. I discovered that FATFS actually _does_ support
UUID, it is just shorted - it is a 32-bit integer, but has to have the
'XXXX-XXXX' format for fstab.

Let's revert this patch and fix the problem properly.

Change-Id: I1d2019f2f93094d8e222b926ac2519e8e9b9c0b5
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
VfatDiskMount: fix vfat UUID string

The right format for the UUID string for vfat in Linux is 'XXXX-XXXX'. This is
how it can be used in fstab, for example (UUID='XXXX-XXXX'). Also, Linux udev
creates /dev/disk/by-uuid/XXXX-XXXX entries for vfat volumes.

The problem in VfatDiskMount is that it provides it in the 'XXXXXXXX' form
(without dash). However, mkfs.vfat does not like the dash, and this is why we
did not have it, I guess.

This patch fixes the situation and makes VfatDiskMount class expose UUID in a
fstab-friendly format. This makes --fstab-entry=uuid option also work for VFAT
volumes (I tested this).

Change-Id: I1d676e3707ef1777df910273381fe4437b415f41
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
raw: export file-system UUIDs

This will be useful when we want to create fstab entries ourselfs by using the
installer framework.

Change-Id: Ibc425517888d45a86b73e8c73abba5639eb7e093
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
baseimager: export partition device node

Also export the device node name for each partition. This will be helpful when
we start generating fstab entries in the installer framework scripts.

In MIC environment, the device node name is easily constructed from the disk
name.  The disk name compes from the KS file from the --ondisk option of the
'part' command. And --ondisk is a mandatory argument.

In other installer environments, the disk names may be very different.

Change-Id: Idafce950e511f4a7693e17be10e69fbb1e7d00d8
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
raw: support the 'fstab' installerfw attribute

Similarly to the 'extlinux' attribute of the 'installerfw' KS command, start
supporitng the 'fstab' attribute. This means, for example, if the KS file has
this command:

installerfw "extlinux,fstab"

then MIC will not install/configure extlinux, and it will not generate
/etc/fstab. Instead, installer framework scripts will do that.

I've added the support only to raw images, since installerfw "extlinux" is
allso supported only by raw images. The liveusb support can be added later. I
do not do this because I cannot test liveusb images at this point, so I am
afraid of breaking it.

Change-Id: Ic6bb7241783aeff571956762a42665fcd8881e3f
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
introduce '--check-pkgs' to check packages included

in some situation like pre-release image, they expect mic
not going on if there are some packages not going to include
in the image

Example: --check-pkgs=eglibc,bash
if either of eglibc and bash will not be present in the image,
mic should not go on the image creation

Signed-off-by: Gui Chen <gui.chen@intel.com>
implement '--check-pkgs' to check if packages included in image

check the given package list, if it will be installed, remove it
from the checking list. when check done, it proves some given
packages won't be installed to the image, mic should abort

Signed-off-by: Gui Chen <gui.chen@intel.com>