23 Commits

Author SHA1 Message Date
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
Michael Vogt
e7a54ad907 boot: add missing tests for HostUbuntuDataForMode() on classic and fix code 2022-09-24 10:51:15 +02:00
Michael Vogt
941c5fcafa boot: update code for latest API changes 2022-09-23 16:43:51 +02:00
Michael Vogt
d1882076fe Merge remote-tracking branch 'upstream/master' into make-bootable-on-classic 2022-09-23 10:38:37 +02:00
Michael Vogt
7d49848996 Merge pull request #12175 from mvo5/refactor-installhost-writable
many: refactor tests to use explicit strings instead of boot.Install{Initramfs,Host}{Writable,FDEData}Dir
2022-09-23 10:38:14 +02:00
Michael Vogt
4e837c9d4e many: make {Install,Initramfs}{{,Host},Writable}Dir a function
The location of these directories depends on the model.

E.g. `InstallHostWritableDir` is
- on classic: `/run/mnt/ubuntu-data`
- on core: `/run/mnt/ubuntu-data/system-data`

So these dirs need to take a minimal model interface instead
of being strings.
2022-09-22 16:27:41 +02:00
Michael Vogt
b253550d24 tests: replace boot.InitramfsWritableDir with explicit string value
This was generated via:
```
$ git grep -l boot.InitramfsWritableDir | grep _test.go | xargs sed -i 's#boot.InitramfsWritableDir#filepath.Join(dirs.GlobalRootDir, "/run/mnt/data/system-data")#'
```
2022-09-22 14:54:00 +02:00
Philip Meulengracht
039dce9c6e boot: add factory-reset cases for boot-flags.
we do this to allow the usage of `snapctl system-mode` during factory-reset as a pre-requisite to running the install-device hook during factory-reset
2022-09-19 08:28:59 +02:00
Alfonso Sánchez-Beato
83a0862ecb boot: test variable data rootfs 2022-08-30 12:27:34 +01:00
Alfonso Sánchez-Beato
bc76e66600 boot,cmd: mount ubuntu-seed for classic if present, make rootfs an arg 2022-08-30 12:27:30 +01:00
Samuele Pedroni
5967930d46 many: use pre-UC20 instead of non-UC20+ as is less clunky 2022-04-29 14:43:39 +02:00
Samuele Pedroni
b8e364fa47 many: switch to UC20+ in user messages (instead of UC20) 2022-04-29 14:30:24 +02:00
Samuele Pedroni
54e84fb8db many: fix imports order (according to gci)
had to make the comment in wrappers/services_test.go a one-liner
otherwise half of it is lost

last set of files needing changing (as per current master)
2021-06-16 09:54:31 +02:00
Samuele Pedroni
37c1255389 boot/image: support image.Customizations.BootFlags
to achieve this change the signature of MakeBootableImage (also drop
now unused argument)

setImageBootFlags needed adjustments and also the tests using it
2021-04-30 21:15:38 +02:00
Ian Johnson
7e21028dfa boot/flags.go: comment fixes
Thanks to Maciej for the suggestions.

Also expand the unit test, also from Maciej's suggestion

Co-authored-by: Maciej Borzecki <maciek.borzecki@gmail.com>
2021-04-14 08:57:23 -05:00
Ian Johnson
c40a2dd95a boot/flags.go: rename RunModeRootfs to HostUbuntuDataForMode + return list
Return a list of locations, since there could hypothetically be multiple mount
points for ubuntu-data, such as in run mode where there is both "/" and
"/run/mnt/data".

Also verify that the install mode directory actually exists before returning
it. While we expect that this function will primarily be used during the
install-device hook which runs by definition after the partitions are created,
it is possible someday we could use this function at a time in install mode
where the partitions haven't been created and thus the mount point doesn't
exist.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2021-04-13 15:29:20 -05:00
Ian Johnson
81dca0d22e Merge branch 'master' into feature/uc20-snapctl-system-mode-2
Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2021-04-13 15:26:37 -05:00
Samuele Pedroni
c57cdb2991 boot,tests: move where we write boot-flags one level up
* boot,tests: move where we write boot-flags one level up

/run/snapd/snap-bootstrap is a scratch directory and user space
shouldn't care a lot about it

* cmd/snap-bootstrap/initramfs-mounts: fix boot-flags location from initramfs

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>

Co-authored-by: Ian Johnson <ian.johnson@canonical.com>
2021-04-12 09:17:57 +02:00
Ian Johnson
1d8b5c8961 boot/flags.go: rename InitramfsSetBootFlags to ...ExposeBootFlagsForSystem
Thanks to @pedronis and @bboozzoo for the suggestions.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2021-04-08 20:39:06 -05:00
Ian Johnson
8aa2fa9d4e boot/flags.go: add RunModeRootfs()
This function is meant to be used by snap{,ctl} system-mode in reporting the
location of ubuntu-data as it is used by run mode. For recover mode in order to
find the location of ubuntu-data, we need to parse degraded.json to get the
mount-location and mount-state, but for the other modes the directory is
statically known.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2021-04-07 18:29:27 -05:00
Ian Johnson
d3c21a17ff boot/flags: make BootFlags filter the result + return specific error
When the flags are filtered out to only be the ones that are currently
understood, then we return a specific error type that can be checked for in
addition to the full set of understood boot flags. This allows more robust
implementations to process understood/supported boot flags while still logging
unknown ones that pop up from untrusted places like the bootenv or possibly a
newer snapd that we reverted away from (or one that was newer and running in
run mode, but now we are running in recover mode).

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2021-04-01 21:49:05 -05:00
Ian Johnson
c098d316f7 boot/flags_test.go: check extra err is nil in the test
Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2021-04-01 21:37:54 -05:00
Ian Johnson
83db9818fb boot: support read/writing boot-flags from userspace/initramfs
Add a family of functions for reading and writing boot-flags in various
contexts:

* Reading the current effective boot flags from either the modeenv or the
  bootenv from the initramfs depending on the mode.
* Writing the current effective boot flags to a file in /run from the initramfs
* Reading the current effective boot flags from userspace (this is from a file
  in /run)
* Writing the next boot flags to the modeenv from userspace
* Reading the next boot flags from the modeenv from userspace
* Writing the next boot flags to the bootenv during snap 
  prepare-image/ubuntu-image time

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2021-03-31 17:37:59 -05:00