Skip to content

Commit a5e6aa9

Browse files
authored
Merge pull request #47 from nandini-matam/ci/add-dockerfile-ci-readme
CI: add Dockerfile and README to support image packing in CI pipeline
2 parents 587548f + 02eac35 commit a5e6aa9

2 files changed

Lines changed: 158 additions & 0 deletions

File tree

CI/Dockerfile

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
FROM ubuntu:24.04
2+
3+
ARG USER_ID
4+
ARG GROUP_ID
5+
ARG USER_NAME
6+
7+
RUN if [ -n "$USER_ID" ] && [ -n "$GROUP_ID" ] && [ -n "$USER_NAME" ]; then \
8+
groupadd -g "$GROUP_ID" "$USER_NAME" && \
9+
useradd -m -u "$USER_ID" -g "$GROUP_ID" -d / "$USER_NAME" ; \
10+
fi
11+
12+
ENV ARCH=arm64
13+
ENV CROSS_COMPILE=aarch64-linux-gnu-
14+
15+
COPY generate_boot_bins.sh /usr/bin/
16+
COPY build.sh /usr/bin/
17+
COPY make_fitimage.sh /usr/bin/
18+
19+
RUN set -eux; \
20+
apt-get update; \
21+
apt-get install -y --no-install-recommends \
22+
ca-certificates \
23+
curl \
24+
git \
25+
binutils \
26+
python3 \
27+
locales \
28+
kmod \
29+
rsync \
30+
systemd-ukify \
31+
dosfstools \
32+
mtools \
33+
cpio \
34+
; \
35+
rm -rf /var/lib/apt/lists/*; \
36+
locale-gen en_US.UTF-8; \
37+
update-locale LANG=en_US.UTF-8; \
38+
\
39+
curl "https://android.googlesource.com/platform/system/tools/mkbootimg/+/refs/heads/android12-release/mkbootimg.py?format=TEXT" \
40+
| base64 --decode > /usr/bin/mkbootimg; \
41+
chmod +x /usr/bin/mkbootimg; \
42+
chmod 755 /usr/bin/generate_boot_bins.sh /usr/bin/build.sh /usr/bin/make_fitimage.sh; \
43+
\
44+
command -v ukify; \
45+
command -v mkfs.vfat; \
46+
command -v mcopy; \
47+
command -v rsync
48+
49+
# Fetch & unpack systemd-boot .deb
50+
ARG SYSTEMD_BOOT_DEB_URL="http://ports.ubuntu.com/pool/universe/s/systemd/systemd-boot-efi_255.4-1ubuntu8_arm64.deb"
51+
RUN set -eux; \
52+
mkdir -p /artifacts/systemd; \
53+
echo "Downloading systemd-boot from: ${SYSTEMD_BOOT_DEB_URL}"; \
54+
curl -fsSL "${SYSTEMD_BOOT_DEB_URL}" -o /artifacts/systemd-boot-efi.deb; \
55+
dpkg-deb -xv /artifacts/systemd-boot-efi.deb /artifacts/systemd; \
56+
test -d /artifacts/systemd/usr/lib/systemd/boot/efi
57+
58+
ENV LANG=en_US.UTF-8
59+
ENV LC_ALL=en_US.UTF-8

CI/README.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# kmake-image-packager
2+
3+
Docker image for packaging bootable Linux kernel artifacts.
4+
5+
This project focuse on generating bootable images (`efi.bin`, `dtb.bin`) from prebuilt kernel artifacts (kernel image and DTB).
6+
7+
8+
# TL;DR (Step-by-Step)
9+
10+
11+
### 1. Clone kmake-image
12+
13+
```bash
14+
git clone git@github.com:qualcomm-linux/kmake-image.git
15+
cd kmake-image
16+
```
17+
18+
### 2. Build the Docker Image
19+
20+
You can build the Docker image in one of the following ways.
21+
22+
#### Option A: Simple build
23+
24+
```bash
25+
docker build -f CI/Dockerfile.ci -t kmake-image-ci .
26+
```
27+
28+
#### Option B: Build with user mapping (recommended)
29+
30+
This avoids file permission issues on generated artifacts.
31+
32+
```bash
33+
docker build \
34+
--build-arg USER_ID=$(id -u) \
35+
--build-arg GROUP_ID=$(id -g) \
36+
--build-arg USER_NAME=$(whoami) \
37+
-f CI/Dockerfile.ci \
38+
-t kmake-image-ci .
39+
```
40+
41+
### 3. Set up the alias in your `.bashrc`
42+
43+
Add the following alias:
44+
45+
```bash
46+
alias kmake-image-ci='docker run -it --rm \
47+
--user $(id -u):$(id -g) \
48+
--workdir="$PWD" \
49+
-v "$(dirname "$PWD")":"$(dirname "$PWD")" \
50+
kmake-image-ci'
51+
```
52+
53+
Apply the change:
54+
55+
```bash
56+
source ~/.bashrc
57+
```
58+
59+
### Prerequisites (Required Artifacts)
60+
61+
Before generating `efi.bin`, ensure the following artifacts are available locally:
62+
63+
- **Kernel Image**: `Image` (uncompressed)
64+
- **Ramdisk**: `initrd.cpio.gz`
65+
- **Target DTB**: example `qcs6490-rb3gen2.dtb`
66+
67+
### 4. Generate `efi.bin`
68+
69+
Run the EFI image generation command:
70+
71+
```bash
72+
kmake-image-ci generate_boot_bins.sh efi \
73+
--ramdisk artifacts/initrd.cpio.gz \
74+
--systemd-boot /artifacts/systemd/usr/lib/systemd/boot/efi/systemd-bootaa64.efi \
75+
--stub /artifacts/systemd/usr/lib/systemd/boot/efi/linuxaa64.efi.stub \
76+
--linux artifacts/Image \
77+
--cmdline "console=ttyMSM0,115200n8 copy-modules rootdelay=10 root=PARTLABEL=rootfs rw rootwait qcom_geni_serial.con_enabled=1" \
78+
--output images
79+
```
80+
81+
### 5. Generate `dtb.bin`
82+
*(For targets supporting a DTB partition)*
83+
84+
```bash
85+
kmake-image-ci generate_boot_bins.sh dtb \
86+
--input artifacts/qcs6490-rb3gen2.dtb \
87+
--output images
88+
```
89+
90+
### 6. Output
91+
92+
The generated files:
93+
94+
- `efi.bin`
95+
- `dtb.bin`
96+
97+
are available in the `images/` directory and are ready to be booted on
98+
**QCS6490 RB3Gen2**.
99+

0 commit comments

Comments
 (0)