Skip to content

Commit 193d83e

Browse files
committed
Add case to get IoT image url
1 parent eb41688 commit 193d83e

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
3+
BASE_URL="https://oem-share.canonical.com/partners"
4+
DCD_FILE="/run/mnt/ubuntu-seed/.disk/info"
5+
6+
convert_to_url() {
7+
local dcd_string="$1"
8+
# Examples:
9+
# canonical-oem-carlsbad:element-v2-uc24:20241205.15:v2-uc24-x01
10+
# canonical-oem-shiner:x8high-som-pdk:20241209-10:
11+
# canonical-oem-denver::20241201-124:
12+
13+
if [[ "$dcd_string" =~ ^canonical-oem-([a-zA-Z0-9]+):([a-zA-Z0-9-]*):([0-9.-]+)(:(.*))?$ ]]; then
14+
# Rule 1: Input string must start with "canonical-oem-" Mandatory
15+
# Rule 2: Project Name (alphabets and numbers) - Mandatory
16+
# Rule 3: Series (alphabets, numbers, and dash "-") - Optional
17+
# Rule 4: Build ID (Numbers, dot ".", and dash "-") - Mandatory
18+
# Rule 5: Additional Information (No limitation) - Optional
19+
local project_name="${BASH_REMATCH[1]}"
20+
local series="${BASH_REMATCH[2]}" # optional
21+
local build_id="${BASH_REMATCH[3]}"
22+
local additional_info="${BASH_REMATCH[4]}" # optional
23+
local image_name=""
24+
25+
if [ -n "$series" ]; then
26+
image_name="${project_name}-${series}-${build_id}.tar.xz"
27+
echo "$BASE_URL/${project_name}/share/${series}/${build_id}/${image_name}"
28+
else
29+
image_name="${project_name}-${build_id}.tar.xz"
30+
echo "$BASE_URL/${project_name}/share/${build_id}/${image_name}"
31+
fi
32+
else
33+
echo "Invalid DCD format: $dcd_string" >&2
34+
exit 1
35+
fi
36+
}
37+
38+
if [ -f "$DCD_FILE" ]; then
39+
dcd_string=$(cat "$DCD_FILE")
40+
url=$(convert_to_url "$dcd_string") || exit 1
41+
echo "$url"
42+
exit 0
43+
else
44+
echo "DCD file not found: $DCD_FILE" >&2
45+
exit 1
46+
fi

contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/installation-time/jobs.pxu

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,12 @@ command:
106106
user: root
107107
_description:
108108
Attaches install mode log to the results.
109+
110+
plugin: attachment
111+
category_id: com.canonical.plainbox::info
112+
id: ce-oem-info/image-url-iot
113+
estimated_duration: 0.1
114+
_description: Get installed image URL based on DCD
115+
_summary: Provides image URL based on DistributionChannelDescriptor meta data
116+
_purpose: To provide a URL to image file that was installed on the system
117+
command: get-image-url-iot.sh

contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/installation-time/test-plan.pxu

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ include:
2222
ce-oem-info/snapd_installation_.*
2323
ce-oem-info/cloud_init_.*
2424
ce-oem-info/install_.*
25+
ce-oem-info/image-url-iot

0 commit comments

Comments
 (0)