Skip to content

Commit 85ad65b

Browse files
authored
Merge branch 'main' into docs/readme-build-flow-diagram
2 parents 268968d + 69eb5e1 commit 85ad65b

21 files changed

Lines changed: 164 additions & 49 deletions

File tree

cmd/os-image-composer/build.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ post:
148148

149149
func displayImageBuildTiming(imageType string, template *config.ImageTemplate) {
150150
startToDownloadImagePkgsDuration := template.GetDurationStartToDownloadImagePkgs()
151+
chrootPkgDownloadDuration := template.GetChrootPkgDownloadDuration()
151152
downloadImagePkgsToPureBuildDuration := template.GetDurationDownloadImagePkgsToPureBuild()
152153
pureImageBuildDuration := template.GetPureImageBuildDuration()
153154
downloadImagePkgsDuration := template.GetDownloadImagePkgsDuration()
@@ -157,6 +158,7 @@ func displayImageBuildTiming(imageType string, template *config.ImageTemplate) {
157158
imageType,
158159
startToDownloadImagePkgsDuration,
159160
downloadImagePkgsDuration,
161+
chrootPkgDownloadDuration,
160162
downloadImagePkgsToPureBuildDuration,
161163
pureImageBuildDuration,
162164
convertImageDuration,

image-templates/elxr12-x86_64-dlstreamer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ systemConfig:
9696
enabled: false # default is true, overridden to false here
9797

9898
packages:
99-
- intel-dlstreamer
99+
- intel-dlstreamer_2025.2.0
100100
- firmware-linux
101101

102102
kernel:

image-templates/ubuntu24-x86_64-dlstreamer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ systemConfig:
9494
- openssh-server
9595
- systemd-resolved
9696
- systemd-timesyncd
97-
- intel-dlstreamer
97+
- intel-dlstreamer_2025.2.0
9898
- linux-firmware
9999

100100
kernel:

image-templates/ubuntu24-x86_64-minimal-ptl-dls.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ systemConfig:
372372
#dls based pkg
373373
- docker.io
374374
- docker-compose-plugin
375-
- intel-dlstreamer
375+
- intel-dlstreamer_2025.2.0
376376

377377
additionalFiles:
378378
- local: ../additionalfiles/ptl/01-network-manager-all.yaml

image-templates/ubuntu24-x86_64-minimal-raw.yml

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,43 @@ target:
2424
arch: x86_64
2525
imageType: raw
2626

27-
# Sample list of additional package repositories; replace codename, url, and pkey values as needed
28-
packageRepositories:
29-
- codename: "company-internal"
30-
url: "<URL>"
31-
pkey: "<PUBLIC_KEY_URL>" # Uncomment and replace in real config
32-
component: "main"
27+
disk:
28+
name: Minimal_Raw # 1:1 mapping to the systemConfigs name
29+
artifacts:
30+
-
31+
type: raw # image file format, valid value [raw, vhd, vhdx, qcow2, vmdk, vdi]
32+
compression: gz # image compression format (optional)
33+
- type: vhdx
34+
size: 4GiB # 4G, 4GB, 4096 MiB also valid. (Required for raw)
35+
partitionTableType: gpt # Partition table type, valid value: [gpt, mbr]
36+
partitions: # Required for raw, optional for ISO, not needed for rootfs.
37+
- id: boot
38+
type: esp
39+
flags:
40+
- esp
41+
- boot
42+
start: 1MiB
43+
end: 513MiB
44+
fsType: fat32
45+
mountPoint: /boot/efi
46+
mountOptions: umask=0077
3347

34-
- codename: "dev-tools"
35-
url: "<URL>"
36-
pkey: "<PUBLIC_KEY_URL>" # Uncomment and replace in real config
37-
38-
- codename: "intel-openvino"
39-
url: "<URL>"
40-
pkey: "<PUBLIC_KEY_URL>" # Uncomment and replace in real config
41-
component: "restricted"
48+
- id: rootfs
49+
type: linux-root-amd64
50+
start: 513MiB
51+
end: "0"
52+
fsType: ext4
53+
mountPoint: /
54+
mountOptions: defaults
4255

4356
systemConfig:
4457
name: minimal
4558
description: Minimal ubuntu image
4659

60+
bootloader:
61+
bootType: efi
62+
provider: grub
63+
4764
immutability:
4865
enabled: false # default is true
4966
# To enable Secure Boot, provide the actual file paths for your environment below and uncomment the relevant lines.
@@ -53,10 +70,13 @@ systemConfig:
5370

5471
packages:
5572
- ubuntu-minimal
56-
- systemd-boot
57-
- dracut-core
73+
- grub-efi-amd64-signed
74+
- initramfs-tools
75+
- grub2-common
76+
- grub-pc-bin
77+
- grub-efi-amd64
78+
- grub-efi-amd64-bin
5879
- systemd
59-
- cryptsetup-bin
6080
- openssh-server
6181
- systemd-resolved
6282
- systemd-timesyncd

internal/chroot/chrootbuild/chrootbuild.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,15 @@ type ChrootBuilder struct {
4848
TargetOsConfig map[string]interface{}
4949
ChrootBuildDir string
5050
ChrootPkgCacheDir string
51+
BuildTemplate *config.ImageTemplate
5152
RpmInstaller rpm.RpmInstallerInterface
5253
DebInstaller deb.DebInstallerInterface
5354
}
5455

56+
func (chrootBuilder *ChrootBuilder) SetBuildTemplate(template *config.ImageTemplate) {
57+
chrootBuilder.BuildTemplate = template
58+
}
59+
5560
// ChrootenvConfig represents the structure of a chrootenv configuration file
5661
type ChrootenvConfig struct {
5762
Essential []string `yaml:"essential,omitempty" json:"essential,omitempty"`
@@ -284,6 +289,9 @@ func (chrootBuilder *ChrootBuilder) BuildChrootEnv(targetOs string, targetDist s
284289
if err != nil {
285290
return fmt.Errorf("failed to download chroot environment packages: %w", err)
286291
}
292+
if chrootBuilder.BuildTemplate != nil {
293+
chrootBuilder.BuildTemplate.FinishChrootPkgDownloadTimer()
294+
}
287295
log.Infof("Downloaded %d packages for chroot environment", len(allPkgsList))
288296

289297
chrootPkgCacheDir := chrootBuilder.GetChrootPkgCacheDir()

internal/chroot/chrootenv.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ type ChrootEnv struct {
5757
ChrootEnvRoot string
5858
ChrootImageBuildDir string
5959
ChrootBuilder chrootbuild.ChrootBuilderInterface
60+
buildTemplate *config.ImageTemplate
6061
TargetOs string // Store targetOs for package manager selection
6162
}
6263

@@ -89,6 +90,13 @@ func (chrootEnv *ChrootEnv) GetChrootEnvRoot() string {
8990
return chrootEnv.ChrootEnvRoot
9091
}
9192

93+
func (chrootEnv *ChrootEnv) SetBuildTemplate(template *config.ImageTemplate) {
94+
chrootEnv.buildTemplate = template
95+
if templateAwareBuilder, ok := chrootEnv.ChrootBuilder.(interface{ SetBuildTemplate(*config.ImageTemplate) }); ok {
96+
templateAwareBuilder.SetBuildTemplate(template)
97+
}
98+
}
99+
92100
func (chrootEnv *ChrootEnv) GetChrootImageBuildDir() string {
93101
return chrootEnv.ChrootImageBuildDir
94102
}
@@ -392,6 +400,9 @@ func (chrootEnv *ChrootEnv) InitChrootEnv(targetOs, targetDist, targetArch strin
392400
chrootBuildDir := chrootEnv.ChrootBuilder.GetChrootBuildDir()
393401
chrootEnvTarPath := filepath.Join(chrootBuildDir, "chrootenv.tar.gz")
394402
if _, err := os.Stat(chrootEnvTarPath); os.IsNotExist(err) {
403+
if templateAwareBuilder, ok := chrootEnv.ChrootBuilder.(interface{ SetBuildTemplate(*config.ImageTemplate) }); ok {
404+
templateAwareBuilder.SetBuildTemplate(chrootEnv.buildTemplate)
405+
}
395406
// Build chroot environment tarball
396407
if err = chrootEnv.ChrootBuilder.BuildChrootEnv(targetOs, targetDist, targetArch); err != nil {
397408
return fmt.Errorf("failed to build chroot environment: %w", err)

internal/config/config.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ type ImageTemplate struct {
9797
downloadPkgsDuration time.Duration
9898
convertImageStart time.Time
9999
convertImageDuration time.Duration
100+
chrootPkgDlStart time.Time
101+
chrootPkgDlDuration time.Duration
100102
buildTimelineStart time.Time
101103
buildFinishedAt time.Time
102104
}
@@ -362,6 +364,26 @@ func (t *ImageTemplate) FinishDownloadImagePkgsTimer() {
362364
}
363365

364366
t.downloadPkgsDuration = time.Since(t.downloadPkgsStart)
367+
t.chrootPkgDlStart = time.Now()
368+
t.chrootPkgDlDuration = 0
369+
}
370+
371+
// FinishChrootPkgDownloadTimer stores elapsed chroot package download wait time if tracking was started.
372+
func (t *ImageTemplate) FinishChrootPkgDownloadTimer() {
373+
if t == nil || t.chrootPkgDlStart.IsZero() {
374+
return
375+
}
376+
377+
t.chrootPkgDlDuration = time.Since(t.chrootPkgDlStart)
378+
}
379+
380+
// GetChrootPkgDownloadDuration returns tracked chroot package download wait duration.
381+
func (t *ImageTemplate) GetChrootPkgDownloadDuration() time.Duration {
382+
if t == nil {
383+
return 0
384+
}
385+
386+
return t.chrootPkgDlDuration
365387
}
366388

367389
// GetDownloadImagePkgsDuration returns tracked downloadImagePkgs duration.
@@ -399,6 +421,13 @@ func (t *ImageTemplate) GetDurationDownloadImagePkgsToPureBuild() time.Duration
399421
return 0
400422
}
401423

424+
if t.chrootPkgDlDuration > 0 {
425+
d -= t.chrootPkgDlDuration
426+
if d < 0 {
427+
return 0
428+
}
429+
}
430+
402431
return d
403432
}
404433

internal/image/imageos/imageos_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,10 @@ func (m *MockChrootEnv) CopyFileFromChrootToHost(hostFilePath, chrootPath string
108108
func (m *MockChrootEnv) UpdateChrootLocalRepoMetadata(chrootRepoDir string, targetArch string, sudo bool) error {
109109
return nil
110110
}
111-
func (m *MockChrootEnv) RefreshLocalCacheRepo() error { return nil }
112-
func (m *MockChrootEnv) InitChrootEnv(targetOs, targetDist, targetArch string) error { return nil }
111+
func (m *MockChrootEnv) RefreshLocalCacheRepo() error { return nil }
112+
func (m *MockChrootEnv) InitChrootEnv(targetOs, targetDist, targetArch string) error {
113+
return nil
114+
}
113115
func (m *MockChrootEnv) CleanupChrootEnv(targetOs, targetDist, targetArch string) error { return nil }
114116
func (m *MockChrootEnv) TdnfInstallPackage(packageName, installRoot string, repositoryIDList []string) error {
115117
return nil

internal/image/isomaker/isomaker_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import (
1616

1717
var log = logger.Logger()
1818

19+
// Mock implementation: always succeed
20+
1921
// Mock implementations for testing
2022
type mockChrootEnv struct {
2123
pkgType string
@@ -117,7 +119,6 @@ func (m *mockChrootEnv) RefreshLocalCacheRepo() error {
117119

118120
// Add missing method to satisfy chroot.ChrootEnvInterface
119121
func (m *mockChrootEnv) InitChrootEnv(targetOs, targetDist, targetArch string) error {
120-
// Mock implementation: always succeed
121122
return nil
122123
}
123124

0 commit comments

Comments
 (0)