Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/system-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ jobs:
- name: Run system tests with loop device
timeout-minutes: 2
run: |
for f in tests/config/system-tests/*
for f in tests/config/system-tests/*.yaml
do
echo "Testing with $f"
echo "Create package"
cp $f tests/data/layout.yaml
G_DEBUG=fatal-warnings partup -d -C tests/data package pkg.partup \
layout.yaml random.bin lorem.txt lorem.tar root.ext4
layout.yaml random.bin lorem.txt lorem.tar dir-struct.tar root.ext4
echo "Show package content"
sudo G_DEBUG=fatal-warnings partup -s show pkg.partup
echo "Install package to loop device"
Expand All @@ -46,6 +46,11 @@ jobs:
echo "Show loop device info"
sudo fdisk -l ${{ env.loop_dev }}
sudo blkid ${{ env.loop_dev }}
verify_script=${f%.*}.sh
if [ -f $verify_script ]; then
echo "Running verification script"
./$verify_script ${{ env.loop_dev }}
fi
git clean -xdf -e loop-file
done
- name: Remove loopdev
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
- Add a FAQ section to the documentation explaining the ``Filesystem has
unsupported feature(s)`` error of ``resize2fs``, caused by the ext4
``orphan_file`` feature and old e2fsprogs versions.
- Add the input options ``exclude`` and ``only``, which allow excluding paths
from, or restricting an input to, specific paths. For ``.tar`` archives they
are passed to tar during extraction, for other inputs the paths are removed
from the partition after writing. See :ref:`input-files`.

.. _release-4.0.0:

Expand Down
52 changes: 52 additions & 0 deletions doc/layout-config-reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,58 @@ into a filesystem, or raw ext[234] filesystem images. See
``--skip-checksums`` is given as a runtime argument. See
:ref:`checksum-verification` for details.

``exclude`` (sequence)
Paths to exclude for this input. Paths to be excluded should be provided as a
sequence of strings. This requires a partition with a valid filesystem.

Relative paths are interpreted relative to the root of the partition and
may contain wildcards (e.g. ``foo/*.c``). Paths that do not match anything
are ignored.

If the input is a ``.tar`` archive, the specified paths are excluded from
extraction using tar's ``--exclude`` option:
https://manpages.debian.org/unstable/tar/tar.1.en.html#exclude

For other input file types, the specified paths are deleted on the partition
after writing the input files.

``exclude`` takes precedence over ``only``.

Available since: :ref:`release-5.0.0`

``only`` (sequence)
A list of paths to only extract/keep on the corresponding partition. This
requires a partition with a valid filesystem.

If the input is a ``.tar`` archive, only the specified members are extracted
(names are matched as given to tar, wildcards are supported):
https://manpages.debian.org/unstable/tar/tar.1.en.html

For other input file types, any other paths are deleted on the partition
after writing the input files, except the ones specified. Relative paths are
interpreted relative to the root of the partition and may contain wildcards.

Available since: :ref:`release-5.0.0`

Example:

.. code-block:: yaml

api-version: 5
partitions:
- label: root
filesystem: ext4
expand: true
input:
- filename: rootfs.tar
exclude:
- var/cache
- usr/share/doc
only:
- etc
- usr
- var

.. _supported-file-types:

Supported File Types
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
project(
'partup', 'c',
version : '4.0.0',
version : '5.0.0',
license : 'GPL-3.0-or-later',
default_options : [
'c_std=c99',
Expand Down
45 changes: 44 additions & 1 deletion src/pu-emmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ typedef struct _PuEmmcInput {
gchar *filename;
gchar *md5sum;
gchar *sha256sum;
GList *exclude;
GList *only;

/* Internal members */
gsize _size;
Expand Down Expand Up @@ -375,7 +377,8 @@ pu_emmc_write_data(PuFlash *flash,
if (g_regex_match_simple(".tar", path, G_REGEX_CASELESS, 0)) {
if (!pu_mount(part_path, part_mount, NULL, NULL, error))
return FALSE;
if (!pu_archive_extract(path, part_mount, error))
if (!pu_archive_extract(path, part_mount, input->exclude,
input->only, error))
return FALSE;
if (!pu_umount(part_mount, error))
return FALSE;
Expand All @@ -387,6 +390,15 @@ pu_emmc_write_data(PuFlash *flash,
return FALSE;
if (!pu_set_ext_label(part_path, part->label, error))
return FALSE;
if (input->exclude || input->only) {
if (!pu_mount(part_path, part_mount, NULL, NULL, error))
return FALSE;
if (!pu_path_remove_exclude_only(part_mount, input->exclude,
input->only, error))
return FALSE;
if (!pu_umount(part_mount, error))
return FALSE;
}
} else if (!part->filesystem) {
if (!pu_write_raw(path, part_path, self->device, 0, 0, 0, error))
return FALSE;
Expand All @@ -395,6 +407,11 @@ pu_emmc_write_data(PuFlash *flash,
return FALSE;
if (!pu_file_copy(path, part_mount, error))
return FALSE;
if (input->exclude || input->only) {
if (!pu_path_remove_exclude_only(part_mount, input->exclude,
input->only, error))
return FALSE;
}
if (!pu_umount(part_mount, error))
return FALSE;
}
Expand Down Expand Up @@ -601,6 +618,8 @@ pu_emmc_class_finalize(GObject *object)
g_free(in->filename);
g_free(in->md5sum);
g_free(in->sha256sum);
g_list_free_full(g_steal_pointer(&in->exclude), g_free);
g_list_free_full(g_steal_pointer(&in->only), g_free);
g_free(in);
}
g_list_free(g_steal_pointer(&part->input));
Expand Down Expand Up @@ -1058,6 +1077,30 @@ pu_emmc_parse_partitions(PuEmmc *emmc,
input->filename = pu_hash_table_lookup_string(iv->data.mapping, "filename", "");
input->md5sum = pu_hash_table_lookup_string(iv->data.mapping, "md5sum", "");
input->sha256sum = pu_hash_table_lookup_string(iv->data.mapping, "sha256sum", "");
GList *exclude_list = pu_hash_table_lookup_list(iv->data.mapping, "exclude", NULL);
if (exclude_list) {
for (GList *e = exclude_list; e; e = e->next) {
PuConfigValue *ev = e->data;
if (ev->type != PU_CONFIG_VALUE_TYPE_STRING) {
g_set_error(error, PU_ERROR, PU_ERROR_EMMC_PARSE,
"'exclude' does not contain a sequence of strings");
return FALSE;
}
input->exclude = g_list_append(input->exclude, g_strdup(ev->data.string));
}
}
GList *only_list = pu_hash_table_lookup_list(iv->data.mapping, "only", NULL);
if (only_list) {
for (GList *o = only_list; o; o = o->next) {
PuConfigValue *ov = o->data;
if (ov->type != PU_CONFIG_VALUE_TYPE_STRING) {
g_set_error(error, PU_ERROR, PU_ERROR_EMMC_PARSE,
"'only' does not contain a sequence of strings");
return FALSE;
}
input->only = g_list_append(input->only, g_strdup(ov->data.string));
}
}
part->input = g_list_prepend(part->input, input);

g_debug("Parsed partition input: filename=%s md5sum=%s sha256sum=%s",
Expand Down
Loading