Commit Graph

4465 Commits

Author SHA1 Message Date
Olivier Gayot 81bc59019c Remove --use-fuse switch and make it the default
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-20 12:01:44 +01:00
Olivier Gayot f1119b02a6 Add --use-fuse switch to kvm-test --install so it can run as non-root
Passing --use-fuse to scripts/kvm-test.py allows to run as non-root.

It requires installation of the package fuseiso so the switch is
disabled by default.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-19 10:10:33 +01:00
Dan Bungert b312a24468
Merge pull request #1161 from dbungert/udi-fixes
Fix two bug reports from ubuntu-desktop-installer
2022-01-13 13:31:10 -07:00
Dan Bungert 7f3f928cfd apt: fix lowerdir handling
lowerdir is a str, not a list
2022-01-13 13:23:45 -07:00
Dan Bungert 94eab6fc84 mirror: add missing await 2022-01-13 13:22:20 -07:00
Dan Bungert 4a672e071e
Merge pull request #1158 from ogayot/bind-uac-into-subiquity-snap
Embed ubuntu-advantage-tools into Subiquity snap and use it
2022-01-13 13:01:03 -07:00
Dan Bungert 0a5c7f585a
Merge pull request #1157 from ogayot/ui-fixes-ua
Small improvements for Ubuntu Advantage dialogs
2022-01-13 12:40:35 -07:00
Dan Bungert 2fb74e5e03
Merge pull request #1160 from ogayot/fix-kvm-test-drive
Fix -drive option and -append option from kvm-test.sh
2022-01-13 12:40:17 -07:00
Olivier Gayot 82aeeecbc6 Fix kernel command line from kvm-test.sh
Since 06ac3f92, we invoke kvm directly through subprocess.run.
Therefore, we must not add extra quotes around the -append options,
otherwise they persist and are passed in the kernel command line:

  $ cat /proc/cmdline
  "autoinstall subiquity-channel=stable" initrd=initrd

Later on, we fail to parse "autoinstall" and "subiquity-channel=stable"
as two distinct options.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-13 12:33:50 -07:00
Olivier Gayot ed0e6861aa Fix -drive option from kvm-test.sh
The function drive() used to return a string in the following format:

  "-drive file=/path/to/iso,..."

However, qemu/kvm expects "-drive" to be an argument and
"file=/path/to/iso,..." to be another argument.

The command was constructed as below since the beginning:

  kvm = [
     "kvm",
     "-cdrom", "custom.iso",          # <- OK
     "-drive file=/path/to/iso,...",  # <- NOK
  ]

Before 06ac3f92, we would join all the arguments using spaces before
executing the kvm command. Therefore we would luckily end up with a
correct command:

  " ".join(kvm)  ->  "kvm -cdrom custom.iso -drive file=/path/to/iso,..."

However, now that we supply the command to subprocess.run directly, the
problem shows up.

Fixed by returning a tuple("-drive", "file=/path/to/iso,...") from
the drive() function.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-13 12:33:47 -07:00
Dan Bungert 79b0c41b65
Merge pull request #1159 from dbungert/kvm-test-ctd
kvm-test: proxy, livefs_edit, debug
2022-01-13 12:29:58 -07:00
Dan Bungert 3a696ca459
Update scripts/kvm-test.py
Co-authored-by: Olivier Gayot <duskcoder@gmail.com>
2022-01-13 12:25:12 -07:00
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
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