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>
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>
* 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>
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>
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>
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>
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>
* 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
* 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
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>
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>
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>
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>
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>
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>