@@ -22,8 +22,8 @@ Before you can build OS images you need to build the toolchain and make sure to
2222[ ** install pre-requisites (Ubuntu)** ] ( /toolkit/docs/building/prerequisites-ubuntu.md ) .
2323
2424> ** Note:**
25- Use stable tag instead of latest for building the OS images with prebuilt packages.
26- This is the recommended approach, as building the * entire toolchain* may take a lot of
25+ Use the * stable* tag instead of * latest* for building the OS images with prebuilt packages.
26+ This is the recommended approach, as building the ** entire toolchain* * may take a lot of
2727 time. Adding the ` REBUILD_TOOLCHAIN=y ` parameter to the ` make ` command rebuilds
2828 the entire toolchain.
2929
@@ -82,61 +82,69 @@ sudo make image -j8 REBUILD_TOOLS=y REBUILD_PACKAGES=n CONFIG_FILE=./imageconfig
8282
8383## Customizing an Image
8484
85- To add packages to the default image, you can define your own ` packagelist.json ` file,
85+ To add packages to the default image, you can define your own ` packagelist.json ` file,
8686pointing to ` rpms ` that should be included in the image. The ` edge-image.json ` file points to
8787multiple ` packagelist ` files, located under ` imageconfigs/packagelists ` . The same ` rpms ` may
88- be included in an ` imageconfig ` file through the ` packagelist ` files. The resulting image
89- will include the set of all ` rpms ` specified within the array of ` packagelist ` files from the
90- ` imageconfig ` .
88+ be included in an ` imageconfig ` file through the ` packagelist ` files.
9189
92- ### Example: Adding an existing RPM (Nano)
90+ The resulting image will include the set of all ` rpms ` specified within the array of
91+ ` packagelist ` files from the ` imageconfig ` .
9392
94- The following example shows how to add ` nano ` as an alternative text editor to the image.
95- You can add the packages for which ` .spec ` files already exist. Simply include them in an
96- existing ` packagelist ` file, or create a new one and add it to the ` imageconfig ` .
93+ ### Example 1: Adding an existing RPM (Nano)
9794
98- ``` bash
99- # Create a new packagelist called utilities.json
100- cat << EOF > ./imageconfigs/packagelists/utilities.json
101- {
102- "packages": [
103- "nano"
104- ]
105- }
106- EOF
107-
108- # Edit the edge-image.json file to add custom packagelist and default login account for testing.
109- ...
110- " PackageLists" : [
111- " packagelists/core-packages-image-systemd-boot.json" ,
112- " packagelists/ssh-server.json" ,
113- " packagelists/virtualization-host-packages.json" ,
114- " packagelists/agents-packages.json" ,
115- " packagelists/tools-tinker.json" ,
116- " packagelists/persistent-mount-package.json" ,
117- " packagelists/fde-verity-package.json" ,
118- " packagelists/selinux-full.json" ,
119- " packagelists/intel-gpu-base.json" ,
120- " packagelists/os-ab-update.json" ,
121- " packagelists/utilities.json"
122- ],
123- " Users" : [
124- {
125- " Name" : " user" ,
126- " Password" : " user"
127- }
128- ],
129- ...
130- ```
95+ Note that you can only add the packages for which SPEC files exist. To add ` nano ` as an
96+ alternative text editor to the image:
13197
132- Then, rebuild the image:
98+ 1 . Define a new JSON file.
13399
134- ``` bash
135- sudo make image -j8 REBUILD_TOOLS=y REBUILD_PACKAGES=n CONFIG_FILE=./imageconfigs/edge-image.json
136- ```
137- ### Add a new package
100+ ``` bash
101+ # Create a new packagelist called utilities.json
102+ cat << EOF > ./imageconfigs/packagelists/utilities.json
103+ {
104+ "packages": [
105+ "nano"
106+ ]
107+ }
108+ EOF
109+ ` ` `
110+
111+ 2. Include it in an existing ` imageconfig` JSON file, for example ` edge-image.json` .
112+ You can also create a new file and add it to the ` imageconfigs` folder.
113+
114+ ` ` ` bash
115+ # Edit the edge-image.json file. Add the custom packagelist and default login account for testing.
116+ ...
117+ "PackageLists": [
118+ "packagelists/core-packages-image-systemd-boot.json",
119+ "packagelists/ssh-server.json",
120+ "packagelists/virtualization-host-packages.json",
121+ "packagelists/agents-packages.json",
122+ "packagelists/tools-tinker.json",
123+ "packagelists/persistent-mount-package.json",
124+ "packagelists/fde-verity-package.json",
125+ "packagelists/selinux-full.json",
126+ "packagelists/intel-gpu-base.json",
127+ "packagelists/os-ab-update.json",
128+ "packagelists/utilities.json"
129+ ],
130+ "Users": [
131+ {
132+ "Name": "user",
133+ "Password": "user"
134+ }
135+ ],
136+ ...
137+ ` ` `
138+
139+ 3. Rebuild the image:
140+
141+ ` ` ` bash
142+ sudo make image -j8 REBUILD_TOOLS=y REBUILD_PACKAGES=n CONFIG_FILE=./imageconfigs/edge-image.json
143+ ` ` `
138144
139- To add a new package you need to generate a ` SPEC ` file for the package which
145+ # ## Example 2: Adding a new RPM package
146+
147+ To add a new package you need to generate a SPEC file for the package which
140148contains all required information for the build infrastructure to generate the
141149` SRPM` and ` RPM` for the package. There are a few steps involved in creating
142150a new package for Edge Microvisor Toolkit.
@@ -147,119 +155,154 @@ a new package for Edge Microvisor Toolkit.
1471554. Build an image with the package included and test locally.
1481565. Upload the tar.gz package to the source package repository after is has been tested locally.
149157
150- You need to first install the required build tools for ` rpm ` . On Fedora you
151- can simply install the required packages with:
158+ ** Prerequisites**
159+
160+ Make sure you have the required build tools for ` rpm` .
161+ On Fedora, you can simply install the required packages with:
152162
153163` ` ` bash
154164sudo dnf install rpm-build rpmdevtools
155165rpmdev-setuptree
156166` ` `
157167
158- ` rpmdev-setuptree ` creates the necessary directories, which you may need to
159- manually create on an Ubuntu distribution.
168+ where ` rpmdev-setuptree` creates the necessary directories.
169+
170+ On Ubuntu, use the following command:
160171
161172` ` ` bash
162173sudo apt-get install rpm
174+ ` ` `
175+
176+ Then, manually create the necessary directories:
177+
178+ ` ` ` bash
163179mkdir -p ~ /rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
164180echo ' %_topdir %(echo $HOME)/rpmbuild' > ~ /.rpmmacros
165181` ` `
166182
167- ** Defining the SPEC file**
168- Define the SPEC file and test that it works as expected and generates locally the required artifacts.
169- the required artifacts. This example builds a simple hello world ` rpm ` package
170- which contains a bash scripts that prints hello world.
183+ ** Preparing the files**
171184
172- ``` bash
173- Name: helloworld
174- Version: 1.0
175- Release: 1%{ ? dist}
176- Summary: Simple Hello World script
185+ 1. Navigate to user home directory.
186+
187+ ` ` ` bash
188+ cd
189+ ` ` `
177190
178- License: MIT
179- URL: https://example.com/helloworld
180- Source0: helloworld-1.0.tar.gz
191+ 2. Define the SPEC file, using the example below.
181192
182- BuildArch: noarch
193+ It will create a simple hello world RPM package, which will include a bash script that
194+ prints * " Hello, world!" * .
183195
184- %description
185- A very basic " Hello World" script packaged as an RPM.
196+ ` ` ` bash
197+ Name: helloworld
198+ Version: 1.0
199+ Release: 1%{? dist}
200+ Summary: Simple Hello World script
186201
187- %prep
188- %setup -q
202+ License: MIT
203+ URL: https://example.com/helloworld
204+ Source0: helloworld-1.0.tar.gz
189205
190- %build
191- # Nothing to build for a shell script
206+ BuildArch: noarch
192207
193- %install
194- mkdir -p %{buildroot}/usr/bin
195- install -m 0755 helloworld.sh %{buildroot}/usr/bin/helloworld
208+ %description
209+ A very basic " Hello, world!" script packaged as an RPM.
196210
197- mkdir -p %{buildroot}/usr/share/helloworld
198- install -m 0644 helloworld.signature.json %{buildroot}/usr/share/helloworld/
211+ %prep
212+ %setup -q
199213
200- %files
201- /usr/bin/helloworld
202- /usr/share/helloworld/helloworld.signature.json
214+ %build
215+ # Nothing to build for a shell script
203216
204- %changelog
205- * Wed May 01 2025 Your Name < you@example.com> - 1.0-1
206- - Initial package
207- ```
217+ %install
218+ mkdir -p %{buildroot}/usr/bin
219+ install -m 0755 helloworld.sh %{buildroot}/usr/bin/helloworld
208220
209- ** Create the archive ** : Create your source archive, add the simple script and
210- make it executable.
221+ mkdir -p %{buildroot}/usr/share/helloworld
222+ install -m 0644 helloworld.signature.json %{buildroot}/usr/share/helloworld/
211223
212- ``` bash
213- # 1. Make your source tree and tarball
214- mkdir -p ~ /helloworld-1.0
215- cat > ~ /helloworld-1.0/helloworld.sh << 'EOF '
216- #!/bin/bash
217- echo "Hello, world!"
218- EOF
219- chmod +x ~ /helloworld-1.0/helloworld.sh
220-
221- tar -czf helloworld-1.0.tar.gz helloworld-1.0/
222-
223- # 2. Compute its SHA-256
224- sum=$( sha256sum helloworld-1.0.tar.gz | awk ' {print $1}' )
225-
226- # 3. Write the JSON signature for the tarball
227- cat > helloworld-1.0.tar.gz.signature.json << EOF
228- {
229- "file": "helloworld-1.0.tar.gz",
230- "sha256": "$sum "
231- }
232- EOF
224+ %files
225+ /usr/bin/helloworld
226+ /usr/share/helloworld/helloworld.signature.json
233227
234- ```
228+ %changelog
229+ * Wed May 01 2025 Your Name < you@example.com> - 1.0-1
230+ - Initial package
231+ ` ` `
235232
236- Copy the RPM package to the building directory and build it.
233+ 3. Create the simple script and make it executable .
237234
238- ``` bash
239- cp helloworld-1.0.tar.gz ~ /rpmbuild/SOURCES/
240- cp helloworld.spec ~ /rpmbuild/SPECS/
241- rpmbuild -ba ~ /rpmbuild/SPECS/helloworld.spec
242- ```
235+ ` ` ` bash
236+ mkdir -p ./helloworld-1.0
237+ cat > ./helloworld-1.0/helloworld.sh << 'EOF '
238+ #!/bin/bash
239+ echo "Hello, world!"
240+ EOF
241+ chmod +x ./helloworld-1.0/helloworld.sh
242+ ```
243+
244+ 4. Compute its SHA-256 and generate the JSON signature for it.
245+
246+ ```bash
247+ sum=$(sha256sum ./helloworld-1.0/helloworld.sh | awk '{print $1}')
248+ cat > ./helloworld-1.0/helloworld.signature.json <<EOF
249+ {
250+ "file": "helloworld.sh",
251+ "sha256": "$sum"
252+ }
253+ EOF
254+ ```
243255
244- ** Adding the SPEC** : Add the ` helloworld.spec ` and the 'helloworld.spec.signature`
245- file to the ` /SPECS ` directory. Finally update the ` cgmanifest ` by using the
256+ 5. Create the tarball archive and generate its JSON signature.
257+
258+ ```bash
259+ tar -czf helloworld-1.0.tar.gz ./helloworld-1.0
260+ sum=$(sha256sum helloworld-1.0.tar.gz | awk '{print $1}')
261+ cat > helloworld-1.0.tar.gz.signature.json <<EOF
262+ {
263+ "file": "helloworld-1.0.tar.gz",
264+ "sha256": "$sum"
265+ }
266+ EOF
267+ ```
268+
269+ 4. Copy the RPM package files to the building directories and build it.
270+
271+ ```bash
272+ cp helloworld-1.0/helloworld-1.0.tar.gz ./rpmbuild/SOURCES
273+ cp helloworld.spec .rpmbuild/SPECS
274+ rpmbuild -ba ./rpmbuild/SPECS/helloworld.spec
275+ ```
276+
277+ **Adding the package**
278+
279+ 1. Create the `helloworld` folder in the `edge-microvisor-toolkit/SPECS` directory.
280+ 2. Copy the `helloworld.spec` and `helloworld.signature.json` files to the
281+ `helloworld` folder.
282+ Finally update the `cgmanifest` by using the
246283provided `python` script.
247284
285+
248286```bash
249287 python3 -m pip install -r ./toolkit/scripts/requirements.txt
250288 python3 ./toolkit/scripts/update_cgmanifest.py first cgmanifest.json ./SPECS/helloworld.spec
251289```
252290
253- ** Local Build and Testing** : If testing is complete and you are ready to contribute this package,
291+ **Local Build and Testing**
292+
293+ If testing is complete and you are ready to contribute this package,
254294please raise a PR and work with a code owner to upload the source tarball to package source mirror.
255295
256296```bash
257297make build-packages # to rebuild the packages
258298```
299+
259300Follow the steps under [Customizing an image](./building-howto.md#Customizing-an-Image) to create
260301an image with your new package.
261302
262- ** Uploading the archive** : Intel will upload the tar.gz archive to the mirror.
303+ **Uploading the archive**
304+
305+ Intel will upload the tar.gz archive to the mirror.
263306
264307### Update an agent
265308
0 commit comments