Commit Graph

79 Commits

Author SHA1 Message Date
Tomas Mudrunka
b334dd132f Override filesystem source path
Signed-off-by: Tomas Mudrunka <harviecz@gmail.com>
2022-03-25 15:05:27 +00:00
Tomas Mudrunka
1c5457cacd Initial F2FS support
Signed-off-by: Tomas Mudrunka <tomas@mudrunka.cz>
2022-03-25 15:53:00 +01:00
Rasmus Villemoes
046fc837b0 collect_mountpoints(): only do timestamp fixup when needed
When trying to use genimage on an embedded target, I hit

  find: unrecognized: -printf
  xargs: invalid option -- '0'

because the busybox I have apparently has somewhat limited "find" and
"xargs" applets. OTOH, I'm not using the "split a rootfs"
functionality - in fact, I'm just pointing rootpath at an empty dir
which won't be used for anything, so the whole thing is redundant.

When there are no non-trivial mountpoint=... options, we might as well
skip the timestamp fixup.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
2022-01-07 10:47:11 +01:00
Rasmus Villemoes
b5edc44d87 add --configdump option
libconfuse has a cfg_print() function for sort-of pretty-printing a
cfg_t* object. Let's expose that via a --configdump option, to make
debugging of complicated setups with several layers of include() a
little easier.

If I can get it to work, I will also be using the output dump directly
on target, i.e. merely using the host genimage as a preprocessor - so
that I can still reuse include() fragments in my image definition, but
I don't have to copy all those files to target when bootstrapping the
eMMC.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
2022-01-07 10:41:53 +01:00
Michael Olbrich
90b83bac14 allow specifying 'holes' in the partition section
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2021-10-22 15:57:39 +02:00
Rasmus Villemoes
0778817e7c add --includepath option
When ${B} was made distinct from ${S} and ${WORKDIR} in
genimage.bbclass in meta-ptx commit 9eaa29b7, use of include() in the
main configuration file to include other fragments from SRC_URI broke.

It can be worked around in a recipe by copying all the fragments to
${B} in a do_genimage[prefunc], but that's awkward. It's more natural
for genimage to take a --includepath option and genimage.bbclass to
pass --includepath ${S}.

This does require libconfuse >= 2.8, while meta-ptx currently has a
recipe for 2.7 (the last release downloadable from savannah, but the
project has moved to github).

confuse.h says:

 * Note that the current directory is not added to the searchpath
 * by default.

That's probably not expected, so when this option is used, always add
"." as well.

In order for this to be meaningful in a config{} section inside the
configuration file, one would have to get libconfuse to call a custom
function when encountering this; it cannot just be a simple
CFG_STR. Because if it doesn't take effect immediately, parsing the
rest of the config file will most likely fail when it hits the
include()s. But the whole option parsing machinery is basically built
around the assumption that options take single string arguments (which
is also why this had to accept a colon-separated list instead of
supporting --includepath being given multiple times). I don't think
it's a huge loss, C files also don't have the proper values of -I
embedded into them. But it does require relaxing the wording in
README.rst a bit.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
2021-06-04 22:10:42 +02:00
Michael Olbrich
1d72d8091f image-hd: stricter option handling
There have been situations where the hybrid mode was accidentally used
because a config contained a bogus partition-type entry.

So lets make this explicit: There is now a new 'partition-table-type'
option where the hybrid mode must be selected explicitly.
The relevant options for mbr and gpt are only acceptable if the
corresponding type (or hybrid) is selected.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2021-04-25 17:15:38 +02:00
Rasmus Villemoes
030e7a3c2e allow each partition to have its own align value
For partitions in the partition table, this defaults to the image's
alignment value, while partitions not listed there use a value of 1,
i.e. no particular alignment requirements.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
2021-03-28 12:52:36 +02:00
Michael Olbrich
84c04645a9 add new image type for android sparse images
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2021-01-13 09:02:51 +01:00
Rasmus Villemoes
15875c15ba allow specifying an image as temporary
When using something like

image @IMAGE@ {
    ....
    partition sysdata {
        image = "sysdata"
	in-partition-table = true
	partition-type-uuid = "L"
    }
}

image sysdata {
    size = 200M
    ext4 {}
    empty = true
}

to create a partition containing an empty file system, it's
undesirable to leave such an empty file system image in the output
directory (especially when building with Yocto, where it then gets
copied to the shared deploy directory).

So allow specifying an image as temporary, putting it in in tmppath()
rather than imagepath().

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
2020-11-17 20:03:42 +01:00
Michael Olbrich
866f216e19 genimage: make sure that IMAGEMOUNTPATH is exported correctly
If the image mountpoint is not explicitly defined, then IMAGEMOUNTPATH is
currently no exported. This is incorrect, because the default mountpoint
for any image is '/'.
Use mountpath() to get the correct path. It handles the default mountpoint
correctly.
Make sure that IMAGEMOUNTPATH is not set if the image is explicitly marked
as empty.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2020-08-28 15:37:18 +02:00
Michael Olbrich
e8cb9b6f49 genimage: make mountpath() argument const
It not modified and this will be needed in the next commit.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2020-08-28 15:37:18 +02:00
Florian Larysch
924aaae088 genimage: initialize return value
The "ret" variable in image_setup is not initialized when an image does
not contain any partitions and the image handler does not provide a
setup function. This can cause image_setup to error out erroneously.

These conditions are fulfilled by the cpio test case, but this bug only
becomes visible when the stack content aligns accordingly.

Initialize ret to 0, as image_setup can be considered successful in this
case.

Signed-off-by: Florian Larysch <fl@n621.de>
2020-08-03 19:26:43 +02:00
Andri Yngvason
075db5e0ae image-hd: Add GPT attributes for hiding partitions on Windows
This allows users to instruct Windows 10 to ignore certain partitions to
various extent.

Signed-off-by: Andri Yngvason <andri.yngvason@marel.com>
2020-03-26 10:53:27 +00:00
Michael Olbrich
fb65bd97f8 genimage: allow sanitize_path() to be used elsewhere
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2020-01-31 12:53:13 +01:00
Michael Olbrich
f4c889b5fc make it easier to create empty filesystems
This is useful when creating multiple images with on config and some of
them should be empty. Also, vfat filesystems cannot be empty right now, so
this makes it possible.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2019-09-22 15:07:52 +02:00
George Hilliard
f2b104aa68 Prefix mountpoints with mp- to avoid conflict with "root"
Specifying an image with mountpoint "/root" would cause the mountpoint's
location to be "root", which conflicts with the location for the actual
filesystem root.

Fix this by appending a prefix.

Closes #67 on GitHub.

Signed-off-by: George Hilliard <thirtythreeforty@gmail.com>
2019-08-07 00:36:02 -05:00
Michael Olbrich
8d9c1a2bd3 genimage: allow percentages for image sizes
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2019-05-07 13:05:20 +02:00
Michael Olbrich
de6168e331 genimage: support absolute output file names
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2019-03-01 16:38:16 +01:00
Michael Olbrich
86b76c6d43 genimage: only delete regular files and symlinks
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2019-03-01 16:38:16 +01:00
Stefan Sørensen
2c92297e8a hdimage: Add GPT support
Signed-off-by: Stefan Sørensen <stefan.sorensen@spectralink.com>
2019-02-12 09:29:54 +01:00
Marc Kleine-Budde
297a9c6300 genimage: fix timestamp of mountpoint directories
After the mv/mkdir of the mountpoints the timestamps of the mountpoint and all
parent dirs are changed.

This patch adds a find/touch loop to fix the timestamp of all directories.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2018-07-19 13:29:39 +02:00
Alexandre Fournier
9e1e7c5860 add qemu handler 2018-03-19 21:55:28 +01:00
Sascha Hauer
ec65ecc5b4 Add FIT image support
This adds support for U-Boot FIT images to the genimage tool.

FIT images are effectively device tree blobs (dtbs) which have
the actual image data as binary properties in the device tree.

FIT image support works by invoking the U-Boot mkimage tool
with a device tree source file (its) as input. The its file
must be handwritten, but the image data is included automatically
by genimage which generates suitable /incbin/ directives on the
fly.

Images in the its file are in a /images/<imagename> node. The
FIT image is seen as a partitioned device, for each /images/<imagename>
there must be a partition named <imagename> in the genimage config
file section for a FIT image.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
[mol: add test files to Makefile.am, handle readonly .its file]
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2018-03-19 15:53:26 +01:00
Sascha Hauer
55f93159c2 genimage: Fix pathes with whitespaces
genimage does not handle pathes with whitespaces correctly whenever
it invokes an external command. Escape all pathes with quotation
marks to make that work.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2018-03-19 15:53:26 +01:00
Sascha Hauer
51aac203af cleanup logging
We have image_error, image_log, error and logmsg which all do the
actual printing themselves. Create a set of error(), info() and
debug() functions which all do the actual printing in the same
function. Also add the same set of functions with a image_ prefix
to do image specific logging. All messages now get a [type] prefix
to make it easier to distinguish them from the stdout/stderr from
invoked commands (see next patch).

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
[mol: don't change the loglevel numbers]
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2018-03-19 14:58:34 +01:00
Marc Kleine-Budde
2643ad8350 genimage: export IMAGEMOUNTPATH to sub processes
As we now sanitize the mount path for partitions, the path should be considered
implementation defined and should not be guessed. Use the environment variable
IMAGEMOUNTPATH in pre and post scripts instead.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2017-12-04 14:54:57 +01:00
Marc Kleine-Budde
5b2a54f72e genimage: fix partitions from sub-sub dirs
genimage works on partitions from sub dirs (e.g.: /opt), but it fails from
sub-sub dirs (e.g.: /usr/local). This patch fixes the problem by using a
sanitized sub dir name instead, where slashes '/' are replaces by minuses '-'.

Fixes: Issue #2.

Suggested-by: Michael Olbrich <m.olbrich@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2017-12-04 14:54:27 +01:00
Gaël PORTAY
04c417a7b6 fix double `;'
Small nitpick.

Signed-off-by: Gaël PORTAY <gael.portay@savoirfairelinux.com>
2017-11-16 22:25:10 -05:00
Gaël PORTAY
191a73aea7 fix indentation violations
Remove trailing blanks and replace spaces by tabulation.

Signed-off-by: Gaël PORTAY <gael.portay@savoirfairelinux.com>
2017-11-16 22:25:10 -05:00
Michael Olbrich
520c4f8bfc util: check asprintf()/vasprintf() return values
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2017-11-12 09:33:04 +01:00
Michael Olbrich
b18e59fd79 genimage: remove bogus closedir()
This line is only reached for 'dir == NULL'.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2017-11-11 18:09:49 +01:00
Julien Viard de Galbert
5984e56a7f cramfs: add handler to create cramfs filesystem images
Signed-off-by: Julien Viard de Galbert <julien.viarddegalbert@openwide.fr>
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2016-09-13 14:51:29 +02:00
Michael Olbrich
6de3e5aaa5 add image type to create rauc bundles
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2016-08-15 12:35:48 +02:00
Michael Olbrich
def2f632d7 check_tmp_path: always call closedir()
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2016-01-12 17:47:16 +01:00
Michael Olbrich
8028a9b1f8 add license file and remove old FSF address from the source files
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2016-01-12 17:47:16 +01:00
Ladislav Michl
14c17c745c genimage: Add static UBI volumes support
Bare images (kernel, U-Boot, its environment) need to reside inside
static UBI volumes. Add read-only partition flag and use it for that
purpose. Also make partition's "image" voluntary as ubinize will yell
anyway. Once this behavior gets modified eventually, it will bring us
possibility to create empty volumes ready for runtime update.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2016-01-12 17:07:31 +01:00
Vivien Didelot
f23b67b7e3 genimage: robustify setenv calls
setenv may fail on invalid key, or segfault on empty value string.

This patch introduces an overwriteenv wrapper to overwrite a given
environment variable, and use an empty string if its value is NULL.

Finally, add 2 functions, setenv_paths and setenv_image to simplify
error checking when overwriting the related environment variables.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-09-14 09:01:29 +02:00
Vivien Didelot
0f46b20f41 genimage: use snprintf instead of asprintf
This avoids allocating a freeing a string for the image size.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-09-14 08:49:56 +02:00
Vivien Didelot
4eaf4f3705 genimage: use a single exit path
Change the "err_out" label for "cleanup" and check the value of ret to
use a single return path from the main function.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-09-14 08:42:35 +02:00
Vivien Didelot
4dd1fbff5d genimage: fix segfault on flash part with no image
With a configuration similar to this:

    image flash.img {
      flash {}
      flashtype = "foo-8mb"

      partition kernel {
        image = "zImage"
        size = 6M
      }

      partition config {
        size = 2M
      }
    }

genimage segfaults in set_flash_type() because image_get() calls
strcmp() with part->image being NULL.

To fix this, skip partitions with no image when setting the flash type.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2015-04-12 10:43:01 +02:00
Michael Olbrich
be2c51fb1b Revert "genimage: image does not use include"
This reverts commit 020a15d10c.

Allowing includes in image sections is a feature. This makes it possible to
define some partitions, e.g. bootloader configuration, in a separate file.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2015-03-16 12:00:04 +01:00
Vivien Didelot
020a15d10c genimage: image does not use include
"include" is a top-level option, so remove it from the "image" section.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-03-13 06:47:20 +01:00
Michael Olbrich
a0d4704f69 cleanup logging
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2014-08-12 11:41:46 +02:00
Juergen Beisert
3171e7020d squashfs: add handler to create squashfs filesystem images
Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
2014-03-10 15:56:58 +01:00
Michael Olbrich
dff2d7c88e cleanup error output
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2013-05-02 20:49:21 +02:00
Michael Olbrich
84c732a648 add ISO image support
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2012-11-25 13:31:09 +01:00
Michael Olbrich
4edee07408 sort image handler
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2012-11-24 22:59:58 +01:00
Michael Olbrich
c88e2d4bf1 genimage: delete target on failure
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2012-09-21 10:22:49 +02:00
Michael Olbrich
a23519e5bf add cpio image support
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2012-09-21 10:22:48 +02:00