[PATCH] debianize: Fix unexpected characters in package lists

13 views
Skip to first unread message

Anton Mikanovich

unread,
Mar 18, 2025, 11:52:27 AM3/18/25
to isar-...@googlegroups.com, Anton Mikanovich
Newer dpkg-deb versions got more pedantic to the control file format.

Introduce debian package list format helper to cleanup empty items or
unexpected commas in dependency options passing to the default control
file.

This prevents errors like:
| dpkg-deb: error: unexpected end of file in archive magic version number in *.deb
| Unexpected character ')' parsing formula 'Package (= ), Architecture (= ), $PackageType (= deb)'!
| There have been errors!
caused by empty DEBIAN_BUILD_DEPENDS value in the line:
| Build-Depends: debhelper-compat (= ${DEBIAN_COMPAT}), ${DEBIAN_BUILD_DEPENDS}
which results in:
| Build-Depends: debhelper-compat (= 13),

Signed-off-by: Anton Mikanovich <ami...@ilbers.de>
---
meta/classes/base.bbclass | 12 ++++++++++++
meta/classes/debianize.bbclass | 14 ++++++++------
2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index 7d4ab49f..2a0eadd7 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -334,3 +334,15 @@ do_unpack[postfuncs] += "create_source_date_epoch_stamp"

def get_source_date_epoch_value(d):
return oe.reproducible.epochfile_read(d.getVar('SDE_FILE'), d)
+
+def deb_list_beautify(d, varname):
+ line = d.getVar(varname)
+ if not line:
+ return ''
+
+ var_list = []
+ for a in line.split(','):
+ stripped = a.strip()
+ if stripped:
+ var_list.append(stripped)
+ return ', '.join(var_list)
diff --git a/meta/classes/debianize.bbclass b/meta/classes/debianize.bbclass
index 5e9d76f3..b9ebc4ba 100644
--- a/meta/classes/debianize.bbclass
+++ b/meta/classes/debianize.bbclass
@@ -18,6 +18,8 @@ DEBIAN_CHANGELOG_TIMESTAMP ??= "3600"
DESCRIPTION ??= "must not be empty"
MAINTAINER ??= "Unknown maintainer <unk...@example.com>"

+DEBIANIZE_BUILD_DEPENDS ?= "debhelper-compat (= ${DEBIAN_COMPAT}), ${DEBIAN_BUILD_DEPENDS}"
+
deb_add_changelog() {
changelog_v="${CHANGELOG_V}"
timestamp="${DEBIAN_CHANGELOG_TIMESTAMP}"
@@ -73,15 +75,15 @@ Section: misc
Priority: optional
Standards-Version: 3.9.6
Maintainer: ${MAINTAINER}
-Build-Depends: debhelper-compat (= ${DEBIAN_COMPAT}), ${DEBIAN_BUILD_DEPENDS}
+Build-Depends: ${@ deb_list_beautify(d, 'DEBIANIZE_BUILD_DEPENDS')}

Package: ${BPN}
Architecture: ${DPKG_ARCH}
-Depends: ${DEBIAN_DEPENDS}
-Provides: ${DEBIAN_PROVIDES}
-Replaces: ${DEBIAN_REPLACES}
-Breaks: ${DEBIAN_BREAKS}
-Conflicts: ${DEBIAN_CONFLICTS}
+Depends: ${@ deb_list_beautify(d, 'DEBIAN_DEPENDS')}
+Provides: ${@ deb_list_beautify(d, 'DEBIAN_PROVIDES')}
+Replaces: ${@ deb_list_beautify(d, 'DEBIAN_REPLACES')}
+Breaks: ${@ deb_list_beautify(d, 'DEBIAN_BREAKS')}
+Conflicts: ${@ deb_list_beautify(d, 'DEBIAN_CONFLICTS')}
Multi-Arch: ${DEBIAN_MULTI_ARCH}
Description: ${DESCRIPTION}
EOF
--
2.34.1

Anton Mikanovich

unread,
Mar 19, 2025, 9:04:47 AM3/19/25
to isar-...@googlegroups.com, Anton Mikanovich
Newer dpkg-deb versions got more pedantic to the control file format.

Introduce debian package list format helper to cleanup empty items or
unexpected commas in dependency options passing to the default control
file.

This prevents errors like:
| dpkg-deb: error: unexpected end of file in archive magic version number in *.deb
| Unexpected character ')' parsing formula 'Package (= ), Architecture (= ), $PackageType (= deb)'!
| There have been errors!
caused by empty DEBIAN_BUILD_DEPENDS value in the line:
| Build-Depends: debhelper-compat (= ${DEBIAN_COMPAT}), ${DEBIAN_BUILD_DEPENDS}
which results in:
| Build-Depends: debhelper-compat (= 13),

Signed-off-by: Anton Mikanovich <ami...@ilbers.de>
---
Changes since v1:
- Update also file headers.

meta/classes/base.bbclass | 16 ++++++++++++++++
meta/classes/debianize.bbclass | 15 +++++++++------
2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index 7d4ab49f..c730eec9 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -1,4 +1,8 @@
+# This software is a part of ISAR.
+#
# Copyright (C) 2003 Chris Larson
+# Copyright (C) 2015-2025 ilbers GmbH
+# Copyright (C) 2017-2025 Siemens AG
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
@@ -334,3 +338,15 @@ do_unpack[postfuncs] += "create_source_date_epoch_stamp"

def get_source_date_epoch_value(d):
return oe.reproducible.epochfile_read(d.getVar('SDE_FILE'), d)
+
+def deb_list_beautify(d, varname):
+ line = d.getVar(varname)
+ if not line:
+ return ''
+
+ var_list = []
+ for a in line.split(','):
+ stripped = a.strip()
+ if stripped:
+ var_list.append(stripped)
+ return ', '.join(var_list)
diff --git a/meta/classes/debianize.bbclass b/meta/classes/debianize.bbclass
index 5e9d76f3..9d9507d9 100644
--- a/meta/classes/debianize.bbclass
+++ b/meta/classes/debianize.bbclass
@@ -1,6 +1,7 @@
# This software is a part of ISAR.
# Copyright (C) 2017-2019 Siemens AG
# Copyright (C) 2021 Siemens Mobility GmbH
+# Copyright (C) 2025 ilbers GmbH
#
# SPDX-License-Identifier: MIT

@@ -18,6 +19,8 @@ DEBIAN_CHANGELOG_TIMESTAMP ??= "3600"
DESCRIPTION ??= "must not be empty"
MAINTAINER ??= "Unknown maintainer <unk...@example.com>"

+DEBIANIZE_BUILD_DEPENDS ?= "debhelper-compat (= ${DEBIAN_COMPAT}), ${DEBIAN_BUILD_DEPENDS}"
+
deb_add_changelog() {
changelog_v="${CHANGELOG_V}"
timestamp="${DEBIAN_CHANGELOG_TIMESTAMP}"
@@ -73,15 +76,15 @@ Section: misc

Anton Mikanovich

unread,
Mar 20, 2025, 10:45:26 AM3/20/25
to isar-...@googlegroups.com, Anton Mikanovich
Newer dpkg-deb versions got more pedantic to the control file format.

Introduce debian package list format helper to cleanup empty items or
unexpected commas in dependency options passing to the default control
file.

This prevents errors like:
| dpkg-deb: error: unexpected end of file in archive magic version number in *.deb
| Unexpected character ')' parsing formula 'Package (= ), Architecture (= ), $PackageType (= deb)'!
| There have been errors!
caused by empty DEBIAN_BUILD_DEPENDS value in the line:
| Build-Depends: debhelper-compat (= ${DEBIAN_COMPAT}), ${DEBIAN_BUILD_DEPENDS}
which results in:
| Build-Depends: debhelper-compat (= 13),

Signed-off-by: Anton Mikanovich <ami...@ilbers.de>
---

Changes since v2:
- Fix missing vardeps.

Changes since v1:
- Update also file headers.

meta/classes/base.bbclass | 16 ++++++++++++++++
meta/classes/debianize.bbclass | 21 +++++++++++++++------
2 files changed, 31 insertions(+), 6 deletions(-)
index 5e9d76f3..4989c601 100644
--- a/meta/classes/debianize.bbclass
+++ b/meta/classes/debianize.bbclass
@@ -1,6 +1,7 @@
# This software is a part of ISAR.
# Copyright (C) 2017-2019 Siemens AG
# Copyright (C) 2021 Siemens Mobility GmbH
+# Copyright (C) 2025 ilbers GmbH
#
# SPDX-License-Identifier: MIT

@@ -18,6 +19,8 @@ DEBIAN_CHANGELOG_TIMESTAMP ??= "3600"
DESCRIPTION ??= "must not be empty"
MAINTAINER ??= "Unknown maintainer <unk...@example.com>"

+DEBIANIZE_BUILD_DEPENDS ?= "debhelper-compat (= ${DEBIAN_COMPAT}), ${DEBIAN_BUILD_DEPENDS}"
+
deb_add_changelog() {
changelog_v="${CHANGELOG_V}"
timestamp="${DEBIAN_CHANGELOG_TIMESTAMP}"
@@ -66,6 +69,12 @@ EOF
}


+deb_create_control[vardeps] += "DEBIANIZE_BUILD_DEPENDS \
+ DEBIAN_DEPENDS \
+ DEBIAN_PROVIDES \
+ DEBIAN_REPLACES \
+ DEBIAN_BREAKS \
+ DEBIAN_CONFLICTS"
deb_create_control() {
cat << EOF > ${S}/debian/control
Source: ${BPN}
@@ -73,15 +82,15 @@ Section: misc

Uladzimir Bely

unread,
Mar 27, 2025, 6:33:13 AM3/27/25
to Anton Mikanovich, isar-...@googlegroups.com
Applied to next.

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