Commit Graph

4556 Commits

Author SHA1 Message Date
Dan Bungert aae3e420b0
Merge pull request #1156 from ogayot/FR-1746
Add support for APT preferences through autoinstall in Subiquity
2022-01-13 12:24:15 -07:00
Olivier Gayot 0cce67a87f Small improvements for Ubuntu Advantage dialogs
* select the relevant button by default when applicable
* make the list of services scroll properly
* add empty lines consistently
* mention that services can be enabled through `ua` (after installation)

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-13 16:08:59 +01:00
Olivier Gayot b03034887c Run ubuntu-advantage from the snap rather from the base ISO
The UAClientUAInterfaceStrategy can now optionally be initialized with
the path to the ubuntu-advantage entry point. Additionally, one can also
specify which Python interpreter should run it.

We leverage on this to force the use of:
 * the Python installation from the Subiquity snap
 * the ubuntu-advantage-tools integrated to the Subiquity snap

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-13 15:35:39 +01:00
Olivier Gayot 6e0c9821fe snapcraft: pickup curtin's support for apt_preferences
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-13 09:32:42 +01:00
Dan Bungert 98bf2943aa kvm-test: pep8 fixes 2022-01-12 14:56:58 -07:00
Dan Bungert e5e5d69a2d kvm-test: proxy, livefs_edit, debug
* add http_proxy recognition.  Picks up from DEBOOTSTRAP_PROXY.
* fix livefs_edit invocation
* include --debug in snap construction
2022-01-12 14:56:58 -07:00
Dan Bungert 7bdeb6707c os-prober: patch instead of sed 2022-01-12 13:33:07 -07:00
Dan Bungert 6bf9b8f734 snapcraft: rev probert for os-prober 2022-01-11 14:34:08 -07:00
Dan Bungert 05c8c70483 snapcraft: +os-prober 2022-01-11 14:34:08 -07:00
Olivier Gayot 9e7bc5053b Add support for APT preferences through autoinstall in Subiquity
The autoinstall schema for "apt" now supports the "preferences"
configuration. Each preference element should contain the properties
described below, that 1:1 map with the keywords from apt_preferences(5):

  * package      <-> Package:
  * pin          <-> Pin:
  * pin-priority <-> Pin-Priority:

These preferences are forwarded to curtin through
subiquity-curtin-apt.conf. Support for these rules must be added to
curtin as well.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-11 18:42:40 +01:00
Olivier Gayot 1995dd002a Add ubuntu-advantage-tools as stage-package
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-11 11:12:10 +01:00
Dan Bungert 5ae52c000b
Merge pull request #1151 from ogayot/FR-1652
Validate UA token & list available services
2022-01-10 10:02:41 -07:00
Dan Bungert 96a53eff14
Merge pull request #1154 from dbungert/autoinstall-disable-components
apt: fix disable_components w/ autoinstall
2022-01-10 09:45:49 -07:00
Dan Bungert 540049143d
Merge pull request #1146 from mwhudson/lp-1954848
do not accept probert results after user has submitted a filesystem config
2022-01-10 08:51:45 -07:00
Olivier Gayot f8704aa246 Merge branch 'main' into FR-1652
Resolve conflicts in PR 1151.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-10 10:53:51 +01:00
Dan Bungert 3d10a71d3c
Merge pull request #1153 from ogayot/ua-with-autoinstall
Add support for ubuntu-advantage with autoinstall
2022-01-07 15:27:41 -07:00
Dan Bungert 2a37cf5efb
Merge pull request #1155 from ogayot/fix-run-tests
Fix language packs detection in integration tests
2022-01-07 15:26:42 -07:00
Olivier Gayot 1a079ecddd Fix extraction of default locale when running integration tests
When running integration tests, the LANG variable in
.subiquity/etc/default/locale is unquoted. The pattern that we use
expects quotes so it does not match.

Fixed by making the test work with or without quotes.

In case quotes are not present, the final part of the pipeline will fail
to find a delimiter so it will print the line unchanged

excerpt from cut(1)

   -f, --fields=LIST
          select  only these fields;  also print any line that contains
          no delimiter character, unless the -s option is specified

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-07 10:42:53 +01:00
Olivier Gayot 27ac4b43b1 Fix language pack detection when running integration tests
Looking at the logs, we can observe that the below command does
not do what it is intended to do:

  if [ -z "$( ls .subiquity/var/cache/apt/archives/) | grep $lang" ] ; then

  ++ ls .subiquity/var/cache/apt/archives/
  + '[' -z 'language-pack-en:amd64
  wamerican:amd64
  wbritish:amd64 | grep ' ']'

The "| grep $lang" part does not execute because it is outside the $()
construct. Therefore, the -z check is always false.

We can fix it by moving the "| grep $lang" part inside the subshell
construct but I took the opportunity to drop the use of the subshell.

Also added --fixed-strings and --quiet options to grep.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-06 12:05:03 +01:00
Olivier Gayot 81c67780ff Add basics checks for token validity in the autoinstall JSON schema
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-06 10:54:08 +01:00
Dan Bungert 8ad8feec31
Merge pull request #1148 from CarlosNihelton/fix-wsl-shutdown
[SystemSetup] Moving pieces of configuration from Subiquity to WSL Launcher
2022-01-05 13:31:22 -07:00
Dan Bungert 9393bf1cd6 free-only: update for change to components storage 2022-01-05 12:55:05 -07:00
Olivier Gayot d07619a6a4 Pass app-wide scale factor to MockedUAInterfaceStrategy
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-05 18:57:29 +01:00
Dan Bungert 81d1b18222
Merge pull request #1150 from ogayot/lsb_release_dry_run
Make consistent calls to lsb_release
2022-01-05 10:54:16 -07:00
Dan Bungert 5a2a7f5ad6 apt: fix disable_components w/ autoinstall
* The mixture of storage for disable_components in and out of the config
  dict was confusing and caused bugs, depending on the flow
* disable_components now solely lives in the dict, like other items
2022-01-05 10:35:05 -07:00
Dan Bungert 68cb0d826f
Merge pull request #1152 from ogayot/fix-test-this-branch
Make sure test-this-branch.sh exits if distro-info is not installed
2022-01-05 09:58:22 -07:00
Dan Bungert ce624ad543
Merge pull request #1149 from dbungert/kvm-test-fixes
kvm-test: cleanups
2022-01-04 11:43:27 -07:00
Dan Bungert 52ede053ac kvm-test: review feedback and fixes
* fix several syntax errors
* missing 'this' item was renamed to 'iso'
* change the simulated 'bash -x' output to stderr
* use shlex functions for join/split
2022-01-04 10:58:09 -07:00
Olivier Gayot d345cf999a Use autoinstall for ubuntu-advantage in integration tests
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-04 17:58:46 +01:00
Olivier Gayot 76278f4d74 Add support for ubuntu-advantage in autoinstall
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-04 17:53:36 +01:00
Olivier Gayot 6d88618b9e Make sure test-this-branch.sh exits if distro-info is not installed
Although the script is running with -e, having two distinct invocations
of a subshell in the same instruction masks failures in the first
subshell invocation. It is similar in essence to what the pipefail
option controls.

As a consequence, the following instruction does not fail if distro-info
is not installed:

  isoname=$(distro-info -d)-live-server-$(dpkg --print-architecture).iso

And therefore, we end up with something like:

  isoname=-live-server-amd64.iso

Fixed by first assigning the value of $(distro-info -d) to a variable.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-04 17:38:43 +01:00
Olivier Gayot 4fffca685e Check the UA token and retrieve the list of features to be enabled
We now validate the UA token when it is supplied. After the user
submits a token, we retrieve the information about the subscription.
Then based on the outcome:

* if the token is valid, we display the list of services that will be
  enabled
* if the token is invalid or expired, we request the user to supply
  another token
* if we are unable to validate the token, for instance because of a
  network issue, then we ask the user if he wants to continue anyway or
go back and try again with (another) token.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2021-12-17 17:41:45 +01:00
Olivier Gayot 972d8ad02e Fetch Ubuntu Advantage subscription information
Implemented classes that can be used to fetch information about a Ubuntu
Advantage subscription based on a UA token.

The first class queries the UA servers using the ua_client script.
The second class reads the output from .json files so it can be used
offline and without delay.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2021-12-17 17:41:45 +01:00
Olivier Gayot fd403ce476 Add sample outputs for ua status --simulate-with-token --format json
This commit introduces example JSON files that would simulate output of
the ua_client script, as in the following command:

  $ ubuntu-advantage status \
      --simulate-with-token "${token}" \
      --format json

Two files are added, one for each of the following scenario:
 * output when supplied a valid, non expired token
 * output when supplied a valid but expired token

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2021-12-17 17:41:45 +01:00
Olivier Gayot 47ed7dbb9b Make consistent calls to lsb_release
We now always call lsb_release() with the application-wide dry-run
boolean. All calls should now be consistent (i.e. without a mix of
examples and files coming from the host)

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2021-12-17 17:08:21 +01:00
Olivier Gayot 475d71e166 Allow to pass dry_run boolean to lsb_release
So that we consistently return the same value from lsb_release() across
all calls that use dry-run, the function now accepts a dry_run argument
(defaulting to False). This way, in dry-run mode, the caller does not
need to supply the path to a specific example file anymore.

  lsb_release(dry_run=True) -> will load examples/lsb-release-focal

Having said that, the caller is still left with the possibility to
specify the example file by using the path argument:

  lsb_release(path="example/lsb-release-impish")

The path and dry_run arguments are mutually exclusive: providing both
will result in a ValueError.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2021-12-17 16:00:52 +01:00
Carlos Nihelton e429babb03 Fixes potential false positive UID findings
Also, splits part of the configure() method:
-  `__query_uid()` finds the username UID
- `_create_user()` creates the user set in IdentityModel
- Both methods accept a fake root path under dryrun.
2021-12-17 10:35:38 -03:00
Olivier Gayot b8516d6fba Revert "Skip the UbuntuAdvantage screen until we can validate the token"
This reverts commit 5403222956.
2021-12-17 09:12:05 +01:00
Dan Bungert 73bc16b8fb
Merge pull request #1140 from ogayot/FR-1652
Add initial integration of Ubuntu Advantage in Subiquity
2021-12-16 16:55:46 -07:00
Dan Bungert 7b3459ea9e
Merge pull request #1147 from ogayot/exception-string-interpolation
Fix exception messages not interpolated properly
2021-12-16 16:26:50 -07:00
Dan Bungert 06ac3f92b5 kvm-test: cleanups
* better command execution
* various build arguments imply --build, so one can do just '-q' where
  one would have to previously '--build -q'
2021-12-16 13:31:13 -07:00
Olivier Gayot 68b9c42fac Fix exception messages not interpolated properly
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2021-12-16 11:35:40 +01:00
Olivier Gayot 5403222956 Skip the UbuntuAdvantage screen until we can validate the token
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2021-12-16 11:07:10 +01:00
Olivier Gayot fe4b6fde6f Only show UA screen if running on LTS release
The UA screen is now shown only if we are running on an LTS release.
In dry-run mode, we pretend to always be on Ubuntu focal.

To implement the possibility to skip the screen, we added another POST
resource to inform the server that we are finished configuring
UbuntuAdvantage.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2021-12-16 11:06:09 +01:00
Michael Hudson-Doyle 784a46845f
Merge pull request #1143 from mwhudson/partition-gaps
add an object to represent a gap between partitions
2021-12-16 15:51:57 +13:00
Michael Hudson-Doyle 573c8e8d05 do not accept probert results after user has submitted a filesystem config
For https://bugs.launchpad.net/bugs/1954848
2021-12-16 14:39:41 +13:00
Carlos Nihelton b17c3d3db9 Cleanup complete.
- No user setup in wsl.conf
- Shutdown controller creates the launcher-command file
2021-12-14 12:13:00 -03:00
Dan Bungert 85a3c6a526
Merge pull request #1144 from ogayot/minor-fixes
Minor fixes in Makefile and tests
2021-12-14 08:05:31 -07:00
Carlos Nihelton bad945f5d7 Remove username from wsl.conf
- This is a cleanup for SystemSetup per DEENG-134 and DEENG-139
- Default user should be set by the WSL launcher.
- Shutdown/reboot actions also.
- Added a structured form of communication between OOBE and launcher.
- /run/launcher-command
2021-12-14 12:04:38 -03:00
Olivier Gayot 9b638270bc Update Makefile .PHONY targets
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2021-12-13 20:20:32 +01:00