[v2] classes/repository: use the proper filename to find the packages under repo

Message ID 20241117154515.906833-1-srinuvasan.a@siemens.com
State Superseded, archived
Headers show
Series [v2] classes/repository: use the proper filename to find the packages under repo | expand

Commit Message

srinuvasan.a Nov. 17, 2024, 3:45 p.m. UTC
From: srinuvasan <srinuvasan.a@siemens.com>

This patch fixes the issue in repo_contians_package function, here we
are adding a few packages to repo again even though the repo already contains those
packages, ideally we should skip those

reproduce the issue:

1. Create the base-apt
2. Again retrigger the base-apt (assume that there is no changes in the previously built base-apt)

here we observed few packages getting added again to the APT, even those
packages already available in the repo.

Basically few packages having the epoch version (automake, git-man, ssh) in the download folder,
but the same packages are cached in the repo without the epoch version, due to this
mismatch, it tries to add the packages again into the repo, to fix this issue,
just find the package name in the repo without the epoch version.

Signed-off-by: srinuvasan <srinuvasan.a@siemens.com>
---
 meta/classes/repository.bbclass | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Uladzimir Bely Nov. 20, 2024, 6:05 a.m. UTC | #1
On Sun, 2024-11-17 at 21:15 +0530, srinuvasan.a via isar-users wrote:
> From: srinuvasan <srinuvasan.a@siemens.com>
> 
> This patch fixes the issue in repo_contians_package function, here we
> are adding a few packages to repo again even though the repo already
> contains those
> packages, ideally we should skip those
> 
> reproduce the issue:
> 
> 1. Create the base-apt
> 2. Again retrigger the base-apt (assume that there is no changes in
> the previously built base-apt)
> 
> here we observed few packages getting added again to the APT, even
> those
> packages already available in the repo.
> 
> Basically few packages having the epoch version (automake, git-man,
> ssh) in the download folder,
> but the same packages are cached in the repo without the epoch
> version, due to this
> mismatch, it tries to add the packages again into the repo, to fix
> this issue,
> just find the package name in the repo without the epoch version.
> 
> Signed-off-by: srinuvasan <srinuvasan.a@siemens.com>
> ---
>  meta/classes/repository.bbclass | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/classes/repository.bbclass
> b/meta/classes/repository.bbclass
> index 28e712fd..7379658d 100644
> --- a/meta/classes/repository.bbclass
> +++ b/meta/classes/repository.bbclass
> @@ -99,7 +99,8 @@ repo_contains_package() {
>      local file="$2"
>      local package
>  
> -    package=$(find ${dir} -name ${file##*/})
> +    file_name=$(echo "${file##*/}" | sed 's/[0-9]%3a//g')

Not sure if epoch versions more than 9 exist for some packages, but I
would add '\+'   here to consider big epoch numbers:

```
$ echo git-man_1%3a2.39.5-0+deb12u1_all.deb | sed 's/[0-9]%3a//g'
git-man_2.39.5-0+deb12u1_all.deb
$ echo git-man_10%3a2.39.5-0+deb12u1_all.deb | sed 's/[0-9]%3a//g'
git-man_12.39.5-0+deb12u1_all.deb
$ echo git-man_10%3a2.39.5-0+deb12u1_all.deb | sed 's/[0-9]\+%3a//g'
git-man_2.39.5-0+deb12u1_all.deb
```

> +    package=$(find ${dir} -name ${file_name})
>      if [ -n "$package" ]; then
>          # yes
>          cmp --silent "$package" "$file" && return 0
> -- 
> 2.34.1
>

Patch

diff --git a/meta/classes/repository.bbclass b/meta/classes/repository.bbclass
index 28e712fd..7379658d 100644
--- a/meta/classes/repository.bbclass
+++ b/meta/classes/repository.bbclass
@@ -99,7 +99,8 @@  repo_contains_package() {
     local file="$2"
     local package
 
-    package=$(find ${dir} -name ${file##*/})
+    file_name=$(echo "${file##*/}" | sed 's/[0-9]%3a//g')
+    package=$(find ${dir} -name ${file_name})
     if [ -n "$package" ]; then
         # yes
         cmp --silent "$package" "$file" && return 0