Make scripts working again

Calling scripts was not working after work
for publishing the project as OSS. A type occurs,
and no handler was found it.

The patch introduces some important decision:
- drop support of shell based scripts:
  only LUA scripts are supported. LUA scripts
  can exec any program and make shell scripts
  redundant.
- there is no difference in sw-description if
  a script is run before or after installing images.
  A script is not needed to be marked as preinstall or postinstall.
  Instead of this, a script contains "preinst" and/or
  "postinst" functions, that the main code automatically
  calls. In this way, the same script can be a pre-install
  and post-install script at the same time.

Documentation for the libconfig parser is updated as well.

Signed-off-by: Stefano Babic <sbabic@denx.de>
Make scripts working again

Calling scripts was not working after work
for publishing the project as OSS. A type occurs,
and no handler was found it.

The patch introduces some important decision:
- drop support of shell based scripts:
  only LUA scripts are supported. LUA scripts
  can exec any program and make shell scripts
  redundant.
- there is no difference in sw-description if
  a script is run before or after installing images.
  A script is not needed to be marked as preinstall or postinstall.
  Instead of this, a script contains "preinst" and/or
  "postinst" functions, that the main code automatically
  calls. In this way, the same script can be a pre-install
  and post-install script at the same time.

Documentation for the libconfig parser is updated as well.

Signed-off-by: Stefano Babic <sbabic@denx.de>
Merge branch 'master' of /opt/tools/Projects/swupdate into master-local
Drop flash.h

Signed-off-by: Stefano Babic <sbabic@denx.de>
Use generic name for flash structure instead of nand_*

Signed-off-by: Stefano Babic <sbabic@denx.de>
Factorize MTD functions and move them to corelib

Signed-off-by: Stefano Babic <sbabic@denx.de>
Drop not used verify_image from flash handler

Signed-off-by: Stefano Babic <sbabic@denx.de>
Fix warning if HW compatibility is not set

Signed-off-by: Stefano Babic <sbabic@denx.de>
parse_config: detect flash handler

Detect if it is required to write a flash in raw mode.
The field "type" must be set to the handler "flash"
in the sw-description file.
The device field is set to the desired MTD device:
both format /dev/mtdX and simply mtdX are accepted.

Signed-off-by: Stefano Babic <sbabic@denx.de>
Add a blacklist for devices not be scanned for UBI

By attaching a UBI device to a MTD partition that is not
thought to be used with UBI damages will damage the
current content. UBI tries to fix issues that do not exist
because the device is not used at all with UBI.

Adding a blacklist, set at compile time with a
configuration option, let to exclude a list
of devices when devices are searched for UBI
volumes.

Signed-off-by: Stefano Babic <sbabic@denx.de>
Rationalize some prototypes in includes

Signed-off-by: Stefano Babic <sbabic@denx.de>
Added handler for raw flash

The handler for raw flash was not working and
there is no support for NAND flash. In fact,
writing to a NAND in raw mode (without UBI layer)
requires to take care of bad blocks.
Code was taken from mtd-utils (nandwrite) to
work correctly with NAND. Most of options
in nandwrite are dropped here because they have
no meaning for swupdate.

Signed-off-by: Stefano Babic <sbabic@denx.de>
Fix warning in swupdate.c

Signed-off-by: Stefano Babic <sbabic@denx.de>
BUG: does not extract script when installing from file

When installing from file, scripts are not extracted
in TMPDIR letting some garbage in the working
directory.

Signed-off-by: Stefano Babic <sbabic@denx.de>
swupdate does not exit on syntax error

When installed from file, the error reported by
the parser is not evaluated and swupdate goes on.

Signed-off-by: Stefano Babic <sbabic@denx.de>
Use only one file for flash definitions

Two includes files (flash.h and ubi_partition.h) were
used to describe flash layout.
Move all definitions in one single file and drop
the other one.

Signed-off-by: Stefano Babic <sbabic@denx.de>
flash_handler: use ERROR insted of TRACE when needed

Signed-off-by: Stefano Babic <sbabic@denx.de>
Preparation for LUA handlers

The patch provides some utilities to add support
for handlers written in the LUA language.
The img structure is converted to a LUA table
and it is passed to the LUA handler
by a wrapper. A LUA handler must return
an integer with its result.

Signed-off-by: Stefano Babic <sbabic@denx.de>
Fix error case in cpio_utils

Signed-off-by: Stefano Babic <sbabic@denx.de>
Add NOCLEANUP debug option

For debugging it is useful to check the extracted files
in the TMPDIR directory. NOCLEANUP does not remove
files after swupdate completed.

Signed-off-by: Stefano Babic <sbabic@denx.de>