From 27ac4b43b1b447deb065141a9520686a02dce3d9 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Thu, 6 Jan 2022 11:36:21 +0100 Subject: [PATCH 1/2] 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 --- scripts/runtests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/runtests.sh b/scripts/runtests.sh index ea119913..fa31ffac 100755 --- a/scripts/runtests.sh +++ b/scripts/runtests.sh @@ -90,7 +90,7 @@ validate () { exit 1 fi lang="$(grep -Eo 'LANG="([^.@ _]+)' .subiquity/etc/default/locale | cut -d \" -f 2)" - if [ -z "$( ls .subiquity/var/cache/apt/archives/) | grep $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/" exit 1 fi From 1a079ecdddd65a11d1863a3d417e676127fe40ab Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Thu, 6 Jan 2022 11:59:30 +0100 Subject: [PATCH 2/2] 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 --- scripts/runtests.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/runtests.sh b/scripts/runtests.sh index fa31ffac..53786239 100755 --- a/scripts/runtests.sh +++ b/scripts/runtests.sh @@ -89,7 +89,8 @@ validate () { echo "user not assigned with the expected group sudo" exit 1 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 echo "expected $lang language packs in directory var/cache/apt/archives/" exit 1