Make sure that urlgrabber gets URLs as strings

URLs of unicode type cause a crash in python-urlgrabber.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Move function optparser_setup out of class MicCmd

Found this problem by pylint. Decorator optparser_setup is not a
instance/class/static method of MicCmd, so move it out.

Also fix wrong indent.

Change-Id: I0315951134360fa6081b904e6323e57c16b7ef9f
Add global declaration to var _LOOP_RULE_PTH

hide_loopdev_presentation() redefine a var with the same name
_LOOP_RULE_PTH by setting its value without global statement. and
its global counterpart can never be changed.

pylint message:
W0621:136,12:hide_loopdev_presentation: Redefining name '_LOOP_RULE_PTH' from outer scope (line 125)

Change-Id: I1cfafa46a933e22c732d4f4963c4a4f6d1ac4c1d
partitionedfs: remove bogus alignment check

The following perfectly valid KS option makes MIC complain about alignment and
exit:

part /d1 --size 1 --fstype=ext4 --ondisk sdb --align 1024

This creates a 1MiB partition and aligned to 1MiB.

And it is even fine to ask for a 1MiB partition to be aligned to 4MiB. So the
alignment size check is totally incorrect - remove it.

Change-Id: If84be72f43c3be91ae5a7c3fa49b10ef1202cf50
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
partitionedfs: improve debugging prints

Print the starting and ending partition sector numbers as well as partition
size. This makes it easier to debug issues.

Change-Id: Ie96872f6902d2b7c12bb043879e06d5b839d986c
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
partitionedfs: simplify the code a tiny bit

When we calculate the minimum disk size, we do not have to search for the last
parition, because we have d['offset'] which points to the first available
sector.

Change-Id: Ida5f92ec11939caa76ad1bf90aee137a2e918d2d
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
paritionedfs: remove the 'extended' key from disk dictionary

The 'extended' key holds the size of the extended partition, and it is only
used once when we create the extended partition. However, we do not really need
this becase we can easily calculate the extended partition size, because we
know the start of the first logical partition and the disk size. Having this
'extended' key only complicates the code unnecessarily.

Change-Id: I58e61e219890339fae63eeb5bdf9f2002401cb72
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
Pass command line info to CreatorError in get_file_size()

Variable "du" does not exist, so pass the command line to error.

Change the local var name "file" to "filename" to avoid conflicting
with builtin function.

Also refactor last "if" statement to more readable max function.

Change-Id: I661e0a02db940d75a8180c3215f95d5ff1ae8802
Merge "partitionedfs: remove bogus alignment check" into devel
Merge "partitionedfs: improve debugging prints" into devel
Merge "partitionedfs: simplify the code a tiny bit" into devel
Merge "paritionedfs: remove the 'extended' key from disk dictionary" into devel
Fix bad indents

Change-Id: I4bd330957aeaeaae8367aafdeffd2f511d479077
paritionedfs: partially fix extended paritions support

Currently MIC is unable to create more than 3 partitions, because the
logical/extended paritions support is broken. This is because the EBR is not
taken into account, so parted fails to create logical partitions. EBR stands
for "Extended Boot Record" and this ia basically a single sector which prepends
every logical parition.

This patch fixes the issue. We take one sector from each partition starting
from the 3rd one (the last primary parition), and this sector will be used by
parted for the EBR. This works nicely and partitions stay aligned correctly for
the best performance.

Change-Id: I678c52f24750388ffdc09c32939541ba3f3e8b8f
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
paritionedfs: do not create extended parition in case of GPT

Change-Id: Ibd2ae31c7e0ed630dd7e392995a21ff90442cc6a
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
partitionedfs: fix extended partitions support

When we use th elegacy MBR paritions and have more than 3 paritions, MIC
creates and extended parition and which allows us to create 4 more logical
paritions. However, this functionality was broken. It was partially fixed in
the previous commit, and this is the final fix.

The problem is that kpartx maps the extended partirion (sometimes, depending on
the version), and MIC tries to use it and fails. Instead, MIC should just skip
the extended parition. This patch adds the corresponding check.

With this fix we can create images with many paritions, and both MBR and GPT
paritions work.

Change-Id: Iabf17c6407942eec7a7051bff52ebf427aa4f3a1
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
kickstart: allow partitions without mount points

We need to be able to create partitions without any file-system and without any
mount-point. However, the KS files parser does not allow this, which this patch
fixes.

Change-Id: If046e8895aaa3bb95f25e317464677e019877819
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
raw: allow partitions without a file-system

Do not error out if a partition does not have a mount point and file-system
type. We want MIC to create partitions without any format and without any
mount-point.

Change-Id: Ib50fecc2ffd501be8b24dac5d57324cf5de72b74
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
partitionedfs: do not try to mount partitions without a mountpoint

With this patch MIC finally allows partitions wothout any mount point.

Change-Id: I110a90754428c2f216d27287526701ea0cdc5b0c
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
raw: use relative path to the kernel image in extlinux.conf

Currently raw image creator works only when there is a separate boot parition.
But when /boot is in the root partition, extlinux is unable to boot the kernel.

The reason of this is that in extlinux.conf MIC specify the absolute path to
the vmlinuz file - '/vmlinuz', which of course does not work when the correct
path is '/boot/vmlinuz'.

The fix seems to be easy - for extlinux the current directory is where the
'syslinux.conf' file is situated. And we know that the 'vmlinuz' file is one
level up. So all we need to do is to ask extlinux to take the look one level
up, i.e., take '../vmlinuz'.

This patch was tested in both configurations - with and without a separate boot
partition.

Change-Id: Ia87d053b46f7712aa491c38ed13ca6cd61c5b7ba
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>