Commit Graph

454 Commits

Author SHA1 Message Date
Miguel Pires
79c5ac14b2 many: remove usages of deprecated io/ioutil package (#13768)
* many: remove usages of deprecated io/ioutil package

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>

* .golangci.yml: remove errcheck ignore rule for io/ioutil

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>

* run-checks: prevent new usages of io/ioutil

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>

---------

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2024-04-03 23:23:24 +02:00
Valentin David
b248f6c7f7 bootloader/grub.go: add new boot chain binary paths 2024-03-13 12:41:32 +01:00
Valentin David
9edec0a419 bootloader/grub.go: return all possible boot chains
We need to resolve the boot chains another place based on the trusted
assets we encountered to be installed. At this point it could be any chain.
We will need to discover later what the correct chain is.

Also make TrustedAssets return an unsorted data structure to make sure
we do not use the order like the comments claimed.
2024-03-13 12:41:32 +01:00
Valentin David
0954b5ac79 gadget: add kernel command-line remove filter to gadget yaml 2023-10-26 09:34:20 +02:00
Valentin David
7ab5e25a69 boot: update cmdline variables also when updating gadget
Since the cmdline variable will contain default arguments for
the edition, we need to update the variable if we change of edition.
2023-10-18 11:20:15 +02:00
Valentin David
33f5a54f40 boot: only use variable snapd_full_cmdline_args
We know what are the default the default command line so that we can
compute measurement, so there is not much reason to use
`snapd_extra_cmdline_args`. Always using `snapd_full_cmdline_args`
will allow us to filter part of the default command line.

There is a potential bug when filtering all arguments, `grub.cfg` will
just revert to the all the default. We will need to fix it when we
introduce the filtering.
2023-10-18 11:20:15 +02:00
Valentin David
0267590c2a bootloader/assets/data/grub-recovery.cfg: set root when chainloading
Upstream grub does not pass to LoadImage the correct path to the
loaded binary. This results in second grub not knowing where it was
loaded from and loading the wrong grub.cfg. If we set "root", then the
path becomes correct.

Currently in mantic, the Ubuntu patch that used to be applied to 2.06
is not applied to 2.12. So we are we are back to upstream behavior.

The common use case for chainloading in EFI with grub (see
30_os-prober) always sets root. So we should do it and not get broken
again.
2023-10-11 10:16:09 +01:00
Miguel Pires
29c9752d66 many: s/ioutil.WriteFile/os.WriteFile (#13217)
Replace ioutil.WriteFile with os.WriteFile since the former has been
deprecated since go1.16 and simply calls the latter.

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2023-09-26 11:38:46 +01:00
Dimitri John Ledkov
d55f3123d4 go: go fix with 1.18
Apply `go fix ./...` to the whole code base using go-1.18 to remove
old build tags.
2023-09-25 13:22:14 +02:00
Philip Meulengracht
0bb8d996ab o/restart: add first part of the new restart logic
Implement RestartParameters which helps keeping track of tasks that needs to restart and why for a change. It also adds the new logic for performing deferred restarts.
2023-08-03 15:22:04 +02:00
Valentin David
d9e4ab8c5e osutil/kcmdline: simplify names 2023-07-31 16:40:56 +02:00
Valentin David
c9bbf25300 osutil: extract kcmdline to its own package 2023-07-31 16:40:56 +02:00
Miguel Pires
b73965e68f bootloader: remove naked return
Removes a naked return that the latest version of golangci-lint
complains about.

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2023-06-12 14:37:13 +01:00
Alex Lewontin
9cf75d31bf bootloader: format recovery boot.sel to mirror gadget boot.sel
Signed-off-by: Alex Lewontin <alex.lewontin@canonical.com>
2023-02-22 17:24:56 +01:00
Alex Lewontin
041b90b183 bootloader: handle uboot envs both with and without header flag byte
Allows snapd to handle uboot envs for uboots with
CONFIG_SYS_REDUNDAND_ENV=n

Signed-off-by: Alex Lewontin <alex.lewontin@canonical.com>
2023-02-22 17:24:56 +01:00
Miguel Pires
d097436c1c many: fix formatting w/ gofmt 1.19
Go 1.19 includes some changes to gofmt which intend to make lists and
heading clearer when rendered (https://go.dev/doc/go1.19). This commit
is the result of running the new gofmt and manually fixing some of it.
This was necessary because the new gofmt assumed lines beginning w/ tabs
to start lists or examples. While this is often true in our codebase,
we occasionally also use tabs to indent the lines after a TODO or FIXME
prefix or in yaml (e.g., excerpts of a snap.yaml). This meant that a lot of the
reformatted comments were broken and had to be fixed manually.

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2023-01-16 14:23:11 +01:00
Miguel Pires
c0c0c19157 bootloader: fix test w/ auto-generated copyright year
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2023-01-06 14:31:40 +01:00
Michael Vogt
d4b4efccef bootloader: hardcode copyright year
The copyright of the auto-generated grub_{recovery,}_cfg_assets.go
file is generated from the current date. This leads to a dirty build
when the year changes. This commit hardcodes the copyright year
to 2022.

Once there is a better go build system (or we use something like
meson) we can re-introduce this because then the generated files
will be no longer in git.
2023-01-06 10:22:05 +01:00
Michael Vogt
8aa058e9df bootloader: error if grub does not have assets for the given architecture 2022-12-01 13:36:56 +01:00
Michael Vogt
946fb0db42 Merge pull request #12285 from alfonsosanchezbeato/fix-grub-no-system
bootloader/assets: fix grub.cfg when there are no labels
2022-11-01 14:24:24 +01:00
Valentin David
2670743b56 bootloader: do not specify Core version in grub entry
Ubuntu Core 22 now shows "Run Ubuntu Core 20" as boot entry.
2022-10-24 17:15:15 +02:00
Alfonso Sánchez-Beato
d4036a5b7a bootloader/assets: fix grub.cfg when there are no labels
grub's regexp does not change the store variable if there is no match,
so checking for empty variable after the regexp call was not really
working. Instead, check for successful regexp call.
2022-10-20 16:23:56 +01:00
Michael Vogt
d0059ad859 Merge pull request #11128 from kubiko/lk-boot-device-state-lock
include/lk: update LK recovery environment definition to include devi…
2022-09-14 15:30:41 +02:00
Ondrej Kubik
2f2b1ff2c2 bootloader/lk,include/lk: more typo fixing in the descriptions
Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>
2022-08-24 16:33:21 +03:00
Michael Vogt
bae7d30786 bootloader,systemd: fix don't use Yoda conditions (ST1017)
Fix all the `don't use Yoda conditions (ST1017)` warnings found
by staticcheck.io.
2022-08-19 10:05:25 +02:00