Changelog: Fix grub.d integration when host and target 32/64 bit
architectures don't match. Namely: pass the correct `--target` parameter
to `grub-install` command instead of relaying on host architecture.
Ticket: MEN-5979
Signed-off-by: Lluis Campos <lluis.campos@northern.tech>
Added a simple check to log a warning when an image is generated with the client
installed, and the version installed will lead to the image being unusable.
Signed-off-by: Ole Petter <ole.orhagen@northern.tech>
Note that we will still use EFI, since Mender doesn't support anything
else, but we will avoid grub.d integration since it won't be prepared
for it in this configuration. Instead the legacy method with a custom
Mender boot script will be used.
Inspired by this thread on Mender Hub:
https://hub.mender.io/t/problems-converting-a-packer-debian11-img-with-mender-convert/5054
Changelog: Title
Ticket: None
Signed-off-by: Kristian Amlie <kristian.amlie@northern.tech>
When introducing grub.d integration, we switched to using the already-
installed grub binary if it existed. But this is not a good idea,
because it may come with hardcoded paths which may fail to load the
script that we put in `/EFI/BOOT`. So revert to the old behavior,
install our own pre-compiled grub binary if grub.d integration is off.
No changelog, since we never released this regression.
Changelog: None
Ticket: None
Signed-off-by: Kristian Amlie <kristian.amlie@northern.tech>
This means that `grub-install` and `update-grub` no longer risk
bricking the device, but will produce boot scripts with Mender support
integrated. It also means that the standard GRUB menu will be
available.
It is supported on x86_64 platforms where `grub.d` is available, and
can be turned on and off with `MENDER_GRUB_D_INTEGRATION`. The default
is to use it if available.
Devices that did not previously use `grub.d` integration won't be
upgraded correctly with it turned on, so it is advised to set
`MENDER_GRUB_D_INTEGRATION=n` if you are upgrading existing devices.
Changelog: Commit
Signed-off-by: Kristian Amlie <kristian.amlie@northern.tech>
The presence of the shim depends on whether Secure Boot is enabled or
not, plus the configuration of the distro. GRUB itself however, will
always be present if the distro uses GRUB with UEFI at all. So check
for that instead.
Of course, without the shim, Secure Boot will not work out of the box,
but this is a misconfigured platform, not a problem with Mender.
Cancel-Changelog: 2b805e29dc
Changelog: If `grub*.efi` preexists on the EFI partition, keep it
instead of installing our own. In all other cases, we fall back to the
old functionality of installing mender-grub and nuking the existing
bootloader.
Signed-off-by: Kristian Amlie <kristian.amlie@northern.tech>
In the case a boot shim is found on the boot partition, we do keep the boot
partition pristine, and only install the generated mender `grub.cfg` file we need.
In all other cases, we fall back to the old functionality of installing
mender-grub and nuking the existing bootloader.
Changelog: commit
Signed-off-by: Ole Petter <ole.orhagen@northern.tech>
It has been broken since the introduction of mender-configure.
This add-on is architecture independent, so when downloading the .deb
directly from the pool we need to look for "all" suffix instead of the
target architecture. This worked fine for "latest" and "master" versions
because the filename for these were resolved via repository's Packages.
Changelog: title
Signed-off-by: Lluis Campos <lluis.campos@northern.tech>
Now the packages from tags will also contain this character. Same fix as
in ed5da386.
Changelog: None
Signed-off-by: Lluis Campos <lluis.campos@northern.tech>
Otherwise won't be possible to install old versions published with the
old schema.
Amends commit b196804
Changelog: None
Signed-off-by: Lluis Campos <lluis.campos@northern.tech>
Changelog: Download and install Debian packages taking into account the
target OS. Now downloads.mender.io serves four distributions: the two
latests releases for Debian and Ubuntu. Probe /etc/os-release to figure
out the correct package to install, and fallback to Debian Buster
packages which was the previous default.
Signed-off-by: Lluis Campos <lluis.campos@northern.tech>
Changelog: Support installing mender-configure addon. Not installed by
default, it can be configured using MENDER_ADDON_CONFIGURE_INSTALL and
MENDER_ADDON_CONFIGURE_VERSION variables.
Changelog: Set mender-configure version to master
Signed-off-by: Lluis Campos <lluis.campos@northern.tech>
As this value is known during modify but not during package, a new
testscfg module has been implemented to take care of adding variables
and exporting the final cfg file.
Changelog: None
Signed-off-by: Lluis Campos <lluis.campos@northern.tech>
Making more explicit the two different use cases that the previous
optional arguments were trying to support.
Changelog: None
Signed-off-by: Lluis Campos <lluis.campos@northern.tech>
Add a deb module with reverse engineered logic to download a given deb
package from an APT repository, and modify mender-client download to use
this method instead of the legacy wget direct download.
Changelog: None
Signed-off-by: Lluis Campos <lluis.campos@northern.tech>
Originally the intention was to fix the U-Boot integration for
Beaglebone, but this seems to have been broken for a long time, almost
a year, and no one has complained about it. The problem appears to be
connected to this commit [1], but it's not entirely clear to me what
the fix should be, and there are a lot of patches for our U-Boot fork.
However, since the U-Boot integration is supposed to be the backup
solution, rather than dig into U-Boot I decided to just fix the UEFI
path instead. This method doesn't require any patching, but there is
a problem with the specific image which is available for download at
the time of writing. So just grab the boot loader and kernel pieces
from a later, yet unbuilt, image, and it all works again.
Changelog: Title
Changelog: beaglebone: Remove U-Boot integration, which has not worked
for a long time. U-Boot will still be used for booting, but GRUB will
be used for integration with Mender, by chainloading via UEFI.
[1] e88d5dbf01
Signed-off-by: Kristian Amlie <kristian.amlie@northern.tech>
Sounds scary, but it happens at build time, not runtime, so it cannot
brick devices. However, it was a frustrating exercise to uncover it,
as it is not entirely deterministic. This has been there for quite a
long time and I honestly cannot tell why it happened to me now.
Perhaps the exact location of the sparse holes on the filesystem makes
a difference. Or perhaps some versions of mkfs can handle it, others
not. All I know for sure, is that with `sparse` enabled I got massive
filesystem corruption (though sane enough to be somewhat readable) on
the rootfs. Without it, it's clean.
Changelog: Title
Signed-off-by: Kristian Amlie <kristian.amlie@northern.tech>
- Issue: #MEN-3725
The following new config variables have been added which closely mirror those used in meta-mender
to give fine grained controll over partition device paths. If partuuid support is enabled then
these partition variables must be used as format doesnt fit device/number variables scheme.
If partuuid support is disabled then partition variables are optional liek in meta-mender.
MENDER_ENABLE_PARTUUID
MENDER_BOOT_PART
MENDER_ROOTFS_PART_A
MENDER_ROOTFS_PART_B
MENDER_DATA_PART
Example:
MENDER_BOOT_PART="/dev/disk/by-partuuid/26445670-f37c-408b-be2c-3ef419866620" #gpt
MENDER_BOOT_PART="/dev/disk/by-partuuid/26445670-01" #dos
MENDER_BOOT_PART="/dev/sda1" #partuuid support disabled
Changelog: Partition UUID support added for gpt/dos partition tables for deterministic booting
Signed-off-by: Dell Green <dell.green@ideaworks.co.uk>
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>
Currently this is redirecting stdout to stderr and then writing the
now blank stdout to the log file. This results in log messages getting
displayed to the screen but missed in the log file.
Changelog: Title
Signed-off-by: Drew Moseley <drew.moseley@northern.tech>
Previously the user would have to manually decompress an input image prior to
handing it over to mender-convert. With this change, files compressed in the
formats: lzma, gzip, or zip archives will be automatically decompressed,
converted, and then recompressed.
Note that the zip archive can only contain one image file, otherwise the
conversion will fail. Thus if the archive contains multiple files, human
interaction is required. This simply involves unzipping the archive yourself,
and then pass in the image, just like in the old workflow.
Ticket: https://tracker.mender.io/browse/MEN-3052
Changelog: Added automatic decompression of input images, so that the convert
tool now accepts compressed input images in the formats: lzma, gzip, and zip.
The images will also be recompressed to the input format automatically.
Signed-off-by: Ole Petter <ole.orhagen@northern.tech>
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>
With GPT there should be a backup partition table at the end of the disk. Before this change, mender-convert-package creates the output image file, writes the partition table, and when it writes the first partition data the file is truncated and the backup partition table is gone.
This change should not cause any worse performance, it leaves the backup partition table when using GPT partition scheme, and makes troubleshooting easier when looking at the partition table of the output diskimage.
Also worth noting, if the output diskimage is written to a disk that is larger than the diskimage, the backup partition table will end up in the wrong place. This can be fixed by running 'sgdisk -e <device>'. The device will still boot without the backup partition table, but it would be good to either document this or make it automatic as part of any "first boot" disk/partition operations.
Changelog: Title
Signed-off-by: Nate Baker <bakern@gmail.com>
This adds color to the warning, error, and fatal log messages, by changing the
colour codes in the terminal for the error level in the log message. This way
warning and errors stick out more from the regular messages, and helps identify
errors.
Changelog: Title
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>
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>