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>
This commit is contained in:
Olivier Gayot 2022-01-06 11:59:30 +01:00
parent 27ac4b43b1
commit 1a079ecddd
1 changed files with 2 additions and 1 deletions

View File

@ -89,7 +89,8 @@ validate () {
echo "user not assigned with the expected group sudo" echo "user not assigned with the expected group sudo"
exit 1 exit 1
fi fi
lang="$(grep -Eo 'LANG="([^.@ _]+)' .subiquity/etc/default/locale | cut -d \" -f 2)" # Extract value of the LANG variable from etc/default/locale (with or without quotes)
lang="$(grep -Eo 'LANG=([^.@ _]+)' .subiquity/etc/default/locale | cut -d= -f 2- | cut -d\" -f 2-)"
if ! ls .subiquity/var/cache/apt/archives/ | grep --fixed-strings --quiet -- "$lang"; then if ! ls .subiquity/var/cache/apt/archives/ | grep --fixed-strings --quiet -- "$lang"; then
echo "expected $lang language packs in directory var/cache/apt/archives/" echo "expected $lang language packs in directory var/cache/apt/archives/"
exit 1 exit 1