[PATCH 1/3] repository: repo_del_package should not remove source packages

20 views
Skip to first unread message

Cedric Hombourger

unread,
Nov 22, 2024, 12:48:38 AM11/22/24
to isar-...@googlegroups.com, Cedric Hombourger
When the architecture of the binary package is "all", repo_del_package would
remove the architecture filter to remove binary for any packages. This
unfortunately causes reprepro to also remove the source package. Modify this
function to use "reprepro removefilter" where we can make sure that only .deb
packages are removed.

Signed-off-by: Cedric Hombourger <cedric.h...@siemens.com>
---
meta/classes/repository.bbclass | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/meta/classes/repository.bbclass b/meta/classes/repository.bbclass
index 28e712fd..42d15823 100644
--- a/meta/classes/repository.bbclass
+++ b/meta/classes/repository.bbclass
@@ -84,14 +84,11 @@ repo_del_package() {
if [ -n "${GNUPGHOME}" ]; then
export GNUPGHOME="${GNUPGHOME}"
fi
- local p=$( dpkg-deb --show --showformat '${Package}' "${file}" )
- local a=$( dpkg-deb --show --showformat '${Architecture}' "${file}" )
- # removing "all" means no arch
- local aarg="-A ${a}"
- [ "${a}" = "all" ] && aarg=""
- reprepro -b "${dir}" --dbdir "${dbdir}" -C main ${aarg} \
- remove "${codename}" \
- "${p}"
+ set -- $( dpkg-deb --show --showformat '${Package} ${Architecture}' "${file}" )
+ local p="${1}" a="${2}"
+ reprepro -b "${dir}" --dbdir "${dbdir}" -C main \
+ removefilter "${codename}" \
+ 'Package (= '${p}'), Architecture (= '${a}'), $PackageType (= deb)'
}

repo_contains_package() {
--
2.34.1

Cedric Hombourger

unread,
Nov 22, 2024, 12:48:38 AM11/22/24
to isar-...@googlegroups.com, Cedric Hombourger
All repository functions take four arguments:
- path to the repository
- path to the database used by the repository management tool
- codename
- file/package

repo_contains_package was the only function deviating from this scheme and its
current implementation only takes a repository path and a file. Since the
repositoty class was introduced to hide implementation details (so we could
move away from reprepro if we wanted to), align that function with others.
The only caller found in the repository (base-apt) was changed to use the new
(standard) API.

Signed-off-by: Cedric Hombourger <cedric.h...@siemens.com>
---
meta/classes/repository.bbclass | 4 +++-
meta/recipes-devtools/base-apt/base-apt.bb | 5 ++++-
2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/meta/classes/repository.bbclass b/meta/classes/repository.bbclass
index 42d15823..b20ec091 100644
--- a/meta/classes/repository.bbclass
+++ b/meta/classes/repository.bbclass
@@ -93,7 +93,9 @@ repo_del_package() {

repo_contains_package() {
local dir="$1"
- local file="$2"
+ local dbdir="$2"
+ local codename="$3"
+ local file="$4"
local package

package=$(find ${dir} -name ${file##*/})
diff --git a/meta/recipes-devtools/base-apt/base-apt.bb b/meta/recipes-devtools/base-apt/base-apt.bb
index 2766bc71..4fad76c5 100644
--- a/meta/recipes-devtools/base-apt/base-apt.bb
+++ b/meta/recipes-devtools/base-apt/base-apt.bb
@@ -24,7 +24,10 @@ populate_base_apt() {

# Check if this package is already in base-apt
ret=0
- repo_contains_package "${REPO_BASE_DIR}/${base_distro}" "${package}" ||
+ repo_contains_package "${REPO_BASE_DIR}/${base_distro}" \
+ "${REPO_BASE_DB_DIR}"/"${base_distro}" \
+ "${BASE_DISTRO_CODENAME}" \
+ "${package}" ||
ret=$?
[ "${ret}" = "0" ] && continue
if [ "${ret}" = "1" ]; then
--
2.34.1

Cedric Hombourger

unread,
Nov 22, 2024, 12:48:38 AM11/22/24
to isar-...@googlegroups.com, Cedric Hombourger
repo_del_package should only remove binary packages (.deb), not
previously added source packages.

repo_contains_package should not assume that the name of downloaded .deb
files will match filenames used by reprepro.

Cedric Hombourger (3):
repository: repo_del_package should not remove source packages
repository: align repo_contains_package signature with other repo
functions
repository: make repo_contains_package query the package database

meta/classes/repository.bbclass | 40 ++++++++++++++++------
meta/recipes-devtools/base-apt/base-apt.bb | 5 ++-
2 files changed, 34 insertions(+), 11 deletions(-)

--
2.34.1

Cedric Hombourger

unread,
Nov 22, 2024, 12:48:39 AM11/22/24
to isar-...@googlegroups.com, Cedric Hombourger
Debian package repositories (created/updated with dak) and reprepro
repositories do not have the same file naming convention (e.g. the
latter does not use Epoch). A full directory scan may also be
expensive for large repositories: use reprepro listfilter to check
for matching packages in the database.

Signed-off-by: Cedric Hombourger <cedric.h...@siemens.com>
---
meta/classes/repository.bbclass | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/meta/classes/repository.bbclass b/meta/classes/repository.bbclass
index b20ec091..bc5852a5 100644
--- a/meta/classes/repository.bbclass
+++ b/meta/classes/repository.bbclass
@@ -98,7 +98,28 @@ repo_contains_package() {
local file="$4"
local package

- package=$(find ${dir} -name ${file##*/})
+ # Extract meta-data from the provided .deb file
+ package=$(dpkg-deb -f ${file} Package Version Architecture)
+
+ # Output for each field is "Field: Value"
+ # odd indexes hold field names, even indexes hold values
+ set -- ${package}
+
+ # lookup ${file} in the database for the current suite
+ package=$(reprepro -b ${dir} --dbdir ${dbdir} \
+ --list-format '${$fullfilename}\n' \
+ listfilter ${codename} '
+ Package (= '${2}'),
+ Version (= '${4}'),
+ Architecture (= '${6}'),
+ $PackageType (= deb)')
+
+ # we only need the first match (should there be more). Use shell builtins to avoid
+ # spawning an additional process (e.g. "head")
+ set -- ${package}
+ package="${1}"
+
+ # package found in the database?
if [ -n "$package" ]; then
# yes
cmp --silent "$package" "$file" && return 0
--
2.34.1

Uladzimir Bely

unread,
Nov 27, 2024, 2:11:22 AM11/27/24
to Cedric Hombourger, isar-...@googlegroups.com
On Fri, 2024-11-22 at 06:48 +0100, 'Cedric Hombourger' via isar-users
wrote:
Applied to next, thanks.

--
Best regards,
Uladzimir.
Reply all
Reply to author
Forward
0 new messages