Skip to content

Commit 16cf196

Browse files
authored
Merge branch 'main' into repo_config
2 parents 6f6e138 + f31b9db commit 16cf196

File tree

5 files changed

+55
-37
lines changed

5 files changed

+55
-37
lines changed

image-templates/azl3-x86_64-dlstreamer.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ packageRepositories:
1919
url: "https://files-rs.edgeorchestration.intel.com/files-edge-orch/microvisor/rpm/3.0/"
2020
pkey: "https://raw.githubusercontent.com/open-edge-platform/edge-microvisor-toolkit/refs/heads/3.0/SPECS/edge-repos/INTEL-RPM-GPG-KEY" # Uncomment and replace in real config
2121

22+
- codename: "OpenVINO"
23+
url: "https://yum.repos.intel.com/openvino/"
24+
pkey: "https://yum.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB" # Uncomment and replace in real config
25+
26+
- codename: "mariner"
27+
url: "https://packages.microsoft.com/yumrepos/cbl-mariner-2.0-prod-extended-x86_64/"
28+
pkey: "https://packages.microsoft.com/azurelinux/3.0/prod/base/x86_64/repodata/repomd.xml.key" # Uncomment and replace in real config
29+
2230
disk:
2331
name: Minimal_Raw # 1:1 mapping to the systemConfigs name
2432
artifacts:
@@ -67,6 +75,7 @@ systemConfig:
6775
- gstreamer
6876
- opencv
6977
- intel-dlstreamer
78+
- openvino
7079

7180
kernel:
7281
version: "6.12"

image-templates/emt3-x86_64-dlstreamer.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ packageRepositories:
1515
url: "https://yum.repos.intel.com/edgeai/"
1616
pkey: "https://yum.repos.intel.com/edgeai/GPG-PUB-KEY-INTEL-DLS.gpg" # Uncomment and replace in real config
1717

18+
- codename: "OpenVINO"
19+
url: "https://yum.repos.intel.com/openvino/"
20+
pkey: "https://yum.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB" # Uncomment and replace in real config
21+
22+
- codename: "mariner"
23+
url: "https://packages.microsoft.com/yumrepos/cbl-mariner-2.0-prod-extended-x86_64/"
24+
pkey: "https://packages.microsoft.com/azurelinux/3.0/prod/base/x86_64/repodata/repomd.xml.key" # Uncomment and replace in real config
25+
1826
disk:
1927
name: Minimal_Raw # 1:1 mapping to the systemConfigs name
2028
artifacts:
@@ -65,6 +73,7 @@ systemConfig:
6573
- gstreamer
6674
- opencv
6775
- intel-dlstreamer
76+
- openvino
6877

6978
# Kernel Configuration
7079
kernel:

internal/ospackage/rpmutils/helper.go

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package rpmutils
33
import (
44
"fmt"
55
"net/url"
6-
"path/filepath"
76
"sort"
87
"strings"
98
"unicode"
@@ -222,8 +221,19 @@ func extractBasePackageNameFromFile(fullName string) string {
222221
// Find the first part that looks like a version (starts with digit)
223222
for i := 1; i < len(parts); i++ {
224223
if len(parts[i]) > 0 && (parts[i][0] >= '0' && parts[i][0] <= '9') {
225-
// Everything before this index is the package name
226-
return strings.Join(parts[:i], "-")
224+
// get the name
225+
maybe_name := strings.Join(parts[:i], "-")
226+
// check if version is part of the name
227+
// full name contains version, if package name has version,
228+
// it will be repeated in the full name
229+
for j := i + 1; j < len(parts); j++ {
230+
if len(parts[j]) > 0 && strings.Contains(parts[j], parts[i]) {
231+
maybe_name = strings.Join(parts[:j], "-")
232+
break
233+
}
234+
}
235+
// return name or name-version
236+
return maybe_name
227237
}
228238
}
229239

@@ -295,15 +305,10 @@ func findAllCandidates(parent ospackage.PackageInfo, depName string, all []ospac
295305
}
296306

297307
// ResolvePackage finds the best matching package for a given package name
298-
func ResolveTopPackageConflicts(want, pkgType string, all []ospackage.PackageInfo) (ospackage.PackageInfo, bool) {
308+
func ResolveTopPackageConflicts(want string, all []ospackage.PackageInfo) (ospackage.PackageInfo, bool) {
299309
var candidates []ospackage.PackageInfo
300310
for _, pi := range all {
301-
// 1) exact name and version matched with .deb filenamae, e.g. acct_7.6.4-5+b1_amd64
302-
if filepath.Base(pi.URL) == want+"."+pkgType {
303-
candidates = append(candidates, pi)
304-
break
305-
}
306-
// 2) exact name, e.g. acct-205-25.azl3.noarch.rpm
311+
// 1) exact name, e.g. acct-205-25.azl3.noarch.rpm
307312
if pi.Name == want {
308313
candidates = append(candidates, pi)
309314
break
@@ -314,28 +319,27 @@ func ResolveTopPackageConflicts(want, pkgType string, all []ospackage.PackageInf
314319
candidates = append(candidates, pi)
315320
continue
316321
}
317-
// // 3) prefix by want-version ("acl-")
318-
// if strings.HasPrefix(pi.Name, want+"-") {
319-
// candidates = append(candidates, pi)
320-
// continue
321-
// }
322-
// // 4) prefix by want.release ("acl-2.3.1-2.")
323-
// if strings.HasPrefix(cleanName, want+".") {
324-
// candidates = append(candidates, pi)
325-
// continue
326-
// }
327-
// // 5) Debian package format (packagename_version_arch.deb)
328-
// if strings.HasPrefix(cleanName, want+"_") {
329-
// candidates = append(candidates, pi)
330-
// }
322+
// 3) prefix by want-version ("acl-")
323+
// expected pi.Name should look like openvino-2025.3.0-2025.3.0.19807-1.noarch.rpm
324+
// want = openvino-2025.3.0
325+
if strings.HasPrefix(pi.Name, want) {
326+
// Extract string after "-" and compare with pi.Version
327+
if dashIdx := strings.LastIndex(want, "-"); dashIdx != -1 {
328+
verStr := want[dashIdx+1:]
329+
if strings.Contains(pi.Version, verStr) {
330+
candidates = append(candidates, pi)
331+
continue
332+
}
333+
}
334+
}
331335
}
332336

333337
if len(candidates) == 0 {
334338
return ospackage.PackageInfo{}, false
335339
}
336340

337341
// If we got an exact match in step (1), it's the only candidate
338-
if len(candidates) == 1 && (candidates[0].Name == want || candidates[0].Name == want+"."+pkgType) {
342+
if len(candidates) == 1 && (candidates[0].Name == want || extractBasePackageNameFromFile(candidates[0].Name) == want) {
339343
return candidates[0], true
340344
}
341345

internal/ospackage/rpmutils/helper_test.go

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -477,9 +477,9 @@ func TestResolveTopPackageConflicts(t *testing.T) {
477477

478478
allPackages := []ospackage.PackageInfo{
479479
{
480-
Name: "acct",
480+
Name: "acct-6.6.4-5+b1-amd64.rpm",
481481
Version: "6.6.4-5+b1",
482-
URL: "https://example.com/acct_6.6.4-5+b1_amd64.deb",
482+
URL: "https://example.com/acct-6.6.4-5+b1-amd64.rpm",
483483
},
484484
{
485485
Name: "acct-205-25.azl3.noarch.rpm",
@@ -509,32 +509,28 @@ func TestResolveTopPackageConflicts(t *testing.T) {
509509
}{
510510
{
511511
name: "Exact match with file extension",
512-
want: "acct_6.6.4-5+b1_amd64",
513-
pkgType: "deb",
512+
want: "acct-6.6.4-5+b1-amd64.rpm",
514513
dist: "",
515-
expectedPkg: "acct",
514+
expectedPkg: "acct-6.6.4-5+b1-amd64.rpm",
516515
expectFound: true,
517516
},
518517
{
519518
name: "Base name match",
520519
want: "acct",
521-
pkgType: "rpm",
522520
dist: "",
523-
expectedPkg: "acct", // Should find the first acct package
521+
expectedPkg: "acct-205-25.azl3.noarch.rpm", // Should find the first acct package
524522
expectFound: true,
525523
},
526524
{
527525
name: "Base name match with dist filter",
528526
want: "acct",
529-
pkgType: "rpm",
530527
dist: "azl3",
531-
expectedPkg: "acct", // The exact package name returned might be different due to filtering logic
528+
expectedPkg: "acct-205-25.azl3.noarch.rpm", // The exact package name returned might be different due to filtering logic
532529
expectFound: true,
533530
},
534531
{
535532
name: "No match",
536533
want: "nonexistent",
537-
pkgType: "rpm",
538534
dist: "",
539535
expectFound: false,
540536
},
@@ -543,7 +539,7 @@ func TestResolveTopPackageConflicts(t *testing.T) {
543539
for _, tt := range tests {
544540
t.Run(tt.name, func(t *testing.T) {
545541
Dist = tt.dist
546-
pkg, found := ResolveTopPackageConflicts(tt.want, tt.pkgType, allPackages)
542+
pkg, found := ResolveTopPackageConflicts(tt.want, allPackages)
547543
if found != tt.expectFound {
548544
t.Errorf("ResolveTopPackageConflicts() found = %v, want %v", found, tt.expectFound)
549545
}

internal/ospackage/rpmutils/resolver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ func MatchRequested(requests []string, all []ospackage.PackageInfo) ([]ospackage
432432
var out []ospackage.PackageInfo
433433

434434
for _, want := range requests {
435-
if pkg, found := ResolveTopPackageConflicts(want, "rpm", all); found {
435+
if pkg, found := ResolveTopPackageConflicts(want, all); found {
436436
out = append(out, pkg)
437437

438438
} else {

0 commit comments

Comments
 (0)