Merge ~rodsmith/plainbox-provider-certification-server:fix-arm64-virt into plainbox-provider-certification-server:master

Proposed by Rod Smith
Status: Merged
Approved by: Jeff Lane 
Approved revision: bb1e135c20259359c92e83db1b1a27d174558093
Merged at revision: e0830aef0cdbe3a429ca6b098ae4c62645792316
Proposed branch: ~rodsmith/plainbox-provider-certification-server:fix-arm64-virt
Merge into: plainbox-provider-certification-server:master
Diff against target: 157 lines (+74/-67)
1 file modified
tools/canonical-certification-precheck (+74/-67)
Reviewer Review Type Date Requested Status
Jeff Lane  Approve
Review via email: mp+331006@code.launchpad.net

Description of the change

If KVM_IMAGE in /etc/xdg/canonical-certification.conf points to a non-.img file, don't attempt to verify its validity in canonical-certification-precheck; instead, accept it as valid but issue a warning. This fixes a problem in that the precheck script would reject such files, which are used on ARM64 and ARMHF platforms.

This fix is a bit half-done, in that it would be better to extract the .img file from the tarball and verify it, or at least accept tarballs only on the platforms that use them; but the problem case seems to be pretty limited, and this is just the precheck script, not Checkbox itself, so writing a lot more code seems pointless.

This diff looks bigger than it is; I had problems with inconsistent formatting (tabs vs. spaces), which ended up growing the diff.

To post a comment you must log in.
Revision history for this message
Jeff Lane  (bladernr) wrote :

FWIW, if you are using Vim, set the tab to be 4 spaces (as opposed to a single tab char):

set tabstop=4
set shiftwidth=4
set expandtab
set softtabstop=4

This way a "tab" is always a consistent 4 characters. Bash doesn't complain like Python will about inconsistency between tabs and spaces.

Revision history for this message
Jeff Lane  (bladernr) wrote :
review: Needs Information
Revision history for this message
Jeff Lane  (bladernr) wrote :

Thanks, the email tied these all together, makes more sense now.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/tools/canonical-certification-precheck b/tools/canonical-certification-precheck
2index 67ac2a1..c87c2ae 100755
3--- a/tools/canonical-certification-precheck
4+++ b/tools/canonical-certification-precheck
5@@ -296,78 +296,85 @@ KVM_Image_Check(){
6 name="KVM Image Check"
7 echoname
8 if grep "^KVM_IMAGE =" /etc/xdg/canonical-certification.conf >/dev/null; then
9- kvmurl=$(grep ^KVM_IMAGE /etc/xdg/canonical-certification.conf|awk '{print $3}')
10- /usr/bin/qemu-img check $kvmurl >/dev/null 2>&1
11- if [ $? = "0" ]; then
12- echo -e " $kvmurl is a valid image.\n Continuing to use this image"
13- pass
14- return 0
15- else
16- echo -e " $kvmurl is not a valid image.\n Would you like to reconfigure it now? [Y/n]"
17- read -s -N1 a
18- if [[ $a == "Y" || $a == "y" || -z $a ]]; then
19- read -e -p " Enter the path of your KVM Image: " kvm
20- sudo sed -i "s,KVM_IMAGE =.*,KVM_IMAGE = $kvm,g" /etc/xdg/canonical-certification.conf
21- kvmurl=$(grep ^KVM_IMAGE /etc/xdg/canonical-certification.conf|awk '{print $3}')
22- /usr/bin/qemu-img check $kvmurl >/dev/null 2>&1
23- if [ $? = "0" ]; then
24- echo -e " $kvmurl is a valid image.\n Continuing to use this image"
25- pass
26- return 0
27- else
28- echo -e " We cannot get our image from $kvmurl.\n Marking as failed."
29- fail
30- return 0
31- fi
32- else
33- echo -e " Leaving configuration but commenting out.\n Trying cloud image."
34- sudo sed -i '/^KVM_IMAGE/ s/^#*/#/' /etc/xdg/canonical-certification.conf
35- fi
36- fi
37+ kvmurl=$(grep ^KVM_IMAGE /etc/xdg/canonical-certification.conf|awk '{print $3}')
38+ if [[ "$kvmurl" =~ .*\.img$ ]] ; then
39+ /usr/bin/qemu-img check $kvmurl >/dev/null 2>&1
40+ if [ $? = "0" ]; then
41+ echo -e " $kvmurl is a valid image.\n Continuing to use this image"
42+ pass
43+ return 0
44+ else
45+ echo -e " $kvmurl is not a valid image.\n Would you like to reconfigure it now? [Y/n]"
46+ read -s -N1 a
47+ if [[ $a == "Y" || $a == "y" || -z $a ]]; then
48+ read -e -p " Enter the path of your KVM Image: " kvm
49+ sudo sed -i "s,KVM_IMAGE =.*,KVM_IMAGE = $kvm,g" /etc/xdg/canonical-certification.conf
50+ kvmurl=$(grep ^KVM_IMAGE /etc/xdg/canonical-certification.conf|awk '{print $3}')
51+ /usr/bin/qemu-img check $kvmurl >/dev/null 2>&1
52+ if [ $? = "0" ]; then
53+ echo -e " $kvmurl is a valid image.\n Continuing to use this image"
54+ pass
55+ return 0
56+ else
57+ echo -e " We cannot get our image from $kvmurl.\n Marking as failed."
58+ fail
59+ return 0
60+ fi
61+ else
62+ echo -e " Leaving configuration but commenting out.\n Trying cloud image."
63+ sudo sed -i '/^KVM_IMAGE/ s/^#*/#/' /etc/xdg/canonical-certification.conf
64+ fi
65+ fi
66+ else # URL does not end in ".img". No way to test, so pass it and hope for the best....
67+ echo -e " $kvmurl is not a\n .img file, so its validity can't be tested."
68+ warn
69+ eval info${i}=\"Unable to test\"
70+ return 0
71+ fi
72
73 else
74- echo -e " KVM_IMAGE is not configured.\n Note: If left unconfigured, we will pull our image from cloud-images.ubuntu.com.\n Would you like to configure it now? [Y/n]"
75- read -s -N1 a
76- if [[ $a == "Y" || $a == "y" || -z $a ]]; then
77- read -e -p " Enter the path of your KVM Image: " kvm
78- sudo sed -i "s,#KVM_IMAGE =.*,KVM_IMAGE = $kvm,g" /etc/xdg/canonical-certification.conf
79- kvmurl=$(grep ^KVM_IMAGE /etc/xdg/canonical-certification.conf|awk '{print $3}')
80- /usr/bin/qemu-img check $kvmurl >/dev/null 2>&1
81- if [ $? = "0" ]; then
82- echo -e " $kvmurl is a valid image.\n Continuing to use this image"
83- pass
84- return 0
85- else
86- echo -e "\n $kvmurl is not a valid image.\n Would you like to reconfigure it now? [Y/n]"
87- read -s -N1 a
88- if [[ $a == "Y" || $a == "y" || -z $a ]]; then
89- read -e -p " Enter the path of your KVM Image: " kvm
90- sudo sed -i "s,KVM_IMAGE =.*,KVM_IMAGE = $kvm,g" /etc/xdg/canonical-certification.conf
91- kvmurl=$(grep ^KVM_IMAGE /etc/xdg/canonical-certification.conf|awk '{print $3}')
92- /usr/bin/qemu-img check $kvmurl >/dev/null 2>&1
93- if [ $? = "0" ]; then
94- echo -e " $kvmurl is a valid image.\n Continuing to use this image"
95- pass
96- return 0
97- else
98- echo -e " Leaving configuration but commenting out.\n Trying cloud image."
99- sudo sed -i '/^KVM_IMAGE/ s/^#*/#/' /etc/xdg/canonical-certification.conf
100- fi
101- else
102- echo -e " Leaving configuration but commenting out.\n Trying cloud image."
103- sudo sed -i '/^KVM_IMAGE/ s/^#*/#/' /etc/xdg/canonical-certification.conf
104- fi
105- fi
106- fi
107+ echo -e " KVM_IMAGE is not configured.\n Note: If left unconfigured, we will pull our image from\n cloud-images.ubuntu.com.\n Would you like to configure it now? [Y/n]"
108+ read -s -N1 a
109+ if [[ $a == "Y" || $a == "y" || -z $a ]]; then
110+ read -e -p " Enter the path of your KVM Image: " kvm
111+ sudo sed -i "s,#KVM_IMAGE =.*,KVM_IMAGE = $kvm,g" /etc/xdg/canonical-certification.conf
112+ kvmurl=$(grep ^KVM_IMAGE /etc/xdg/canonical-certification.conf|awk '{print $3}')
113+ /usr/bin/qemu-img check $kvmurl >/dev/null 2>&1
114+ if [ $? = "0" ]; then
115+ echo -e " $kvmurl is a valid image.\n Continuing to use this image"
116+ pass
117+ return 0
118+ else
119+ echo -e "\n $kvmurl is not a valid image.\n Would you like to reconfigure it now? [Y/n]"
120+ read -s -N1 a
121+ if [[ $a == "Y" || $a == "y" || -z $a ]]; then
122+ read -e -p " Enter the path of your KVM Image: " kvm
123+ sudo sed -i "s,KVM_IMAGE =.*,KVM_IMAGE = $kvm,g" /etc/xdg/canonical-certification.conf
124+ kvmurl=$(grep ^KVM_IMAGE /etc/xdg/canonical-certification.conf|awk '{print $3}')
125+ /usr/bin/qemu-img check $kvmurl >/dev/null 2>&1
126+ if [ $? = "0" ]; then
127+ echo -e " $kvmurl is a valid image.\n Continuing to use this image"
128+ pass
129+ return 0
130+ else
131+ echo -e " Leaving configuration but commenting out.\n Trying cloud image."
132+ sudo sed -i '/^KVM_IMAGE/ s/^#*/#/' /etc/xdg/canonical-certification.conf
133+ fi
134+ else
135+ echo -e " Leaving configuration but commenting out.\n Trying cloud image."
136+ sudo sed -i '/^KVM_IMAGE/ s/^#*/#/' /etc/xdg/canonical-certification.conf
137+ fi
138+ fi
139+ fi
140 fi
141 kvmurl="http://cloud-images.ubuntu.com/$codename/current/$codename-server-cloudimg-$arch-disk1.img"
142 if curl --output /dev/null --silent --head -fail "$kvmurl"; then
143- echo -e " We can get our image from $kvmurl.\n Continuing to use this image"
144- pass
145- else
146- echo -e " We cannot get our image from $kvmurl.\n Marking as failed"
147- fail
148- fi
149+ echo -e " We can get our image from $kvmurl.\n Continuing to use this image"
150+ pass
151+else
152+ echo -e " We cannot get our image from $kvmurl.\n Marking as failed"
153+ fail
154+fi
155 }
156
157 # Check local availability of LXD images or pull from Internet, which tends to be slow

Subscribers

People subscribed via source and target branches

to all changes: