Skip to content

Commit 0f89f67

Browse files
authored
Fix support for ICT based usb creation (#110)
Signed-off-by: Rajeev Ranjan <rajeev2.ranjan@intel.com>
1 parent bb3a340 commit 0f89f67

4 files changed

Lines changed: 57 additions & 10 deletions

File tree

Makefile

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,37 @@ build: check-proxy check-docker build-base
130130
@echo "Preparing USB Installation Artifacts (containerized in Ubuntu 24.04)"
131131
@set -a; . $(PROXY_FILE) 2>/dev/null || true; set +a; \
132132
cd $(dir $(abspath $(firstword $(MAKEFILE_LIST)))) && \
133+
ICT_MOUNT_ARGS=""; \
134+
CONTAINER_ICT_IMG=""; \
135+
if [ "$(MODE)" = "image-from-tool" ]; then \
136+
if [ -z "$(ICT_IMG)" ]; then \
137+
echo "ERROR: MODE=image-from-tool requires ICT_IMG=/path/to/image.raw.gz" >&2; \
138+
echo "Example: make build MODE=image-from-tool ICT_IMG=/home/user/images/minimal-desktop-ubuntu-24.04.raw.gz" >&2; \
139+
exit 1; \
140+
fi; \
141+
case "$(ICT_IMG)" in \
142+
/*) ICT_ABS="$(ICT_IMG)" ;; \
143+
*) ICT_ABS="$$(readlink -m "$(ICT_IMG)")" ;; \
144+
esac; \
145+
ICT_DIR="$$(dirname "$$ICT_ABS")"; \
146+
ICT_BASE="$$(basename "$$ICT_ABS")"; \
147+
case "$$ICT_BASE" in \
148+
*.raw.gz|*.raw.img.gz) ;; \
149+
*) echo "ERROR: ICT_IMG must end in .raw.gz or .raw.img.gz (got: $$ICT_BASE)" >&2; exit 1;; \
150+
esac; \
151+
if [ ! -f "$$ICT_ABS" ] && [ ! -r "$$ICT_ABS" ]; then \
152+
if ! sudo test -f "$$ICT_ABS"; then \
153+
echo "ERROR: ICT_IMG not found on host: $$ICT_ABS" >&2; \
154+
echo "Hint: ICT typically writes images under ~/ict/builds or ~/ict/workspace as root when built with 'sudo -E ./image-composer-tool build'." >&2; \
155+
exit 1; \
156+
fi; \
157+
echo "Note: ICT_IMG is root-owned; container (privileged) will read it via bind mount."; \
158+
fi; \
159+
ICT_MOUNT_ARGS="-v $$ICT_DIR:/ict-image-src:ro"; \
160+
CONTAINER_ICT_IMG="/ict-image-src/$$ICT_BASE"; \
161+
echo "ICT image (host): $$ICT_ABS"; \
162+
echo "ICT image (container): $$CONTAINER_ICT_IMG"; \
163+
fi; \
133164
echo "Building orchestrator image: $(BUILD_ARTIFACTS_IMAGE)"; \
134165
docker build \
135166
--build-arg http_proxy="$${http_proxy:-}" \
@@ -157,8 +188,9 @@ build: check-proxy check-docker build-base
157188
-e HOST_GID="$$(id -g)" \
158189
-v "$$PWD":/workspace \
159190
-v /var/run/docker.sock:/var/run/docker.sock \
191+
$$ICT_MOUNT_ARGS \
160192
$(BUILD_ARTIFACTS_IMAGE) \
161-
"$(MODE)" "$(ICT_IMG)"
193+
"$(MODE)" "$$CONTAINER_ICT_IMG"
162194
@echo "---END MAKEFILE Build---"
163195

164196
lint: shellcheck

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,20 @@ Use the `image-from-tool` mode when you already have an image generated by Image
102102
make build MODE=image-from-tool ICT_IMG=/absolute/path/to/minimal-desktop-ubuntu-24.04.raw.gz
103103
```
104104

105+
`ICT_IMG` may point to any readable file on the host (absolute or relative to `$PWD`); it does not have to live inside the repository. `make` resolves the path, bind-mounts the containing directory read-only into the build container, and stages the image into `infrastructure/build-artifacts/` for packaging.
106+
105107
The following are the supported Image Composer Tool image extensions:
106108
- `.raw.gz`
107109
- `.raw.img.gz`
108110

109-
Example:
111+
Examples:
110112

111113
```bash
114+
# Absolute path anywhere on the host
112115
make build MODE=image-from-tool ICT_IMG=/home/user/images/minimal-desktop-ubuntu-24.04.raw.gz
116+
117+
# Path relative to the repository root
118+
make build MODE=image-from-tool ICT_IMG=./minimal-desktop-ubuntu-24.04.raw.gz
113119
```
114120

115121
Build output:

docs/user-guide/how-to/advanced-image-customization.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ cd ../edge-node-infrastructure-blueprint
171171
make build MODE=image-from-tool ICT_IMG=/absolute/path/to/minimal-desktop-ubuntu-24.04.raw.gz
172172
```
173173

174+
`ICT_IMG` may be any readable file on the host — absolute path or path relative to
175+
the repository root. `make` resolves the path and bind-mounts the containing
176+
directory read-only into the build container, so the image does not need to live
177+
inside the repository.
178+
174179
Example:
175180

176181
```bash

infrastructure/build-artifacts/build-installation-artifacts.sh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ if eval "$tar_cmd" > /dev/null; then
181181
echo "##############################################################################################"
182182
echo " "
183183
echo " "
184-
echo "USB Installation files--> usb-installation-files.tar.gz created successfully, under $(pwd)"
184+
echo "USB Installation files--> usb-installation-files.tar.gz created successfully, under infrastructure/build-artifacts/out"
185185
echo " "
186186
echo " "
187187
echo "###############################################################################################"
@@ -200,30 +200,34 @@ popd > /dev/null || exit 1
200200
}
201201

202202
# Use a pre-built ICT image as the OS image
203+
# The Makefile bind-mounts the host directory containing ICT_IMG at /ict-image-src
204+
# and passes /ict-image-src/<basename> as ICT_IMG to this script.
203205
use-ict-image(){
204206

205207
if [ -z "$ICT_IMG" ]; then
206-
echo "ICT_IMG is not provided."
208+
echo "ERROR: ICT_IMG is not provided."
207209
echo "Usage: make build MODE=image-from-tool ICT_IMG=/path/to/image.raw.gz"
208210
exit 1
209211
fi
210212

211213
if [ ! -f "$ICT_IMG" ]; then
212-
echo "ICT image not found: $ICT_IMG"
214+
echo "ERROR: ICT image not found inside container at: $ICT_IMG"
215+
echo "The Makefile bind-mounts the host directory containing ICT_IMG at /ict-image-src."
216+
echo "If you invoked the script directly (not via 'make build'), ensure ICT_IMG is a path visible inside this container."
213217
exit 1
214218
fi
215219

216220
if ! [[ "$ICT_IMG" =~ \.(raw\.gz|raw\.img\.gz)$ ]]; then
217-
echo "Error: ICT image must have a .raw.gz or .raw.img.gz extension"
221+
echo "ERROR: ICT image must have a .raw.gz or .raw.img.gz extension (got: $ICT_IMG)"
218222
exit 1
219223
fi
220224

221225
os_filename=$(basename "$ICT_IMG")
222-
cp "$ICT_IMG" .
223-
if [ "$?" -eq 0 ]; then
224-
echo "ICT image ready: $os_filename"
226+
echo "Using ICT image: $ICT_IMG ($(du -h "$ICT_IMG" | awk '{print $1}'))"
227+
if cp "$ICT_IMG" .; then
228+
echo "ICT image staged for packaging: $os_filename"
225229
else
226-
echo "Failed to copy ICT image, please check!"
230+
echo "ERROR: Failed to copy ICT image into build-artifacts directory."
227231
exit 1
228232
fi
229233

0 commit comments

Comments
 (0)