Commit Graph
239 Commits
Author SHA1 Message Date
Arzhan Kinzhalin 0bf72acbe3 Install systemd as a fallback when in image mode. 2017-10-22 03:35:51 +00:00
Arzhan Kinzhalin 98f2f93fd7 Merge branch 'kai/shim-systemd' 2017-10-18 20:16:17 +00:00
Ikey Doherty 5a1f9d261b lib: Address upstream util-linux partlist regression
This fixes a segfault occuring within clr-boot-manager's usage of the
`blkid_partlist_numof_partitions` function that will now segfault when
passed a NULL blkid_partlist, as of util-linux 2.30.x series.

This change will ensure all consumers of the cbm_blkid API will continue to
function as before, but safe guard against the util-linux internal changes
that broke the counter function to determine how many partitions are present.

Note that this behaviour only manifested on LVM installations, which have
a more advanced probing scheme within clr-boot-manager.

Solus Issue: https://dev.solus-project.com/T4763

Signed-off-by: Ikey Doherty <ikey@solus-project.com>
2017-10-18 14:56:00 +01:00
Arzhan Kinzhalin 8f534f0e35 Refactor to get rid of _impl functions. 2017-10-16 09:36:58 +00:00
Arzhan Kinzhalin 26bbec84c1 Use env var to turn off EFI var manipulation.
To turn off creation and modification of EFI variable, define
environment variable CBM_BOOTVAR_TEST_MODE=yes.
2017-10-12 20:36:07 +00:00
Arzhan Kinzhalin 8966a64612 Recover the beauty. 2017-10-11 19:50:44 +00:00
Arzhan Kinzhalin f2fedf1e12 Add diagnostics and err handling for shim/systemd. 2017-10-11 08:33:52 +00:00
Brett T. Warden e8c7070064 Fix typo in error message
Fix dermine->determine
2017-10-10 17:20:07 -07:00
Arzhan Kinzhalin d8166f7a1b Remove leftover mark for unused argument. 2017-09-19 18:56:14 +00:00
Arzhan Kinzhalin d1f96a4bbd Re-enable nice automated formatting. 2017-09-19 18:49:02 +00:00
Arzhan Kinzhalin 49868238a7 Fix tests (and implementation). 2017-09-19 18:49:02 +00:00
Arzhan Kinzhalin 827f24f2a0 Use boot mount provided by bootman.
Prefix source and destination for install/update using boot root
returned by boot_manager_get_boot_dir() as opposed to BOOT_DIRECTORY.
Both work, but boot_manager_get_boot_dir() allows for testing.
2017-09-19 18:49:02 +00:00
Arzhan Kinzhalin c4c0d1b201 Change code style to 8-space indent. 2017-09-19 18:49:02 +00:00
Arzhan Kinzhalin 4b2e4dadc1 Add the boot record first to the boot order. 2017-09-19 18:49:02 +00:00
Arzhan Kinzhalin 2133e5f6fa Fix memory usage. 2017-09-19 18:49:02 +00:00
Arzhan Kinzhalin 1e125542fb Use capital hex in boot vars(compliant with UEFI). 2017-09-19 18:49:02 +00:00
Arzhan Kinzhalin d2c0fa4248 Make bootvar_create return boot var name.
Also, pass the ESP mount point instead of host bootloader path to
determine the partition information.
2017-09-19 18:49:02 +00:00
Arzhan Kinzhalin 43baee8f91 Reuse set_default_kernel from systemd-class. 2017-09-19 18:49:02 +00:00
Arzhan Kinzhalin 809aeb2ce8 Remove debug output. 2017-09-19 18:49:02 +00:00
Arzhan Kinzhalin b8b996968d Move implementation. Rename and prefix functions. 2017-09-19 18:49:02 +00:00
Arzhan Kinzhalin 79b8c78b91 Clean up. Refactor. 2017-09-19 18:49:02 +00:00
Arzhan Kinzhalin 30e9f06760 Avoid creating duplicate Boot* vars.
Attempt to find variables with exaact same content before creating a new
one.
2017-09-19 18:49:02 +00:00
Arzhan Kinzhalin eacdfc4293 Make internal function static. 2017-09-19 18:49:02 +00:00
Arzhan Kinzhalin d0bbf4df13 Separate host and ESP paths and use them properly. 2017-09-19 18:49:02 +00:00
Arzhan Kinzhalin 9df212a9c3 Clean up. 2017-09-19 18:49:02 +00:00
Arzhan Kinzhalin 1269f54de2 Add/correct copyright notice. 2017-09-19 18:49:02 +00:00
Arzhan Kinzhalin 065662f702 Rename files, clean up. 2017-09-19 18:49:02 +00:00
Arzhan Kinzhalin 84860370d7 Add draft implementation of boot var support. 2017-09-19 18:49:02 +00:00
Arzhan Kinzhalin b3bc61b254 Get rid of the maybe uninitialized warning. 2017-09-19 18:49:02 +00:00
Arzhan Kinzhalin e9fd24b763 WIP: efi boot var implementation. 2017-09-19 18:49:02 +00:00
Arzhan Kinzhalin 4f52d149af Add working impl of kernel install. 2017-09-19 18:49:02 +00:00
Arzhan Kinzhalin 734c911d44 Use get_kernel_dst() instead of hard-coded value. 2017-09-19 18:49:02 +00:00
Arzhan Kinzhalin edebfc34bd Clean up. 2017-09-19 18:49:02 +00:00
Arzhan Kinzhalin 32904c4bc0 Ask bootloader where to copy the kernels. 2017-09-19 18:49:02 +00:00
Arzhan Kinzhalin 61ba7e9d8d Add partial implementation.
Bootloaders are installed, but not kernels. Kernels are installed
(copied) into wrong location by a completely different piece of code.
2017-09-19 18:49:02 +00:00
Arzhan Kinzhalin 4837aef7f9 Add stub shim-systemd support.
Does nothing at this point.
2017-09-19 18:49:02 +00:00
Ikey Doherty 9bdd68d4c5 cmdline: Support vendor provided stateless fragments
This change introduces support for vendor kernel configuration fragments,
which typically live within the /usr/share/kernel/cmdline.d directory.
These are useful to vendors and OEMs to pre-enable some hardware quirks
such as acpi_os, i8042 tweaks, etc.

These files take a higher precedence than the /etc/ files, however to
ensure we abide by a proper stateless policy we allow the concept of masking
and disabling in the style of systemd. The files in the "vendor config"
directory are considered masked when a file with the same base name lives
within the "system config" (/etc/kernel/cmdline.d) tree. The vendor file
will be skipped regardless of system config validity in this instance.

To allow disabling entirely of the vendor config file, the local system
administrator may follow the masking approach as described as above, but
instead of creating a override, symlink this file to /dev/null. This will
cause the file to be removed entirely from any kind of parsing. This link
logic is only valid within the context of the system config directory.

Signed-off-by: Ikey Doherty <ikey@solus-project.com>
2017-09-13 12:42:46 -07:00
Arzhan Kinzhalin a4048569a7 Fix the end of string condition. 2017-07-26 06:14:54 -07:00
Ikey Doherty 6c0a383788 cli: Return the correct value when set_timeout works
Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>
2017-06-16 15:08:33 +01:00
Ikey Doherty c44abcba98 Fix the ordering of UEFI vs legacy probing
The first and most important change is to ensure that we never try to
grab the host ESP when we're operating in image mode. This alone causes
issues when producing images using "--path", i.e. VHD imagery.

Secondly, we ensure that we *always* set image mode *before* we set the
prefix, as this prefix is only ever set once. This is the part where we
inspect the root of the system we're looking at, and determine whether
we're dealing with legacy or UEFI, or legacy+gpt (i.e. Azure images).

Lastly, we make sure that update_image follows the lead of update_native
by re-initialising the bootloader prior to using it, with the current
root + boot directory settings, ensuring we're always using fresh
values and world view.

Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>
2017-06-16 15:06:03 +01:00
Ikey Doherty 349301473f kernel: Allow lack of modules to be non-fatal
The lack of kernel modules during install isn't necessarily fatal, and
some kernel configurations might be without modules entirely. Notably,
given that kernel modules are to be marked as resident on disk, even if
we have multiple packages compromising a kernel and separate modules, those
old modules will be removed at the time of the kernel change, and at no
other time, ensuring an atomic update.

This resolves #67.

Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>
2017-05-30 11:51:40 -07:00
Ikey Doherty 567adab339 Ensure to include sysmacros.h for major/minor usage
As of glibc 2.25, warnings will be emitted at compile time to state
that you must explicitly include the header now, due to libraries
tending to have their own definitions.

Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>
2017-05-02 10:51:27 -07:00
Ikey Doherty 1fdb5aa6aa bootman: Ensure that we use the full namespace for EFI assets
Prior to this change, the kernel and initrd paths were not using the
namespace directory during kernel removal, leading to assets being left
on the disk and filling up the ESP with junk that could not be reclaimed.

This change introduces the simple fix, as well as the UEFI specific test
to ensure that the files are being removed.

Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>
2017-05-02 10:23:59 -07:00
Ikey Doherty 6e9b2b6c52 bootman: Remove legacy kernel blobs from bootdir
Since we switched to legacy vs UEFI namespacing, we only removed the target
path for the internal kernel removal code. This means that non UEFI systems
are being left with old blobs, unmanaged, on the boot partition.

This change ensures we always remove excess blobs for legacy booting systems
and not wasting space in that boot partition/dir.

Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>
2017-04-04 09:14:27 -07:00
Ikey Doherty 95cced4319 bootloaders/syslinux: Avoid duplicated entries in output
Due to our repair vs 1:1 "is installed" method changes, it is possible that
a kernel may be asked to be installed more than one time. As such we modify
the syslinux implementation to match that of GRUB2, and ensure that the
kernels being added to the list are all unique.

Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>
2017-04-04 09:14:27 -07:00
Ikey Doherty 85e6594f0f bootloaders/grub2: Use a submenu structure for non default kernels
This change will ensure that the newly selected default kernel is always
the first in the menu, which will also ensure that by default it is the
selected boot entry in GRUB2.

Any other "non default" kernels fall under a submenu structure after the
default kernel, allowing the user to manually select them with keyboard
navigation.

Lastly, to mitigate any potential upgrade issues with dual boot situations,
whereby another distro owns the GRUB2 in use, we select a default kernel
from the list if there is only one kernel, making sure we always have a
/vmlinuz shortcut to satisfy dual boot needs.

Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>
2017-04-04 09:14:27 -07:00
Ikey Doherty 7399e96d69 bootman: Allow native UEFI to "win" on GPT system containing legacy boot
Given the nature of a GPT system, it is permitted to have a legacy boot
partition, *and* an EFI System Partition. Thus, prior to this commit, a
chroot repair of a system would only ever find the legacy boot partition
and not the UEFI partition.

Likewise, in a booted system, we would run into the same problem, leading
to bricked systems on update. Now, we'll only try to determine a legacy
boot device if we're definitely not running in native UEFI mode, that is
to say, !image_mode, and /sys/firmware/efi exists. This allows us to skip
an unusable partition in favour of our ESP.

This commit fixes #58.

Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>
2017-03-30 10:07:25 -07:00
Ikey Doherty b50c4606cb probe: Add support to determine if a device uses a GPT table or not
In accordance with issue #53, we must only use the PartUUID for root=
entries when we *know* that the partition definitely resides on a GPT
disk.

Whilst an EFI System Partition must live on a GPT disk to be considered
a valid ESP, there is no such constraint on the rootfs itself. Cases
emerged during testing of an MBR rootfs partition, with a GPT disk used
to house the ESP itself.

This change ensures we only ever write a root=PARTUUID if we're fully
certain of the topology, otherwise all bootloaders will automatically
fall back to root=UUID entries.

Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>
2017-03-29 09:07:35 -07:00
Ikey Doherty d055bd46bf bootman: Always reinit using a valid boot directory
Previously the modify_bootloader invocation would attempt to reinit itself
with the abs_bootdir. However, in the instance of a native image, we've
had no reason to set a new boot_dir, thus this value is now NULL, leading
to set_boot_dir to fail for the first time.

Once this is set here, i.e. because we're looking at a real root, we
fire off the reinspection and everything "just works".

This change helps, in part, issue #54.

Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>
2017-03-28 20:35:43 -07:00
Ikey Doherty 338106a69f bootman: Collapse double slashed boot directory where possible
In the event that the boot dir exists, we can realpath it to collapse our
returned path to remove any double slashes which in turn would've stopped
the lookup function working for cbm_is_mounted, when determining if the ESP
is already mounted or not.

This helps, in part, issue #54.

Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>
2017-03-28 20:35:43 -07:00