The current code enumerates the partitions and uses the index of this enumeration to query partition parameters rather than the actual partition number that is reported and expected by partx. This might not work in certain cases.
Example:
/dev/sda1
/dev/sda2
/dev/sda5
The partition number of the last partition is 5 but current code will use 3. This PR fixes this so that the actual number reported by partx is used for all operations rather than the enumerated index.
ChangeLog: Fix error when partitions numbers are not sequential
Signed-off-by: Purushotham Nayak <purunaya@cisco.com>
This adds more accurate descriptions of what error actually occured during
script execution, as compared to previously, where it would silently fail, and
it could be hard to figure out exactly where the error occured.
Now, upon an error, the script will always output these lines (or similar) at the end:
```bash
2020-04-23 18:53:34 [ERROR] [mender-convert] mender-convert failed
2020-04-23 18:53:34 [DEBUG] [mender-convert-extract] When running: (./mender-convert-extract:109): run_and_log_cmd():
dd if=/dev/zer of=work/boot-generated.vfat count=40 bs=1M status=none
dd: failed to open '/dev/zer': No such file or directory
2020-04-23 18:53:34 [ERROR] [mender-convert] mender-convert exit code: 1
```
Which is a description of which part of the program failed. What the exit code
was, and the last command entry in the debug log, and if any, the collected
output from the command is printed.
Changelog: Print improved error diagnostics before exiting on an error
Signed-off-by: Ole Petter <ole.orhagen@northern.tech>
Previously there was a mix between two, and four spaces.
This commits unifies all scripts to use two-spaces for indentation.
Changelog: None
Signed-off-by: Ole Petter <ole.orhagen@northern.tech>
Previously some scripts were calling env and bash, some were only calling bash.
This commit unifies the scripts to all use `#! /usr/bin/env bash`
Changelog: None
Signed-off-by: Ole Petter <ole.orhagen@northern.tech>
This is necessary for the U-boot -> EFI -> GRUB integration to be
complete as many boards embedd the U-Boot binary at the start
of the SD/eMMC a.k.a boot-gap.
When MENDER_COPY_BOOT_GAP is enabled, it will be copied from the
input disk image to the output ".sdimg"
MEN-2784
Changelog: Title
Signed-off-by: Mirza Krak <mirza.krak@northern.tech>
Minor spelling errors in user facing messages
Changelog: None
Signed-off-by: Ole Petter <ole.orhagen@northern.tech>
Spell fixes
The userfacing logging had a couple of spelling errors
Changelog: None
Signed-off-by: Ole Petter <ole.orhagen@northern.tech>
Current logic actually fails when no '-c/--config' options are provided, with this error:
$ MENDER_ARTIFACT_NAME="test-1" ./mender-convert --disk-image input/Armbian_5.95_Tinkerboard_Debian_buster_next_4.19.69_minimal.img
Running mender-convert-extract: --disk-image input/Armbian_5.95_Tinkerboard_Debian_buster_next_4.19.69_minimal.img
2019-10-02 12:46:39 [INFO] [mender-convert-extract] Using configuration file: configs/mender_convert_config
2019-10-02 12:46:39 [INFO] [mender-convert-extract] Using configuration file: ''
modules/config.sh: line 28: '': No such file or directory
The 'configs' array is actually not empty when passed to modules/config.sh
as it will contain "''", which will be translated as a array element and
hence the above failure.
This commit ensures that we set a valid default value to 'configs',
which is the 'mender_convert_config'. This is moved from modules/config.sh,
to the calling scripts that define the array of configs.
Fixes: 9b944615a8 ("configs: Support multiple config files on command line.")
Changelog: None
Signed-off-by: Mirza Krak <mirza.krak@northern.tech>
The current support for this fails due to incorrect use
of bash arrays.
Also, use the printf '%q' formatting code to add proper quotes
to the config file names to ensure that it works properly
with spaces in the file names.
Signed-off-by: Drew Moseley <drew.moseley@northern.tech>
Changelog: Title
The goals of the re-write was to achieve the following:
1. It should be easy to extend the tool to support other boards or distributions
2. We should not compile code in the tool (rely on binaries built elsewhere)
compiling code increases complexity, due to requirement of toolchains etc.
3. The tool shall not be designed around specific hardware/platform types
- This is the case today with the usage of --device-type flag
4 The tool should be to convert images without knowing anything about the hardware/platform
relates to above 3.
5. Configuration interface should be simplified
- command line flags -> configuration files
6. Platform specific code shall be provided trough “hooks”, and are not part of the “core” mender-convert code
7. It shall be easy to extend functionality
- support for rootfs overlay to inject user applications/configurations
- ability to override how the Mender Artifact is generated (to be able to sign and include state-scripts)
8. Code structure should be modular
- Eases Maintenance and possibility of making isolated changes
Changelog: Title
Signed-off-by: Mirza Krak <mirza.krak@northern.tech>